-
Notifications
You must be signed in to change notification settings - Fork 0
/
mask7_slots.h
366 lines (315 loc) · 16.3 KB
/
mask7_slots.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
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
/*
This file is part of SCADA Plastic rolling machine.
Copyright 2018, Prointegra SL.
SCADA Plastic rolling machine is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SCADA Plastic rolling machiner is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SCADA Plastic rolling machine.
If not, see <https://www.gnu.org/licenses/>.
*/
//###############################################################
//# mask7_slots.h for ProcessViewServer created: mié jul 30 10:16:29 2014
//# please fill out these slots
//# here you find all possible events
//# Yours: Lehrig Software Engineering
//###############################################################
// todo: uncomment me if you want to use this data aquisiton
// also uncomment this classes in main.cpp and pvapp.h
// also remember to uncomment rllib in the project file
//extern rlModbusClient modbus;
//extern rlSiemensTCPClient siemensTCP;
//extern rlPPIClient ppi;
extern rlDataAcquisition adqui;
//extern rlSiemensTCPClient siemensTCP;
//extern rlPPIClient ppi;
extern Alarm myalarm;
extern GLOBAL_DATA MyData;
static void setState(PARAM *p, DATA *d, int value, int id, const char *IMAGEN_ON, const char * IMAGEN_OFF, const char* IMAGEN_INDEFINIDO)
{ // helper function
char filename[80] = "";
if (value == 0) strcpy(filename,IMAGEN_OFF);
else if(value > 0) strcpy(filename,IMAGEN_ON);
else strcpy(filename,IMAGEN_INDEFINIDO);
//printf("DEBUG: image set: %s , valor: %d\n",filename,value );
pvSetImage(p,id,filename);
}
static void multisetState(PARAM *p, DATA *d, int value0,int value1, int id, const char *IMAGEN_0, const char * IMAGEN_1,const char * IMAGEN_2,const char * IMAGEN_3, const char* IMAGEN_INDEFINIDO)
{ // helper function
char filename[80] = "";
if ((value0 == 0) && (value1 == 0)) strcpy(filename,IMAGEN_0);
else if ((value0 > 0) && (value1 == 0)) strcpy(filename,IMAGEN_1);
else if ((value0 == 0) && (value1 > 0)) strcpy(filename,IMAGEN_2);
else if ((value0 > 0) && (value1 > 0)) strcpy(filename,IMAGEN_3);
else strcpy(filename,IMAGEN_INDEFINIDO);
printf("DEBUG: image set: %s , valor 0: %d valor 1: %d\n",filename,value0,value1 );
pvSetImage(p,id,filename);
}
static int slotInit(PARAM *p, DATA *d)
{
char text[100];
int address;
int i;
int* word;
if(p == NULL || d == NULL) return -1;
//memset(d,0,sizeof(DATA));
ReadCommDATA(&d);
//iniciamos alarmas
InitAlarms(&d);
//digitals
//digitales
pvDownloadFile(p,"./images/green.png");
pvDownloadFile(p,"./images/Empujador_rojo.png");
pvDownloadFile(p,"./images/Globo_ON.png");
pvDownloadFile(p,"./images/Brazo1_verde.png"); //arriba bloq
pvDownloadFile(p,"./images/Brazo1_verde2.png"); //arriba bloq der
pvDownloadFile(p,"./images/Brazo2_rojo.png"); //intermedia sin bloq
pvDownloadFile(p,"./images/Brazo2_rojo2.png"); //intermedia sin bloq der
pvDownloadFile(p,"./images/Brazo2_verde.png"); //intermedia bloq
pvDownloadFile(p,"./images/Brazo2_verde2.png"); //intermedia bloq der
pvDownloadFile(p,"./images/Brazo3_rojo.png"); //abajo sin bloq
pvDownloadFile(p,"./images/Brazo3_rojo2.png"); //abajo sin bloq der
pvDownloadFile(p,"./images/Brazo3_verde.png"); //abajo bloq
pvDownloadFile(p,"./images/Brazo3_verde2.png"); //abajo bloq der
//REB1
word = (int*)malloc(16*sizeof(int));
word2digitals(d->val[SCW_STATUSR1B],&word);//Psret,psext,ejedesb,ejebloq,cantabj,cantarr,pisonarr,pisonPMarr
for(i=0;i<16;i++)
d->statusR1[i]=word[i];
multisetState(p,d,word[0],word[1],imagen_psden_r1,"./images/Empujador_rojo.png","./images/Empujador_verde.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png");
if(word[3]) //eje bloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde.png","./images/Brazo3_verde.png","./images/Brazo1_verde.png","./images/Brazo2_verde.png","./images/Brazo2_verde.png");
else if(word[2]) //eje desbloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_rojo.png","./images/Brazo3_rojo.png","./images/Brazo1_rojo.png","./images/Brazo2_rojo.png","./images/Brazo2_rojo.png");
else //indefinido
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde.png","./images/Brazo3_verde.png","./images/Brazo1_verde.png","./images/Brazo2_verde.png","./images/Brazo2_verde.png");
setState(p,d,word[6],imagen_pison_r1,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[7],imagen_pm_r1,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[8],imagen_glob_r1,"./images/green.png","./images/grey.png","./images/grey.png");
//REB2
word2digitals(d->val[SCW_STATUSR2B],&word);//Psret,psext,ejedesb,ejebloq,cantabj,cantarr,pisonarr,pisonPMarr
for(i=0;i<16;i++)
d->statusR2[i]=word[i];
multisetState(p,d,word[0],word[1],imagen_psden_r2,"./images/Empujador_rojo.png","./images/Empujador_verde.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png");
if(word[3]) //eje bloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde2.png","./images/Brazo3_verde2.png","./images/Brazo1_verde2.png","./images/Brazo2_verde2.png","./images/Brazo2_verde2.png");
else if(word[2]) //eje desbloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_rojo2.png","./images/Brazo3_rojo2.png","./images/Brazo1_rojo2.png","./images/Brazo2_rojo2.png","./images/Brazo2_rojo2.png");
else //indefinido
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde2.png","./images/Brazo3_verde2.png","./images/Brazo1_verde2.png","./images/Brazo2_verde2.png","./images/Brazo2_verde2.png");
setState(p,d,word[6],imagen_pison_r2,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[7],imagen_pm_r2,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[8],imagen_glob_r2,"./images/green.png","./images/grey.png","./images/grey.png");
//DESB
word2digitals(d->val[SCW_STATUSDB],&word);//Psret,psext,ejedesb,ejebloq,cantabj,cantarr,pisonsuparr,pisoninfarr,pisonarr_t,pisonabj_t,globo
for(i=0;i<16;i++)
d->statusD[i]=word[i];
multisetState(p,d,word[0],word[1],imagen_psden_d,"./images/Empujador_rojo.png","./images/Empujador_verde.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png");
if(word[3]) //eje bloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde.png","./images/Brazo3_verde.png","./images/Brazo1_verde.png","./images/Brazo2_verde.png","./images/Brazo2_verde.png");
else if(word[2]) //eje desbloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_rojo.png","./images/Brazo3_rojo.png","./images/Brazo1_rojo.png","./images/Brazo2_rojo.png","./images/Brazo2_rojo.png");
else //indefinido
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde.png","./images/Brazo3_verde.png","./images/Brazo1_verde.png","./images/Brazo2_verde.png","./images/Brazo2_verde.png");
setState(p,d,word[6],imagen_pmsup_d,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[7],imagen_pminf_d,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[8],imagen_pisarr_t,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[9],imagen_pisabj_t,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[10],imagen_glob_d,"./images/green.png","./images/grey.png","./images/grey.png");
delete(word);
//////////////////////////
//mask navigation control
MyData.lastMask = MyData.thisMask;
MyData.thisMask = 7;
return 0;
}
static int slotNullEvent(PARAM *p, DATA *d)
{
int* word;
int i;
if(p == NULL || d == NULL) return -1;
ReadCommDATA(&d);
//digitales
//REB1
word = (int*)malloc(16*sizeof(int));
word2digitals(d->val[SCW_STATUSR1B],&word);//Psret,psext,ejedesb,ejebloq,cantabj,cantarr,pisonarr,pisonPMarr
for(i=0;i<16;i++)
d->statusR1[i]=word[i];
multisetState(p,d,word[0],word[1],imagen_psden_r1,"./images/Empujador_rojo.png","./images/Empujador_verde.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png");
if(word[3]) //eje bloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde.png","./images/Brazo3_verde.png","./images/Brazo1_verde.png","./images/Brazo2_verde.png","./images/Brazo2_verde.png");
else if(word[2]) //eje desbloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_rojo.png","./images/Brazo3_rojo.png","./images/Brazo1_rojo.png","./images/Brazo2_rojo.png","./images/Brazo2_rojo.png");
else //indefinido
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde.png","./images/Brazo3_verde.png","./images/Brazo1_verde.png","./images/Brazo2_verde.png","./images/Brazo2_verde.png");
setState(p,d,word[6],imagen_pison_r1,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[7],imagen_pm_r1,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[8],imagen_glob_r1,"./images/Globo_ON.png","./images/Globo_OFF.png","./images/Globo_OFF.png");
//REB2
word2digitals(d->val[SCW_STATUSR2B],&word);//Psret,psext,ejedesb,ejebloq,cantabj,cantarr,pisonarr,pisonPMarr
for(i=0;i<16;i++)
d->statusR2[i]=word[i];
multisetState(p,d,word[0],word[1],imagen_psden_r1,"./images/Empujador_rojo.png","./images/Empujador_verde.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png");
if(word[3]) //eje bloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde2.png","./images/Brazo3_verde2.png","./images/Brazo1_verde2.png","./images/Brazo2_verde2.png","./images/Brazo2_verde2.png");
else if(word[2]) //eje desbloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_rojo2.png","./images/Brazo3_rojo2.png","./images/Brazo1_rojo2.png","./images/Brazo2_rojo2.png","./images/Brazo2_rojo2.png");
else //indefinido
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde2.png","./images/Brazo3_verde2.png","./images/Brazo1_verde2.png","./images/Brazo2_verde2.png","./images/Brazo2_verde2.png");
setState(p,d,word[6],imagen_pison_r2,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[7],imagen_pm_r2,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[8],imagen_glob_r2,"./images/Globo_ON.png","./images/Globo_OFF.png","./images/Globo_OFF.png");
//DESB
word2digitals(d->val[SCW_STATUSDB],&word);//Psret,psext,ejedesb,ejebloq,cantabj,cantarr,pisonsuparr,pisoninfarr,pisonarr_t,pisonabj_t,globo
for(i=0;i<16;i++)
d->statusD[i]=word[i];
multisetState(p,d,word[0],word[1],imagen_psden_d,"./images/Empujador_rojo.png","./images/Empujador_verde.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png","./images/Empujador_rojo.png");
if(word[3]) //eje bloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde.png","./images/Brazo3_verde.png","./images/Brazo1_verde.png","./images/Brazo2_verde.png","./images/Brazo2_verde.png");
else if(word[2]) //eje desbloqueado
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_rojo.png","./images/Brazo3_rojo.png","./images/Brazo1_rojo.png","./images/Brazo2_rojo.png","./images/Brazo2_rojo.png");
else //indefinido
multisetState(p,d,word[4],word[5],imagen_cantilever_r1,"./images/Brazo2_verde.png","./images/Brazo3_verde.png","./images/Brazo1_verde.png","./images/Brazo2_verde.png","./images/Brazo2_verde.png");
setState(p,d,word[6],imagen_pmsup_d,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[7],imagen_pminf_d,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[8],imagen_pisarr_t,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[9],imagen_pisabj_t,"./images/green.png","./images/grey.png","./images/grey.png");
setState(p,d,word[10],imagen_glob_d,"./images/Globo_ON.png","./images/Globo_OFF.png","./images/Globo_OFF.png");
delete(word);
//alarmas
//cout << "DEBUG: numero de alarmas antes de la funcion: " << d->num_alarmas << endl;
CheckAlarms(&d,&p,alarmHTML);
return 0;
}
static int slotButtonEvent(PARAM *p, int id, DATA *d)
{
if(p == NULL || id == 0 || d == NULL) return -1;
return 0;
}
static int slotButtonPressedEvent(PARAM *p, int id, DATA *d)
{
if(p == NULL || id == 0 || d == NULL) return -1;
return 0;
}
static int slotButtonReleasedEvent(PARAM *p, int id, DATA *d)
{
if(p == NULL || id == 0 || d == NULL) return -1;
if (id == but_volver)
{
show_mask2(p);
}
else if(id == alarmHTML)
{
show_mask4(p);
}
return 0;
}
static int slotTextEvent(PARAM *p, int id, DATA *d, const char *text)
{
if(p == NULL || id == 0 || d == NULL || text == NULL) return -1;
else if(id == alarmHTML)
{
show_mask4(p);
}
return 0;
}
static int slotSliderEvent(PARAM *p, int id, DATA *d, int val)
{
if(p == NULL || id == 0 || d == NULL || val < -1000) return -1;
return 0;
}
static int slotCheckboxEvent(PARAM *p, int id, DATA *d, const char *text)
{
if(p == NULL || id == 0 || d == NULL || text == NULL) return -1;
return 0;
}
static int slotRadioButtonEvent(PARAM *p, int id, DATA *d, const char *text)
{
if(p == NULL || id == 0 || d == NULL || text == NULL) return -1;
return 0;
}
static int slotGlInitializeEvent(PARAM *p, int id, DATA *d)
{
if(p == NULL || id == 0 || d == NULL) return -1;
return 0;
}
static int slotGlPaintEvent(PARAM *p, int id, DATA *d)
{
if(p == NULL || id == 0 || d == NULL) return -1;
return 0;
}
static int slotGlResizeEvent(PARAM *p, int id, DATA *d, int width, int height)
{
if(p == NULL || id == 0 || d == NULL || width < 0 || height < 0) return -1;
return 0;
}
static int slotGlIdleEvent(PARAM *p, int id, DATA *d)
{
if(p == NULL || id == 0 || d == NULL) return -1;
return 0;
}
static int slotTabEvent(PARAM *p, int id, DATA *d, int val)
{
if(p == NULL || id == 0 || d == NULL || val < -1000) return -1;
return 0;
}
static int slotTableTextEvent(PARAM *p, int id, DATA *d, int x, int y, const char *text)
{
if(p == NULL || id == 0 || d == NULL || x < -1000 || y < -1000 || text == NULL) return -1;
return 0;
}
static int slotTableClickedEvent(PARAM *p, int id, DATA *d, int x, int y, int button)
{
if(p == NULL || id == 0 || d == NULL || x < -1000 || y < -1000 || button < 0) return -1;
return 0;
}
static int slotSelectionEvent(PARAM *p, int id, DATA *d, int val, const char *text)
{
if(p == NULL || id == 0 || d == NULL || val < -1000 || text == NULL) return -1;
return 0;
}
static int slotClipboardEvent(PARAM *p, int id, DATA *d, int val)
{
if(p == NULL || id == 0 || d == NULL || val < -1000) return -1;
return 0;
}
static int slotRightMouseEvent(PARAM *p, int id, DATA *d, const char *text)
{
if(p == NULL || id == 0 || d == NULL || text == NULL) return -1;
//pvPopupMenu(p,-1,"Menu1,Menu2,,Menu3");
return 0;
}
static int slotKeyboardEvent(PARAM *p, int id, DATA *d, int val, int modifier)
{
if(p == NULL || id == 0 || d == NULL || val < -1000 || modifier < -1000) return -1;
return 0;
}
static int slotMouseMovedEvent(PARAM *p, int id, DATA *d, float x, float y)
{
if(p == NULL || id == 0 || d == NULL || x < -1000 || y < -1000) return -1;
return 0;
}
static int slotMousePressedEvent(PARAM *p, int id, DATA *d, float x, float y)
{
if(p == NULL || id == 0 || d == NULL || x < -1000 || y < -1000) return -1;
return 0;
}
static int slotMouseReleasedEvent(PARAM *p, int id, DATA *d, float x, float y)
{
if(p == NULL || id == 0 || d == NULL || x < -1000 || y < -1000) return -1;
return 0;
}
static int slotMouseOverEvent(PARAM *p, int id, DATA *d, int enter)
{
if(p == NULL || id == 0 || d == NULL || enter < -1000) return -1;
return 0;
}
static int slotUserEvent(PARAM *p, int id, DATA *d, const char *text)
{
if(p == NULL || id == 0 || d == NULL || text == NULL) return -1;
return 0;
}