DELL
2024-03-29 73eab4bcadb946276108ee29a3837c7c35fd8867
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
//package com.beanit.test;
//
//import com.alibaba.fastjson.JSON;
//import com.beanit.openiec61850.*;
//import com.beanit.rabbitmq.Producer;
//import com.beanit.socket.Client;
//import com.beanit.test.utils.*;
//import com.beanit.test.view.MyTableRenderer;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import sun.misc.BASE64Encoder;
//
//import javax.swing.*;
//import javax.swing.event.TableModelEvent;
//import javax.swing.event.TableModelListener;
//import javax.swing.table.DefaultTableModel;
//import java.awt.*;
//import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;
//import java.awt.event.WindowAdapter;
//import java.awt.event.WindowEvent;
//import java.io.IOException;
//import java.net.InetAddress;
//import java.net.UnknownHostException;
//import java.util.*;
//import java.util.List;
//import java.util.Timer;
////电科院送检测试类
///**
// * @author LiBiChao
// * @create 2019-08-06
// * @update 2020-10-20
// */
//public class MyClient {
//
//    private static final Logger logger = LoggerFactory.getLogger(MyClient.class);
//
//    private Producer producer;
//
//    private JTable mainTable;
//    private DefaultTableModel tableModel;
//    private String[] columnTitles = { "变电站", "IP地址", "端口", "上次采集时间"};
//    private JScrollPane jsPane;
//    private Thread threads[];
//    private Timer timers[];
//    private Timer monitorTimer;
//    private Timer wakeUpTimer;
//    private Timer networkReviewTimer;
//    private JLabel labelTips;
//    private JTextField txtCollectDelay;
//    private JTextField txtSubstationDelay;
//    private JTextField txtSubstationList;
//    private JRadioButton radioCollectData = new JRadioButton("是");
//    private JRadioButton radioNotCollectData = new JRadioButton("否");
//    private JRadioButton radioCollectFile = new JRadioButton("是");
//    private JRadioButton radioNotCollectFile = new JRadioButton("否");
//    private JRadioButton radioDeleteRemote = new JRadioButton("是");
//    private JRadioButton radioNotDeleteRemote = new JRadioButton("否");
//    private boolean isCollectRemoteData = true;
//    private boolean isCollectRemoteFile = false;
//    private boolean isDeleteRemoteFile = false;
//    private static int CollectIntervalTimes = 1000 * 60 * 60 * 2; //同一站点采集两个小时
//    private static int SubstaionIntervalTimes = 1000 * 60 * 3; //站点间采集间隔3分钟
//    private JButton btnSetting;
//    private JButton btnStart;
//    private JButton btnDetail;
//    private boolean isRunning  = false;
//
//    private static String sendMessageMethod = "mq";   //可选mq和areaIII
//    private static Client client;
//
//    public void ClientMain(){
//
//        logger.debug("ClientMain init...");
//
//        JFrame frm = new JFrame();
//        frm.setLocation(100, 100);
//        frm.setSize(680, 610);
//        //frm.setBounds(100, 100, 300, 300);  // 功能与上面相同
//        frm.setTitle("云南电网变电在线监测采集系统 -【二区主站】");
//        Container c = frm.getContentPane(); // frm中包含一个内容窗格, 需要获取内容窗格,再设置背景颜色,直接设置frm的背景颜色会被内容窗格挡住
//        c.setBackground(new Color(230, 230, 230));
//        frm.setLayout(null);                // 如过不设置为null默认,按钮会充满整个内容框,挡住背景颜色
//
//        //配置信息-采集间隔
//        JLabel labelCollect = new JLabel("采集间隔:");
//        labelCollect.setLocation(50, 10);
//        labelCollect.setSize(70, 25);
//        frm.add(labelCollect);
//        txtCollectDelay = new JTextField();
//        txtCollectDelay.setLocation(120, 10);
//        txtCollectDelay.setSize(50, 25);
//        txtCollectDelay.setText("120");
//        txtCollectDelay.setEditable(false);
//        frm.add(txtCollectDelay);
//        JLabel collectUnit = new JLabel("分钟");
//        collectUnit.setLocation(170, 10);
//        collectUnit.setSize(80, 25);
//        frm.add(collectUnit);
//        //配置信息-站点间隔
//        JLabel labelSubstation = new JLabel("站点间隔:");
//        labelSubstation.setLocation(220, 10);
//        labelSubstation.setSize(70, 25);
//        frm.add(labelSubstation);
//        txtSubstationDelay = new JTextField();
//        txtSubstationDelay.setLocation(290, 10);
//        txtSubstationDelay.setSize(50, 25);
//        txtSubstationDelay.setText("5");
//        txtSubstationDelay.setEditable(false);
//        frm.add(txtSubstationDelay);
//        JLabel substationUnit = new JLabel("分钟");
//        substationUnit.setLocation(340, 10);
//        substationUnit.setSize(80, 25);
//        frm.add(substationUnit);
//        //配置信息-采集列表
//        JLabel labelSubstationList = new JLabel("列表配置:");
//        labelSubstationList.setLocation(390, 10);
//        labelSubstationList.setSize(70, 25);
//        frm.add(labelSubstationList);
//        txtSubstationList = new JTextField();
//        txtSubstationList.setLocation(460, 10);
//        txtSubstationList.setSize(120, 25);
//        txtSubstationList.setText("substation_list.txt");
//        txtSubstationList.setEditable(false);
//        frm.add(txtSubstationList);
//        //配置信息-采集数据
//        JLabel labelCollectData = new JLabel("采集数据:");
//        labelCollectData.setLocation(50, 40);
//        labelCollectData.setSize(70, 25);
//        frm.add(labelCollectData);
//        ButtonGroup collectDataBtnGroup = new ButtonGroup();
//        collectDataBtnGroup.add(radioCollectData);
//        radioCollectData.setLocation(120, 40);
//        radioCollectData.setSize(40, 25);
//        radioCollectData.setSelected(true);
//        radioCollectData.setEnabled(false);
//        frm.add(radioCollectData);
//        collectDataBtnGroup.add(radioNotCollectData);
//        radioNotCollectData.setLocation(160, 40);
//        radioNotCollectData.setSize(40, 25);
//        radioNotCollectData.setEnabled(false);
//        frm.add(radioNotCollectData);
//        //配置信息-采集文件
//        JLabel labelCollectFile = new JLabel("采集谱图:");
//        labelCollectFile.setLocation(220, 40);
//        labelCollectFile.setSize(70, 25);
//        frm.add(labelCollectFile);
//        ButtonGroup collectFileBtnGroup = new ButtonGroup();
//        collectFileBtnGroup.add(radioCollectFile);
//        radioCollectFile.setLocation(290, 40);
//        radioCollectFile.setSize(40, 25);
//        radioCollectFile.setEnabled(false);
//        frm.add(radioCollectFile);
//        collectFileBtnGroup.add(radioNotCollectFile);
//        radioNotCollectFile.setLocation(330, 40);
//        radioNotCollectFile.setSize(40, 25);
//        radioNotCollectFile.setSelected(true);
//        radioNotCollectFile.setEnabled(false);
//        frm.add(radioNotCollectFile);
//        //配置信息-删除远端文件
//        JLabel labelDeleteRemote = new JLabel("采完删除:");
//        labelDeleteRemote.setLocation(390, 40);
//        labelDeleteRemote.setSize(70, 25);
//        frm.add(labelDeleteRemote);
//        ButtonGroup deleteBtnGroup = new ButtonGroup();
//        deleteBtnGroup.add(radioDeleteRemote);
//        radioDeleteRemote.setLocation(460, 40);
//        radioDeleteRemote.setSize(40, 25);
//        radioDeleteRemote.setEnabled(false);
//        frm.add(radioDeleteRemote);
//        deleteBtnGroup.add(radioNotDeleteRemote);
//        radioNotDeleteRemote.setLocation(500, 40);
//        radioNotDeleteRemote.setSize(40, 25);
//        radioNotDeleteRemote.setSelected(true);
//        radioNotDeleteRemote.setEnabled(false);
//        frm.add(radioNotDeleteRemote);
//
//        //配置按钮
//        btnSetting = new JButton("配置");
//        btnSetting.setLocation(550, 80);
//        btnSetting.setSize(90, 30);
//        btnSetting.setBackground(new Color(224, 234, 244));
//        btnSetting.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                //logger.debug(e.getActionCommand());
//                if(isRunning){
//                    //logger.debug("请先停止采集再进行配置!#_#");
//                    labelTips("请先停止采集再进行配置!", "warning");
//                    return;
//                }
//                if(txtCollectDelay.isEditable()){
//                    int intCollectIntervalMinute = Integer.valueOf(txtCollectDelay.getText());
//                    CollectIntervalTimes = intCollectIntervalMinute * 60 * 1000;
//                    int intSubstationIntervalMinute = Integer.valueOf(txtSubstationDelay.getText());
//                    SubstaionIntervalTimes = intSubstationIntervalMinute * 60 * 1000;
//                    if(radioCollectData.isSelected()){
//                        isCollectRemoteData = true;
//                    }else {
//                        isCollectRemoteData = false;
//                    }
//                    if(radioCollectFile.isSelected()){
//                        isCollectRemoteFile = true;
//                    }else {
//                        isCollectRemoteFile = false;
//                    }
//                    if(radioDeleteRemote.isSelected()){
//                        isDeleteRemoteFile = true;
//                    }else{
//                        isDeleteRemoteFile = false;
//                    }
//                    txtCollectDelay.setEditable(false);
//                    txtSubstationDelay.setEditable(false);
//                    txtSubstationList.setEditable(false);
//                    radioCollectData.setEnabled(false);
//                    radioNotCollectData.setEnabled(false);
//                    radioCollectFile.setEnabled(false);
//                    radioNotCollectFile.setEnabled(false);
//                    radioDeleteRemote.setEnabled(false);
//                    radioNotDeleteRemote.setEnabled(false);
//                    //重新加载站点列表
//                    dataLoad();
//                    btnSetting.setText("配置");
//                    labelTips("配置保存成功!", "");
//                }else {
//                    txtCollectDelay.setEditable(true);
//                    txtSubstationDelay.setEditable(true);
//                    txtSubstationList.setEditable(true);
//                    radioCollectData.setEnabled(true);
//                    radioNotCollectData.setEnabled(true);
//                    radioCollectFile.setEnabled(true);
//                    radioNotCollectFile.setEnabled(true);
//                    radioDeleteRemote.setEnabled(true);
//                    radioNotDeleteRemote.setEnabled(true);
//                    btnSetting.setText("保存");
//                    txtCollectDelay.requestFocus();
//                    labelTips("编辑配置...", "");
//                }
//            }
//        });
//        frm.add(btnSetting);
//        //采集详情
//        btnDetail = new JButton("采集详情");
//        btnDetail.setLocation(150, 80);
//        btnDetail.setSize(90, 30);
//        btnDetail.setBackground(new Color(224, 234, 244));
//        btnDetail.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                logger.debug(e.getActionCommand());
//                int rowIndex = mainTable.getSelectedRow();
//                if(rowIndex < 0){
//                    //logger.debug("未选择站点!#_#");
//                    labelTips("未选择站点!", "warning");
//                    return;
//                }
//                MyClientGui myClientGui = new MyClientGui();
//                myClientGui.setIpTextField(tableModel.getValueAt(rowIndex, 1).toString());
//                myClientGui.setPortTextField(tableModel.getValueAt(rowIndex, 2).toString());
//                //myClientGui.dispose();
//            }
//        });
//        frm.add(btnDetail);
//
//        //确定按钮
//        btnStart = new JButton("开始采集");
//        btnStart.setLocation(50, 80);
//        btnStart.setSize(90, 30);
//        btnStart.setBackground(new Color(224, 234, 244));
//        btnStart.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                if(tableModel.getRowCount() <= 0){
//                    //logger.warn("采集列表为空!");
//                    labelTips("采集列表为空!", "warning");
//                    return;
//                }
//                if(txtCollectDelay.isEditable()){
//                    //logger.warn("请先保存配置!");
//                    labelTips("请先保存配置!", "warning");
//                    return;
//                }
//
//                if (ConfigUtil.isNetworkReview){
//                    if (!isRunning) {
//                        startNetworkReview();
//                        isRunning = true;
//                        btnStart.setText("停止检查");
//                    }else{
//                        networkReviewTimer.cancel();
//                        isRunning = false;
//                        btnStart.setText("开始检查");
//                    }
//                    return;
//                }
//
//                if(!isRunning) {
//                    //启动状态监视器
//                    monitorSchedule();
//                    //重连定时器
//                    wakeUpSchedule();
//                    isRunning = true;
//                    btnStart.setText("停止采集");
//                    collectStart();
//                }else{
//                    collectStop();
//                    //停止监视器
//                    monitorTimer.cancel();
//                    logger.debug("状态监视器已停止。");
//                    //停止重连器
//                    wakeUpTimer.cancel();
//                    logger.debug("重连定时器已停止。");
//                    isRunning = false;
//                    btnStart.setText("开始采集");
//                }
//            }
//        });
//        frm.add(btnStart);
//        //站点增加按钮
//        JButton btnAddRow = new JButton("增加站点");
//        btnAddRow.setLocation(250, 80);
//        btnAddRow.setSize(90, 30);
//        btnAddRow.setBackground(new Color(224, 234, 244));
//        btnAddRow.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                if(isRunning){
//                    logger.warn("采集中不能增加站点!");
//                    return;
//                }
//                //tableModel.setRowCount(tableModel.getDataVector().size() + 1);
//                tableModel.setRowCount(tableModel.getRowCount() + 1);
//                tableModel.setValueAt("null", tableModel.getRowCount() - 1, 0);
//                mainTable.changeSelection(tableModel.getRowCount() - 1, 0, true, false);
//            }
//        });
//        frm.add(btnAddRow);
//
//        //删除增加按钮
//        JButton btnDelRow = new JButton("删除站点");
//        btnDelRow.setLocation(350, 80);
//        btnDelRow.setSize(90, 30);
//        btnDelRow.setBackground(new Color(224, 234, 244));
//        btnDelRow.addActionListener(new ActionListener() {
//            @Override
//            public void actionPerformed(ActionEvent e) {
//                if(isRunning){
//                    logger.warn("采集中不能删除站点!");
//                    labelTips("采集中不能删除站点!", "warning");
//                    return;
//                }
//                int rowIndex = mainTable.getSelectedRow();
//                if(rowIndex < 0){
//                    logger.debug("未选择站点!#_#");
//                    labelTips("未选择站点#_#!", "warning");
//                    return;
//                }
//                boolean flag = ConfigUtil.delSubstation(txtSubstationList.getText(), rowIndex);
//                if (flag) {
//                    tableModel.removeRow(rowIndex);
//                }
//                logger.debug("--------------- 删除:" + flag + "--------------------");
//            }
//        });
//        frm.add(btnDelRow);
//
//        //JTable
//        tableModel = new DefaultTableModel(columnTitles, 0);
//        tableModel.addTableModelListener(new TableModelListener() {
//            @Override
//            public void tableChanged(TableModelEvent e) {
//
//                if(e.getType() == TableModelEvent.UPDATE){
//                    if(e.getLastRow() >= 0){
//                        int rowIndex = e.getLastRow();
//                        int colIndex = e.getColumn();
//                        String strValue = tableModel.getValueAt(rowIndex, colIndex).toString();
//                        //System.out.println(" setSubstationValue: [" + rowIndex + ", " + colIndex + "]=>" + strValue);
//                        boolean flag = ConfigUtil.setSubstationValue(txtSubstationList.getText(), rowIndex, colIndex, strValue);
//                        //System.out.println(flag + " setSubstationValue: [" + rowIndex + ", " + colIndex + "]=>" + strValue);
//                    }
//                }
//            }
//        });
//
//        mainTable = new JTable(tableModel);
//        //mainTable.getColumnModel().getColumn(1).setCellEditor(new MyRender());//设置编辑器
//        //mainTable.getColumnModel().getColumn(1).setCellRenderer(new MyRender() );
//        jsPane = new JScrollPane(mainTable);
//        jsPane.setSize(600, 400);
//        jsPane.setLocation(30, 130);
//        frm.add(jsPane);
//        mainTable.setDefaultRenderer(Object.class, new MyTableRenderer());
//
//        //底部提示信息
//        JLabel labelTipsTitle = new JLabel("提示信息:");
//        labelTipsTitle.setLocation(50, 530);
//        labelTipsTitle.setSize(70, 25);
//        frm.add(labelTipsTitle);
//        labelTips = new JLabel("welcome!");
//        labelTips.setLocation(120, 530);
//        labelTips.setSize(500, 25);
//        frm.add(labelTips);
//
//        dataLoad();
//
//        //frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//        frm.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
//        frm.addWindowListener(new WindowAdapter() {
//            @Override
//            public void windowClosing(WindowEvent e) {
//                super.windowClosing(e);
//                int result = JOptionPane.showConfirmDialog(null, "确认退出?", "确认",JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
//                if (result == JOptionPane.OK_OPTION) {
//                    // 退出
//                    System.exit(0);
//                }
//            }
//        });
//
//        if (ConfigUtil.isNetworkReview){
//            btnStart.setText("开始检查");
//            btnAddRow.setEnabled(false);
//            btnDelRow.setEnabled(false);
//            btnDetail.setEnabled(false);
//            btnSetting.setEnabled(false);
//        }
//
//        frm.setVisible(true);
//
//        // 三区服务连接
//        //client = new Client();
//        //client.init();
//        //client.conn();
//
//
//        //初始化消息队列
//        if(ConfigUtil.isDebug){
//            return;
//        }
//        try {
//            producer = new Producer("ztjc");
//            logger.debug("消息队列初始化完成!^_^");
//        } catch (IOException e) {
//            System.out.println("消息队列初始化失败!@_@");
//            e.printStackTrace();
//        }
//    }
//
//    /**
//     * 状态监视器
//     */
//    private void monitorSchedule(){
//        monitorTimer = new Timer();
//        monitorTimer.schedule(new TimerTask() {
//            @Override
//            public void run() {
//                //刷新mainTabled的数据状态,可发送心跳
//                //System.out.print("*");
//                int rowIndex = mainTable.getSelectedRow();
//                int colIndex = mainTable.getSelectedColumn();
//                //logger.debug(rowIndex + " - " + colIndex);
//                mainTable.changeSelection(rowIndex, colIndex, true, false);
//                mainTable.changeSelection(rowIndex, colIndex, true, false);
//            }
//        }, 1000, 3000);
//        logger.debug("状态监视器已启动。");
//    }
//
//    /**
//     * 定时唤醒任务
//     */
//    private void wakeUpSchedule(){
//        wakeUpTimer = new Timer();
//        int substationCount = mainTable.getRowCount();
//        long startTime = substationCount * SubstaionIntervalTimes;
//        wakeUpTimer.schedule(new TimerTask() {
//            @Override
//            public void run() {
//                logger.debug("重连定时器开始执行...");
//                for (int i = 0; i < substationCount; i++){
//                    String name = tableModel.getValueAt(i,0).toString();
//                    String ip = tableModel.getValueAt(i,1).toString();
//                    int port = Integer.valueOf(tableModel.getValueAt(i,2).toString());
//                    String lastTime = tableModel.getValueAt(i,3).toString();
//                    if(lastTime != null && lastTime.length() == 19){
//                        long millisTime = SimpleUtils.DateTimeToMillisTime(lastTime);
//                        if((System.currentTimeMillis() - 3 * 60 * 60 * 1000) > millisTime){
//                            logger.debug("重连定时器【" + (i + 1) + " - " + name + "】 开始连接至变电站 => " + ip + ":" + port
//                                    + " [" + SimpleUtils.CurrentDateTime() + "]");
//                            collectToSubstation(ip, port, i);
//                        }else{
//                            continue;
//                        }
//                    }else{
//                        logger.debug("重连定时器【" + (i + 1) + " - " + name + "】 开始连接至变电站 => " + ip + ":" + port
//                                + " [" + SimpleUtils.CurrentDateTime() + "]");
//                        collectToSubstation(ip, port, i);
//                    }
//                }
//            }
//        }, startTime, 5 * 60 * 1000);
//        logger.debug("重连定时器" + Math.floor((startTime/60)/1000) + "分钟后启动。");
//    }
//
//    protected void collectToSubstation(String ip, int port, int rowIndex){
//        String subStationName = mainTable.getValueAt(rowIndex, 0).toString();
//        ClientSap clientSap = new ClientSap();
//        //clientSap.setMaxMmsPduSize(6500000);
//        //logger.debug("MaxMmsPduSize: " + clientSap.getMaxMmsPduSize());
//        InetAddress address;
//        try {
//            address = InetAddress.getByName(ip);
//        } catch (UnknownHostException e1) {
//            logger.error("【" + subStationName + "】 IP地址错误: " + "ip Address ERROR"   );
//            labelTips("【" + subStationName + "】 IP地址错误!", "error");
//            e1.printStackTrace();
//            return;
//        }
//        try {
//            if (port < 1 || port > 0xFFFF) {
//                throw new NumberFormatException("端口超出范围: " + "port must be in range [1, 65535]");
//            }
//        } catch (NumberFormatException e) {
//            logger.error("【" + subStationName + "】 端口异常: " + "port ERROR");
//            labelTips("【" + subStationName + "】 端口异常!", "error");
//            e.printStackTrace();
//            return;
//        }
//
//        //clientSap.setTSelLocal(settingsFrame.getTselLocal());
//        //clientSap.setTSelRemote(settingsFrame.getTselRemote());
//
//        ClientAssociation association;
//        try {
//            association = clientSap.associate(address, port, null, null);
//        } catch (IOException e) {
//            logger.debug("【" + subStationName + "】 连接失败: " + e.getMessage());
//            labelTips("【" + subStationName + "】 连接失败!", "error");
////            if(ConfigUtil.isNetworkReview) {
////                checkNet(ip, port);
////            }
//            sendErrorLog(subStationName, ip, e.getMessage());
//            checkNet(subStationName, ip, port);
//            return;
//        }
//
//        //数据读取
//        if(isCollectRemoteData) {
//            boolean flag = readData(association, ip, subStationName);
//            if(flag){
//                String strDate = SimpleUtils.CurrentDateTime();
//                tableModel.setValueAt(strDate, rowIndex, 3);
//                boolean flag2 = ConfigUtil.setSubstationValue(txtSubstationList.getText(), rowIndex, 3, strDate);
//                logger.debug("【" + subStationName + "】 本次采集任务完成!");
//                labelTips("【" + subStationName + "】 完成一次采集任务!", "");
//            }else{
//                logger.debug("【" + subStationName + "】 本次采集任务结束,但存在异常*_*!");
//                labelTips("【" + subStationName + "】 采集任务结束,存在异常!", "error");
//                checkNet(subStationName, ip, port);
//            }
//        }
//
//        if(!isCollectRemoteFile){
//            association.disconnect();
//            association.close();
//            //logger.debug(association.isOpen() + "");
//            return;
//        }
//        //文件读取
//        String dirName = "";
//        List fileList = null;
//        try {
//            fileList = association.getFileDirectory(dirName);
//        } catch (ServiceError serviceError) {
//            serviceError.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//        for(int i = 0; i < fileList.size(); i++){
//            FileInformation remoteFile = (FileInformation)fileList.get(i);
//            String fileName = remoteFile.getFilename();
//            if(fileName.contains("COMTRADE")){
//                dirName = fileName;
//                try {
//                    fileList = association.getFileDirectory(dirName);
//                } catch (ServiceError serviceError) {
//                    serviceError.printStackTrace();
//                } catch (IOException e) {
//                    e.printStackTrace();
//                }
//                break;
//            }
//        }
//        if(fileList == null){
//            logger.debug("【" + subStationName + "】 远程文件目录读取失败");
//            labelTips("【" + subStationName + "】 远程文件目录读取失败!", "error");
//        }
//        //定义文件临时存储目录
//        final String tempSavePath = "temp/tempSavePath/" + ip;
//        FileOption.creatDir(tempSavePath); //创建目录
//        //定义文件采集日志目录
//        final String tempLogFile = "log.txt";
//        String lastLog = FileOption.readFileLastLine(tempSavePath, tempLogFile);
//        if(!FileOption.fileExist(tempSavePath + "/" + tempLogFile)){
//            FileOption.createFile(tempSavePath, tempLogFile); //创建文件
//            lastLog = "[sendCount:0, deleteCount:0]-Time " + "2019-09-01 00:00:00";
//            FileOption.writeFile(lastLog, tempSavePath, tempLogFile);
//        }
//        logger.debug("【" + subStationName + "】 读取上次谱图采集日志: " + lastLog);
//        logger.debug("【" + subStationName + "】 读取远程文件数量: " + fileList.size());
//        labelTips("【" + subStationName + "】 读取远程文件数量: " + fileList.size(), "");
//        int sendCount = 0;
//        List<String> deleteList = new ArrayList();
//        for(int i = 0; i < fileList.size(); i++){
//            //if(i > 2) continue;
//            //限制单次采集不超过5000个文件
//            if(sendCount >= 5000){
//                continue;
//            }
//            sendCount ++;
//            FileInformation remoteFile = (FileInformation)fileList.get(i);
////            long fileMillisTime = remoteFile.getLastModified().getTimeInMillis();
////            //文件时间小于上次采集的时间则忽略
////            if(fileMillisTime < startDate){
////                continue;
////            }
//            final String fileName = remoteFile.getFilename();
//            //清理已存在的临时文件
//            FileOption.deleteFile(tempSavePath, fileName);
//            logger.debug("\n开始采集文件:" + System.currentTimeMillis() + " => file-" + (i + 1) + ": " + fileName
//                    + " Size: " + remoteFile.getFileSize());
//            try {
//                association.getFile(fileName, new GetFileListener() {
//                    @Override
//                    public boolean dataReceived(byte[] fileData, boolean moreFollows) {
//                        //logger.debug("开始写入临时文件前时间:" + System.currentTimeMillis());
//                        boolean isSaved = FileOption.writeBinaryFile(tempSavePath, fileName, fileData, true);
//                        //logger.debug("完成写入临时文件后时间:" + System.currentTimeMillis());
//                        //logger.debug(tempSavePath + fileName + " save: " + isSaved);
//                        //logger.debug("moreFollows:" + moreFollows);
//                        while (moreFollows){
//                            return true;
//                        }
//                        //文件传输完成,打包文件
//                        //logger.debug("单个文件传输完成时间:" + System.currentTimeMillis());
//                        String strData = getFileCompressBase64(tempSavePath, fileName);
//                        //logger.debug("生成数据时间:" + System.currentTimeMillis());
//                        //logger.debug("temp file temp saved: " + fileName);
//                        //打包完成,删除文件
//                        boolean deleteFlag = FileOption.deleteFile(tempSavePath, fileName);
//                        //boolean deleteFlag = false;
//                        if(!deleteFlag){
//                            logger.debug("temp file delete: " + "failure");
//                        }
//                        boolean complete = sendFileDate(ip, fileName, strData);
//                        if(complete){
//                            deleteList.add(fileName);
//                        }
//                        return false;
//                    }
//                });
//            } catch (ServiceError serviceError) {
//                serviceError.printStackTrace();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }
//        //记录执行日志
//        String newLogStr = "\n" + "[sendCount:" + sendCount + ", deleteCount:" + deleteList.size() + "]-Time "
//                + SimpleUtils.MillisToDateTime(System.currentTimeMillis());
//        //更新采集时间
//        String strDate = SimpleUtils.CurrentDateTime();
//        tableModel.setValueAt(strDate, rowIndex, 3);
//        //记录采集日志
//        FileOption.writeFile(newLogStr, tempSavePath, tempLogFile, true);
//        logger.debug("【" + subStationName + "】 谱图采集完成!");
//        labelTips("【" + subStationName + "】 本次谱图采集完成!", "");
//        if(!isDeleteRemoteFile){
//            association.disconnect();
//            association.close();
//            return;
//        }
//        //删除远程文件
//        for(int i = 0; i < deleteList.size(); i++){
//            try {
//                association.deleteFile(deleteList.get(i));
//                logger.debug("remote file delete: " + deleteList.get(i));
//            } catch (ServiceError serviceError) {
//                serviceError.printStackTrace();
//                logger.debug("remote file delete: " + "failure");
//            } catch (IOException e) {
//                e.printStackTrace();
//                logger.debug("remote file delete: " + "failure");
//            }
//        }
//        logger.debug("【" + subStationName + "】 远程谱图文件删除完成!");
//        association.disconnect();
//        association.close();
//        //logger.debug(association.isOpen() + "");
//        //logger.debug("恭喜你!本次采集完成了!!!");
//    }
//
//    private boolean readData(ClientAssociation association, String ipAddress, String subStationName){
//        ServerModel serverModel;
//        try {
//            logger.debug("【" + subStationName + "】 开始读取数据模型...");
//            labelTips("【" + subStationName + "】 开始读取数据模型...", "");
//            serverModel = association.retrieveModel();
//            logger.debug("【" + subStationName + "】 数据模型读取成功^_^");
//            logger.debug("【" + subStationName + "】 开始采集数据...");
//            labelTips("【" + subStationName + "】 开始采集数据^_^...", "");
//            association.getAllDataValues();
//
//            for(ModelNode modelNodeLD : serverModel.getChildren()) {
//                LogicalDevice logicalDevice = (LogicalDevice)modelNodeLD;
//                if (logicalDevice.getReference().toString().contains("_LD0")) {//过滤综合数据处理单元LD0
//                    continue;
//                }
//                for (ModelNode modelNodeLN : logicalDevice.getChildren()) {
//                    LogicalNode logicalNode = (LogicalNode)modelNodeLN;
//                    int start = logicalNode.getReference().toString().indexOf('/');
//                    String lnReference = logicalNode.getReference().toString().substring(start);
//                    if(lnReference.contains("LLN0")// 综合数据处理单元LD下面LLN0
//                            | lnReference.contains("GGIO")// 综合数据处理单元LD下面GGIO
//                            | lnReference.contains("LPHD")// 综合数据处理单元LD下面LPHD
//                            | lnReference.contains("RDRE")) {// 综合数据处理单元LD下面RDRE
//                        continue;
//                    }
//
//                    logger.debug(logicalNode.getName());
//                    List<String> doKeyList = new ArrayList<>();
//                    for (ModelNode modelNodeDO : logicalNode.getChildren()) {
//                        if (!doKeyList.contains(modelNodeDO.getName())) {
//                            doKeyList.add(modelNodeDO.getName());
//                        } else {
//                            continue;
//                        }
//                    }
//
//                    if(!doKeyList.contains("NamPlt")){
//                        String errorMsg = "【" + subStationName + "】 " + logicalNode.getReference().toString() + "配置文件铭牌定义错误";
//                        logger.error(logicalNode.getReference().toString() + " not contain NamPlt!!!!");
//                        labelTips(errorMsg, "error");
//                        sendErrorLog(subStationName, ipAddress, errorMsg);
//                        continue;
//                    }
//                    doKeyList.remove("NamPlt");
//
//                    //Map<String, Object> mapId = new HashMap<>();
//                    ModelNode modelNodeId = logicalNode.getChild("NamPlt", Fc.DC);
//                    Map<String, Object> mapId = getChildrenData(modelNodeId);
//                    String strNamPltValue = ((Map<String, Object>)mapId.get("dU")).get("value").toString();
//                    //byte[] byteNamPltValue = strNamPltValue.getBytes();
//                    //String packageType = "Linux";
//                    //packageType = "Windows";
//                    //if(packageType.equals("Windows")){
//                        //strNamPltValue = new String(byteNamPltValue, "UTF-8");
//                    //}
//                    String[] strNamPltValues = strNamPltValue.split("\\|");
//                    //logger.debug("" + NamPltValues.length);
//
//                    if(strNamPltValues.length < 5){
//                        String errorMsg = "【" + subStationName + "】 NamPlt:dU=>" + strNamPltValue + " ;描述错误!";
//                        logger.error(errorMsg);
//                        labelTips("【" + subStationName + "】 配置文件铭牌dU值定义错误", "error");
//                        sendErrorLog(subStationName, ipAddress, errorMsg);
//                        //continue;
//                    }
//                    //logger.debug(strNamPltValues[4].length() + "");
//                    if(strNamPltValues.length >= 5 && strNamPltValues[4].length() < 2){
//                        String errorMsg = "【" + subStationName + "】 NamPlt:dU=>" + strNamPltValue + " ;相位描述不完整!";
//                        logger.error(errorMsg);
//                        labelTips("【" + subStationName + "】 配置文件铭牌dU值相位描述不完整", "error");
//                        sendErrorLog(subStationName, ipAddress, errorMsg);
//                        //continue;
//                    }
//                    //logger.debug(JSON.toJSONString(mapId));
//                    logger.debug("【" + subStationName + "】 ------ [" + strNamPltValue + "] " + logicalNode.getReference().toString() + " 开始打包发送数据: " + doKeyList.size() +" 条 ------");
//                    for (String doKey : doKeyList){
//                        Map<String, Object> mapDo = new HashMap<>();
//                        for (Fc fc: SimpleUtils.FcList()){
//                            ModelNode modelNodeDo = logicalNode.getChild(doKey, fc);
//                            if(modelNodeDo == null){
//                                continue;
//                            }
//                            Map<String, Object> mapDataChildren = getChildrenData(modelNodeDo);
//                            if(mapDataChildren.get("t") != null){
//                                Map<String, Object> mapDataTime = (HashMap)mapDataChildren.get("t");
//                                long dataTime = SimpleUtils.DateTimeToMillisTime(mapDataTime.get("value").toString(), "yyyyMMddHHmmss");
//                                if(System.currentTimeMillis() - dataTime > 2 * 24 * 60 * 60 * 1000){
//                                    //logger.debug(mapDataTime.get("value").toString());
//                                    sendErrorLog(subStationName, ipAddress, logicalNode.getChild(doKey).getReference().toString() + ":" + mapDataTime.get("value").toString());
//                                }
//                            }
//                            mapDo.put(fc.toString(), getChildrenData(modelNodeDo));
//                        }
//                        mapDo.put("ID", mapId);
//                        Map<String, Object> mapData = new HashMap<>();
//                        mapData.put("type", "GC");
//                        if (ConfigUtil.isDebug) {
//                            logger.debug(doKey);
//                            logger.debug(logicalNode.getChild(doKey).getReference().toString());
//                        }
//                        mapData.put(ipAddress + "$" + logicalNode.getChild(doKey).getReference().toString(), mapDo);
//                        String data = JSON.toJSONString(mapData);
//                        //logger.debug(data);
//                        sendDataToMQ(data);
//                        //sendDataToIII(data);
//                        System.out.println(data);
//                    }
//                }
//            }
//        } catch (ServiceError e) {
//            System.out.println("Service Error requesting model." + e.getMessage());
//            String errorMsg = "Service Error requesting model." + e.getMessage().toString();
//            sendErrorLog(subStationName, ipAddress, errorMsg);
//            association.close();
//            return false;
//        } catch (IOException e) {
//            System.out.println("Fatal IOException requesting model." + e.getMessage());
//            String errorMsg = "Fatal IOException requesting model." + e.getMessage().toString();
//            sendErrorLog(subStationName, ipAddress, errorMsg);
//            return false;
//        }
//
//        //ServerModelParser parser = new ServerModelParser(serverModel);
//        return true;
//    }
//
//    private Map<String, Object> getChildrenData(ModelNode modelNode){
//        //logger.debug(modelNode.getName());
//        Map<String, Object> mapData = new HashMap<>();
//        if(modelNode.getChildren() == null){
//            try{
//                mapData = getBasicData(modelNode);
//            }catch (Exception e){
//                logger.error("数据解析出错!");
//                e.printStackTrace();
//            }
//            return mapData;
//        }
//        for (ModelNode modelNodeChild : modelNode.getChildren()) {
//            mapData.put(modelNodeChild.getName(), getChildrenData(modelNodeChild));
//        }
//        return mapData;
//    }
//
//    private Map<String, Object> getBasicData(ModelNode modelNode){
//        Map<String, Object> map = new HashMap<>();
//        BasicDataAttribute dataAttribute = (BasicDataAttribute)modelNode;
//        String dataReference = dataAttribute.getReference().toString();
//        map.put("basicType", dataAttribute.getBasicType().toString());
//        map.put("dchg", dataAttribute.getDchg());
//        map.put("qchg", dataAttribute.getQchg());
//        map.put("dupd", dataAttribute.getDupd());
//        //logger.debug((dataAttribute).toString());
////        if((dataReference.length() + 2) == dataAttribute.toString().length()){
////            map.put("value", null);
////            return map;
////        }
//        switch (dataAttribute.getBasicType()) {
//            case BOOLEAN:
//                map.put("value", ((BdaBoolean)dataAttribute).getValue());
//                break;
//            case ENTRY_TIME:
//                map.put("value", SimpleUtils.DataTimeParse(((BdaEntryTime)dataAttribute).getValueString()));
//                break;
//            case FLOAT32:
//                map.put("value", ((BdaFloat32)dataAttribute).getFloat().toString());
//                break;
//            case FLOAT64:
//                map.put("value", ((BdaFloat64)dataAttribute).getDouble().toString());
//                break;
//            case INT16:
//                map.put("value", ((BdaInt16)dataAttribute).getValue());
//                break;
//            case INT16U:
//                map.put("value", ((BdaInt16U)dataAttribute).getValue());
//                break;
//            case INT32:
//                map.put("value", ((BdaInt32)dataAttribute).getValue());
//                break;
//            case INT32U:
//                map.put("value", ((BdaInt32U)dataAttribute).getValue());
//                break;
//            case INT64:
//                map.put("value", ((BdaInt64)dataAttribute).getValue());
//                break;
//            case INT8:
//                map.put("value", ((BdaInt8)dataAttribute).getValue());
//                break;
//            case INT8U:
//                map.put("value", ((BdaInt8U)dataAttribute).getValue());
//                break;
//            case OCTET_STRING:
//                map.put("maxLength", ((BdaOctetString)dataAttribute).getMaxLength());
//                map.put("value", new String(((BdaOctetString)dataAttribute).getValue()));
//                break;
//            case TIMESTAMP:
//                map.put("value", SimpleUtils.DataTimeParse(((BdaTimestamp)dataAttribute).getValueString()));
//                break;
//            case UNICODE_STRING:
//                //logger.debug(((BdaUnicodeString)dataAttribute).toString());
//                //logger.debug(new String(((BdaUnicodeString)dataAttribute).getValue()));
//                map.put("maxLength", ((BdaUnicodeString)dataAttribute).getMaxLength());
//                map.put("value", new String(((BdaUnicodeString)dataAttribute).getValue()));
//                break;
//            case VISIBLE_STRING:
//                map.put("maxLength", ((BdaVisibleString)dataAttribute).getMaxLength());
//                        map.put("value", new String(((BdaVisibleString)dataAttribute).getValue()));
//                break;
//            case CHECK:
//                map.put("maxNumBits", ((BdaCheck)dataAttribute).getMaxNumBits());
//                map.put("value", ((BdaCheck)dataAttribute).getValueString());
//                break;
//            case DOUBLE_BIT_POS:
//                map.put("maxNumBits", ((BdaOptFlds)dataAttribute).getMaxNumBits());
//                map.put("value", ((BdaDoubleBitPos)dataAttribute).getDoubleBitPos().toString());
//                break;
//            case OPTFLDS:
//                map.put("maxNumBits", ((BdaOptFlds)dataAttribute).getMaxNumBits());
//                map.put("value", ((BdaOptFlds)dataAttribute).getValueString());
//                break;
//            case QUALITY:
//                //logger.debug(((BdaQuality)dataAttribute).toString());
//                //logger.debug(((BdaQuality)dataAttribute).getValue().toString());
//                //logger.debug(((BdaQuality)dataAttribute).getValidity().toString());
//                //logger.debug(((BdaQuality)dataAttribute).getValidity().getIntValue() + "");
//                map.put("maxNumBits", ((BdaQuality)dataAttribute).getMaxNumBits());
//                if((dataReference.length() + 2) == dataAttribute.toString().length()) {
//                    map.put("value", BdaQuality.Validity.GOOD);
//                    break;
//                }
//                map.put("value", ((BdaQuality)dataAttribute).getValidity().toString());
//                break;
//            case REASON_FOR_INCLUSION:
//                map.put("maxNumBits", ((BdaReasonForInclusion)dataAttribute).getMaxNumBits());
//                map.put("value", ((BdaReasonForInclusion)dataAttribute).getValueString());
//                break;
//            case TAP_COMMAND:
//                map.put("maxNumBits", ((BdaTapCommand)dataAttribute).getMaxNumBits());
//                map.put("value", ((BdaTapCommand)dataAttribute).getTapCommand().toString());
//                break;
//            case TRIGGER_CONDITIONS:
//                map.put("maxNumBits", ((BdaTriggerConditions)dataAttribute).getMaxNumBits());
//                map.put("value", ((BdaTriggerConditions)dataAttribute).getValueString());
//                break;
//            default:
//                logger.debug("BasicType " + dataAttribute.getBasicType() + " unknown");
//                //map.put("value", ((BdaEntryTime)dataAttribute).getValue());
//                //throw new IllegalArgumentException("BasicType " + dataAttribute.getBasicType() + " unknown");
//        }
//        return map;
//    }
//
//    private boolean sendDataToMQ(String data){
//        if (ConfigUtil.isDebug) {
//            logger.debug("发送数据:" + data);
//        }
//        if(producer == null){
//            if(!ConfigUtil.isDebug) {
//                //logger.error("消息队列初始化未完成");
//            }
//            return false;
//        }
//        try {
//            producer.sendMessage(data);
//        } catch (IOException e) {
//            e.printStackTrace();
//            return false;
//        }
//        return true;
//    }
//
//    private boolean sendDataToIII(String data){
//        // 检查/唤醒连接
//        client.conn();
//        try {
//            System.out.println("try socket client send");
//            client.sendData(data);
//        } catch (Exception e) {
//            e.printStackTrace();
//            return false;
//        }
//        return true;
//    }
//
//    private boolean sendErrorLog(String substationName, String ipAddress, String data){
//        Map<String, Object> errorMsgMap = new HashMap<>();
//        if(ipAddress == null || ipAddress.length() < 7){
//            return false;
//        }
//        errorMsgMap.put("type", "ERR_MSG");
//        errorMsgMap.put("name", substationName);
//        errorMsgMap.put("ip", ipAddress);
//        errorMsgMap.put("data", data);
//        errorMsgMap.put("datetime", SimpleUtils.CurrentDateTime());
//        sendDataToMQ(JSON.toJSONString(errorMsgMap));
//        return true;
//    }
//
//    private boolean sendFileDate(String ip, String fileName, String fileData) {
//        //logger.debug(fileName);
//        Map<String, Object> mapData = new HashMap<>();
//        mapData.put("type", "WF");//type目前有GC、ZT、ZH,增加一个WF标记为谱图
//        Map<String, Object> mapSubData = new HashMap<>();
//        Map<String, Object> mapSubSubData = new HashMap<>();
//        mapSubSubData.put("fileName", FileOption.trimPath(fileName));
//        mapSubData.put("ID", mapSubSubData);
//        mapSubData.put("FD", fileData);
//        //mapData.put(ip + "$" + "BSCYB01HNZF2_ZT2202/PTRSIML1" + "." + "WaveFileNum", mapSubData);
//        mapData.put(ip + "$" + "WaveFileNum", mapSubData);
//        String data = JSON.toJSONString(mapData);
//        //logger.debug(jsonObject.toString());
//        return sendDataToMQ(data);
//    }
//
//    /**
//     * 读取文件进行压缩并编码
//     * @param filePath
//     * @param fileName
//     * @return
//     */
//    private String getFileCompressBase64(String filePath, String fileName) {
//        byte[] fileBytes = FileOption.readFileByByte(filePath, fileName);
//        //logger.debug("二进制长度 = " + fileBytes.length);
//        //压缩
//        //logger.debug("压缩前时间:" + System.currentTimeMillis());
//        byte[] compressBytes = GZIPUtils.compress(fileBytes);
//        //logger.debug("压缩后时间:" + System.currentTimeMillis());
//        //logger.debug("二进制压缩后长度 = " + compressBytes.length);
//        //编码
//        final BASE64Encoder encoder = new BASE64Encoder();
//        //logger.debug("编码前时间:" + System.currentTimeMillis());
//        final String encodedStr = encoder.encode(compressBytes);
//        //logger.debug("编码后时间:" + System.currentTimeMillis());
//        //logger.debug("编码后字符串长度 = " + encodedStr.length());
//        return encodedStr;
//    }
//
//    protected void collectStart() {
//        threads = new Thread[tableModel.getRowCount()];
//        timers = new Timer[tableModel.getRowCount()];
//        logger.debug("初始化 " + tableModel.getRowCount() + " 个站点!");
//        for(int i = 0; i < tableModel.getRowCount(); i++){
////            if(i != 0){
////                continue;
////            }
//            final String name = tableModel.getValueAt(i,0).toString();
//            final String ip = tableModel.getValueAt(i,1).toString();
//            final int port = Integer.valueOf(tableModel.getValueAt(i,2).toString());
//            final int threadIndex = i;
//            threads[i] = new Thread(new Runnable() {
//                @Override
//                public void run() {
//                    timers[threadIndex] = new Timer();
//
//                    TimerTask timerTask = new TimerTask() {
//                        @Override
//                        public void run() {
//                            logger.debug("定时任务【" + (threadIndex + 1) + " - " + name + "】 开始连接至变电站 => " + ip + ":" + port
//                                    + " [" + SimpleUtils.CurrentDateTime() + "]");
//                            collectToSubstation(ip, port, threadIndex);
//                        }
//                    };
//                    timers[threadIndex].schedule(timerTask, threadIndex * SubstaionIntervalTimes, CollectIntervalTimes);
//                }
//            });
//            threads[i].start();
//        }
//    }
//
//    protected void collectStop(){
//        for(int i = 0; i < timers.length; i++){
//            //logger.debug(threads[i].isAlive() + "");
//            timers[i].cancel();
//        }
//        logger.debug("停止 " + timers.length + " 个采集任务!");
//        labelTips("停止 " + timers.length + " 个采集任务!", "");
//    }
//
//    protected void dataLoad(){
//        tableModel.setDataVector(ConfigUtil.readSubstation(txtSubstationList.getText()), columnTitles);
//        //logger.debug("-- 站点列表加载完成 --");
//        labelTips("站点列表加载完成^_^!", "");
//    }
//
//    private void labelTips(String msg, String msgType){
//        msg = msg + "[" + SimpleUtils.CurrentDateTime() + "]";
//        switch (msgType){
//            case "error":
//                labelTips.setText(msg);
//                labelTips.setForeground(Color.RED);
//                break;
//            case "warning":
//                labelTips.setText(msg);
//                labelTips.setForeground(Color.PINK);
//                break;
//            default:
//                labelTips.setText(msg);
//                labelTips.setForeground(Color.BLACK);
//        }
//    }
//
//    public void checkNet(String substationName, String ipAddress, int port){
//        Map<String, Object> networkMsg = new HashMap<>();
//        boolean pingResult = NetworkUtils.pingByLinuxCmd(ipAddress, 5 * 1000);
//        boolean telnetResult = NetworkUtils.telnet(ipAddress, port, 5 * 1000);
//        networkMsg.put("type", "NET");
//        networkMsg.put("name", substationName);
//        networkMsg.put("ip", ipAddress);
//        networkMsg.put("port", 102);
//        networkMsg.put("ping", pingResult);
//        networkMsg.put("telnet", telnetResult);
//        networkMsg.put("datetime", SimpleUtils.CurrentDateTime());
//        sendDataToMQ(JSON.toJSONString(networkMsg));
//    }
//
//    public void startNetworkReview(){
//        networkReviewTimer = new Timer();
//        networkReviewTimer.schedule(new TimerTask() {
//            @Override
//            public void run() {
//                logger.debug("开始检测网络...");
//                String ipListFileStr = FileOption.readFileByString("myconfig/ip_list.txt", "UTF-8");
//                String newIpListFileStr = "";
//                String[] ipList = ipListFileStr.split("\n");
//                for (String ip: ipList) {
//                    logger.debug(ip);
//                    Map<String, Object> networkMsg = new HashMap<>();
//                    if(ip == null || ip.length() < 7){
//                        continue;
//                    }
//                    String[]  ipInfo = ip.split("-");
//                    if(ipInfo[1] == null){
//                        continue;
//                    }
//                    boolean pingResult = NetworkUtils.pingByLinuxCmd(ipInfo[1], 5 * 1000);
//                    boolean telnetResult = NetworkUtils.telnet(ipInfo[1], 102, 5 * 1000);
//                    //newIpListFileStr += ipInfo[0] + "-" + ipInfo[1] + "-" + pingResult + "-" + telnetResult + "-" + SimpleUtils.CurrentDateTime() + "\n";
//                    newIpListFileStr += ipInfo[1] + "-" + pingResult + "-" + telnetResult + "-" + SimpleUtils.CurrentDateTime() + "\n";
//                    networkMsg.put("type", "NET");
//                    networkMsg.put("name", ipInfo[0]);
//                    networkMsg.put("ip", ipInfo[1]);
//                    networkMsg.put("port", 102);
//                    networkMsg.put("ping", pingResult);
//                    networkMsg.put("telnet", telnetResult);
//                    networkMsg.put("datetime", SimpleUtils.CurrentDateTime());
//                    sendDataToMQ(JSON.toJSONString(networkMsg));
//                    logger.debug(JSON.toJSONString(networkMsg));
//                    FileOption.writeFile(newIpListFileStr, "myconfig", "ip_list_result.txt");
//                }
//                //FileOption.writeFile(newIpListFileStr, "myconfig", "ip_list_result.txt");
//                logger.debug("检测完成!");
//            }
//        }, 1000, 10 * 60 * 1000);
//    }
//
//    public static void main(String[] args) {
//
//        logger.debug("System starting...");
//        MyClient clientGui = new MyClient();
//        clientGui.ClientMain();
//    }
//}