-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathspecific.h
147 lines (115 loc) · 4.36 KB
/
specific.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//***************************************************************************
// Automation Control
// File specific.h
// This code is distributed under the terms and conditions of the
// GNU GENERAL PUBLIC LICENSE. See the file LICENSE for details.
// Date 16.04.2020 - Jörg Wendel
//***************************************************************************
#pragma once
#include "daemon.h"
#include "p4io.h"
//***************************************************************************
// Class P4d
//***************************************************************************
class P4d : public Daemon, public FroelingService
{
public:
P4d();
virtual ~P4d();
const char* myTitle() override { return "Heizung"; }
int init() override;
int exit() override;
enum PinMappings
{
};
enum AnalogInputs
{
};
enum SpecialValues // 'SP'
{
};
protected:
int initDb() override;
int exitDb() override;
int standbyUntil() override;
int readConfiguration(bool initial) override;
int applyConfigurationSpecials() override;
int loadStates() override;
int atMeanwhile() override;
int updateSensors() override;
void afterUpdate() override;
int updateErrors();
int doLoop() override;
int updateState();
void scheduleTimeSyncIn(int offset = 0);
int sendErrorMail();
int sendStateMail();
int isMailState();
int process() override;
int performJobs() override;
void logReport() override;
bool onCheckRights(long client, Event event, uint rights) override;
int dispatchOther(const char* topic, const char* message) override;
int dispatchMqttS3200CommandRequest(json_t* jData);
int parGet(cDbTable* tableMenu, std::string& error, int result = success);
int parSet(cDbTable* tableMenu, const char* value, std::string& error);
std::list<ConfigItemDef>* getConfiguration() override { return &configuration; }
int updateTimeRangeData();
int initMenu(bool updateParameters = false);
int updateParameter(cDbTable* tableMenu);
int calcStateDuration();
int initValueFacts(bool truncate = false);
const char* getTextImage(const char* key, const char* text) override;
// WS request
int dispatchSpecialRequest(Event event, json_t* oObject, long client) override;
int performLogin(json_t* oObject) override;
int performPellets(json_t* array, long client);
int performPelletsAdd(json_t* array, long client);
int performCommand(json_t* obj, long client) override;
int performErrors(long client);
int performMenu(json_t* oObject, long client);
int performMenuByParent(json_t* oObject, long client, int parent);
int performMenuBySearch(json_t* oObject, long client, const char* search);
int performParEditRequest(json_t* oObject, long client);
int performTimeParEditRequest(json_t* oObject, long client);
int performParStore(json_t* oObject, long client);
int performTimeParStore(json_t* oObject, long client);
int commands2Json(json_t* obj) override;
int s3200State2Json(json_t* obj);
int configChoice2json(json_t* obj, const char* name) override;
// config
int stateCheckInterval {10};
char* ttyDevice {};
int tSync {no};
int maxTimeLeak {10};
char* stateMailAtStates {};
double consumptionPerHour {0};
char* knownStates {};
char* heatingType {};
// data
cDbTable* tablePellets {};
cDbTable* tableMenu {};
cDbTable* tableErrors {};
cDbTable* tableTimeRanges {};
cDbValue minValue;
cDbValue endTime;
cDbStatement* selectAllMenuItems {};
cDbStatement* selectMenuItemsByParent {};
cDbStatement* selectMenuItemsByChild {};
cDbStatement* selectAllErrors {};
cDbStatement* selectPendingErrors {};
cDbStatement* selectAllPellets {};
cDbStatement* selectStokerHours {};
cDbStatement* selectStateDuration {};
Sem* sem {};
P4Request* request {};
Serial* serial {};
Status currentState;
bool stateChanged {false};
time_t nextStateAt {0};
std::map<int,time_t> stateDurations;
int errorsPending {0};
time_t nextTimeSyncAt {0};
// statics
static std::list<ConfigItemDef> configuration;
};