-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBslibQueue.h
95 lines (70 loc) · 2.13 KB
/
BslibQueue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* @file BslibQueue.h
* @author Edison
* @brief Encolador de mensajes para main
* @version 1.0.1
* @date 2021-04-13
*
* @copyright DataAnalitic (c) {2021}
*
*/
#ifndef BslibQueue_h
#define BslibQueue_h
#include <LinkedListLib.h>
#include "RTClib.h"
#include "Arduino.h"
#define DEFAULT_SUBJ "NO"
#define DEFAULT_PRIO 0
#define EMPTY_DATA ""
#define START_ID 0
#define START_PUSHED_T 0
//Some Subjects
#define ARRIVED "A"
#define TO_SEND "S"
/**
* [Message description]
*/
class Message{
private:
String Subject; //Message Subject
int priority; //Message Priority
String data; //Message Data
uint8_t pushed; //Message's Pushed Time
TimeSpan timestamp; //Message's Timestamp
public:
Message():
Subject(DEFAULT_SUBJ),
priority(DEFAULT_PRIO),
data(EMPTY_DATA),
timestamp(TimeSpan(0,0,0,0)),
pushed(START_PUSHED_T) {} //Constructor
void set_subject(String _subject);
void set_priority(int _priority);
void set_data(String _data);
void set_pushed(int _pushed);
void set_timestamp(DateTime _now);
String get_subject();
int get_priority();
String get_data();
int get_pushed();
TimeSpan get_timestamp();
int get_age(DateTime now);
String to_string();
};
/**
* [BslibQueue description]
*/
class BslibQueue{
private:
LinkedList<Message> queue ; //LinkedList of BslibQueue
public:
BslibQueue() {} //Constructor
void push(Message msg);
void requeue(Message msg);
Message pop();
bool is_empty();
int get_size();
void sort();
String to_string();
};
#endif