-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogramWheel.h
More file actions
69 lines (64 loc) · 2.14 KB
/
Copy pathprogramWheel.h
File metadata and controls
69 lines (64 loc) · 2.14 KB
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
/**
* Program Wheel is a class which can read out the
* progwheel.xml configuration file and provide the
* parameter values for the incu8ator controller class.
* The progwheel.xml file must be on the path /etc/incu8ator/
* This class counts the elapsed time and it can tell the
* current necessary temperature and humidty values as well as
* the elapsed time.
*/
#ifndef PROGRAMWHEELH_
#define PROGRAMWHEELH_
#include <iostream>
#include <fstream>
#include <sstream>
#include <time.h>
#include <unistd.h>
#include <cstdlib>
#include <vector>
#include <stdexcept>
#include <thread>
#include "./pugi/pugixml-1.7/src/pugixml.hpp"
#include "elapsedTimeThread.h"
#include "log.h"
class programWheel {
private:
pugi::xml_document doc;
pugi::xml_parse_result result;
pugi::xml_node root;
const char *progWheelXMLPath;
const char *statusXMLPath;
int stepID;
const int MAX_STEPS;
const char *ROOT_NODE_NAME;
const char *STEP_NODE_NAME;
const char *HOUR_NODE_NAME;
const char *TEMP_NODE_NAME;
const char *HUM_NODE_NAME;
const char *STATE_NODE_NAME;
const char *STEPID_NODE_NAME;
const char *ELAPSED_NODE_NAME;
struct Step {
double interval;
double temp;
double hum;
int id;
Step(double i, double t, double h, int in_id) :
interval(i), temp(t), hum(h), id(in_id) {;}
};
std::vector<Step> steps;
elapsedTimeThread *el;
bool processConfig(std::string& errConf);
bool saveStatus(int stepID, double elapsedSeconds);
bool loadStatus(int& stepID, double& elapsedSeconds, std::string& res);
public:
programWheel(void) : progWheelXMLPath("/etc/incu8ator/progwheel.xml\0"),statusXMLPath("/etc/incu8ator/state.xml\0"), stepID(0), MAX_STEPS(100), ROOT_NODE_NAME("incu8ator\0"), STEP_NODE_NAME("step\0"), HOUR_NODE_NAME("hour\0"), TEMP_NODE_NAME("temp\0"), HUM_NODE_NAME("hum\0"), STATE_NODE_NAME("state\0"), STEPID_NODE_NAME("stepID\0"), ELAPSED_NODE_NAME("elapsed\0") {log::_ident("incu8ator<programWheel>");}
~programWheel(void) {if(el) delete el;}
double getWantedTemperature(void);
double getWantedHumidity(void);
double getElapsedHours(void);
double getInterval(void);
bool initProgramWheel(std::string& res);
bool startProgramWheel(void);
};
#endif