forked from EZTechBrasil/EZClientCSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
1793 lines (1501 loc) · 75.8 KB
/
Form1.cs
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace EZClientCSharp
{
public partial class Form1 : Form
{
private byte[] lastStates = new byte[100];
public Form1()
{
InitializeComponent();
}
#region Carregamento do form
private void Form1_Load(object sender, EventArgs e)
{
Int32 ct = 0;
String version = "";
edServerAddress.Text = "192.168.1.111";
// Carrega lista de bombas
for (ct = 1; ct < 32; ct++)
cbPump.Items.Add(ct);
cbPump.SelectedIndex = 0;
// Carrega lista de bicos
for (ct = 1; ct <= 8; ct++)
cbHose.Items.Add(ct);
cbHose.SelectedIndex = 0;
// Preenche lista de tipos de preset
cbPresetType.Items.Add("Dinheiro");
cbPresetType.Items.Add("Volume");
cbPresetType.SelectedIndex = 0;
// Le versao da EZClient.dll
EZInterface.DllVersion(ref version);
WriteMessage(version);
}
#endregion
#region Get CompanyID
// <summary>
// Calcula o codigo referente ao ID do bico nos concentradores CBC da Companytec.
// HoseNumber: numero fisico do bico na bomba
// PumpNumber: numero da bomba
// </summary>
//
private String CompanyID(short HoseNumber, short PumpNumber)
{
int Offset;
switch (HoseNumber)
{
case 2: Offset = 0x44; break;
case 3: Offset = 0x84; break;
case 4: Offset = 0xC4; break;
default: // Outros valores são tratados como Bico 1
Offset = 0x04;
break;
}
return ((PumpNumber - 1) + Offset).ToString("X2");
}
#endregion
#region Avalia retorno das APIS EZForecourt e gera mensagem de erro
private Boolean GoodResult(Int32 res)
{
string MSG;
if (res == 0)
return (true);
MSG = EZInterface.ResultString(res);
WriteMessage(" *** Error: (" + res + ") " + MSG);
return (false);
}
#endregion
#region Método de Escrever Mensagens no Box
private void WriteMessage(String msg)
{
listMessageBox.Items.Add(msg);
listMessageBox.SelectedIndex = listMessageBox.Items.Count - 1;
listMessageBox.SelectedIndex = -1;
}
#endregion
#region Autentificação
private void btLogon_Click(object sender, EventArgs e)
{
short tipoDeCliente;
int clienteID = 35;
IntPtr iprt = new IntPtr(0);
DateTime dateTime = DateTime.Now;
if (chProcEvents.Checked)
tipoDeCliente = 7;
else
tipoDeCliente = 1;
if (edServerAddress.Enabled == true)
{
WriteMessage("Conectando no servidor: " + edServerAddress.Text);
if (GoodResult(EZInterface.ClientLogonEx(clienteID, tipoDeCliente, edServerAddress.Text, 5123, 5124, 10000, 0, new IntPtr(0), 0)))
{
edServerAddress.Enabled = false;
chProcEvents.Enabled = false;
btLogon.Text = "Logoff";
EZInterface.SetClientType(EZInterface.SINK_CLIENT_EVENT);
}
if (GoodResult(EZInterface.SetDateTime(dateTime)))
WriteMessage("Data e Hora do concentrador atualizada com sucesso");
}
else
{
WriteMessage("Desconectando do servidor: " + edServerAddress.Text);
GoodResult(EZInterface.ClientLogoff());
edServerAddress.Enabled = true;
chProcEvents.Enabled = true;
btLogon.Text = "Logon";
}
}
#endregion
#region Limpar Mensagens do Box
private void btClearMessages_Click(object sender, EventArgs e)
{
listMessageBox.Items.Clear();
}
#endregion
#region Liberação pelo Cartão
private void btReadCards_Click(object sender, EventArgs e)
{
int CardID = 0;
int Number = 0;
string Name = "";
int PumpID = 0;
short CardType = 0;
int ParentID = 0;
Int64 Tag = 0;
DateTime TimeStamp = new DateTime();
// Verifica conexao
if (!GoodResult(EZInterface.TestConnection()))
return;
while (true)
{
// Le ID do primeiro cartao da lista
if (EZInterface.GetCardReadByOrdinal(1, ref CardID) != 0)
break;
// LE dados do cartao
if (!GoodResult(EZInterface.GetCardReadProperties(CardID, ref Number, ref Name, ref PumpID, ref CardType, ref ParentID, ref Tag, ref TimeStamp)))
break;
WriteMessage(" --- Cartao Lido: " +
" ID= " + CardID +
", Numero= " + Number +
", Nome= " + Name +
", PumpID= " + PumpID +
", CardType= " + CardType +
", ParentID= " + ParentID +
", Tag= " + Tag.ToString("X10") +
", TimeStamp= " + TimeStamp);
// Esta função so funciona se a Autorizacao estiver configurada com um tipo de cartao:
// "Carta/Placa", "Frentista", "Cliente", "Frentista E Cliente", "Frentista OU Cliente"
if (GoodResult(EZInterface.TagAuthorise(PumpID, Tag, (short)EZInterface.TAllocLimitType.NO_LIMIT_TYPE, 0, 0xFF, 1)))
break;
WriteMessage(" --- Bomba " + PumpID + "Autorizada com Cartao " + Tag);
// Apaga Cartao da lista
if (!GoodResult(EZInterface.DeleteCardRead(CardID)))
break;
}
}
#endregion
#region Checando a conexão
private void btCheckConnection_Click(object sender, EventArgs e)
{
if (!GoodResult(EZInterface.TestConnection()))
{
edServerAddress.Enabled = true;
btLogon_Click(this, null);
}
else
WriteMessage("Conexao com EZServer OK!");
}
#endregion
#region Método do Time
private void timerAppLoop_Tick(object sender, EventArgs e)
{
if (chProcEvents.Checked == true)
InternalProccessEvents();
else // Processamento por Pooling
ReadPumpsStatus();
}
#endregion
#region Lendo o status das bombas
private void ReadPumpsStatus()
{
int PumpsCount = 0;
String PumpStates = "";
String CurrentHose = "";
String DeliveriesCount = "";
int Idx = 0;
int CurStatus = 0;
int CurHose = 0;
int CurDelv = 0;
String StrStatus = "";
byte[] cstatus;
byte[] chose;
byte[] cdeliv;
System.Text.ASCIIEncoding conv = new System.Text.ASCIIEncoding();
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() == 0)
{
// Verifica a quantidade de bombas configuradas
if (!GoodResult(EZInterface.GetPumpsCount(ref PumpsCount)))
return;
// Le o estado de todas as bombas configuradas
if (!GoodResult(EZInterface.GetAllPumpStatuses(ref PumpStates, ref CurrentHose, ref DeliveriesCount)))
return;
cstatus = conv.GetBytes(PumpStates);
chose = conv.GetBytes(CurrentHose);
cdeliv = conv.GetBytes(DeliveriesCount);
for (Idx = 1; Idx <= PumpsCount; Idx++)
{
CurStatus = cstatus[Idx - 1] - '0'; // EZClient.TPumpState(Ord(PumpStates[Idx])-Ord('0'));
CurHose = chose[Idx - 1] - '0';
CurDelv = cdeliv[Idx - 1] - '0';
switch ((EZInterface.TPumpState)CurStatus) // PAM10)
{
case EZInterface.TPumpState.INVALID_PUMP_STATE: StrStatus = "estado invalido."; break; // 0 - OFFLINE
case EZInterface.TPumpState.NOT_INSTALLED_PUMP_STATE: StrStatus = "nao instalada."; break; // 6 - CLOSE
case EZInterface.TPumpState.NOT_RESPONDING_1_PUMP_STATE: StrStatus = "Bomba nao responde."; break; // 0 - OFFLINE
case EZInterface.TPumpState.IDLE_PUMP_STATE: StrStatus = "em espera (desocupada)."; break; // 1 - IDLE
case EZInterface.TPumpState.PRICE_CHANGE_STATE: StrStatus = "troca de preco."; break; // 1 - IDLE
case EZInterface.TPumpState.AUTHED_PUMP_STATE: StrStatus = "Bomba Autorizada"; break; // 9 - AUTHORIZED
case EZInterface.TPumpState.CALLING_PUMP_STATE: StrStatus = "esperando autorizacao."; break; // 5 - CALL
case EZInterface.TPumpState.DELIVERY_STARTING_PUMP_STATE: StrStatus = "abastecimeneto iniciando."; break; // 2 - BUSY
case EZInterface.TPumpState.DELIVERING_PUMP_STATE: StrStatus = "abastecendo."; break; // 2 - BUSY
case EZInterface.TPumpState.TEMP_STOPPED_PUMP_STATE: StrStatus = "parada temporaria (no meio de uma abastecimento) (STOP)."; break; // 8 - STOP
case EZInterface.TPumpState.DELIVERY_FINISHING_PUMP_STATE: StrStatus = "abastecimento finalizando (fluxo de produto diminuindo)."; break; // 2 - BUSY
case EZInterface.TPumpState.DELIVERY_FINISHED_PUMP_STATE: StrStatus = "abastecimento finalizado (parou de sair combustivel)."; break; // 2 - BUSY
case EZInterface.TPumpState.DELIVERY_TIMEOUT_PUMP_STATE: StrStatus = "abastecimento excedeu tempo maximo."; break; // 1 - IDLE
case EZInterface.TPumpState.HOSE_OUT_PUMP_STATE: StrStatus = "bico fora do guarda-bico (CALL)."; break; // 5 - CALL
case EZInterface.TPumpState.PREPAY_REFUND_TIMEOUT_STATE: StrStatus = "prazo de pre-determinacao esgotado."; break; // 1 - IDLE
case EZInterface.TPumpState.DELIVERY_TERMINATED_STATE: StrStatus = "abastecimento terminado (EOT)"; break; // 3 - EOT
case EZInterface.TPumpState.ERROR_PUMP_STATE: StrStatus = "Erro (resposta de erro da bomba)."; break; // 0 - OFFLINE
case EZInterface.TPumpState.NOT_RESPONDING_2_PUMP_STATE: StrStatus = "EZID nao responde."; break;
case EZInterface.TPumpState.LAST_PUMP_STATE: StrStatus = "Ultimo estado da bomba?"; break;
default:
StrStatus = "estado desconhecido = " + CurStatus;
break;
}
if (lastStates[Idx - 1] != cstatus[Idx - 1])
{
WriteMessage("Bomba " + Idx + ", Bico " + chose[Idx - 1] +
", Pendentes " + cdeliv[Idx - 1] +
", Status: " + StrStatus);
//lastStates.IndexOf(PumpStates[Idx], Idx);
lastStates[Idx - 1] = cstatus[Idx - 1];
}
}
}
}
#endregion
#region Processamento de eventos
private void InternalProccessEvents()
{
int EvtCt = 0;
short EvtType = 0;
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
// Inicia processamento de eventos
if (!GoodResult(EZInterface.ProcessEvents()))
return;
// Le numero de eventos disponiveis
if (!GoodResult(EZInterface.GetEventsCount(ref EvtCt)))
return;
while (true)
{
// Le o proximo evento
if (!GoodResult(EZInterface.GetNextEventType(ref EvtType)))
return;
if (EvtType != 0)
WriteMessage(" -> EVENTO GERADO <- : " + EvtType);
switch ((EZInterface.ClientEvent)EvtType)
{
//---------------------------------------------------------------------
case EZInterface.ClientEvent.PUMP_EVENT: // Trata Eventos das Bombas
EventPump();
break;
//---------------------------------------------------------------------
case EZInterface.ClientEvent.DELIVERY_EVENT: // Eventos de abastecimento
EventDelivery();
break;
//---------------------------------------------------------------------
case EZInterface.ClientEvent.CARD_READ_EVENT: // Eventos de leitores de cartoes
EventCardRead();
break;
//---------------------------------------------------------------------
case EZInterface.ClientEvent.DB_LOG_ETOTALS: // Evento de mudanca de encerrantes
EventDbLogETotals();
break;
//---------------------------------------------------------------------
case EZInterface.ClientEvent.SERVER_EVENT: // Eventos do servidor
EventServer();
break;
//---------------------------------------------------------------------
case EZInterface.ClientEvent.CLIENT_EVENT: // Eventos de POS (client)
EventClient();
break;
//---------------------------------------------------------------------
case EZInterface.ClientEvent.ZB2G_STATUS_EVENT: // Eventos de Zigbee
EventZB2G();
break;
//---------------------------------------------------------------------
case EZInterface.ClientEvent.LOG_EVENT_EVENT: // Log eventos
EventLog();
break;
//---------------------------------------------------------------------
case EZInterface.ClientEvent.DB_TANK_STATUS: // Eventos de Tanque
EventTank();
break;
//---------------------------------------------------------------------
case EZInterface.ClientEvent.NO_CLIENT_EVENT: // Trata Eventos do Cliente
return;
//---------------------------------------------------------------------
default:
GoodResult(EZInterface.DiscardNextEvent());
WriteMessage("Não há eventos");
break;
}
}
}
#endregion
#region Evento da Bomba
private void EventPump()
{
int PumpID = 0;
int PumpNumber = 0;
short State = 0;
short ReservedFor = 0;
int ReservedBy = 0;
int HoseID = 0;
int HoseNumber = 0;
int HosePhysicalNumber = 0;
int GradeID = 0;
int GradeNumber = 0;
short PriceLevel = 0;
double Price = 0;
double Volume = 0;
double Value = 0;
short StackSize = 0;
int PhysicalNumber = 0;
short Side = 0;
short Address = 0;
short PriceLevel1 = 0;
short PriceLevel2 = 0;
short PumpType = 0;
int PortID = 0;
short AuthMode = 0;
short StackMode = 0;
short PrepayAllowed = 0;
short PreauthAllowed = 0;
short PriceFormat = 0;
short ValueFormat = 0;
short VolumeFormat = 0;
Int64 Tag = 0;
int AttendantID = 0;
int AttendantNumber = 0;
Int64 AttendantTag = 0;
int CardClientID = 0;
int CardClientNumber = 0;
Int64 CardClientTag = 0;
double CurFlowRate = 0;
double PeakFlowRate = 0;
//String cbcID = "";
String GradeName = "";
String ShortGradeName = "";
String PumpName = "";
String AttendantName = "";
String CardClientName = "";
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
if (GoodResult(EZInterface.GetNextPumpEventEx3(ref PumpID, ref PumpNumber, ref State,
ref ReservedFor, ref ReservedBy, ref HoseID,
ref HoseNumber, ref HosePhysicalNumber,
ref GradeID, ref GradeNumber, ref GradeName,
ref ShortGradeName, ref PriceLevel, ref Price,
ref Volume, ref Value, ref StackSize,
ref PumpName, ref PhysicalNumber, ref Side,
ref Address, ref PriceLevel1, ref PriceLevel2,
ref PumpType, ref PortID, ref AuthMode,
ref StackMode, ref PrepayAllowed, ref PreauthAllowed,
ref PriceFormat, ref ValueFormat, ref VolumeFormat,
ref Tag, ref AttendantID, ref AttendantNumber,
ref AttendantName, ref AttendantTag, ref CardClientID,
ref CardClientNumber, ref CardClientName, ref CardClientTag,
ref CurFlowRate, ref PeakFlowRate)))
{
WriteMessage(" PumpEvent: " +
" PumpID= " + PumpID +
", PumpNumber= " + PumpNumber +
", State= " + State +
", ReservedFor= " + ReservedFor +
", ReservedBy= " + ReservedBy +
", HoseID= " + HoseID +
", HoseNumber= " + HoseNumber +
", HosePhisicalNumber= " + HosePhysicalNumber +
", GradeID= " + GradeID +
", GradeName= " + GradeName +
", GradeNumber= " + GradeNumber +
", ShortGradeName= " + ShortGradeName +
", PriceLevel= " + PriceLevel +
", Price= " + Price +
", Volume= " + Volume +
", Value= " + Value +
", StackSize= " + StackSize +
", PumpName= " + PumpName +
", PhysicalNumber= " + PhysicalNumber +
", Side= " + Side +
", Address= " + Address +
", PriceLevel1= " + PriceLevel1 +
", PriceLevel2= " + PriceLevel2 +
", PumpType= " + PumpType +
", PortID= " + PortID +
", AuthMode= " + AuthMode +
", StackMode= " + StackMode +
", PrepayAllowed= " + PrepayAllowed +
", PreauthAllowed= " + PreauthAllowed +
", PriceFormat= " + PriceFormat +
", ValueFormat= " + ValueFormat +
", VolumeFormat= " + VolumeFormat +
", Tag= " + Tag +
", AttendantID= " + AttendantID +
", AttendantNumber= " + AttendantNumber +
", AttendantName= " + AttendantName +
", AttendantTag= " + AttendantTag +
", CardClientID= " + CardClientID +
", CardClientNumber= " + CardClientNumber +
", CardClientName= " + CardClientName +
", CardClientTag= " + CardClientTag +
", CurFlowRate= " + CurFlowRate +
", PeakFlowRate= " + PeakFlowRate);
WriteMessage(" Bico Equivalente CBC: " + CompanyID((short)HoseNumber, (short)PumpNumber));
}
}
#endregion
#region Evento de Abastecimento
private void EventDelivery()
{
int DeliveryID = 0;
int HosePhysicalNumber = 0;
int TankID = 0;
int TankNumber = 0;
short DeliveryState = 0;
short DeliveryType = 0;
double Volume2 = 0;
DateTime CompletedDT = new DateTime();
int LockedBy = 0;
int Age = 0;
DateTime ClearedDT = new DateTime();
double OldVolumeETot = 0;
double OldVolume2ETot = 0;
double OldValueETot = 0;
double NewVolumeETot = 0;
double NewVolume2ETot = 0;
double NewValueETot = 0;
int Duration = 0;
int PumpID = 0;
int PumpNumber = 0;
int HoseID = 0;
int HoseNumber = 0;
//short HosePhisicalNumber = 0;
int GradeID = 0;
int GradeNumber = 0;
short PriceLevel = 0;
double Price = 0;
double Volume = 0;
double Value = 0;
int ReservedBy = 0;
Int64 Tag = 0;
int AttendantID = 0;
int AttendantNumber = 0;
Int64 AttendantTag = 0;
int CardClientID = 0;
int CardClientNumber = 0;
Int64 CardClientTag = 0;
double PeakFlowRate = 0;
short State = 0;
short Type = 0;
//String cbcID = "";
String TankName = "";
String GradeShortName = "";
String GradeCode = "";
String PumpName = "";
String GradeName = "";
String AttendantName = "";
String CardClientName = "";
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
if (GoodResult(EZInterface.GetNextDeliveryEventEx3(ref DeliveryID, ref HoseID, ref HoseNumber, ref HosePhysicalNumber, ref PumpID, ref PumpNumber, ref PumpName,
ref TankID, ref TankNumber, ref TankName,
ref GradeID, ref GradeNumber, ref GradeName, ref GradeShortName, ref GradeCode,
ref State, ref Type, ref Volume, ref PriceLevel,
ref Price, ref Value, ref Volume2, ref CompletedDT, ref LockedBy,
ref ReservedBy, ref AttendantID, ref Age, ref ClearedDT,
ref OldVolumeETot, ref OldVolume2ETot, ref OldValueETot,
ref NewVolumeETot, ref NewVolume2ETot, ref NewValueETot,
ref Tag, ref Duration, ref AttendantNumber, ref AttendantName, ref AttendantTag,
ref CardClientID, ref CardClientNumber, ref CardClientName, ref CardClientTag)))
{
// Primeiro abastecimento pode ser invalido
if (DeliveryID > 0)
{
WriteMessage(" DeliveryEvent: " +
" DeliveryID= " + DeliveryID +
", HoseID= " + HoseID +
", HoseNumber= " + HoseNumber +
", HosePhysicalNumber= " + HosePhysicalNumber +
", PumpID= " + PumpID +
", PumpNumber= " + PumpNumber +
", PumpName= " + PumpName +
", TankID= " + TankID +
", TankNumber= " + TankNumber +
", TankName= " + TankName +
", GradeID= " + GradeID +
", GradeNumber= " + GradeNumber +
", GradeName= " + GradeName +
", GradeShortName= " + GradeShortName +
", GradeCode= " + GradeCode +
", DeliveryState= " + DeliveryState +
", DeliveryType= " + DeliveryType +
", Volume= " + Volume +
", PriceLevel= " + PriceLevel +
", Price= " + Price +
", Value= " + Value +
", Volume2= " + Volume2 +
", CompletedDT= " + CompletedDT +
", LockedBy= " + LockedBy +
", ReservedBy= " + ReservedBy +
", AttendantID= " + AttendantID +
", Age= " + Age +
", ClearedDT= " + ClearedDT +
", OldVolumeETot= " + OldVolumeETot +
", OldVolume2ETot= " + OldVolume2ETot +
", OldValueETot= " + OldValueETot +
", NewVolumeETot= " + NewVolumeETot +
", NewVolume2ETot= " + NewVolume2ETot +
", NewValueETot= " + NewValueETot +
", Tag= " + Tag +
", Duration= " + Duration +
", AttendantNumber= " + AttendantNumber +
", AttendantName= " + AttendantName +
", AttendantTag= " + AttendantTag +
", CardClientID= " + CardClientID +
", CardClientNumber= " + CardClientNumber +
", CardClientName= " + CardClientName +
", CardClientTag= " + CardClientTag +
",PeakFlowRate= " + PeakFlowRate);
WriteMessage(" Bico Equivalente CBC: " + CompanyID((short)HoseNumber, (short)PumpNumber));
}
}
}
#endregion
#region Evento de Leitura de Cartão
private void EventCardRead()
{
int CardReadID = 0;
int Number = 0;
short CardType = 0;
int ParentID = 0;
DateTime TimeStamp = new DateTime();
Int64 Tag = 0;
int PumpID = 0;
String Name = "";
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
WriteMessage("Leitura de cartão solicitada!");
if (GoodResult(EZInterface.GetNextCardReadEvent(ref CardReadID, ref Number, ref Name,
ref PumpID, ref CardType, ref ParentID,
ref Tag, ref TimeStamp)))
{
WriteMessage("\n------ CardReadEvent: CardReadID " + CardReadID +
", Number " + Number +
", Name " + Name +
", PumpID " + PumpID);
WriteMessage(" CardType " + CardType +
", ParentID " + ParentID +
", Tag " + Tag +
", TimeStamp " + TimeStamp);
// <summary>
// Rotina utilizada para identificar o status do cartão lido.
// </summary>
switch ((EZInterface.TTagType)CardType)
{
case EZInterface.TTagType.ATTENDANT_TAG_TYPE:
WriteMessage(" Attendant: " + Name + " Tag " + Tag);
break;
case EZInterface.TTagType.BLOCKED_ATTENDANT_TAG_TYPE:
WriteMessage("\n Blocked attendant: " + Name + " Tag " + Tag);
break;
case EZInterface.TTagType.WRONG_SHIFT_ATTENDANT_TAG_TYPE:
WriteMessage("\n Wrong shift attendant: " + Name + " Tag " + Tag);
break;
case EZInterface.TTagType.CLIENT_TAG_TYPE:
WriteMessage("\n Client: " + Name + " Tag " + Tag);
break;
case EZInterface.TTagType.BLOCKED_CLIENT_TAG_TYPE:
WriteMessage("\n Blocked Client: " + Name + " Tag " + Tag);
break;
case EZInterface.TTagType.UNKNOWN_TAG_TYPE:
WriteMessage("\n Unknown Tag read: " + Tag);
break;
default:
WriteMessage("\n Unknown Tag type: " + CardType + " Tag " + Tag);
break;
}
GoodResult(EZInterface.DeleteCardRead(CardReadID));
}
}
#endregion
#region Evento de mudanca de encerrantes
private void EventDbLogETotals()
{
int HoseID = 0;
double Volume = 0;
double Value = 0;
double VolumeETot = 0;
double ValueETot = 0;
int HoseNumber = 0;
int HosePhysicalNumber = 0;
int PumpID = 0;
int PumpNumber = 0;
int TankID = 0;
int TankNumber = 0;
int GradeID = 0;
String PumpName = "";
String TankName = "";
String GradeName = "";
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
if (GoodResult(EZInterface.GetNextDBHoseETotalsEventEx(ref HoseID, ref Volume, ref Value,
ref VolumeETot, ref ValueETot,
ref HoseNumber, ref HosePhysicalNumber,
ref PumpID, ref PumpNumber, ref PumpName,
ref TankID, ref TankNumber, ref TankName,
ref GradeID, ref GradeName)))
{
WriteMessage("------ HoseETotalEvent: HoseID " + HoseID + ", Volume " + Volume + " Value " + Value);
WriteMessage(" VolumeETot " + VolumeETot + ", ValueETot " + ValueETot);
WriteMessage(" HoseNumber " + HoseNumber + ", HosePhysicalNumber " + HosePhysicalNumber);
WriteMessage(" PumpID " + PumpID + ", PumpNumber " + PumpNumber + ", PumpName " + PumpName);
WriteMessage(" TankID " + TankID + ", TankNumber " + TankNumber + ", TankName " + TankName);
WriteMessage(" GradeID " + GradeID + ", GradeName " + GradeName);
}
}
#endregion
#region Evento do EZServer
private void EventServer()
{
int EventID = 0;
String EventText = "";
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
if (GoodResult(EZInterface.GetNextServerEvent(ref EventID, ref EventText)))
WriteMessage("------ ServerEvent: EventID " + EventID + ", EventText " + EventText);
}
#endregion
#region Evento de Client
private void EventClient()
{
int EventID = 0;
short ClientID = 0;
String EventText = "";
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
if (GoodResult(EZInterface.GetNextClientEvent(ref ClientID, ref EventID, ref EventText)))
WriteMessage("------ ClientEvent: ClientID " + ClientID + ", EventID " + EventID + ", EventText " + EventText);
}
#endregion
#region Evento dos dispositivos ZigBee
private void EventZB2G()
{
Int32 PortID = 0;
Int64 ZBAddress = 0;
Int16 LQI = 0;
Int16 RSSI = 0;
Int64 ParZBAddress = 0;
Int16 ZBChannel = 0;
Int16 MemBlocks = 0;
Int16 MemFree = 0;
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
if (GoodResult(EZInterface.GetNextZB2GStatusEvent(ref PortID, ref ZBAddress, ref LQI, ref RSSI, ref ParZBAddress, ref ZBChannel, ref MemBlocks, ref MemFree)))
WriteMessage("------ ZigBeeEvent: PortID " + PortID + ", Endereço ZigBee " + ZBAddress + ", LQI " + LQI + ", RSSI " + RSSI + ", ParZBAddress " + ParZBAddress + ", Canal " + ZBChannel + ", Memória Bloqueada " + MemBlocks + ", Memória Livre " + MemFree);
}
#endregion
#region Evento Logged
private void EventLog()
{
Int32 LogEventID = 0;
Int16 DeviceType = 0;
Int32 DeviceID = 0;
Int32 DeviceNumber = 0;
String DeviceName = "";
Int16 EventLevel = 0;
Int16 EventType = 0;
String EventDesc = "";
DateTime GeneratedDT = new DateTime();
DateTime ClearedDT = new DateTime();
Int32 ClearedBy = 0;
Int32 AckedBy = 0;
Double Volume = 0;
Double Value = 0;
Double ProductVolume = 0;
Double ProductLevel = 0;
Double WaterLevel = 0;
Double Temperature = 0;
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
if (GoodResult(EZInterface.GetNextLogEventEvent(ref LogEventID,
ref DeviceType, ref DeviceID, ref DeviceNumber,
ref DeviceName, ref EventLevel, ref EventType,
ref EventDesc, ref GeneratedDT, ref ClearedDT,
ref ClearedBy, ref AckedBy, ref Volume,
ref Value, ref ProductVolume, ref ProductLevel,
ref WaterLevel, ref Temperature)))
{
WriteMessage("------ LogEvent: LogEventID " + LogEventID +
", DeviceType " + DeviceType + ", DeviceID " + DeviceID +
", DeviceNumber " + DeviceNumber + ", DeviceName " + DeviceName +
", EventLevel " + EventLevel + ", EventType " + EventType +
", EventDesc " + EventDesc + ", GeneratedDT " + GeneratedDT +
", ClearedDT " + ClearedDT + ", ClearedBy " + ClearedBy +
", AckedBy " + AckedBy + ", Volume " + Volume +
", Value " + Value + ", ProductVolume " + ProductVolume +
", ProductLevel " + ProductLevel + ", WaterLevel " + WaterLevel +
", Temperature " + Temperature);
}
}
#endregion
#region Evento de Tanque
private void EventTank()
{
Int32 TankID = 0;
Double GaugeVolume = 0;
Double GaugeTCVolume = 0;
Double GaugeUllage = 0;
Double GaugeTemperature = 0;
Double GaugeLevel = 0;
Double GaugeWaterVolume = 0;
Double GaugeWaterLevel = 0;
Int32 TankNumber = 0;
String TankName = "";
Int32 GradeID = 0;
String GradeName = "";
Int16 Type = 0;
Double Capacity = 0;
Double Diameter = 0;
Int32 GaugeID = 0;
Int16 ProbeNo = 0;
Int16 State = 0;
Int32 AlarmsMask = 0;
// Verifica se esta conectado ao servidor
if (EZInterface.TestConnection() != 0)
return;
if (GoodResult(EZInterface.GetNextDBTankStatusEventEx2(ref TankID,
ref GaugeVolume, ref GaugeTCVolume, ref GaugeUllage,
ref GaugeTemperature, ref GaugeLevel, ref GaugeWaterVolume,
ref GaugeWaterLevel, ref TankNumber, ref TankName,
ref GradeID, ref GradeName, ref Type,
ref Capacity, ref Diameter, ref GaugeID,
ref ProbeNo, ref State, ref AlarmsMask)))
{
WriteMessage("------ TankEvent: TankID " + TankID +
", GaugeVolume " + GaugeVolume + ", GaugeTCVolume " + GaugeTCVolume +
", GaugeUllage " + GaugeUllage + ", GaugeTemperature " + GaugeTemperature +
", GaugeLevel " + GaugeLevel + ", GaugeWaterVolume " + GaugeWaterVolume +
", GaugeWaterLevel " + GaugeWaterLevel + ", TankNumber " + TankNumber +
", TankName " + TankName + ", GradeID " + GradeID +
", GradeName " + GradeName + ", Type " + Type +
", Capacity " + Capacity + ", Diameter " + Diameter +
", GaugeID " + GaugeID + ", ProbeNo " + ProbeNo +
", State " + State + ", AlarmsMask " + AlarmsMask);
}
}
#endregion
#region Listando todas as configurações.
private void btLoadConfig_Click(object sender, EventArgs e)
{
ListGrades();
ListTanks();
ListSensors();
ListPumps();
ListZigbee();
ListHoses();
}
#endregion
#region Lista configuração de combustíveis
private void ListGrades()
{
int Idx = 0;
int Ct = 0;
int Id = 0;
int Number = 0;
Int16 Type = 0;
String Name = "";
String ShortName = "";
String Code = "";
//--------------------------------------------------------------------
// Ler o numero de produtos configurados //
if (!GoodResult(EZInterface.GetGradesCount(ref Ct)))
return;
WriteMessage("[Produtos " + Ct + "]---------------------------------------------------");
for (Idx = 0; Idx < Ct; Idx++)
{
if (EZInterface.GetGradeByOrdinal(Idx + 1, ref Id) != 0)
return;
if (GoodResult(EZInterface.GetGradePropertiesEx(Id, ref Number, ref Name, ref ShortName, ref Code, ref Type)))
WriteMessage(" Grade: " + Number + ", Nome: " + Name + ", Abreviado: " + ShortName + ", Codigo: " + Code + ", Tipo: " + Type);
}
WriteMessage("");
}
#endregion
#region Listar Tanques
private void ListTanks()
{
int Idx = 0;
int Ct = 0;
int Id = 0;
int Number = 0;
int GradeID = 0;
int GradeNumber = 0;
int GaugeID = 0;
int GaugeAlarmsMask = 0;
short TType = 0;
short State = 0;
short ProbeNo = 0;
double Capacity = 0;
double Diameter = 0;
double TheoVolume = 0;
double GaugeVolume = 0;
double GaugeTCVolume = 0;
double GaugeUllage = 0;
double GaugeTemperature = 0;
double GaugeLevel = 0;
double GaugeWaterVolume = 0;
double GaugeWaterLevel = 0;