-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackupeval.cpp
More file actions
297 lines (276 loc) · 11.2 KB
/
backupeval.cpp
File metadata and controls
297 lines (276 loc) · 11.2 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#include "backupeval.h"
#include <TimeRelayFuncA.h>
#include <TimeRelayFuncB.h>
#include <Declarations.h>
#include "SizeStruct.h"
#include <Relay.h>
/*Defined in mainwindow.cpp*/
extern ResultsData Skt0140; //Backup Post Lube OFF cycle
extern ResultsData Skt0141; //Backup Posl lube continuous
extern ResultsData Skt0142; //Total postlube
extern ResultsData Skt0143; //Backup Post Lube ON cycle
extern ResultsData Skt0145; //Fire detected rolldown lube
extern ResultsData Skt0144; //Header pressure high Backup pump off
extern ResultsData Ska0131; //Controller active
extern ResultsData Ska0141; //Controller active
extern ResultsData Ska0132; //Controller active
extern ResultsData Ska0133; //Post lube not required
extern ResultsData Ska0134; //Backup command off
extern ResultsData Ska0135; //AC PRE/POST pump drive
extern ResultsData Ska0136; //Lube oil header pressure high
extern ResultsData Ska0137; //Lube pump inhibit
extern ResultsData Ska0138; //Backup lube oil pump off
extern ResultsData Ska0244; //No fire detected
extern TimeRelayFuncA kt0140; //Backup Post Lube OFF cycle
extern TimeRelayFuncA kt0141; //Backup Posl lube continuous
extern TimeRelayFuncA kt0142; //Total postlube
extern TimeRelayFuncA kt0143; //Backup Post Lube ON cycle
extern TimeRelayFuncA kt0145; //Fire detected rolldown lube
extern TimeRelayFuncB kt0144; //Header pressure high Backup pump off
extern Relay ka0131; //Controller active
extern Relay ka0141; //Controller active
extern Relay ka0132; //Controller active
extern Relay ka0133; //Post lube not required
extern Relay ka0134; //Backup command off
extern Relay ka0135; //AC PRE/POST pump drive
extern Relay ka0136; //Lube oil header pressure high
extern Relay ka0137; //Lube pump inhibit
extern Relay ka0138; //Backup lube oil pump off
extern Relay ka0244; //No fire detected
extern QVector<double>dbltime;
extern bool m3150;
extern bool postlube;//POSTLUBE
extern bool ps3200;//Header switch
extern bool controllerActive;
extern int timer_main_sec;//Total poslube
extern int timer_program_total;//10% more than Total Postlube
void BackupEval(int program_timer)
{
//First branch KT0140, KT0141 and KT0142
if (ka0132.contactsNC() || ka0133.contactsNC())
{
if (kt0143.contactsNC())
{
kt0140.enable=1;//off cycle
kt0140.ckIfDN();
}
else
{
kt0140.enable=0;
kt0140.ckIfDN();
}
kt0141.enable=1;//Backup post lube continuous
kt0141.ckIfDN();
kt0142.enable=1;//Total post lube
kt0142.ckIfDN();
}
else
{
kt0140.enable=0;//off cycle
kt0140.ckIfDN();
kt0141.enable=0;//Backup post lube continuous
kt0141.ckIfDN();
kt0142.enable=0;//Total post lube
kt0142.ckIfDN();
}
//Second branch KT0143 - Backup pump post lube On cycle
if (kt0140.contactsNO())
{
kt0143.enable=1;//Backup pump post lube ON cycle
kt0143.ckIfDN();
}
else
{
kt0143.enable=0;//Backup pump post lube ON cycle
kt0143.ckIfDN();
}
//KT0144 Function B is always enabled (header pressure high backup pump off)
kt0144.enable=1;
//KT0144 controlled by switch input (header pressure high backup pump off)
if (ka0136.contactsNO() && ka0138.contactsNO())
{
kt0144.switchON=1;//KT0144 - header pressure high backup pump off
kt0144.ckIfDN();
}
else
{
kt0144.switchON=0;//KT0144 - header pressure high backup pump off
kt0144.ckIfDN();
}
//Fire detected roll down relay KT0145
if (ka0244.contactsNC())
{
kt0145.enable=1;
kt0145.ckIfDN();
}
else
{
kt0145.enable=0;
kt0145.ckIfDN();
}
bool acpump1{0}, acpump2{0};
{
//KA0135 branch -1 (AC Pre/Post pump drive)
if (ka0137.contactsNO() && ka0131.contactsNC())
{
acpump1=1;
}
//KA0135 branch -2 (AC Pre/Post pump drive)
if (m3150 && ka0131.contactsNO())
{
acpump2=1;
}
if (acpump1 || acpump2)
ka0135.enable=1;
else
ka0135.enable=0;
}
//KA0136 header pressure high
if (ps3200)
{
ka0136.enable=1;
}
//KA0137 Lube pump inhibit
if (kt0145.contactsNO() || kt0142.contactsNO())//Fire detected rolldown lube OR Total postlube
{
ka0137.enable=1;
}
else
{
ka0137.enable=0;
}
//KA0138 - Backup lube oil pump off
bool line1{0},line2{0},line3{0}, line4{0}, line5{0};
{
if (ka0134.contactsNO() && ka0132.contactsNO())
{
line1=1;
}
if (kt0140.contactsNC() && kt0141.contactsNO())
{
line2=1;
}
if (kt0144.contactsNO() && ka0132.contactsNC())
{
line3=1;
}
if (line2 && ka0132.contactsNC())
{
line4=1;
}
if (ka0137.contactsNO() && ka0132.contactsNC())
{
line5=1;
}
if (line1 || line3 || line4 || line5)
{
ka0138.enable=1;
}
else
{
ka0138.enable=0;
}
}
//Create output
//Backup Post Lube OFF cycle
Skt0140.NO[program_timer]=kt0140.contactsNO();
Skt0140.NC[program_timer]=kt0140.contactsNC();
Skt0140.elapsed[program_timer]=kt0140.elapsed;
Skt0140.dblNO[program_timer]=kt0140.contactsNO();
Skt0140.dblNC[program_timer]=kt0140.contactsNC();
Skt0140.dblelapsed[program_timer]=kt0140.elapsed;
//Backup Posl lube continuous
Skt0141.NO[program_timer]=kt0141.contactsNO();
Skt0141.NC[program_timer]=kt0141.contactsNC();
Skt0141.dblNO[program_timer]=kt0141.contactsNO();
Skt0141.dblNC[program_timer]=kt0141.contactsNC();
//Total postlube
Skt0142.NO[program_timer]=kt0142.contactsNO();
Skt0142.NC[program_timer]=kt0142.contactsNC();
Skt0142.dblNO[program_timer]=kt0142.contactsNO();
Skt0142.dblNC[program_timer]=kt0142.contactsNC();
//Backup Post Lube ON cycle
Skt0143.NO[program_timer]=kt0143.contactsNO();
Skt0143.NC[program_timer]=kt0143.contactsNC();
Skt0143.dblNO[program_timer]=kt0143.contactsNO();
Skt0143.dblNC[program_timer]=kt0143.contactsNC();
//Header pressure high Backup pump off
Skt0144.NO[program_timer]=kt0144.contactsNO();
Skt0144.NC[program_timer]=kt0144.contactsNC();
Skt0144.dblNO[program_timer]=kt0144.contactsNO();
Skt0144.dblNC[program_timer]=kt0144.contactsNC();
//Fire detected rolldown lube
Skt0145.NO[program_timer]=kt0145.contactsNO();
Skt0145.NC[program_timer]=kt0145.contactsNC();
Skt0145.dblNO[program_timer]=kt0145.contactsNO();
Skt0145.dblNC[program_timer]=kt0145.contactsNC();
//Controller active
Ska0131.NO[program_timer]=ka0131.contactsNO();
Ska0131.NC[program_timer]=ka0131.contactsNC();
Ska0131.enable[program_timer]=ka0131.enable;
Ska0131.dblNO[program_timer]=ka0131.contactsNO();
Ska0131.dblNC[program_timer]=ka0131.contactsNC();
Ska0131.dblEnable[program_timer]=ka0131.enable;
//Controller active
Ska0132.NO[program_timer]=ka0132.contactsNO();
Ska0132.NC[program_timer]=ka0132.contactsNC();
Ska0132.enable[program_timer]=ka0132.enable;
Ska0132.dblNO[program_timer]=ka0132.contactsNO();
Ska0132.dblNC[program_timer]=ka0132.contactsNC();
Ska0132.dblEnable[program_timer]=ka0132.enable;
//Controller active
Ska0141.NO[program_timer]=ka0141.contactsNO();
Ska0141.NC[program_timer]=ka0141.contactsNC();
Ska0141.enable[program_timer]=ka0141.enable;
Ska0141.dblNO[program_timer]=ka0141.contactsNO();
Ska0141.dblNC[program_timer]=ka0141.contactsNC();
Ska0141.dblEnable[program_timer]=ka0141.enable;
//Post lube not required
Ska0133.NO[program_timer]=ka0133.contactsNO();
Ska0133.NC[program_timer]=ka0133.contactsNC();
Ska0133.enable[program_timer]=ka0133.enable;
Ska0133.dblNO[program_timer]=ka0133.contactsNO();
Ska0133.dblNC[program_timer]=ka0133.contactsNC();
Ska0133.dblEnable[program_timer]=ka0133.enable;
//Backup command off
Ska0134.NO[program_timer]=ka0134.contactsNO();
Ska0134.NC[program_timer]=ka0134.contactsNC();
Ska0134.enable[program_timer]=ka0134.enable;
Ska0134.dblNO[program_timer]=ka0134.contactsNO();
Ska0134.dblNC[program_timer]=ka0134.contactsNC();
Ska0134.dblEnable[program_timer]=ka0134.enable;
//AC PRE/POST pump drive
Ska0135.NO[program_timer]=ka0135.contactsNO();
Ska0135.NC[program_timer]=ka0135.contactsNC();
Ska0135.enable[program_timer]=ka0135.enable;
Ska0135.dblNO[program_timer]=ka0135.contactsNO();
Ska0135.dblNC[program_timer]=ka0135.contactsNC();
Ska0135.dblEnable[program_timer]=ka0135.enable;
//Lube oil header pressure high
Ska0136.NO[program_timer]=ka0136.contactsNO();
Ska0136.NC[program_timer]=ka0136.contactsNC();
Ska0136.enable[program_timer]=ka0136.enable;
Ska0136.dblNO[program_timer]=ka0136.contactsNO();
Ska0136.dblNC[program_timer]=ka0136.contactsNC();
Ska0136.dblEnable[program_timer]=ka0136.enable;
//Lube pump inhibit
Ska0137.NO[program_timer]=ka0137.contactsNO();
Ska0137.NC[program_timer]=ka0137.contactsNC();
Ska0137.enable[program_timer]=ka0137.enable;
Ska0137.dblNO[program_timer]=ka0137.contactsNO();
Ska0137.dblNC[program_timer]=ka0137.contactsNC();
Ska0137.dblEnable[program_timer]=ka0137.enable;
//Backup lube oil pump off
Ska0138.NO[program_timer]=ka0138.contactsNO();
Ska0138.NC[program_timer]=ka0138.contactsNC();
Ska0138.enable[program_timer]=ka0138.enable;
Ska0138.dblEnable[program_timer]=ka0138.enable;
//No fire detected
Ska0244.NO[program_timer]=ka0244.contactsNO();
Ska0244.NC[program_timer]=ka0244.contactsNC();
Ska0244.enable[program_timer]=ka0244.enable;
Ska0244.dblNO[program_timer]=ka0244.contactsNO();
Ska0244.dblNC[program_timer]=ka0244.contactsNC();
Ska0244.dblEnable[program_timer]=ka0244.enable;
dbltime[program_timer]=program_timer;
}