-
Notifications
You must be signed in to change notification settings - Fork 1
/
mask9_slots.h
executable file
·454 lines (383 loc) · 12.5 KB
/
mask9_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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/*
This file is part of PiResiduos.
Copyright 2017-2018, Prointegra SL.
PiResiduos 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.
PiResiduos 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 PiResiduos.
If not, see <https://www.gnu.org/licenses/>.
*/
//###############################################################
//# mask9_slots.h for ProcessViewServer created: vie mar 17 12:33:32 2017
//# please fill out these slots
//# here you find all possible events
//# Yours: Lehrig Software Engineering
//# PANTALLA DE EDICION DE DI
//###############################################################
// 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; //Change if applicable
//extern rlSiemensTCPClient siemensTCP;
//extern rlPPIClient ppi;
extern std::string type;
extern std::string nombre;
extern station * myStation;
extern SYNC_DATA my_ssh_syncro_data;
extern GLOBAL_DATA globalconfiguration;
#include <boost/algorithm/string.hpp>
#include "mask9_data.h"
#include "mask9_tools.h"
#include "mask_tools.h"
static int slotInit(PARAM *p, DATA *d)
{
pvShow(p,COMBOTRANSPORTISTA);
if(p == NULL || d == NULL) return -1;
//
pvResize(p,0,1910,1020);
//memset(d,0,sizeof(DATA));
std::string wholeTitle = getTitle();
pvSetText(p,LABTYPE,wholeTitle.c_str());
std::vector<std::string> prodNames = formDI->retAllProds4Combo(localDatabase);
//only if transfer we can choose product, other options simply watch already selected product
if(formDI->retForm() == 2 && formDI->retDepMovType() == DEF_MOV_TRANSFER)
{populateCombo(p,COMBOPRODUCTO,prodNames);
pvShow (p,COMBOPRODUCTO);}
else
pvHide(p,COMBOPRODUCTO);
if(formDI->retDepProdCode() == 0)
pvShow(p,FRAME7RED);
if(formDI->retDepProdCode() > 0)
{
pvHide(p,FRAME7RED);
std::string fullName = formDI->retDepProdFullName();
std::string field = std::to_string(formDI->retDepProdLER());
pvSetText(p,EDITLER,field.c_str());
pvSetText(p,EDITDESCLER,fullName.c_str());
pvSetText(p,EDITPELIGRO,formDI->retDepProdPeligro().c_str());
std::string strPeso = std::to_string(formDI->retDepTotalWeight());
pvSetText(p,EDITPESO,strPeso.c_str());
if(formDI->retForm() == 2 && formDI->retDepMovType() == DEF_MOV_TRANSFER)
setComboBoxPos(p,COMBOPRODUCTO,prodNames, formDI->retDepProdFullName() + " " + std::to_string(formDI->retDepProdCode()));
}
//////////////////////////////////////////////
//combobox drivers
formDI->updteDrivers(localDatabase);
std::vector <std::string> driversName = formDI->retAllDriversNames();
populateCombo(p,COMBOTRANSPORTISTA,driversName);
std::string temporal;
pvSetText(p,EDITNOMBRE,formDI->retDepDriName().c_str());
pvSetText(p,EDITNIF,formDI->retDepDriNif().c_str()); //DNI
pvSetText(p,EDITDIREC,formDI->retDepDriAddr().c_str()); //Direccion
temporal = std::to_string(formDI->retDepDriZip()); //CodigoPostal
pvSetText(p,EDITCP,temporal.c_str());
pvSetText(p,EDITMUNI,formDI->retDepDriCity().c_str()); //Ciudad
pvSetText(p,EDITPRO,formDI->retDepDriProv().c_str()); //Provincia
pvSetText(p,EDITCA,formDI->retDepDriReg().c_str()); //Comunidad Autonoma
temporal = std::to_string(formDI->retDepDriNima()); //NIMA
pvSetText(p,EDITNIMA,temporal.c_str());
temporal = std::to_string(formDI->retDepDriNumIns());
pvSetText(p,EDITREG,temporal.c_str()); //Nº inscripcion en el registro
temporal = std::to_string(formDI->retDepDriPhone()); //Telefono
pvSetText(p,EDITTFN,temporal.c_str());
pvSetText(p,EDITEMAIL,formDI->retDepDriMail().c_str()); //Email
if(formDI->retDepDriCode() == 0)
pvShow(p,FRAME8RED);
else
pvHide(p,FRAME8RED);
setComboBoxPos(p,COMBOTRANSPORTISTA,driversName,formDI->retDepDriName());
//console
consoleRefresh(p,d);
pvHide(p,LOADINGFORM);
return 0;
}
static int slotNullEvent(PARAM *p, DATA *d)
{
if(p == NULL || d == NULL) return -1;
//máquina de cambio de estados Entrada PT
std::cout << "#######DEBUG EDICION DI######" << std::endl;
std::cout << "############" << std::endl;
//console
consoleRefresh(p,d);
//date and Time
setDate(p,d,LABDATE);
setTime(p,d,LABTIME);
//syncronization
int i = reconnectSSH(&my_ssh_syncro_data);
if(i == -1)
console.push_back("*ERROR* hubo un error intentando reconectar el tunel ssh, ejecute el script manualmente");
else if (i>=0)
console.push_back("(INFO) reconexión del tunel ssh para la base de datos central, efectuada");
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 == BUT1) //salvar
{
std::cout << "form save" << std::endl;
switch(formDI->retForm())
{
case(1): //unloading
if(formEntrada)
delete formEntrada;
formEntrada = new inputForm();
formEntrada->copyFrom(formDI);
if(formDI)
delete formDI;
formDI = NULL;
show_mask4(p);
break;
case(2)://loading
if(formSalida)
delete formSalida;
formSalida = new outputForm();
formSalida->copyFrom(formDI);
if(formDI)
delete formDI;
formDI = NULL;
show_mask5(p);
break;
default://unknown
if(formDI)
delete formDI;
formDI = NULL;
show_mask4(p);
break;
}
}
else if(id == BUT2) //CANCEL
{
std::cout << "form reset" << std::endl;
switch(formDI->retForm())
{
case(1):
if(formDI)
delete formDI;
formDI = NULL;
show_mask4(p);
break;
case(2):
if(formDI)
delete formDI;
formDI = NULL;
show_mask5(p);
break;
default:
if(formDI)
delete formDI;
formDI = NULL;
show_mask4(p);
break;
}
}
else if(id == BUT1234)
show_mask6(p);
else if(id == BUT5)
show_mask7(p);
else if(id == BUT6)
show_mask8(p);
else if(id == BUT78)
show_mask9(p);
else if(id == BUT910)
show_mask10(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;
if(id==COMBOTRANSPORTISTA)
{
std::string temporal;
std::string name = text;
if(!name.compare("ELIJA")) //CLEAR
{
std::cout<< "estamos en ELIJA"<< std::endl;
/*pvSetText(p,EDITNOMBRE,"");
pvSetText(p,EDITNIF,"");
pvSetText(p,EDITDIREC,"");
pvSetText(p,EDITCP,"");
pvSetText(p,EDITMUNI,"");
pvSetText(p,EDITPRO,"");
pvSetText(p,EDITCA,"");
pvSetText(p,EDITNIMA,"");
pvSetText(p,EDITREG,"");
pvSetText(p,EDITTFN,"");
pvSetText(p,EDITEMAIL,"");
pvShow(p,FRAME8RED);
formDI->resetDepDriver();*/
}
else
{
formDI->setDriverByName(name);
pvSetText(p,EDITNOMBRE,name.c_str()); //Nombre
pvSetText(p,EDITNIF,formDI->retDepDriNif().c_str()); //DNI
pvSetText(p,EDITDIREC,formDI->retDepDriAddr().c_str()); //Direccion
temporal = std::to_string(formDI->retDepDriZip()); //CodigoPostal
pvSetText(p,EDITCP,temporal.c_str());
pvSetText(p,EDITMUNI,formDI->retDepDriCity().c_str()); //Ciudad
pvSetText(p,EDITPRO,formDI->retDepDriProv().c_str()); //Provincia
pvSetText(p,EDITCA,formDI->retDepDriReg().c_str()); //Comunidad Autonoma
temporal = std::to_string(formDI->retDepDriNima()); //NIMA
pvSetText(p,EDITNIMA,temporal.c_str());
temporal = std::to_string(formDI->retDepDriNumIns());
pvSetText(p,EDITREG,temporal.c_str()); //Nº inscripcion en el registro
temporal = std::to_string(formDI->retDepDriPhone()); //Telefono
pvSetText(p,EDITTFN,temporal.c_str());
pvSetText(p,EDITEMAIL,formDI->retDepDriMail().c_str()); //Email
pvHide(p,FRAME8RED);
}
pvSetFocus(p,COMBOTRANSPORTISTA);
}
else if(id==COMBOPRODUCTO)
{
std::string name = text;
if(!name.compare("ELIJA")) //CLEAR
{
pvShow(p,FRAME7RED);
pvSetText(p,EDITLER,"");
pvSetText(p,EDITDESCLER,"");
pvSetText(p,EDITPELIGRO,"");
pvSetText(p,EDITPESO,"");
formDI->resetDepProduct();
}
else
{
long prodCode = retCodeFromString(name," ");
if(prodCode)
{
pvHide(p,FRAME7RED);
formDI->setDepProdCode(prodCode);
formDI->setAllProductData(localDatabase);
std::string field = std::to_string(formDI->retDepProdLER());
pvSetText(p,EDITLER,field.c_str());
pvSetText(p,EDITDESCLER,formDI->retDepProdFullName().c_str());
pvSetText(p,EDITPELIGRO,formDI->retDepProdPeligro().c_str());
std::string strPeso = std::to_string(formDI->retDepTotalWeight());
pvSetText(p,EDITPESO,strPeso.c_str());
}
else
{
pvShow(p,FRAME7RED);
pvSetText(p,EDITLER,"");
pvSetText(p,EDITDESCLER,"");
pvSetText(p,EDITPELIGRO,"");
pvSetText(p,EDITPESO,"");
formDI->resetDepProduct();
}
}
pvSetFocus(p,COMBOPRODUCTO);
}
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 == -1 || 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;
}