-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfrmmain.cpp
More file actions
6237 lines (5911 loc) · 241 KB
/
frmmain.cpp
File metadata and controls
6237 lines (5911 loc) · 241 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
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
#include "frmmain.h"
#include "ui_frmmain.h"
#include "iconhelper.h"
#include "../myhelper.h"
#include "datastruct.h"
#include <qtextcodec.h>
#include "qstring.h"
#include <QString>
#include <qglobal.h>
#include <QByteArray>
#include <QTextCodec>
#include <QDebug>
#include "../TreeViewClass/itemdelegate.h"
#include "../TreeViewClass/treeitem.h"
#include "../TreeViewClass/treemodel.h"
#include <QtSql>
#include "frmoperateparentmsgbox.h"
#include "frmreadslavemsg.h"
#include "../DATA/slavemsg.h"
#include <phonon/audiooutput.h>
#include <phonon/seekslider.h>
#include <phonon/mediaobject.h>
#include <phonon/volumeslider.h>
#include <phonon/backendcapabilities.h>
#include "./AppConfig/myapp.h"
#include <QSettings>
QList<VoiceInfoBank> voiceLibrary;
QString sFilePath;
QString frmMain::ConnectVersion = "2.7,2.8";
frmMain::frmMain(QWidget *parent) :
QDialog(parent),
ui(new Ui::frmMain)
{
ui->setupUi(this);
sFilePath = QApplication::applicationDirPath()+"/Voice/";
comBuffer = new CCycleBuffer(1024*100);
//mMediaObj = Phonon::createPlayer(Phonon::MusicCategory);
mMediaObj =new Phonon::MediaObject();
audioOutput = new Phonon::AudioOutput();
Phonon::createPath(mMediaObj,audioOutput);
myHelper::FormInCenter(this);
searchTimeOut = new QTimer(this);
searchTime = new QTimer(this);
udpClient = new QUdpSocket(this);
//实例化QTcpServer服务器,进行监听,等待客户端的连接
tcpServer = new myTcpServer(this);
windowStatus=0;
//开始监听
bool ok=tcpServer->listen(QHostAddress::Any,13710);
//tcpClient = new QTcpSocket(this);
//用在多客户端监听同一个服务器端口等时特别有效),和ReuseAddressHint模式(重新连接服务器)
//udpClient->bind(myApp::UdpPort.toInt());
iconConnected = QIcon(":/image/slave_online.ico");
iconDisConnected = QIcon(":/image/slave_offline.ico");
iconConnecting = QIcon(":/image/slave_connecting.ico");
gateOpen = "border-image:url(:/设备状态图标/image/设备状态图标/门-打开.png);border:0px;";
gateClose = "border-image:url(:/设备状态图标/image/设备状态图标/门-关闭.png);border:0px;";
fanClose = "border-image:url(:/使用状态图标/image/使用状态图标/风扇-关闭.png);border:0px;";
warning = "border-image:url(:/状态图标/image/图标/报警.png);border:0px;";
statusNull = "border-image:url(:/使用状态图标/image/使用状态图标/未知状态.png);border:0px;";
doorStatusNull = statusNull; //"border-image:url(:/设备状态图标/image/设备状态图标/门-未知.png);border:0px;";
openLock = "border-image:url(:/使用状态图标/image/使用状态图标/门-解锁.png);border:0px;";
closeLock = "border-image:url(:/使用状态图标/image/使用状态图标/门-锁闭.png);border:0px;";
//使用状态图标
usingGif = new QMovie(":/使用状态图标/image/使用状态图标/使用状态-使用.gif");
notUsingIcon = "border-image:url(:/使用状态图标/image/使用状态图标/使用状态-空闲.png);border:0px;";
//照明状态图标
zhaoMingOpen = "border-image:url(:/使用状态图标/image/使用状态图标/照明灯-开.png);border:0px;";
zhaoMingClose = "border-image:url(:/使用状态图标/image/使用状态图标/照明灯-关.png);border:0px;";
//灯箱状态图标
dengXiangOpen= "border-image:url(:/使用状态图标/image/使用状态图标/灯箱-开.png);border:0px;";
dengXiangClose = "border-image:url(:/使用状态图标/image/使用状态图标/灯箱-关.png);border:0px;";
//灯箱状态图标
treeViewContextMenu = NULL;
currentSlave = NULL;
//报警状态图标
qieGeAlarm = "border-image:url(:/报警状态图标/image/报警状态图标/切割报警-报警.png);border:0px;";
qieGeNormal = "border-image:url(:/报警状态图标/image/报警状态图标/切割报警-正常.png);border:0px;";
baoJingDisable = "border-image:url(:/报警状态图标/image/报警状态图标/报警-未启用.png);border:0px;";
btnAlarm = "border-image:url(:/报警状态图标/image/报警状态图标/按钮报警-报警.png);border:0px;";
btnNormal = "border-image:url(:/报警状态图标/image/报警状态图标/按钮报警-正常.png);border:0px;";
//震动报警
zhenDongAlarm = "border-image:url(:/报警状态图标/image/报警状态图标/震动报警-报警.png);border:0px;";
zhenDongNormal = "border-image:url(:/报警状态图标/image/报警状态图标/震动报警-正常.png);border:0px;";
//烟雾报警
yanWuAlarm = "border-image:url(:/报警状态图标/image/报警状态图标/烟感报警-报警.png);border:0px;";
yanWuNormal = "border-image:url(:/报警状态图标/image/报警状态图标/烟感报警-正常.png);border:0px;";
//温度报警
tempAlarm = "border-image:url(:/报警状态图标/image/报警状态图标/温度报警-报警.png);border:0px;";
tempNormal = "border-image:url(:/报警状态图标/image/报警状态图标/温度报警-正常.png);border:0px;";
//玻璃破碎报警
boLiAlarm = "border-image:url(:/报警状态图标/image/报警状态图标/玻璃破碎报警-报警.png);border:0px;";
boLiNormal = "border-image:url(:/报警状态图标/image/报警状态图标/玻璃破碎报警-正常.png);border:0px;";
//水浸报警
shuiQinAlarm = "border-image:url(:/报警状态图标/image/报警状态图标/水位报警-报警.png);border:0px;";
shuiQinNormal = "border-image:url(:/报警状态图标/image/报警状态图标/水位报警-正常.png);border:0px;";
fangHuCangUse = "border-image:url(:/使用状态图标/image/使用状态图标/门-启用.png);border:0px;";
fangHuCangNotUse = "border-image:url(:/使用状态图标/image/使用状态图标/门-禁用.png);border:0px;";
/**************加钞间状态图标**************************/
//加钞间状态图标
iconCjcWorkNormalState = "border-image:url(:/加钞间图标/image/加钞间状态图标/工作状态-正常.gif);border:0px;";//工作状态-正常
iconCjcWorkIsGuardingState = "border-image:url(:/加钞间图标/image/加钞间状态图标/工作状态-正常有人值守.gif);border:0px;";//工作状态-正常 有人值守
iconCjcWorkOperateMainCardState = "border-image:url(:/加钞间图标/image/加钞间状态图标/工作状态-主卡注册、删除状态.png);border:0px;";//工作状态-主卡添加,删除
iconCjcWorkEditAdminState = "border-image:url(:/加钞间图标/image/加钞间状态图标/修改管理员.png);border:0px;";//工作状态-修改管理员
iconCjcAlarmSetGuardState = "border-image:url(:/加钞间图标/image/加钞间状态图标/报警状态-设防.png);border:0px;";//报警状态-设防
iconCjcAlarmWaitSetGuardState = "border-image:url(:/加钞间图标/image/加钞间状态图标/报警状态-等待设防.png);border:0px;";//报警状态-等待设防
iconCjcAlarmResetGuardState = "border-image:url(:/加钞间图标/image/加钞间状态图标/报警状态-撤防.png);border:0px;";//报警状态-撤防
iconCjcAlarmIllegalOpenDoorEnable = "border-image:url(:/加钞间图标/image/加钞间状态图标/非法开门报警-报警.png);border:0px;";//非法开门报警状态-报警
iconCjcAlarmIllegalOpenDoorDisable = "border-image:url(:/加钞间图标/image/加钞间状态图标/非法开门报警-正常.png);border:0px;";//非法开门报警状态-正常
iconCjcAlarmIllegalInEnable = "border-image:url(:/加钞间图标/image/加钞间状态图标/非法入侵报警-报警.png);border:0px;";//非法入侵报警状态-报警
iconCjcAlarmIllegalInDisable = "border-image:url(:/加钞间图标/image/加钞间状态图标/非法入侵-正常.png);border:0px;";//非法入侵报警状态-正常
/**************加钞间状态图标结束**************************/
selectedParentName = "";
movie = new QMovie(":/使用状态图标/image/使用状态图标/风扇-打开.gif");
connectingGif = new QMovie(":/联网状态图标/image/联网状态图标/连接中.gif");
select_Parent_sql = "select * from TZone";
select_macParent_sql = "SELECT ZName FROM TBelong WHERE Mac=";
select_indexParent_sql = "SELECT IndexInTree FROM TZone WHERE ZName=";
select_TSlave_sql = "select * from TSlave";
select_TParamater_sql = "SELECT * FROM TParamater WHERE Mac=:mac";
select_TVoice_sql = "SELECT * FROM TVoice";
select_TMparamater_sql = "SELECT * FROM TParamater";
select_Module_sql = "SELECT * FROM TModule";
select_TNetWork_sql = "SELECT * FROM SlaveNetWork WHERE Mac=:mac";
select_TUser_sql = "SELECT * FROM TPermit";
insert_TZone_sql = "insert into TZone values (?, ?)";
insert_TSlave_sql = "insert into TSlave values (?,?,?,?,?,?,?)";
insert_TParamater_sql = "insert into TParamater (Mac,OpenLockTime,OperationTime,RemindTimeout,"
"Interval,NoManOpenTime,OpenFanTemp,HumanDetectingInputType,"
"HumanDetectingType,LockType,LockWhileIdle,FangQiewarning,"
"Model,StartHour,StartMinute,StopHour,StopMinute,ExistManUseLine,"
"LPMWelcome,LPMUsing,LPMMaintaining,"
"Volume,Welcome,Use,Maintaining,Reminding,Timeout,Goodbye,DoorOpen,NotLocked,SlideDoor,"
"btnAlarmEnable,cutAlarmEnable,zhengDongAlarmEnable,yanWuAlarmEnable,"
"boLiAlarmEnable,shuiQinAlarmEnable,tempAlarmEnable,userNum,systemAlarmStatus,setGuardDelayTime,"
"isMonitorOrNot,inDoorModel,outDoorModel,doorCiAlarmEnable,existManAlarmEnable)"
" values "
"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
insert_TMparamater_sql = "insert into TMparamater (Name,OpenLockTime,OperationTime,RemindTimeout,"
"Interval,NoManOpenTime,OpenFanTemp,HumanDetectingInputType,"
"HumanDetectingType,LockType,LockWhileIdle,FangQiewarning,"
"Model,StartHour,StartMinute,StopHour,StopMinute,ExistManUseLine,"
"LPMWelcome,LPMUsing,LPMMaintaining,"
"Volume,Welcome,Use,Maintaining,Reminding,Timeout,Goodbye,DoorOpen,NotLocked,SlideDoor,"
"btnAlarmEnable,cutAlarmEnable,zhengDongAlarmEnable,yanWuAlarmEnable,"
"boLiAlarmEnable,shuiQinAlarmEnable,tempAlarmEnable,userNum,systemAlarmStatus,setGuardDelayTime,"
"isMonitorOrNot,inDoorModel,outDoorModel,doorCiAlarmEnable,existManAlarmEnable)"
" values "
"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
insert_TBelong_sql = "insert into TBelong values (?,?)";
insert_TVoice_sql = "insert into TVoice values (?,?,?,?)";
insert_TModule_sql = "insert into TModule values (?,?)";
insert_TNetWork_sql = "insert into SlaveNetWork values (?,?,?,?,?,?)";
delete_TSlave_sql = "delete from TSlave where Mac = ?";
delete_TZone_sql = "delete from TZone where ZName = ?";
delete_TBelong_sql = "delete from TBelong where Mac = ?";
delete_TParamater_sql = "delete from TParamater where Mac = ?";
delete_TVoice_sql = "delete from TVoice where Name = ?";
delete_TMparamater_sql = "delete from TMparamater where Name = ?";
delete_TModule_sql = "delete from TModule where Name = ?";
delete_TNetWork_sql = "delete from SlaveNetWork where Mac = ?";
update_TSlave_index_sql = "update TSlave set IndexInTree = :index where Mac = :name";
update_TSlave_sql = "update TSlave set Type = :type,Version = :version, Name = :name,Ip = :ip where Mac = :mac";
update_TZone_index_sql = "update TZone set IndexInTree = :index where ZName = :name";
update_TZone_name_sql = "update TZone set ZName = :name where IndexInTree = :index";
update_TBelong_ZName_sql = "update TBelong set ZName = :name where Mac = :mac";
update_TPara_sql = "update TParamater set OpenLockTime=:OpenLockTime,"
"OperationTime=:OperationTime, RemindTimeout=:RemindTimeout,"
"Interval=:Interval,NoManOpenTime=:NoManOpenTime,"
"OpenFanTemp=:OpenFanTemp,HumanDetectingInputType=:HumanDetectingInputType,"
"HumanDetectingType=:HumanDetectingType,LockType=:LockType,"
"LockWhileIdle=:LockWhileIdle,FangQiewarning=:FangQiewarning,"
"Model=:Mode,StartHour=:startHour,StartMinute=:startMinute,"
"StopHour=:stopHour,StopMinute=:stopMinute,ExistManUseLine=:manEnable,"
"LPMWelcome=:lpmWelcome,LPMUsing=:lpmUsing,LPMMaintaining=:lpmMaintaining,"
"Volume=:volume,Welcome=:welcome,Maintaining=:maintaining,"
"Reminding=:reminding,Timeout=:timeout,Goodbye=:goodbye,DoorOpen=:doorOpen,"
"NotLocked=:notLocked,Use=:using,SlideDoor=:slideDoor,"
"btnAlarmEnable=:btnAlarmEnable,cutAlarmEnable=:cutAlarmEnable,zhengDongAlarmEnable=:zhengDongAlarmEnable,yanWuAlarmEnable=:yanWuAlarmEnable,"
"boLiAlarmEnable=:boLiAlarmEnable,shuiQinAlarmEnable=:shuiQinAlarmEnable,tempAlarmEnable=:tempAlarmEnable,"
"userNum=:userNum,systemAlarmStatus=:systemAlarmStatus,setGuardDelayTime=:setGuardDelayTime,"
"isMonitorOrNot=:isMonitorOrNot,inDoorModel=:inDoorModel,outDoorModel=:outDoorModel,"
"doorCiAlarmEnable=:doorCiAlarmEnable,existManAlarmEnable=:existManAlarmEnable"
" where Mac = :mac";
update_TVoice_sql = "update TVoice set Md5=:md5,FileName=:fileName where Name = :name";
update_TMparamater_sql = "update TMparamater set OpenLockTime=:OpenLockTime,"
"OperationTime=:OperationTime, RemindTimeout=:RemindTimeout,"
"Interval=:Interval,NoManOpenTime=:NoManOpenTime,"
"OpenFanTemp=:OpenFanTemp,HumanDetectingInputType=:HumanDetectingInputType,"
"HumanDetectingType=:HumanDetectingType,LockType=:LockType,"
"LockWhileIdle=:LockWhileIdle,FangQiewarning=:FangQiewarning,"
"Model=:Mode,StartHour=:startHour,StartMinute=:startMinute,"
"StopHour=:stopHour,StopMinute=:stopMinute,ExistManUseLine=:manEnable,"
"LPMWelcome=:lpmWelcome,LPMUsing=:lpmUsing,LPMMaintaining=:lpmMaintaining,"
"Volume=:volume,Welcome=:welcome,Maintaining=:maintaining,"
"Reminding=:reminding,Timeout=:timeout,Goodbye=:goodbye,DoorOpen=:doorOpen,"
"NotLocked=:notLocked,Use=:using,SlideDoor=:slideDoor,"
"btnAlarmEnable=:btnAlarmEnable,cutAlarmEnable=:cutAlarmEnable,zhengDongAlarmEnable=:zhengDongAlarmEnable,yanWuAlarmEnable=:yanWuAlarmEnable,"
"boLiAlarmEnable=:boLiAlarmEnable,shuiQinAlarmEnable=:shuiQinAlarmEnable,tempAlarmEnable=:tempAlarmEnable,"
"userNum=:userNum,systemAlarmStatus=:systemAlarmStatus,setGuardDelayTime=:setGuardDelayTime,"
"isMonitorOrNot=:isMonitorOrNot,inDoorModel=:inDoorModel,outDoorModel=:outDoorModel,"
"doorCiAlarmEnable=:doorCiAlarmEnable,existManAlarmEnable=:existManAlarmEnable"
" where Name = :name";
update_TModule_sql = "update TModule set Name=:name where level = 2";
update_TPuser_sql = "update TPermit set permitEditSystemPar=:permitEditSystemPar,"
"permitEditAreaInfo=:permitEditAreaInfo, permitRegFangHuCang=:permitRegFangHuCang,"
"permitLogoutFangHuCang=:permitLogoutFangHuCang,permitEditSoundLiabrary=:permitEditSoundLiabrary,"
"permitEditModule=:permitEditModule,permitEditFangHuCangPar=:permitEditFangHuCangPar,"
"permitEditZhaoMingPar=:permitEditZhaoMingPar,permitEditVoicePar=:permitEditVoicePar,"
"permitAdjustTime=:permitAdjustTime,permitOpenDoor=:permitOpenDoor,"
"permitUseorNotusedFangHuCang=:permitUseorNotusedFangHuCang,permitLockorOpenFangHuCang=:permitLockorOpenFangHuCang,"
"permitEditLedText=:permitEditLedText,permitChangeAdmin=:permitChangeAdmin"
" where Level = :Level";
model = new TreeModel(this);
slaveListModel = new ListModel(this);
database = QSqlDatabase::addDatabase("QSQLITE");
database.setDatabaseName(myApp::AppPath+"table.db");
//打开数据库
if(!database.open())
{
QLOG_FATAL() <<database.lastError();
myHelper::ShowMessageBoxError("数据库文件打开错误!");
this->close();
}
query = new QSqlQuery(database);
systemLogquery = new QSqlQuery(database);
slaveLogquery = new QSqlQuery(database);
treeViewParentTbModel = new QSqlTableModel(this, database);
voiceModel = new QSqlTableModel(this,database);
moduleModel = new QSqlTableModel(this,database);
treeViewParentTbModel->setEditStrategy(QSqlTableModel::OnManualSubmit);//设置为手动保存后才会真正写入数据库
searchEquForm = new frmSearchEquipment();
addEquForm = new frmAddSlave();
frmSelectParentInTree = new SelectParentInTree();
//frmOperateParent = new frmOperateParentInTree();
frmOperateItemBox = new FrmOperateParentMsgBox();
frmSaveSound = new FrmSaveSound();
//frmEditSlavePara = new frmEditParamater();
//frmEditZhaoMing = new frmEditZhaoMingPara();
frmVoiceManager = new FrmManagerVoice();
frmReadSoundProcess = new FrmReadSoundProcess();
//frmSelectSound = new FrmSelectSound();
//frmAddSound = new FrmAddSound();
frmManagerModel = new FrmManagerModule();
frmUseModule = new FrmUseModule();
//frmModulePara = new FrmModulePara();
frmAlarm = new frmAlarmBox();
//frmEditAlarm = new frmEditAlarmPara();
frmEditUserPwd = new FrmEditUserPwd();
frmInfo = new frmSoftwareInfo();
frmEditUserPermission = new frmGuestPermissionConfig();
ui->btnLed0Ok->setVisible(false);
ui->btnLed1Ok->setVisible(false);
ui->btnLed2Ok->setVisible(false);
connect(this,SIGNAL(sigAnalysisData()),this,SLOT(slotAnalysisData()));
connect(udpClient,SIGNAL(readyRead()),this,SLOT(readPacketage()));
connect(searchTimeOut,SIGNAL(timeout()),this,SLOT(slotEmitSearchDone()));
connect(searchTime,SIGNAL(timeout()),this,SLOT(slotEmitSearchDone()));
connect(searchEquForm,SIGNAL(SearchEqument()),this,SLOT(SearchEqument()));
connect(addEquForm,SIGNAL(sigConnectToSlave(QString)),this,SLOT(slotConnectToSlave(QString)));
connect(this,SIGNAL(sigConnectedToSlave(bool,paraData*)),addEquForm,SLOT(DisplayResult(bool,paraData*)));
connect(addEquForm,SIGNAL(sigRegisterSlave(paraData*)),this,SLOT(slotRegisterSlave(paraData *)));
connect(this,SIGNAL(SearchedEqument(QList<TreeViewItem*>*,QList<paraData*>*)),searchEquForm,SLOT(DisplayResult(QList<TreeViewItem*>*,QList<paraData*>*)));
connect(searchEquForm,SIGNAL(registerSlaves(QList<paraData*>)),this,SLOT(RegisterSlaves(QList<paraData*>)));
connect(ui->treeView,SIGNAL(clicked(QModelIndex)),this,SLOT(slotchangeSlaveDisplay(QModelIndex)));
connect(ui->treeView,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(slotTreeViewCustomContextMenuRequested(QPoint)));
connect(tcpServer,SIGNAL(ClientConnect(int,QTcpSocket *)),this,SLOT(ClientConnect(int,QTcpSocket *)));
connect(this,SIGNAL(sigSendParentTbModel(QSqlTableModel *)),frmSelectParentInTree,SLOT(setTreeViewModel(QSqlTableModel *)));
//connect(this,SIGNAL(sigSendParentTbModel(QSqlTableModel *)),frmOperateParent,SLOT(setTreeViewModel(QSqlTableModel *)));
connect(frmSelectParentInTree,SIGNAL(sigSelected(QString)),this,SLOT(slotSelectParentIndex(QString)));
connect(frmSelectParentInTree,SIGNAL(sigAddNewParentInTree()),this,SLOT(slotAddNewParentInTree()));
//connect(frmOperateParent,SIGNAL(sigParentInTreeChanged(bool)),this,SLOT(slotParentInTreeDataChanged(bool)));
connect(treeViewParentTbModel,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(slotTreeParentChanged(QModelIndex,QModelIndex)));
connect(ui->listView,SIGNAL(clicked(QModelIndex)),this,SLOT(slotchangeSlaveDisplayFromListView(QModelIndex)));
connect(frmOperateItemBox,SIGNAL(sigoperate(QString)),this,SLOT(sloteditedName(QString)));
connect(frmSaveSound,SIGNAL(sigoperate(QString)),this,SLOT(sloteditedName(QString)));
//connect(frmSelectSound,SIGNAL(sigoperate(QString)),this,SLOT(sloteditedName(QString)));
connect(ui->btnTime,SIGNAL(clicked(bool)),this,SLOT(btnWtiteNowTime()));
//connect(this,SIGNAL(sigEditFangHuCangPara(paraFangHuCang,quint8)),frmEditSlavePara,SLOT(initPara(paraFangHuCang,quint8)));
//connect(this,SIGNAL(sigZhaoMingPara(paraZhaoMing,quint8)),frmEditZhaoMing,SLOT(initPara(paraZhaoMing,quint8)));
connect(ui->btnOpenDoor,SIGNAL(clicked(bool)),this,SLOT(slotOpenDoor()));
connect(ui->btnReadMsg,SIGNAL(clicked(bool)),this,SLOT(slotShowReadMsgProcess()));
connect(ui->btnChange0,SIGNAL(clicked(bool)),this,SLOT(slotbtnLed0TextChange()));
connect(ui->btnChange1,SIGNAL(clicked(bool)),this,SLOT(slotbtnLed1TextChange()));
connect(ui->btnChange2,SIGNAL(clicked(bool)),this,SLOT(slotbtnLed2TextChange()));
connect(ui->btnLed0Ok,SIGNAL(clicked(bool)),this,SLOT(slotbtnSetLed0TextOk()));
connect(ui->btnLed1Ok,SIGNAL(clicked(bool)),this,SLOT(slotbtnSetLed1TextOk()));
connect(ui->btnLed2Ok,SIGNAL(clicked(bool)),this,SLOT(slotbtnSetLed2TextOk()));
connect(ui->btnVoiceOk,SIGNAL(clicked(bool)),this,SLOT(slotBtnSetSoundVolume()));
connect(this,SIGNAL(sigSendVoiceTbModel(QSqlTableModel*)),frmVoiceManager,SLOT(setTreeViewModel(QSqlTableModel*)));
//connect(this,SIGNAL(sigSendVoiceTbModel(QSqlTableModel*)),frmSelectSound,SLOT(setTreeViewModel(QSqlTableModel*)));
connect(this,SIGNAL(sigSendModuleTbModel(QList<SlaveVersion *>,QList<paraModule*>)),frmManagerModel,SLOT(slotSetTableModel(QList<SlaveVersion *>,QList<paraModule*>)));
connect(this,SIGNAL(sigSendModuleTbModel(QList<SlaveVersion *>)),frmUseModule,SLOT(slotSetTableModel(QList<SlaveVersion *>)));
connect(ui->btnChangeHySound,SIGNAL(clicked(bool)),this,SLOT(slotBtnChangeHySound()));
connect(ui->btnChangeSyzSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnChangesyzSound()));
connect(ui->btnChangeWhzDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnChangeWhzSound()));
connect(ui->btnChangeTimeoutWarnSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnChangeTimeoutWarnSound()));
connect(ui->btnChangeTimeouTiShiSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnChangeTimeoutTiShiSound()));
connect(ui->btnChangeOpenDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnChangeOpenDoorSound()));
connect(ui->btnChangeOutDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnChangeOutDoorSound()));
connect(ui->btnChangeFailLockSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnChangeFailLockSound()));
connect(ui->btnChangeLaDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnChangeLaDoorSound()));
connect(frmVoiceManager,SIGNAL(sigDeleteVoice(QString)),this,SLOT(slotDeleteVoice(QString)));
connect(frmVoiceManager,SIGNAL(sigAddVoicetoDatabase(QString,QString)),this,SLOT(slotAddVoice(QString,QString)));
connect(this,SIGNAL(sigAddVoiceEnd(int)),frmVoiceManager,SLOT(slotShowAddVoiceEndWindow(int)));
connect(ui->btnReadHySound,SIGNAL(clicked(bool)),this,SLOT(slotBtnReadHySound()));
connect(ui->btnReadSyzSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnReadSyzSound()));
connect(ui->btnReadWhzSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnReadWhzSound()));
connect(ui->btnReadTimeouTiShiSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnReadTimeoutTiShiSound()));
connect(ui->btnReadTimeoutWarnSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnReadTimeoutWarnSound()));
connect(ui->btnReadOutDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnReadOutDoorSound()));
connect(ui->btnReadOpenDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnReadOpenDoorSound()));
connect(ui->btnReadFailLockSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnReadFailLockSound()));
connect(ui->btnReadLaDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnReadLaDoorSound()));
connect(ui->btnSetFangHuCangPara,SIGNAL(clicked(bool)),this,SLOT(slotShowEditParaDialog()));
connect(ui->btnSetZhaoMingPrar,SIGNAL(clicked(bool)),this,SLOT(slotShowEditZhaoMingParaDialog()));
connect(ui->btnPlayHySound,SIGNAL(clicked(bool)),this,SLOT(slotBtnPlayHySound()));
connect(ui->btnPlaySyzSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnPlaySyzSound()));
connect(ui->btnPlayWhzSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnPlayWhzSound()));
connect(ui->btnPlayTimeoutWarnSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnPlayTimeoutWarnSound()));
connect(ui->btnPlayTimeoutTiShiSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnPlayTimeoutTiShiSound()));
connect(ui->btnPlayOutDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnPlayOutDoorSound()));
connect(ui->btnPlayOpenDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnPlayOpenDoorSound()));
connect(ui->btnPlayFailLockSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnPlayFailLockSound()));
connect(ui->btnPlayLaDoorSound,SIGNAL(clicked(bool)),this,SLOT(slotBtnPlayLaDoorSound()));
connect(frmVoiceManager,SIGNAL(sigPlaySound(QString)),this,SLOT(slotBtnPlaySound(QString)));
connect(ui->btnLock,SIGNAL(clicked(bool)),this,SLOT(slotRemoteCloseLock()));
connect(ui->btnReadMsg,SIGNAL(clicked(bool)),this,SLOT(slotReadSlaveMsg()));
//connect(frmSelectSound,SIGNAL(sigPlaySound(QString)),this,SLOT(slotBtnPlaySound(QString)));
//connect(frmManagerModel,SIGNAL(sigAddParaModule()),this,SLOT(slotShowAddModuleWindows()));
//connect(frmManagerModel,SIGNAL(sigEditParaModule(QModelIndex)),this,SLOT(slotShowEditModuleWindows(QModelIndex)));
//connect(frmModulePara,SIGNAL(sigEditZhaoMingPara(paraZhaoMing,quint8)),frmEditZhaoMing,SLOT(initPara(paraZhaoMing,quint8)));
//connect(frmModulePara,SIGNAL(sigShowEditZhaoMingParaWindow()),this,SLOT(slotShowEditZhaoMingParaWindow()));
//connect(frmEditZhaoMing,SIGNAL(sigSaveZhaoMingPara(paraZhaoMing*)),frmModulePara,SLOT(slotSetZhaoMingPara(paraZhaoMing*)));
//connect(frmEditZhaoMing,SIGNAL(sigSaveAreaZhaoMingPara(paraZhaoMing*)),this,SLOT(slotSaveAreaSlaveZhaoMingPara(paraZhaoMing*)));
//connect(frmModulePara,SIGNAL(sigEditFangHuCangPara(paraFangHuCang,quint8)),frmEditSlavePara,SLOT(initPara(paraFangHuCang,quint8)));
//connect(frmModulePara,SIGNAL(sigShowEditFangHuCangParaWindow()),this,SLOT(slotShowEditFangHuCangParaWindow()));
//connect(frmEditSlavePara,SIGNAL(sigSaveFangHuCangPara(paraFangHuCang*)),frmModulePara,SLOT(slotSetFangHuCangPara(paraFangHuCang*)));
//connect(frmEditSlavePara,SIGNAL(sigSaveAreaFangHuCangPara(paraFangHuCang*)),this,SLOT(slotSaveAreaSlaveWorkPara(paraFangHuCang*)));
//connect(frmModulePara,SIGNAL(sigChangModuleSound(quint8)),this,SLOT(slotChangeModuleSound(quint8)));
//connect(this,SIGNAL(sigChangeModuleSound(quint8,QString)),frmModulePara,SLOT(slotSetSound(quint8,QString)));
//connect(frmModulePara,SIGNAL(sigUpdateSoundName(paraData*)),this,SLOT(slotUpdateModuleSoundName(paraData*)));
//connect(frmModulePara,SIGNAL(sigSaveModulePara(QString,paraData*)),this,SLOT(slotSaveModulePara(QString,paraData*)));
connect(frmManagerModel,SIGNAL(sigDelParaModule(QModelIndex)),this,SLOT(slotDeleteModule(QModelIndex)));
connect(frmUseModule,SIGNAL(sigSelectModule(QModelIndex)),this,SLOT(slotUseModule(QModelIndex)));
connect(frmManagerModel,SIGNAL(sigInParaModule(paraModule*)),this,SLOT(slotSaveModulePara(paraModule*)));
connect(frmManagerModel,SIGNAL(sigSaveModulePara(paraModule*)),this,SLOT(slotSaveParaModule(paraModule*)));
connect(frmEditUserPwd,SIGNAL(sigUpdateUserpwd()),this,SLOT(slotUpdateUserPwd()));
connect(frmEditUserPermission,SIGNAL(sigWriteUserPermitPara(UserPermission*)),this,SLOT(slotEditUserPermission(UserPermission*)));
//加钞间连接
connect(ui->btnSetCjcPara,SIGNAL(clicked(bool)),this,SLOT(slotShowSetCjcParaDialog()));
connect(ui->btnAddKey,SIGNAL(clicked(bool)),this,SLOT(slotbtnAddKey()));
connect(ui->btnDeleteKey,SIGNAL(clicked(bool)),this,SLOT(slotbtnDeleteKey()));
connect(ui->btnChangeAdmin,SIGNAL(clicked(bool)),this,SLOT(slotbtnChangeAdminKey()));
connect(ui->btnEnOrDisAbleFangHuCang,SIGNAL(clicked(bool)),this,SLOT(slotEnableOrDisableSlave()));
InitStyle();
//初始化设备和tree结构
InitForm();
//显示系统日志记录
//slotShowSystemLog(systemLogList);
//获取区域列表
getParentTreeModel();
//获取声音列表
readVoiceData();
//获取模板列表
readModuleData();
updateSlaveListDisplay();
changeStockedPageDisplay(0);
clearFormStatusDisplay();
//获取treeview的选择模型 发生变化时触发槽函数
selectionModel = ui->treeView->selectionModel();
connect(selectionModel,SIGNAL(selectionChanged(QItemSelection,QItemSelection)),this,SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));
listViewSelectModel = ui->listView->selectionModel();
this->setAttribute(Qt::WA_DeleteOnClose,true);//关闭后释放内存
tcpClient=NULL;
}
frmMain::~frmMain()
{
delete searchEquForm;
delete addEquForm;
delete frmSelectParentInTree;
delete frmOperateItemBox;
delete frmSaveSound;
delete frmVoiceManager;
delete frmReadSoundProcess;
//delete frmAddSound;
delete frmManagerModel;
delete frmUseModule;
delete frmAlarm;
delete frmEditUserPwd;
delete frmInfo;
delete frmEditUserPermission;
delete usingGif;
delete movie;
delete connectingGif;
delete mMediaObj;
delete ui;
}
void frmMain::ReInitStyle()
{
if(currentUser.level <= 1)
{
editUserPermission->setVisible(true);
}
else
{
editUserPermission->setVisible(false);
}
}
void frmMain::InitStyle()
{
//设置窗体标题栏隐藏
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
//设置软件标题
ui->lab_Title->setText(myApp::SoftTitle);
location = this->geometry();
max = false;
mousePressed = false;
//安装事件监听器,让标题栏识别鼠标双击
ui->lab_Title->installEventFilter(this);
IconHelper::Instance()->SetIcon(ui->btnMenu_Close, QChar(0xf00d), 10);
IconHelper::Instance()->SetIcon(ui->btnMenu_Max, QChar(0xf096), 10);
IconHelper::Instance()->SetIcon(ui->btnMenu_Min, QChar(0xf068), 10);
IconHelper::Instance()->SetIcon(ui->btnMenu, QChar(0xf0c9), 10);
//IconHelper::Instance()->SetIcon(ui->lab_Ico, QChar(0xf015), 12);
userParaEnable=0;
ui->jcjTabSlavePara->setHidden(true);
//菜单栏设计
menuBar = new QMenuBar(ui->widget);
//menuBar->setGeometry(QRect(0,0,3000,40));
QMenu* menu = menuBar->addMenu(tr("&设备"));
QMenu* menu1 = menuBar->addMenu(tr("&参数"));
QMenu* menuVoice = menuBar->addMenu(tr("&声音"));
QMenu* menuModule = menuBar->addMenu(tr("&模板"));
QMenu* menuLog = menuBar->addMenu(tr("&记录"));
QMenu* menuHelp = menuBar->addMenu(tr("&帮助"));
actionSearch = menu->addAction(QIcon(":/image/select.png"),tr("&搜索设备"));
actionSearch->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
actionAdd = menu->addAction(QIcon(":/image/add.png"),tr("&添加设备"));
QAction *editUserPwd = menu->addAction(QIcon(":/image/edit.ico"),tr("&修改密码"));
editUserPermission = menu->addAction(QIcon(":/image/edit.ico"),tr("&修改操作员权限"));
QAction *editFangHuCangPara = menu1->addAction(QIcon(":/工具栏图标/image/快捷按钮图标/工作参数.png"),tr("工作参数"));
QAction *editZhaoMingPara = menu1->addAction(QIcon(":/工具栏图标/image/快捷按钮图标/照明参数.png"),tr("照明参数"));
enableUserPara = menu1->addAction(tr("&使能用户参数"));
enableUserPara->setCheckable(true);
QAction *managerVoice = menuVoice->addAction(tr("管理声音"));
QAction *managerModule = menuModule->addAction(tr("管理模板"));
QAction *useModule = menuModule->addAction(QIcon(":/工具栏图标/image/快捷按钮图标/应用模板.png"),tr("应用模板"));
//记录菜单下的项
QAction *loadSlaveLog = menuLog->addAction(QIcon(":/工具栏图标/image/快捷按钮图标/应用模板.png"),tr("读取记录"));
QAction *searchSlaveLog = menuLog->addAction(QIcon(":/image/search.png"),tr("查询防护舱记录"));
QAction *searchManualLog = menuLog->addAction(QIcon(":/image/search.png"),tr("查询软件操作记录"));
//帮助菜单下的项
QAction *softwareInfo = menuHelp->addAction(QIcon(":/image/info.ico"),tr("关于本软件"));
QAction *contactUs = menuHelp->addAction(QIcon(":/image/contact us.ico"),tr("软件帮助"));
ui->gridLayout_2->setMenuBar(menuBar);
//工具箱建立
QAction *actionSetClock = new QAction(QIcon(":/使用状态图标/image/使用状态图标/使用状态-使用.gif"),tr("&校准时间"),this);
toolBar = new QToolBar(ui->widget_2);
//toolBar->setFixedHeight(55);
toolBar->addAction(actionSearch);
toolBar->addAction(actionAdd);
toolBar->addAction(actionSetClock);
toolBar->addAction(editFangHuCangPara);
toolBar->addAction(editZhaoMingPara);
toolBar->addAction(useModule);
//toolBar->setGeometry(0,0,3000,50);
//toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);//图标在前 文字在后
toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);//图标在上 文字在下
ui->gridLayout_3->setMenuBar(toolBar);
connect(actionSearch,SIGNAL(triggered()),this,SLOT(searchEqu()));
connect(actionAdd,SIGNAL(triggered()),this,SLOT(addEqu()));
connect(editFangHuCangPara,SIGNAL(triggered()),this,SLOT(slotShowEditParaDialog()));
connect(editZhaoMingPara,SIGNAL(triggered()),this,SLOT(slotShowEditZhaoMingParaDialog()));
connect(managerVoice,SIGNAL(triggered(bool)),this,SLOT(slotBtnVoiceManager()));
connect(managerModule,SIGNAL(triggered(bool)),this,SLOT(slotShowManagerModuleWindows()));
connect(useModule,SIGNAL(triggered(bool)),this,SLOT(slotShowUseModuleWindows()));
connect(actionSetClock,SIGNAL(triggered(bool)),this,SLOT(btnWtiteNowTime()));
connect(editUserPwd,SIGNAL(triggered(bool)),this,SLOT(slotShowEditUserPwdWindow()));
connect(softwareInfo,SIGNAL(triggered(bool)),this,SLOT(slotShowContactWindow()));
connect(contactUs,SIGNAL(triggered(bool)),this,SLOT(slotOpenHelpFile()));
connect(editUserPermission,SIGNAL(triggered(bool)),this,SLOT(slotShowEditUserPermissionWindow()));
connect(loadSlaveLog,SIGNAL(triggered(bool)),this,SLOT(slotReadSlaveMsg()));
connect(searchSlaveLog,SIGNAL(triggered(bool)),this,SLOT(slotShowSearchSlaveLogWindow()));
connect(searchManualLog,SIGNAL(triggered(bool)),this,SLOT(slotShowSearchSystemLogWindow()));
connect(enableUserPara,SIGNAL(triggered(bool)),this,SLOT(slotSetUserParaEnable()));
//窗口最大化显示
on_btnMenu_Max_clicked();
QPixmap pixmap(myApp::AppPath+myApp::MainPageImage);
ui->label->setPixmap(pixmap);
//QStringList header;
//header<<"参数名称"<<"值";
//ui->tableWidget->setHorizontalHeaderLabels(header);
ui->tableWidget->setColumnCount(2);
ui->tableWidget->setRowCount(6);
ui->tableWidget->horizontalHeader()->hide();//隐藏表头
ui->tableWidget->verticalHeader()->hide();//隐藏行号
ui->tableWidget->setColumnWidth(0,80);
ui->tableWidget->setColumnWidth(1,118);
ui->tableWidget->setSelectionMode(QAbstractItemView::NoSelection);
ui->tableWidget->setItem(0,0,new QTableWidgetItem("设备名称"));
ui->tableWidget->setItem(1,0,new QTableWidgetItem("设备类型"));
ui->tableWidget->setItem(2,0,new QTableWidgetItem("版本号"));
ui->tableWidget->setItem(3,0,new QTableWidgetItem("MAC地址"));
ui->tableWidget->setItem(4,0,new QTableWidgetItem("IP地址"));
ui->tableWidget->setItem(5,0,new QTableWidgetItem("联网模式"));
ui->tableWidgetFangHuCang->setColumnCount(4);
ui->tableWidgetFangHuCang->setRowCount(6);
ui->tableWidgetFangHuCang->setColumnWidth(0,140);
ui->tableWidgetFangHuCang->setColumnWidth(1,60);
ui->tableWidgetFangHuCang->setColumnWidth(2,160);
ui->tableWidgetFangHuCang->setColumnWidth(3,60);
ui->tableWidgetFangHuCang->horizontalHeader()->hide();//隐藏表头
ui->tableWidgetFangHuCang->verticalHeader()->hide();//隐藏行号
ui->tableWidgetFangHuCang->setItem(0,0,new QTableWidgetItem("锁具类型"));
ui->tableWidgetFangHuCang->setItem(1,0,new QTableWidgetItem("开锁信号持续时间"));
ui->tableWidgetFangHuCang->setItem(2,0,new QTableWidgetItem("人体检测信号输入方式"));
ui->tableWidgetFangHuCang->setItem(3,0,new QTableWidgetItem("人体检测装置类型"));
ui->tableWidgetFangHuCang->setItem(4,0,new QTableWidgetItem("舱体空闲时是否锁门"));
ui->tableWidgetFangHuCang->setItem(5,0,new QTableWidgetItem("风扇启动温度"));
ui->tableWidgetFangHuCang->setItem(0,2,new QTableWidgetItem("检测不到人体后开门等待时间"));
ui->tableWidgetFangHuCang->setItem(1,2,new QTableWidgetItem("业务办理允许最大时间"));
ui->tableWidgetFangHuCang->setItem(2,2,new QTableWidgetItem("超时提醒播放时间"));
ui->tableWidgetFangHuCang->setItem(3,2,new QTableWidgetItem("超时提醒播放间隔"));
ui->tableWidgetFangHuCang->setItem(4,2,new QTableWidgetItem("防切割报警功能"));
ui->tableWidgetFangHuCang->setItem(5,2,new QTableWidgetItem(""));
//设置单元格右对齐
for(int i=0;i<6;i++)
{
ui->tableWidgetFangHuCang->item(i,0)->setTextAlignment(Qt::AlignRight|Qt::AlignCenter);
}
for(int i=0;i<6;i++)
{
ui->tableWidgetFangHuCang->item(i,2)->setTextAlignment(Qt::AlignRight|Qt::AlignCenter);
}
/**********************加钞间参数标签页**********************/
ui->tableWidgeCjc->setColumnCount(2);
ui->tableWidgeCjc->setRowCount(7);
ui->tableWidgeCjc->setColumnWidth(0,140);
ui->tableWidgeCjc->setColumnWidth(1,90);
ui->tableWidgeCjc->horizontalHeader()->hide();//隐藏表头
ui->tableWidgeCjc->verticalHeader()->hide();//隐藏行号
ui->tableWidgeCjc->setItem(0,0,new QTableWidgetItem("开锁延时"));
ui->tableWidgeCjc->setItem(1,0,new QTableWidgetItem("设防延时时间"));
ui->tableWidgeCjc->setItem(2,0,new QTableWidgetItem("刷卡人数"));
ui->tableWidgeCjc->setItem(3,0,new QTableWidgetItem("进门方式"));
ui->tableWidgeCjc->setItem(4,0,new QTableWidgetItem("出门方式"));
ui->tableWidgeCjc->setItem(5,0,new QTableWidgetItem("系统报警状态"));
ui->tableWidgeCjc->setItem(6,0,new QTableWidgetItem("值守状态"));
//设置单元格右对齐
for(int i=0;i<7;i++)
{
ui->tableWidgeCjc->item(i,0)->setTextAlignment(Qt::AlignRight|Qt::AlignCenter);
}
ui->tablewidgetZhaoMing->setColumnCount(2);
ui->tablewidgetZhaoMing->setRowCount(3);
ui->tablewidgetZhaoMing->setColumnWidth(0,180);
ui->tablewidgetZhaoMing->setColumnWidth(1,120);
ui->tablewidgetZhaoMing->horizontalHeader()->hide();//隐藏表头
ui->tablewidgetZhaoMing->verticalHeader()->hide();//隐藏行号
ui->tablewidgetZhaoMing->setItem(0,0,new QTableWidgetItem("模式"));
ui->tablewidgetZhaoMing->setItem(1,0,new QTableWidgetItem("时间段"));
ui->tablewidgetZhaoMing->setItem(2,0,new QTableWidgetItem("舱体有人使用即点亮照明灯"));
for(int i=0;i<3;i++)
{
ui->tablewidgetZhaoMing->item(i,0)->setTextAlignment(Qt::AlignRight|Qt::AlignCenter);
}
//系统日志显示窗口初始化
ui->systemLog->setColumnCount(2);
ui->systemLog->horizontalHeader()->hide();//隐藏表头
ui->systemLog->verticalHeader()->hide();//隐藏行号
ui->systemLog->horizontalHeader()->setStretchLastSection(true);//关键
ui->systemLog->setColumnWidth(0, 150);
ui->systemLog->setContextMenuPolicy(Qt::CustomContextMenu);
ui->systemLog->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
//防护舱日志显示窗口初始化
ui->tableWidgetSlaveLog->setColumnCount(3);
ui->tableWidgetSlaveLog->horizontalHeader()->hide();//隐藏表头
ui->tableWidgetSlaveLog->verticalHeader()->hide();//隐藏行号
ui->tableWidgetSlaveLog->horizontalHeader()->setStretchLastSection(true);//关键
ui->tableWidgetSlaveLog->setColumnWidth(0, 150);
ui->tableWidgetSlaveLog->setColumnWidth(1, 200);
ui->tableWidgetSlaveLog->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tableWidgetSlaveLog->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui->tableWidgetAlarmPara->setColumnCount(2);
ui->tableWidgetAlarmPara->setRowCount(9);
ui->tableWidgetAlarmPara->setColumnWidth(0,250);
ui->tableWidgetAlarmPara->setColumnWidth(1,80);
ui->tableWidgetAlarmPara->horizontalHeader()->hide();//隐藏表头
ui->tableWidgetAlarmPara->verticalHeader()->hide();//隐藏行号
ui->tableWidgetAlarmPara->setItem(0,0,new QTableWidgetItem("是否启用按钮报警"));
ui->tableWidgetAlarmPara->setItem(1,0,new QTableWidgetItem("是否启用防切割报警"));
ui->tableWidgetAlarmPara->setItem(2,0,new QTableWidgetItem("是否启用震动报警"));
ui->tableWidgetAlarmPara->setItem(3,0,new QTableWidgetItem("是否启用烟雾报警"));
ui->tableWidgetAlarmPara->setItem(4,0,new QTableWidgetItem("是否启用玻璃破碎报警"));
ui->tableWidgetAlarmPara->setItem(5,0,new QTableWidgetItem("是否启用水浸报警"));
ui->tableWidgetAlarmPara->setItem(6,0,new QTableWidgetItem("是否启用温度报警"));
ui->tableWidgetAlarmPara->setItem(7,0,new QTableWidgetItem(""));
ui->tableWidgetAlarmPara->setItem(8,0,new QTableWidgetItem(""));
for(int i=0;i<9;i++)
{
ui->tableWidgetAlarmPara->item(i,0)->setTextAlignment(Qt::AlignRight|Qt::AlignCenter);
}
//窗口分隔比例设置
if(myHelper::FileIsExist("AppConfig.ini"))
{
readSettings();
}
else
{
ui->splitter_2->setStretchFactor(0,8);//树型结构占用空间比例
ui->splitter_2->setStretchFactor(1,12);//其他占用空间比例
ui->splitter->setStretchFactor(0,5);//其他占用空间比例
ui->splitter->setStretchFactor(1,8);//日志输出占用空间比例
ui->splitter_3->setStretchFactor(0,12);//设备列表占用空间比例
ui->splitter_3->setStretchFactor(1,12);//设备参数占用空间比例
}
}
void frmMain::slotSetUserParaEnable()
{
enableUserPara->setChecked(true);
//ui->jcjTabSlavePara->setHidden(false);
windowStatus=0;
userParaEnable=1;
//slotupdateSlaveStatusDisplay(¤tSlave->equParaData);
}
void frmMain::InitForm()
{
bool exitInList=false;
//读取分支树父辈
if(!query->exec(select_Parent_sql))
{
QLOG_ERROR() <<query->lastError();
}
else
{
while(query->next())
{
TreeViewItem *treeItem = new TreeViewItem();
treeItem->text = query->value(0).toString();
treeItem->index = query->value(1).toInt();
treeItem->mac = treeItem->index;
treeItem->setSlave(NULL);
treeItem->parentIndexInTree = -1;
for(int i=0;i<viewlist.count();i++)
{
if(viewlist.at(i)->text == treeItem->text)
{
exitInList = true;
break;
}
}
if(!exitInList)
{
viewlist.append(treeItem);
}
exitInList=false;
}
}
//读取设备
if(!query->exec(select_TSlave_sql))
{
QLOG_ERROR() <<query->lastError();
}
else
{
while(query->next())
{
//构建参数类实例
paraData *pdat = new paraData();
bool autolink;
TreeViewItem *treeItem = new TreeViewItem();
treeItem->mac=query->value(0).toString();
pdat->net.macAddr = treeItem->mac;
for(int i=0;i<viewlist.count();i++)
{
if(viewlist.at(i)->mac == treeItem->mac)
{
exitInList = true;
break;
}
}
if(exitInList)
{
continue;
exitInList=false;
}
pdat->slaveType = query->value(1).toInt();
pdat->version = query->value(2).toString();
QStringList verlist = pdat->version.split(".");
pdat->mainVer = verlist.at(0).toInt();
pdat->secondVer = verlist.at(1).toInt();
pdat->waiSheModel = verlist.at(2).toInt();
pdat->xiuDingVer = verlist.at(3).toInt();
treeItem->text = query->value(3).toString();
pdat->name = treeItem->text;
QString tempstr="";
//添加日志记录
switch (pdat->slaveType) {
case 0:
tempstr="加载防护舱“";
break;
case 1:
tempstr="加载加钞间“";
break;
default:
break;
}
InsertOneSystemLogAndShow(tempstr+pdat->name+"("+pdat->net.macAddr+")"+"”");
pdat->net.ip = query->value(4).toString();
autolink = query->value(5).toBool();
treeItem->index = query->value(6).toInt();
//读取设备的网络参数
QSqlQuery *selectSlaveNetWork = new QSqlQuery(database);
selectSlaveNetWork->prepare(select_TNetWork_sql);
selectSlaveNetWork->bindValue(":mac",pdat->net.macAddr);
if(!selectSlaveNetWork->exec())
{
QLOG_ERROR() <<selectSlaveNetWork->lastError();
}
else
{
while(selectSlaveNetWork->next())
{
pdat->net.macAddr = selectSlaveNetWork->value(0).toString();
pdat->net.ip = selectSlaveNetWork->value(1).toString();
pdat->net.gateWay = selectSlaveNetWork->value(2).toString();
pdat->net.subnetMask = selectSlaveNetWork->value(3).toString();
pdat->net.networkModel = selectSlaveNetWork->value(4).toInt();
pdat->net.remoteIp = selectSlaveNetWork->value(5).toString();
}
}
QSqlQuery *selectParaentId = new QSqlQuery(database);
//查找mac地址对应的父的名称
QString parentname="";//父的名称
//int parentid=0;
QString strSql = select_macParent_sql+"'"+treeItem->mac+"'";
selectParaentId->prepare(strSql);
if(!selectParaentId->exec())
{
QLOG_ERROR() <<selectParaentId->lastError();
}
else
{
while(selectParaentId->next())
{
parentname = selectParaentId->value(0).toString();
}
}
//读取对应父的indexInTree
strSql = select_indexParent_sql+"'"+parentname+"'";
selectParaentId->prepare(strSql);
if(!selectParaentId->exec())
{
QLOG_ERROR() <<selectParaentId->lastError();
}
else
{
while(selectParaentId->next())
{
treeItem->parentIndexInTree = selectParaentId->value(0).toInt();
//qDebug()<<treeItem->parentId;
}
}
delete selectParaentId;
QSqlQuery *readPara = new QSqlQuery(database);
//读取参数 根据设备型号pdat->slaveType判断需要读取的参数
/************************************************************/
readPara->prepare(select_TParamater_sql);
readPara->bindValue(":mac",pdat->net.macAddr);
if(!readPara->exec())
{
QLOG_ERROR() <<readPara->lastError();
}
else
{
while(readPara->next())
{
pdat->fangHuCang.openLockTime = readPara->value(1).toInt();
pdat->fangHuCang.OptBussinessTime = readPara->value(2).toInt();
pdat->fangHuCang.timeOutRemind = readPara->value(3).toInt();
pdat->fangHuCang.warnningDelayTime= readPara->value(4).toInt();
pdat->fangHuCang.noManOpenLockTime= readPara->value(5).toInt();
pdat->fangHuCang.fanRunTemperature= readPara->value(6).toInt();
pdat->fangHuCang.signalModel = readPara->value(7).toInt();
pdat->fangHuCang.peopleEquModel = readPara->value(8).toInt();
pdat->fangHuCang.lockModel = readPara->value(9).toInt();
pdat->fangHuCang.kongCangLockorNot= readPara->value(10).toInt();
pdat->fangHuCang.fangQiewarnning = readPara->value(11).toInt();
pdat->zhaoMing.Model =readPara->value(12).toInt();
pdat->zhaoMing.startHour = readPara->value(13).toInt();
pdat->zhaoMing.startMinute= readPara->value(14).toInt();
pdat->zhaoMing.endHour = readPara->value(15).toInt();
pdat->zhaoMing.endMinute = readPara->value(16).toInt();
pdat->zhaoMing.manEnable = readPara->value(17).toInt();
pdat->ledText[0]= readPara->value(18).toString();
pdat->ledText[1]= readPara->value(19).toString();
pdat->ledText[2]= readPara->value(20).toString();
pdat->soundVolume=readPara->value(21).toInt();
pdat->soundMd5[0]=myHelper::hexStringtoByteArray(readPara->value(22).toString());
pdat->soundMd5[2]=myHelper::hexStringtoByteArray(readPara->value(23).toString());
pdat->soundMd5[3]=myHelper::hexStringtoByteArray(readPara->value(24).toString());
pdat->soundMd5[4]=myHelper::hexStringtoByteArray(readPara->value(25).toString());
pdat->soundMd5[5]=myHelper::hexStringtoByteArray(readPara->value(26).toString());
pdat->soundMd5[6]=myHelper::hexStringtoByteArray(readPara->value(27).toString());
pdat->soundMd5[7]=myHelper::hexStringtoByteArray(readPara->value(28).toString());
pdat->soundMd5[1]=myHelper::hexStringtoByteArray(readPara->value(29).toString());
pdat->soundMd5[8]=myHelper::hexStringtoByteArray(readPara->value(30).toString());
//读取报警设置参数
pdat->alarmPara.btnAlarmEnable = readPara->value(31).toBool();
pdat->alarmPara.cutAlarmEnable = readPara->value(32).toBool();
pdat->alarmPara.zhengDongAlarmEnable = readPara->value(33).toBool();
pdat->alarmPara.yanWuAlarmEnable = readPara->value(34).toBool();
pdat->alarmPara.boLiAlarmEnable = readPara->value(35).toBool();
pdat->alarmPara.shuiQinAlarmEnable = readPara->value(36).toBool();
pdat->alarmPara.tempAlarmEnable = readPara->value(37).toBool();
/***************************/
//加钞间独有的参数
pdat->fangHuCang.userNum=readPara->value(38).toInt();; //D2 刷卡人数(1-10人)N+1,如果设置为0表示单卡进出,不为0表示多卡
pdat->fangHuCang.systemAlarmStatus=readPara->value(39).toInt();; //D3 设置系统报警状态:0 - 撤防;1 - 设防
pdat->fangHuCang.setGuardDelayTime=readPara->value(40).toInt();; //D4 设防延时时间(1-90秒钟)
pdat->fangHuCang.isMonitorOrNot=readPara->value(41).toInt();; //D5 是否有人值守:0 - 无人值守;1 - 有人值守
pdat->fangHuCang.inDoorModel=readPara->value(42).toInt();; //D6: 进门方式 0-指纹;1-ID卡;2-TM卡;3-ID卡+密码;4-密码
pdat->fangHuCang.outDoorModel=readPara->value(43).toInt();;
//报警参数
pdat->alarmPara.doorCiAlarmEnable=readPara->value(44).toBool();; //非法开门报警
pdat->alarmPara.existManAlarmEnable=readPara->value(45).toBool();; //非法入侵报警
}
}
delete readPara;
//构建设备类实例
Equipment *temp=new Equipment(this);
temp->autoLink = autolink;
connectToUpdateSlaveToDB(temp);
temp->EquInit(*pdat);
//将树结构和设备类关联在一起
treeItem->setSlave(temp);
//更新树结构
viewlist.append(treeItem);
//获取声音对应的名字
getSlaveSoundName(temp->GetEquAll());
}
}
//读取模板类
if(!query->exec("select * from TMparamater"))
{
QLOG_ERROR() <<query->lastError();
}
else
{
while(query->next())
{
paraModule * module = new paraModule();
module->name = query->value(0).toString();
module->pdat.fangHuCang.openLockTime = query->value(1).toInt();
module->pdat.fangHuCang.OptBussinessTime = query->value(2).toInt();
module->pdat.fangHuCang.timeOutRemind = query->value(3).toInt();
module->pdat.fangHuCang.warnningDelayTime= query->value(4).toInt();
module->pdat.fangHuCang.noManOpenLockTime= query->value(5).toInt();
module->pdat.fangHuCang.fanRunTemperature= query->value(6).toInt();
module->pdat.fangHuCang.signalModel = query->value(7).toInt();
module->pdat.fangHuCang.peopleEquModel = query->value(8).toInt();
module->pdat.fangHuCang.lockModel = query->value(9).toInt();
module->pdat.fangHuCang.kongCangLockorNot= query->value(10).toInt();
module->pdat.fangHuCang.fangQiewarnning = query->value(11).toInt();
module->pdat.zhaoMing.Model =query->value(12).toInt();
module->pdat.zhaoMing.startHour = query->value(13).toInt();
module->pdat.zhaoMing.startMinute= query->value(14).toInt();
module->pdat.zhaoMing.endHour = query->value(15).toInt();
module->pdat.zhaoMing.endMinute = query->value(16).toInt();
module->pdat.ledText[0]= query->value(18).toString();
module->pdat.ledText[1]= query->value(19).toString();
module->pdat.ledText[2]= query->value(20).toString();
module->pdat.soundVolume=query->value(21).toInt();
module->pdat.soundMd5[0]=myHelper::hexStringtoByteArray(query->value(22).toString());
module->pdat.soundMd5[2]=myHelper::hexStringtoByteArray(query->value(23).toString());
module->pdat.soundMd5[3]=myHelper::hexStringtoByteArray(query->value(24).toString());
module->pdat.soundMd5[4]=myHelper::hexStringtoByteArray(query->value(25).toString());
module->pdat.soundMd5[5]=myHelper::hexStringtoByteArray(query->value(26).toString());
module->pdat.soundMd5[6]=myHelper::hexStringtoByteArray(query->value(27).toString());
module->pdat.soundMd5[7]=myHelper::hexStringtoByteArray(query->value(28).toString());
module->pdat.soundMd5[1]=myHelper::hexStringtoByteArray(query->value(29).toString());
module->pdat.soundMd5[8]=myHelper::hexStringtoByteArray(query->value(30).toString());
//读取报警设置参数
module->pdat.alarmPara.btnAlarmEnable = query->value(31).toBool();
module->pdat.alarmPara.cutAlarmEnable = query->value(32).toBool();
module->pdat.alarmPara.zhengDongAlarmEnable = query->value(33).toBool();
module->pdat.alarmPara.yanWuAlarmEnable = query->value(34).toBool();
module->pdat.alarmPara.boLiAlarmEnable = query->value(35).toBool();
module->pdat.alarmPara.shuiQinAlarmEnable = query->value(36).toBool();
module->pdat.alarmPara.tempAlarmEnable = query->value(37).toBool();
/***************************/
//加钞间独有的参数
module->pdat.fangHuCang.userNum = query->value(38).toInt();; //D2 刷卡人数(1-10人)N+1,如果设置为0表示单卡进出,不为0表示多卡
module->pdat.fangHuCang.systemAlarmStatus = query->value(39).toInt();; //D3 设置系统报警状态:0 - 撤防;1 - 设防
module->pdat.fangHuCang.setGuardDelayTime = query->value(40).toInt();; //D4 设防延时时间(1-90秒钟)
module->pdat.fangHuCang.isMonitorOrNot = query->value(41).toInt();; //D5 是否有人值守:0 - 无人值守;1 - 有人值守
module->pdat.fangHuCang.inDoorModel = query->value(42).toInt();; //D6: 进门方式 0-指纹;1-ID卡;2-TM卡;3-ID卡+密码;4-密码
module->pdat.fangHuCang.outDoorModel = query->value(43).toInt();;
//报警参数
module->pdat.alarmPara.doorCiAlarmEnable = query->value(44).toBool();; //非法开门报警
module->pdat.alarmPara.existManAlarmEnable = query->value(45).toBool();; //非法入侵报警
moduleList.append(module);
}
}
for(int j=0;j<moduleList.count();j++)
{
paraData * para = &moduleList.at(j)->pdat;
for(int i=0;i<9;i++)
{
QString fileName="";
QString name="";
QString md5 = para->soundMd5[i].toHex();
Select_TVoice_FileName_Name(name,fileName,md5);
para->voiceFileName[i]=fileName;
para->soundName[i]= name;
}
}