-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIODaemonMsg.h
109 lines (88 loc) · 1.97 KB
/
IODaemonMsg.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* @file IODaemonMsg.h
* @Author BeeeOn team - Richard Wolfert ([email protected])
* @date July 2016
* @brief Class representing messages from BeeeOn ioDaemon
*/
#pragma once
#include <iostream>
#include <string>
#include <Poco/JSON/JSON.h>
#include <Poco/JSON/Object.h>
#include <Poco/Logger.h>
class ledConfiguration {
public:
bool m_red;
bool m_green;
unsigned char m_blue;
};
class IODaemonMsg {
public:
IODaemonMsg();
void debug_print(Poco::Logger& log);
void parse(const std::string &data, Poco::Logger& log);
std::string createDaemonMsg() const;
bool isUpdate() const
{
return (m_eventName == "updateLeds");
}
bool isValid() const
{
return m_validity;
}
void setValidity(const bool &validity)
{
m_validity = validity;
}
std::string getEventName() const
{
return m_eventName;
}
void setEventName(const std::string &eventName)
{
m_eventName = eventName;
}
std::string getAction() const
{
return m_action;
}
void setAction(const std::string &action)
{
m_action = action;
}
std::string getSenderName() const
{
return m_senderName;
}
void setSenderName(const std::string &senderName)
{
m_senderName = senderName;
}
unsigned char getPriority() const
{
return m_priority;
}
void setPriority(const unsigned char &priority)
{
m_priority = priority;
}
ledConfiguration getLedConf() const
{
return m_ledConf;
}
void setLedConf(const ledConfiguration &ledConf)
{
m_ledConf = ledConf;
}
private:
std::string m_eventName;
std::string m_action;
std::string m_senderName;
unsigned char m_priority;
ledConfiguration m_ledConf;
bool m_validity;
Poco::JSON::Object::Ptr parseJsonObject(const std::string &data);
std::string extractString(const Poco::JSON::Object::Ptr &jsonObject, const std::string &key);
unsigned char extractChar(const Poco::JSON::Object::Ptr &jsonObject, const std::string &key);
ledConfiguration parseLedConfiguration(const Poco::JSON::Object::Ptr &jsonObject, const std::string &key);
};