-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModuleADT.cpp
65 lines (55 loc) · 1.33 KB
/
ModuleADT.cpp
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
/**
* @file ModuleADT.cpp
* @Author Martin Cechmanek
* @date December, 2015
* @brief Abstract Data Type class for common interface for all modules
*/
#include "ModuleADT.h"
ModuleADT::ModuleADT(std::shared_ptr<Aggregator> agg_, std::string logger_name, std::string MODULE, IOTMessage msg_) :
agg(agg_),
log(Poco::Logger::get(logger_name)),
msg(msg_)
{
using Poco::Util::IniFileConfiguration;
try {
cfg = new IniFileConfiguration(std::string(MODULES_DIR)+std::string(MODULE)+".ini");
}
catch (Poco::Exception& ex) {
log.error("Exception with config file reading:\n" + ex.displayText());
inicialized = false;
return;
}
sensor.version = 1;
sensor.pairs = 1;
msg.state = "data";
msg.priority = MSG_PRIO_SENSOR;
msg.offset = 0;
tt = fillDeviceTable();
inicialized = true;
}
/**
* @brief Starting point for module thread function.
*/
void ModuleADT::start() {
if (inicialized) {
module_thread = std::thread(&ModuleADT::threadFunction, this);
}
}
/**
* @brief End point of module thread.
*/
void ModuleADT::stop() {
if (inicialized) {
module_thread.join();
}
}
/**
* @brief Check if device with specific id is part of this module
* can be overriden in specific child class.
* @return true if it is
*/
bool ModuleADT::belongTo(euid_t sensor_id) {
return (sensor.euid == sensor_id);
}
ModuleADT::~ModuleADT() {
}