Aruna
sisTypes.h
Go to the documentation of this file.
1 //
2 // Created by noeel on 15-04-20.
3 //
4 
5 #ifndef ARUNA_SISTYPES_H
6 #define ARUNA_SISTYPES_H
7 
8 #include <cstddef>
9 #include <cstring>
10 
11 namespace aruna {
12  namespace sis {
16  enum class level_t : uint8_t {
17  NOTIFY = 0,
18  WARNING = 1,
19  CRITICAL = 2,
20  MAX = 3,
21  };
22 
26  enum class type_t : uint8_t {
27  UNKNOWN = 0,
28  DEFAULT = 1,
29  WATER = 2,
30  MAX = 3,
31  };
32 
36  struct status_t {
37 // TODO constructor and encode_size const?
38 
40  char description[32];
42 
43  explicit status_t(type_t type): type(type) {};
44  virtual ~status_t() {};
45  virtual uint8_t get_encode_size() {
46  return strlen(description) + 3;
47  }
48 
49  virtual void encode(uint8_t *buffer) {
50  buffer[0] = (uint8_t) type;
51  buffer[1] = (uint8_t) level;
52  buffer[2] = strlen(description);
53  memcpy((char *) &buffer[3], (const char *) description, strlen(description));
54  }
55 
56  virtual void decode(uint8_t *to_decode) {
57  type = (type_t) to_decode[0];
58  level = (level_t) to_decode[1];
59  memcpy(description, (char *) &to_decode[3], to_decode[2]);
60  }
61  };
62  }
63 
64 }
65 #endif //ARUNA_SISTYPES_H
Definition: comm.cpp:14
type_t
Type of status.
Definition: sisTypes.h:26
level_t
SIS urgency level.
Definition: sisTypes.h:16
status_t(type_t type)
Definition: sisTypes.h:43
virtual uint8_t get_encode_size()
Definition: sisTypes.h:45
virtual ~status_t()
Definition: sisTypes.h:44
sis::level_t level[(uint8_t) sis::type_t::MAX]
Definition: watcher.cpp:16
virtual void encode(uint8_t *buffer)
Definition: sisTypes.h:49
status that is to be reported to the watcher
Definition: sisTypes.h:36
virtual void decode(uint8_t *to_decode)
Definition: sisTypes.h:56