1
zhanghua
2024-09-26 c775c6953d9759e70f08acbfa8f6d7490aaae3d1
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
package com.netsdk.demo.customize;
 
import com.netsdk.demo.util.CaseMenu;
import com.netsdk.lib.NetSDKLib;
import com.netsdk.lib.ToolKits;
import com.netsdk.lib.enumeration.NET_EM_CFG_OPERATE_TYPE;
import com.netsdk.lib.structure.*;
import com.netsdk.lib.utils.Initialization;
import com.sun.jna.Memory;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Scanner;
import static com.netsdk.lib.NetSDKLib.*;
import static com.netsdk.lib.NetSDKLib.NET_DIAGNOSIS_VIDEO_LOSS_FRAME_DETECTION;
 
/**
 * @author 291189
 * @version 1.0
 * @description ERR220913031 
 * @date 2022/9/15 14:27
 */
public class StartVideoDiagnosisDemo extends Initialization {
 
    Scanner scanner=new Scanner(System.in);
 
    //视频诊断参数表
    public void VideoDiagnosisProfileConfig() {
        String strCmd = NetSDKLib.CFG_CMD_VIDEODIAGNOSIS_PROFILE; // 视频诊断参数表命令
        int nChn = 0;     // 通道号
 
        NetSDKLib.CFG_VIDEODIAGNOSIS_PROFILE   profiles=new     NetSDKLib.CFG_VIDEODIAGNOSIS_PROFILE();
        profiles.nTotalProfileNum=10;
 
 
 
        NetSDKLib.CFG_VIDEO_DIAGNOSIS_PROFILE[]    profileArr=new NetSDKLib.CFG_VIDEO_DIAGNOSIS_PROFILE[profiles.nTotalProfileNum];
 
        for(int i=0;i<profileArr.length;i++){
            profileArr[i]=new NetSDKLib.CFG_VIDEO_DIAGNOSIS_PROFILE();
 
            NetSDKLib.CFG_VIDEO_DITHER_DETECTION cfg_pstDither = new NetSDKLib.CFG_VIDEO_DITHER_DETECTION();
 
            profileArr[i].pstDither=new Memory(cfg_pstDither.size());
 
            profileArr[i].pstDither.clear(cfg_pstDither.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstDither, profileArr[i].pstDither,0);
 
 
            NetSDKLib.CFG_VIDEO_STRIATION_DETECTION cfg_pstStriation   =new NetSDKLib.CFG_VIDEO_STRIATION_DETECTION();
 
            profileArr[i].pstStriation=new Memory(cfg_pstStriation.size());
 
            profileArr[i].pstStriation.clear(cfg_pstStriation.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstStriation, profileArr[i].pstStriation,0);
 
            NetSDKLib.CFG_VIDEO_LOSS_DETECTION cfg_pstLoss   =new NetSDKLib.CFG_VIDEO_LOSS_DETECTION();
 
            profileArr[i].pstLoss=new Memory(cfg_pstLoss.size());
 
            profileArr[i].pstLoss.clear(cfg_pstLoss.size());
 
 
            ToolKits.SetStructDataToPointer(cfg_pstLoss, profileArr[i].pstLoss,0);
 
 
            NetSDKLib.CFG_VIDEO_COVER_DETECTION cfg_pstCover   =new NetSDKLib.CFG_VIDEO_COVER_DETECTION();
 
            profileArr[i].pstCover=new Memory(cfg_pstCover.size());
 
            profileArr[i].pstCover.clear(cfg_pstCover.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstCover, profileArr[i].pstCover,0);
 
 
            NetSDKLib.CFG_VIDEO_FROZEN_DETECTION cfg_pstFrozen   =new NetSDKLib.CFG_VIDEO_FROZEN_DETECTION();
 
            profileArr[i].pstFrozen=new Memory(cfg_pstFrozen.size());
 
            profileArr[i].pstFrozen.clear(cfg_pstFrozen.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstFrozen, profileArr[i].pstFrozen,0);
 
 
            NetSDKLib.CFG_VIDEO_BRIGHTNESS_DETECTION cfg_pstBrightness   =new NetSDKLib.CFG_VIDEO_BRIGHTNESS_DETECTION();
 
            profileArr[i].pstBrightness=new Memory(cfg_pstBrightness.size());
 
            profileArr[i].pstBrightness.clear(cfg_pstBrightness.size());
 
 
            ToolKits.SetStructDataToPointer(cfg_pstBrightness, profileArr[i].pstBrightness,0);
 
 
            NetSDKLib.CFG_VIDEO_CONTRAST_DETECTION cfg_pstContrast   =new NetSDKLib.CFG_VIDEO_CONTRAST_DETECTION();
 
            profileArr[i].pstContrast=new Memory(cfg_pstContrast.size());
 
            profileArr[i].pstContrast.clear(cfg_pstContrast.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstContrast, profileArr[i].pstContrast,0);
 
 
            NetSDKLib.CFG_VIDEO_UNBALANCE_DETECTION cfg_pstUnbalance  =new NetSDKLib.CFG_VIDEO_UNBALANCE_DETECTION();
 
            profileArr[i].pstUnbalance=new Memory(cfg_pstUnbalance.size());
 
            profileArr[i].pstUnbalance.clear(cfg_pstUnbalance.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstUnbalance, profileArr[i].pstUnbalance,0);
 
 
 
            NetSDKLib.CFG_VIDEO_NOISE_DETECTION cfg_pstNoise  =new NetSDKLib.CFG_VIDEO_NOISE_DETECTION();
 
            profileArr[i].pstNoise=new Memory(cfg_pstNoise.size());
 
            profileArr[i].pstNoise.clear(cfg_pstNoise.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstNoise, profileArr[i].pstNoise,0);
 
 
            NetSDKLib.CFG_VIDEO_BLUR_DETECTION cfg_pstBlur =new NetSDKLib.CFG_VIDEO_BLUR_DETECTION();
 
            profileArr[i].pstBlur=new Memory(cfg_pstBlur.size());
 
            profileArr[i].pstBlur.clear(cfg_pstBlur.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstBlur, profileArr[i].pstBlur,0);
 
 
 
            NetSDKLib.CFG_VIDEO_SCENECHANGE_DETECTION cfg_pstSceneChange=new NetSDKLib.CFG_VIDEO_SCENECHANGE_DETECTION();
 
            profileArr[i].pstSceneChange=new Memory(cfg_pstSceneChange.size());
 
            profileArr[i].pstSceneChange.clear(cfg_pstSceneChange.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstSceneChange, profileArr[i].pstSceneChange,0);
 
 
 
            NetSDKLib.CFG_VIDEO_DELAY_DETECTION cfg_pstVideoDelay=new NetSDKLib.CFG_VIDEO_DELAY_DETECTION();
 
            profileArr[i].pstVideoDelay=new Memory(cfg_pstVideoDelay.size());
 
            profileArr[i].pstVideoDelay.clear(cfg_pstVideoDelay.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstVideoDelay, profileArr[i].pstVideoDelay,0);
 
 
 
            NetSDKLib.CFG_PTZ_MOVING_DETECTION cfg_pstPTZMoving=new NetSDKLib.CFG_PTZ_MOVING_DETECTION();
 
            profileArr[i].pstPTZMoving=new Memory(cfg_pstPTZMoving.size());
 
            profileArr[i].pstPTZMoving.clear(cfg_pstPTZMoving.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstPTZMoving, profileArr[i].pstPTZMoving,0);
 
 
            NetSDKLib.CFG_VIDEO_BLACKWHITE_DETECTION cfg_pstBlackAndWhite=new NetSDKLib.CFG_VIDEO_BLACKWHITE_DETECTION();
 
            profileArr[i].pstBlackAndWhite=new Memory(cfg_pstBlackAndWhite.size());
 
            profileArr[i].pstBlackAndWhite.clear(cfg_pstBlackAndWhite.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstBlackAndWhite, profileArr[i].pstBlackAndWhite,0);
 
 
            NetSDKLib.CFG_VIDEO_DRAMATICCHANGE_DETECTION cfg_pstDramaticChange=new NetSDKLib.CFG_VIDEO_DRAMATICCHANGE_DETECTION();
 
            profileArr[i].pstDramaticChange=new Memory(cfg_pstDramaticChange.size());
 
            profileArr[i].pstDramaticChange.clear(cfg_pstDramaticChange.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstDramaticChange, profileArr[i].pstDramaticChange,0);
 
 
            CFG_VIDEO_AVAILABILITY_DETECTION cfg_pstVideoAvailability=new CFG_VIDEO_AVAILABILITY_DETECTION();
 
            profileArr[i].pstVideoAvailability=new Memory(cfg_pstVideoAvailability.size());
 
            profileArr[i].pstVideoAvailability.clear(cfg_pstVideoAvailability.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstVideoAvailability, profileArr[i].pstVideoAvailability,0);
 
 
            CFG_VIDEO_SNOWFLAKE_DETECTION cfg_pstSnowflake=new CFG_VIDEO_SNOWFLAKE_DETECTION();
 
            profileArr[i].pstSnowflake=new Memory(cfg_pstSnowflake.size());
 
            profileArr[i].pstSnowflake.clear(cfg_pstSnowflake.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstSnowflake, profileArr[i].pstSnowflake,0);
 
 
            CFG_VIDEO_ALGORITHMTYPE_DETECTION cfg_pstVideoAlgorithmType=new CFG_VIDEO_ALGORITHMTYPE_DETECTION();
 
            profileArr[i].pstVideoAlgorithmType=new Memory(cfg_pstVideoAlgorithmType.size());
 
            profileArr[i].pstVideoAlgorithmType.clear(cfg_pstVideoAlgorithmType.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstVideoAlgorithmType, profileArr[i].pstVideoAlgorithmType,0);
 
 
            CFG_VIDEO_FILCKERING_DETECTION cfg_pstuVideoFilckeringDetection=new CFG_VIDEO_FILCKERING_DETECTION();
 
            profileArr[i].pstuVideoFilckeringDetection=new Memory(cfg_pstuVideoFilckeringDetection.size());
 
            profileArr[i].pstuVideoFilckeringDetection.clear(cfg_pstuVideoFilckeringDetection.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstuVideoFilckeringDetection, profileArr[i].pstuVideoFilckeringDetection,0);
 
 
            CFG_VIDEO_LOSS_FRAME_DETECTION cfg_pstuVideoLossFrameDetection=new CFG_VIDEO_LOSS_FRAME_DETECTION();
 
            profileArr[i].pstuVideoLossFrameDetection=new Memory(cfg_pstuVideoLossFrameDetection.size());
 
            profileArr[i].pstuVideoLossFrameDetection.clear(cfg_pstuVideoLossFrameDetection.size());
 
            ToolKits.SetStructDataToPointer(cfg_pstuVideoLossFrameDetection, profileArr[i].pstuVideoLossFrameDetection,0);
        }
 
        NetSDKLib.CFG_VIDEO_DIAGNOSIS_PROFILE    profile=new NetSDKLib.CFG_VIDEO_DIAGNOSIS_PROFILE();
        profiles.pstProfiles=new Memory(profile.size()*profiles.nTotalProfileNum);
        profiles.pstProfiles.clear(profile.size()*profiles.nTotalProfileNum);
 
        ToolKits.SetStructArrToPointerData(profileArr,profiles.pstProfiles);
 
 
        boolean b
                = ToolKits.GetDevConfig(loginHandle, nChn, strCmd, profiles);
 
        if(b){
            int nReturnProfileNum = profiles.nReturnProfileNum;
 
            printlns("nReturnProfileNum:"+nReturnProfileNum);
 
            Pointer pstProfiles = profiles.pstProfiles;
 
        ToolKits.GetPointerDataToStructArr(pstProfiles,profileArr);
 
 
                NetSDKLib.CFG_VIDEO_DIAGNOSIS_PROFILE cfg_profile = profileArr[0];
                try {
 
                    printlns("szName:"+new String(cfg_profile.szName,encode));
 
 
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
                NetSDKLib.CFG_VIDEO_DITHER_DETECTION  dither=new NetSDKLib.CFG_VIDEO_DITHER_DETECTION();
 
                Pointer pstDither = cfg_profile.pstDither;
 
                ToolKits.GetPointerData(pstDither,dither);
                printlns("dither.bEnable:"+dither.bEnable);
                printlns("dither.nMinDuration:"+dither.nMinDuration);
                printlns("dither.byThrehold1:"+dither.byThrehold1);
                printlns("dither.byThrehold2:"+dither.byThrehold2);
 
                NetSDKLib.CFG_VIDEO_STRIATION_DETECTION  striation=new NetSDKLib.CFG_VIDEO_STRIATION_DETECTION();
 
                Pointer pstStriation = cfg_profile.pstStriation;
 
                ToolKits.GetPointerData(pstStriation,striation);
 
                printlns("striation.bEnable:"+striation.bEnable);
                printlns("striation.nMinDuration:"+striation.nMinDuration);
                printlns("striation.byThrehold1:"+striation.byThrehold1);
                printlns("striation.byThrehold2:"+striation.byThrehold2);
                printlns("striation.bUVDetection:"+striation.bUVDetection);
 
 
                ToolKits.ByteArrZero(cfg_profile.szName);//byte[]清空
 
                String name="test001";
 
                ToolKits.StringToByteArray(name,cfg_profile.szName);
 
                dither.nMinDuration=10;
 
                ToolKits.SetStructDataToPointer(dither,pstDither,0);
 
 
                ToolKits.SetStructDataToPointer(striation,pstStriation,0);
 
 
                ToolKits.SetStructArrToPointerData(profileArr,profiles.pstProfiles);
 
                if(ToolKits.SetDevConfig(loginHandle, nChn, strCmd, profiles)) {
 
                    System.out.println("设置视频诊断参数成功!");
                } else {
                    System.err.println("设置视频诊断参数失败, " + ToolKits.getErrorCode());
                }
 
            }
 
 
    }
 
 
    /**
     * 获取任务名称
     */
    ArrayList<String> nameList = new ArrayList<String>();
    public void GetMemberNames(String command) {
 
        nameList.clear();
 
        int nNameCount = 10;  // 任务名称个数
 
        NetSDKLib.NET_ARRAY[] arrays = new NetSDKLib.NET_ARRAY[nNameCount];
        for(int i = 0; i < nNameCount; i++) {
            arrays[i] = new NetSDKLib.NET_ARRAY();
            arrays[i].pArray = new Memory(260);   //  缓冲区 目前最小260字节, 需要用户自己申请
            arrays[i].pArray.clear(260);
            arrays[i].dwArrayLen = 260;
        }
 
        /*
         * 入参
         */
        NetSDKLib.NET_IN_MEMBERNAME stIn  = new NetSDKLib.NET_IN_MEMBERNAME();
        stIn.szCommand = command/*NetSDKLib.CFG_CMD_VIDEODIAGNOSIS_TASK*/;   // 配置命令, 获取任务的成员名称
 
        /*
         * 出参
         */
        NetSDKLib.NET_OUT_MEMBERNAME stOut = new NetSDKLib.NET_OUT_MEMBERNAME();
        stOut.nTotalNameCount = nNameCount;
        stOut.pstNames = new Memory(arrays[0].size() * nNameCount);
        stOut.pstNames.clear(arrays[0].size() * nNameCount);
 
        ToolKits.SetStructArrToPointerData(arrays, stOut.pstNames);
 
        if(netSdk.CLIENT_GetMemberNames(loginHandle, stIn, stOut, 3000)) {
            ToolKits.GetPointerDataToStructArr(stOut.pstNames, arrays);
            System.out.println("nRetNameCount:"+stOut.nRetNameCount);
            for(int i = 0; i < stOut.nRetNameCount; i++) {
                System.out.println("成员名称:" + ToolKits.GetPointerDataToGBKString(arrays[i].pArray, arrays[i].dwArrayLen));
                nameList.add(ToolKits.GetPointerDataToGBKString(arrays[i].pArray, arrays[i].dwArrayLen));
            }
        } else {
            System.err.println("获取配置成员名称失败, " + ToolKits.getErrorCode());
        }
    }
 
    /**
     * 视频诊断任务获取
     */
 
    public void VideoDiagnosisTaskGet() {
 
        // 单个获取
            for(int i=0;i<nameList.size();i++){
                VideoDiagnosisTaskGetSingle(nameList.get(i));
            }
 
    }
 
    // 获取所有计划名称,然后再获取每个计划的具体信息
    public void GetVideoDiagnosisTask() {
        // 获取所有任务名称,然后再获取每个任务的具体信息
        GetMemberNames(NetSDKLib.CFG_CMD_VIDEODIAGNOSIS_TASK);
 
    }
 
 
    /**
     * 根据任务名称,获取具体的信息
     */
    public void VideoDiagnosisTaskGetSingle(String taskName) {
        /////////////////////  获取单个任务的具体信息    //////////////////////////////////
        int nSourceNum = 128;        // 任务数据源的个数,用户自己定义
        int nChn = 0;  // 通道号
        String strCmd = "VideoDiagnosisTask." + taskName;
        printlns("strCmd:"+strCmd);
        // 任务数据源
        NetSDKLib.CFG_TAST_SOURCES[] sources = new NetSDKLib.CFG_TAST_SOURCES[nSourceNum];
        for(int i = 0; i < nSourceNum; i++) {
            sources[i] = new NetSDKLib.CFG_TAST_SOURCES();
        }
 
        // 任务
        NetSDKLib.CFG_DIAGNOSIS_TASK[] tasks = new NetSDKLib.CFG_DIAGNOSIS_TASK[1];
        tasks[0] = new NetSDKLib.CFG_DIAGNOSIS_TASK();
        tasks[0].nTotalSourceNum = nSourceNum;
        tasks[0].pstSources = new Memory(sources[0].size() * nSourceNum);
        tasks[0].pstSources.clear(sources[0].size() * nSourceNum);
 
        ToolKits.SetStructArrToPointerData(sources, tasks[0].pstSources);
 
        /*
         * 视频诊断任务表
         */
        NetSDKLib.CFG_VIDEODIAGNOSIS_TASK msg = new NetSDKLib.CFG_VIDEODIAGNOSIS_TASK();
        msg.nTotalTaskNum = 1;
        msg.pstTasks = new Memory(tasks[0].size());
        msg.pstTasks.clear(tasks[0].size());
 
        ToolKits.SetStructArrToPointerData(tasks, msg.pstTasks);
 
        /*
         *  获取
         */
        if(GetDevConfig(loginHandle, nChn, strCmd, msg)) {
            ToolKits.GetPointerDataToStructArr(msg.pstTasks, tasks);
            ToolKits.GetPointerDataToStructArr(tasks[0].pstSources, sources);
 
            // 输出打印
            printlns("任务名称:" + taskName);
            try {
                printlns("诊断参数表名:" + new String(tasks[0].szProfileName,encode).trim());
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
 
            for(int i = 0; i < tasks[0].nReturnSourceNum; i++) {
                printlns("持续诊断时间:" + sources[i].nDuration);
                printlns("视频通道号:" + sources[i].nVideoChannel);
                try {
                    printlns("设备地址:" + new String(sources[i].stRemoteDevice.szAddress,encode).trim());
                    printlns("视频流地址:" + new String(sources[i].szPath,encode).trim());
                    //szPath
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
 
            System.out.println();
 
        } else {
            System.err.println("获取任务失败, " + ToolKits.getErrorCode());
        }
    }
 
 
    /*
     * 获取,只适用  诊断任务的获取
     */
    public boolean GetDevConfig(NetSDKLib.LLong hLoginHandle, int nChn, String strCmd, NetSDKLib.SdkStructure cmdObject) {
        boolean result = false;
        IntByReference error = new IntByReference(0);
        int nBufferLen = 2*1024*1024;
        byte[] strBuffer = new byte[nBufferLen];
 
        if(netSdk.CLIENT_GetNewDevConfig(hLoginHandle, strCmd, nChn, strBuffer, nBufferLen,error,3000,null)) {
            cmdObject.write();
            if (config.CLIENT_ParseData(NetSDKLib.CFG_CMD_VIDEODIAGNOSIS_TASK_ONE, strBuffer, cmdObject.getPointer(),
                    cmdObject.size(), null)) {
                cmdObject.read();
                result = true;
            } else {
                System.err.println("Parse VideoDiagnosisTask.x, Config Failed!" + ToolKits.getErrorCode());
                result = false;
            }
        } else {
            System.err.println("Get" + strCmd + "Config Failed!" + ToolKits.getErrorCode());
            result = false;
        }
        return result;
    }
    /*
     * 设置,只适用  诊断任务的设置
     */
    public boolean SetDevConfig(NetSDKLib.LLong hLoginHandle, int nChn, String strCmd, NetSDKLib.SdkStructure cmdObject) {
        boolean result = false;
        int nBufferLen = 2*1024*1024;
        byte szBuffer[] = new byte[nBufferLen];
        for(int i=0; i<nBufferLen; i++)szBuffer[i]=0;
        IntByReference error = new IntByReference(0);
        IntByReference restart = new IntByReference(0);
 
        cmdObject.write();
        if (config.CLIENT_PacketData(NetSDKLib.CFG_CMD_VIDEODIAGNOSIS_TASK_ONE, cmdObject.getPointer(), cmdObject.size(),
                szBuffer, nBufferLen)) {
            cmdObject.read();
            if( netSdk.CLIENT_SetNewDevConfig(hLoginHandle, strCmd, nChn, szBuffer, nBufferLen, error, restart, 3000)) {
                result = true;
            } else {
                System.err.printf("Set %s Config Failed! Last Error = %x\n" , strCmd , ToolKits.getErrorCode());
                result = false;
            }
        } else {
            System.err.println("Packet VideoDiagnosisTask.x Config Failed!");
            result = false;
        }
        return result;
    }
 
    /**
     * 视频诊断任务设置
     */
    public void VideoDiagnosisTaskSet() {
        String[] address = {"172.23.12.248"};
        printlns("新增1,修改2");  //task名称相同更新 不同为新增
        int nextInt = scanner.nextInt();
        if(nextInt==1){
            String task = scanner.next();
            VideoDiagnosisTaskSetSingle(task, address, 30, "test001");
 
        }else if(nextInt==2){
            if(nameList.size()==0){
            }else {
                VideoDiagnosisTaskSetSingle(nameList.get(0), address, 60, "test001");
            }
        }
 
 
    }
    /**
     * 视频诊断任务单个设置
     * 设备登陆后,根据 deviceinfo.byChanNum  获取通道个数
     * 如果 172.25.242.120  这个设备有16个通道,则有16个数据源,通道从0~15
     * @param taskName  任务名称
     * @param address  数据源数组
     * @param nDuration  持续时间
     * @param profileName  配置参数表名
     */
    public void VideoDiagnosisTaskSetSingle(String taskName, String[] address, int nDuration, String profileName) {
        int nChn = 0;  // 通道号
        String strCmd = "VideoDiagnosisTask." + taskName;
 
        int nSourceNum = address.length;   // 数据源个数
 
        // 任务数据源
        NetSDKLib.CFG_TAST_SOURCES[] sources = new NetSDKLib.CFG_TAST_SOURCES[nSourceNum];
        for(int i = 0; i < nSourceNum; i++) {
            sources[i] = new NetSDKLib.CFG_TAST_SOURCES();
        }
 
        for(int i = 0; i < nSourceNum; i++) {
            sources[i].abRemoteDevice = 1;
            try {
                System.arraycopy(address[i].getBytes(encode), 0, sources[i].szDeviceID, 0, address[i].getBytes(encode).length);
                System.arraycopy(address[i].getBytes(encode), 0, sources[i].stRemoteDevice.szAddress, 0, address[i].getBytes(encode).length);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            byte[] szPath = sources[i].szPath;
            String path="rtsp://admin:admin123@172.23.12.248:554/cam/realmonitor?channel=1&subtype=0";
            ToolKits.ByteArrZero(szPath);
            try {
                System.arraycopy(path.getBytes(encode), 0, szPath, 0, path.getBytes(encode).length);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            sources[i].nVideoChannel = i;
            sources[i].nDuration = nDuration;
        }
 
        // 任务
        NetSDKLib.CFG_DIAGNOSIS_TASK[] tasks = new NetSDKLib.CFG_DIAGNOSIS_TASK[1];
        tasks[0] = new NetSDKLib.CFG_DIAGNOSIS_TASK();
        tasks[0].nTotalSourceNum = nSourceNum;
        tasks[0].pstSources = new Memory(sources[0].size() * nSourceNum);
        tasks[0].pstSources.clear(sources[0].size() * nSourceNum);
 
        // 设置诊断表名称
        try {
            System.arraycopy(profileName.getBytes(encode), 0, tasks[0].szProfileName, 0, profileName.getBytes(encode).length);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
 
        ToolKits.SetStructArrToPointerData(sources, tasks[0].pstSources);
 
        /*
         * 视频诊断任务表
         */
        NetSDKLib.CFG_VIDEODIAGNOSIS_TASK msg = new NetSDKLib.CFG_VIDEODIAGNOSIS_TASK();
        msg.nTotalTaskNum = 1;
        msg.pstTasks = new Memory(tasks[0].size());
        msg.pstTasks.clear(tasks[0].size());
 
        ToolKits.SetStructArrToPointerData(tasks, msg.pstTasks);
 
        if(SetDevConfig(loginHandle, nChn, strCmd, msg)) {
            System.out.println("设置诊断任务成功!");
        } else {
            System.err.println("设置诊断任务失败, " + ToolKits.getErrorCode());
        }
    }
   // 获取所有计划名称,然后再获取每个计划的具体信息
    public void GetVideoDiagnosisProject() {
        // 获取所有计划名称,然后再获取每个计划的具体信息
        GetMemberNames(NetSDKLib.CFG_CMD_VIDEODIAGNOSIS_PROJECT);
    }
 
    public void VideoDiagnosisProjectGet() {
 
        for(int i=0;i<nameList.size();i++){
            VideoDiagnosisProjectGetSingle(nameList.get(i));
        }
    }
 
    String[] dates = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
    public void VideoDiagnosisProjectGetSingle(String projectName) {
        int nChn = 0;
        int strCmd = NET_EM_CFG_OPERATE_TYPE.NET_EM_VIDEODIAGNOSIS_PROJECT;
 
        NET_VIDEODIAGNOSIS_PROJECT_INFO project =new NET_VIDEODIAGNOSIS_PROJECT_INFO();
        try {
            System.arraycopy(projectName.getBytes(encode), 0, project.szProjectName, 0, projectName.getBytes(encode).length);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        project.nTotalTaskNum  = 10;
        NET_PROJECT_TASK[] task = new NET_PROJECT_TASK[10];
        for (int i = 0; i < 10; i ++ ) {
            task[i] = new NET_PROJECT_TASK();
        }
        project.pstProjectTasks = new Memory(task[0].size()*10);
        ToolKits.SetStructArrToPointerData(task, project.pstProjectTasks);
        project.write();
 
        if(netSdk.CLIENT_GetConfig(loginHandle, strCmd, nChn, project.getPointer(), project.size(), 5000, null)) {
            System.out.println("获取计划成功!");
            project.read();
 
            for (int i = 0; i < project.nReturnTaskNum; i ++ ) {
                int offset = 0;
                ToolKits.GetPointerDataToStruct(project.pstProjectTasks, offset, task[i]);
                offset += task[i].size();
            }
 
 
            for(int i = 0; i < project.nReturnTaskNum; i++) {
                //System.out.println("计划名称:" + new String(project.szProjectName).trim());
                System.out.println("任务使能:" + task[i].bEnable);
                System.out.println("任务名称:" + new String(task[i].szTaskName).trim());
 
                // 时间第一维代表,周日~周六,第二维代表时间段,可以设置6个,目前的设置,只设置第一个有效
                for(int j = 0; j < 7; j++) {
                    System.out.println("日期:" + dates[j]);
                    System.out.println("时间:" + task[i].Section[j].stuTimeSection[0].startTime() + "-" +
                            task[i].Section[j].stuTimeSection[0].endTime());
                }
            }}else {
            System.err.println("获取计划失败, " + ToolKits.getErrorCode());
        }
    }
 
 
 
    /**
     * 视频诊断计划设置
     */
    public void VideoDiagnosisProjectSet() {
        PROJECT_INFO[] projectInfo = new PROJECT_INFO[1];
        printlns("输入task名称");
        String task
                = scanner.next();
        printlns("输入project名称");
        String projectName
                = scanner.next();
        projectInfo[0] = new PROJECT_INFO(projectName, task, "00:00:00", "23:59:59");
 
        // 诊断计划设置
        SetVideoDiagnosisProject(projectInfo);
    }
 
    public void SetVideoDiagnosisProject(PROJECT_INFO[] projectInfo) {
        int nChn = 0;
        int strCmd = NET_EM_CFG_OPERATE_TYPE.NET_EM_VIDEODIAGNOSIS_PROJECT;
        int nProjectNum = projectInfo.length;   // 计划个数,用户自己设置
 
        for(int i = 0; i < nProjectNum; i++) {
 
            NET_VIDEODIAGNOSIS_PROJECT_INFO project =new NET_VIDEODIAGNOSIS_PROJECT_INFO();
 
            try {
                System.arraycopy(projectInfo[i].projectName.getBytes(encode), 0, project.szProjectName, 0, projectInfo[i].projectName.getBytes(encode).length);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
 
            project.nTotalTaskNum=1;
 
            NET_PROJECT_TASK task = new NET_PROJECT_TASK();
            task.bEnable = 1;
            task.bIsCycle=1;
            task.bIsRepeat=1;
            task.nCycleInterval=10;
            project.pstProjectTasks = new Memory(task.size()*project.nTotalTaskNum);
 
            try {
                System.arraycopy(projectInfo[i].taskName.getBytes(encode), 0, task.szTaskName, 0, projectInfo[i].taskName.getBytes(encode).length);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
 
            for(int j = 0; j < 7; j++) {
                task.Section[j].stuTimeSection[0].bEnable = 1;
                task.Section[j].stuTimeSection[0].iBeginHour = projectInfo[i].startHour;
                task.Section[j].stuTimeSection[0].iBeginMin = projectInfo[i].startMinute;
                task.Section[j].stuTimeSection[0].iBeginSec = projectInfo[i].startSecond;
                task.Section[j].stuTimeSection[0].iEndHour = projectInfo[i].endHour;
                task.Section[j].stuTimeSection[0].iEndMin = projectInfo[i].endMinute;
                task.Section[j].stuTimeSection[0].iEndSec = projectInfo[i].endSecond;
            }
 
            ToolKits.SetStructDataToPointer(task, project.pstProjectTasks,0);
            project.write();
 
            if(netSdk.CLIENT_SetConfig(loginHandle, strCmd, nChn, project.getPointer(), project.size(), 5000, null, null)) {
                System.out.println("设置计划成功!");
            }else {
                System.err.println("设置计划失败, " + ToolKits.getErrorCode());
            }
 
        }
    }
 
    class PROJECT_INFO {
        // 计划名称
        String projectName;
 
        // 任务名称
        String taskName;
 
        // 开始/结束时间
        int startHour;
        int startMinute;
        int startSecond;
        int endHour;
        int endMinute;
        int endSecond;
 
        public PROJECT_INFO(String projectName, String taskName, String startTime, String endTime) {
            this.projectName = projectName;
            this.taskName = taskName;
            this.startHour = Integer.parseInt(startTime.split(":")[0]);
            this.startMinute = Integer.parseInt(startTime.split(":")[1]);
            this.startSecond = Integer.parseInt(startTime.split(":")[2]);
            this.endHour = Integer.parseInt(endTime.split(":")[0]);
            this.endMinute = Integer.parseInt(endTime.split(":")[1]);
            this.endSecond = Integer.parseInt(endTime.split(":")[2]);
        }
    }
 
 
    private static NetSDKLib.LLong m_lDiagnosisHandle = new NetSDKLib.LLong(0);
 
    /**
     * 视频诊断订阅,当诊断完成后,会收到事件,一个计划只收到一个事件
     */
    public void StartVideoDiagnosis() {
        /*
         * 入参
         */
        NetSDKLib.NET_IN_VIDEODIAGNOSIS stIn = new NetSDKLib.NET_IN_VIDEODIAGNOSIS();
        stIn.nDiagnosisID = -1;
        stIn.dwWaitTime = 5000;
        stIn.cbVideoDiagnosis = RealVideoDiagnosis.getInstance();
 
        /*
         * 出参
         */
        NetSDKLib.NET_OUT_VIDEODIAGNOSIS stOut = new NetSDKLib.NET_OUT_VIDEODIAGNOSIS();
 
        if(netSdk.CLIENT_StartVideoDiagnosis(loginHandle, stIn, stOut)) {
            m_lDiagnosisHandle = stOut.lDiagnosisHandle;
            System.out.println("视频诊断订阅成功!");
        } else {
            System.err.println("订阅失败, " + ToolKits.getErrorCode());
        }
    }
 
    // 取消订阅
    public void StopVideoDiagnosis() {
        if(m_lDiagnosisHandle.longValue() != 0) {
            if(netSdk.CLIENT_StopVideoDiagnosis(m_lDiagnosisHandle)) {
                System.out.println("取消视频诊断订阅!");
                m_lDiagnosisHandle.setValue(0);
            }
        }
    }
 
 
    private static class RealVideoDiagnosis implements NetSDKLib.fRealVideoDiagnosis {
        private RealVideoDiagnosis() {}
 
        private static class RealVideoDiagnosisHolder {
            private static RealVideoDiagnosis instance = new RealVideoDiagnosis();
        }
 
        private static RealVideoDiagnosis getInstance() {
            return RealVideoDiagnosis.RealVideoDiagnosisHolder.instance;
        }
 
        @Override
        public int invoke(NetSDKLib.LLong lDiagnosisHandle,
                          NetSDKLib.NET_REAL_DIAGNOSIS_RESULT pDiagnosisInfo, Pointer pBuf,
                          int nBufLen, Pointer dwUser) {
 
            NetSDKLib.NET_VIDEODIAGNOSIS_COMMON_INFO commons = new NetSDKLib.NET_VIDEODIAGNOSIS_COMMON_INFO();
 
            ToolKits.GetPointerData(pDiagnosisInfo.pstDiagnosisCommonInfo, commons);
 
            int dwBufSize = pDiagnosisInfo.dwBufSize;
 
            System.out.println("dwBufSize:"+dwBufSize);
 
            System.out.println("nTypeCount:"+pDiagnosisInfo.nTypeCount);
 
            Pointer pDiagnosisResult
                    = pDiagnosisInfo.pDiagnosisResult;
 
            int count=0;
 
            for(int i=0;i<pDiagnosisInfo.nTypeCount;i++){
 
                NetSDKLib.NET_DIAGNOSIS_RESULT_HEADER header=new NetSDKLib.NET_DIAGNOSIS_RESULT_HEADER();
 
                ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,header);
 
 
                byte[] szDiagnosisType
                        = header.szDiagnosisType;
                int nDiagnosisTypeLen
                        = header.nDiagnosisTypeLen;
 
                count+=header.dwSize;
 
                if(NET_DIAGNOSIS_DITHER.equals(new String(szDiagnosisType).trim())){
                    System.out.println(" 视频抖动检测:");
                    NetSDKLib.NET_VIDEO_DITHER_DETECTIONRESULT result=new NetSDKLib.NET_VIDEO_DITHER_DETECTIONRESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
 
                    count+=result.dwSize;
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
 
                }else if(NET_DIAGNOSIS_STRIATION.equals(new String(szDiagnosisType).trim())){
                    System.out.println(" 视频条纹检测:");
                    NetSDKLib.NET_VIDEO_STRIATION_DETECTIONRESULT result=new NetSDKLib.NET_VIDEO_STRIATION_DETECTIONRESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                    System.out.println(" szPicUrl:"+new String(result.szPicUrl) );
                }else if(NET_DIAGNOSIS_LOSS.equals(new String(szDiagnosisType).trim())){
 
                    System.out.println(" 视频丢失检测:");
                    NetSDKLib.NET_VIDEO_LOSS_DETECTIONRESULT result=new NetSDKLib.NET_VIDEO_LOSS_DETECTIONRESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
 
 
                    count+=result.dwSize;
 
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                    System.out.println(" szPicUrl:"+new String(result.szPicUrl) );
                }else if(NET_DIAGNOSIS_COVER.equals(new String(szDiagnosisType).trim())){
 
                    System.out.println(" 视频遮挡检测:");
 
                    NET_VIDEO_COVER_DETECTIONRESULT  result=new NET_VIDEO_COVER_DETECTIONRESULT();
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                }else if(NET_DIAGNOSIS_FROZEN.equals(new String(szDiagnosisType).trim())){
 
                    System.out.println(" 视频冻结检测:");
                    NET_VIDEO_FROZEN_DETECTIONRESULT  result=new NET_VIDEO_FROZEN_DETECTIONRESULT();
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
 
                    count+=result.dwSize;
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                }else if(NET_DIAGNOSIS_BRIGHTNESS.equals(new String(szDiagnosisType).trim())){
 
                    System.out.println(" 视频亮度异常检测:");
                    NET_VIDEO_BRIGHTNESS_DETECTIONRESULT     result=new NET_VIDEO_BRIGHTNESS_DETECTIONRESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                    System.out.println(" szPicUrl:"+new String(result.szPicUrl) );
 
                }else if(NET_DIAGNOSIS_CONTRAST.equals( new String(szDiagnosisType).trim())){
                    System.out.println(" 视频对比度异常检测:");
                    NET_VIDEO_CONTRAST_DETECTIONRESULT  result=new NET_VIDEO_CONTRAST_DETECTIONRESULT();
 
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                    System.out.println(" szPicUrl:"+new String(result.szPicUrl) );
                }else if(NET_DIAGNOSIS_UNBALANCE.equals(new String(szDiagnosisType).trim())){
                    System.out.println(" 视频偏色检测:");
                    NET_VIDEO_UNBALANCE_DETECTIONRESULT result=new NET_VIDEO_UNBALANCE_DETECTIONRESULT();
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                    System.out.println(" szPicUrl:"+new String(result.szPicUrl) );
                }else if(NET_DIAGNOSIS_NOISE.equals(new String(szDiagnosisType).trim())){
                    System.out.println(" 视频噪声检测:");
                    NET_VIDEO_NOISE_DETECTIONRESULT  result=new NET_VIDEO_NOISE_DETECTIONRESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                    System.out.println(" szPicUrl:"+new String(result.szPicUrl) );
 
 
                }else if(NET_DIAGNOSIS_BLUR.equals(new String(szDiagnosisType).trim()) ){
                    System.out.println(" 视频模糊检测:");
                    NET_VIDEO_BLUR_DETECTIONRESULT result=new NET_VIDEO_BLUR_DETECTIONRESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                    System.out.println(" szPicUrl:"+new String(result.szPicUrl) );
 
                }else if(NET_DIAGNOSIS_SCENECHANGE.equals(new String(szDiagnosisType).trim())){
                    System.out.println(" 视频场景变化检测:");
 
                    NET_VIDEO_SCENECHANGE_DETECTIONRESULT result=new NET_VIDEO_SCENECHANGE_DETECTIONRESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
                }else if(NET_DIAGNOSIS_VIDEO_DELAY.equals(new String(szDiagnosisType).trim())){
                    System.out.println(" 视频延时检测:");
                    NET_VIDEO_DELAY_DETECTIONRESUL result=new NET_VIDEO_DELAY_DETECTIONRESUL();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
 
                    count+=result.dwSize;
                    System.out.println(" nSignalDelay:"+result.nSignalDelay);
                    System.out.println(" nStreamDelay:"+result.nStreamDelay);
                    System.out.println(" nIFrameDelay:"+result.nIFrameDelay);
 
 
                }else if(NET_DIAGNOSIS_PTZ_MOVING.equals( new String(szDiagnosisType).trim() )){
                    System.out.println(" 云台移动检测:");
 
                    NET_PTZ_MOVING_DETECTIONRESULT result=new NET_PTZ_MOVING_DETECTIONRESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
 
                    System.out.println(" emPTZMovingUp:"+result.emPTZMovingUp);
                    System.out.println(" emPTZMovingDown:"+result.emPTZMovingDown);
                    System.out.println(" emPTZMovingLeft:"+result.emPTZMovingLeft);
                    System.out.println(" emPTZMovingRight:"+result.emPTZMovingRight);
                    System.out.println(" emPTZMovingZoomWide:"+result.emPTZMovingZoomWide);
                    System.out.println(" emPTZMovingZoomTele:"+result.emPTZMovingZoomTele);
 
                }else if(NET_DIAGNOSIS_BLACK_WHITE.equals(new String(szDiagnosisType).trim())){
                    System.out.println(" 黑白图像检测:");
                    NET_BLACK_WHITE_DETECTIONRESULT result=new NET_BLACK_WHITE_DETECTIONRESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
 
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
 
                    System.out.println(" szPicUrl:"+ new String(result.szPicUrl) );
 
 
                }else if(NET_DIAGNOSIS_DRAMATIC_CHANGE.equals( new String(szDiagnosisType).trim() )){
                    System.out.println(" 场景剧变检测:");
                    NET_DIAGNOSIS_DRAMATIC_DETECTIONRESULT result=new NET_DIAGNOSIS_DRAMATIC_DETECTIONRESULT();
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
 
 
                }else if(NET_DIAGNOSIS_VIDEO_AVAILABILITY.equals(new String(szDiagnosisType).trim())){
                    System.out.println(" 视频完好率监测:");
 
                    NET_VIDEO_AVAILABILITY_DETECTIONRESULT   result=new NET_VIDEO_AVAILABILITY_DETECTIONRESULT();
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
 
                    System.out.println(" nSignalDelay:"+result.nSignalDelay);
                    System.out.println(" nStreamDelay:"+result.nStreamDelay);
                    System.out.println(" nIFrameDelay:"+result.nIFrameDelay);
 
                } else if(NET_DIAGNOSIS_SNOWFLAKE.equals(new String(szDiagnosisType).trim())){
                    System.out.println(" 雪花屏检测:");
                    NET_VIDEO_SNOWFLAKE_DETECTIONRESULT result=new NET_VIDEO_SNOWFLAKE_DETECTIONRESULT();
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
 
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
 
                    System.out.println(" szPicUrl:"+new String(result.szPicUrl));
                }else if(NET_DIAGNOSIS_VIDEO_ALGORITHMTYPE.equals( new String(szDiagnosisType).trim() )){
                    System.out.println(" 视频算法类型检测:");
                    NET_VIDEO_ALGORITHMTYPE_DETECTIONRESULT result=new NET_VIDEO_ALGORITHMTYPE_DETECTIONRESULT();
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
                    count+=result.dwSize;
                    System.out.println(" bFaceAlgorithm:"+result.bFaceAlgorithm);
                    System.out.println(" nFaceAlgorithmValue:"+result.nFaceAlgorithmValue);
                    System.out.println(" bHumanBodyAlgorithm:"+result.bHumanBodyAlgorithm);
 
                    System.out.println(" nHumanBodyAlgorithmValue:"+result.nHumanBodyAlgorithmValue);
                    System.out.println(" bVehicleAlgorithm:"+result.bVehicleAlgorithm);
 
                    System.out.println(" nVehicleAlgorithmValue:"+result.nVehicleAlgorithmValue);
 
                    System.out.println(" bPlateNumAlgorithm:"+result.bPlateNumAlgorithm);
 
                    System.out.println(" nPlateNumAlgorithmValue:"+result.nPlateNumAlgorithmValue);
 
                }else if(NET_DIAGNOSIS_VIDEO_FILCKERING_DETECTION.equals( new String(szDiagnosisType).trim() )){
                    System.out.println(" 视频闪频检测:");
                    NET_VIDEO_FILCKERING_DETECTION_RESULT result=new NET_VIDEO_FILCKERING_DETECTION_RESULT();
 
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
 
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
 
                } else if(NET_DIAGNOSIS_VIDEO_LOSS_FRAME_DETECTION.equals(new String(szDiagnosisType).trim())){
                    NET_VIDEO_LOSS_FRAME_DETECTION_RESULT result=new NET_VIDEO_LOSS_FRAME_DETECTION_RESULT();
                    ToolKits.GetPointerDataToStruct(pDiagnosisResult,count,result);
 
                    count+=result.dwSize;
 
                    System.out.println(" nValue:"+result.nValue);
                    System.out.println(" emState:"+result.emState);
                    System.out.println(" nDuration:"+result.nDuration);
 
                }else {
                    System.out.println("other szDiagnosisType:"+new String(szDiagnosisType));
                    count+=nDiagnosisTypeLen;
                }
 
            }
 
 
            System.out.println("计划名称:" + ToolKits.GetPointerDataToGBKString(commons.stProject.pArray, commons.stProject.dwArrayLen));
            System.out.println("任务名称:" + ToolKits.GetPointerDataToGBKString(commons.stTask.pArray, commons.stTask.dwArrayLen));
            System.out.println("参数表名称:" + ToolKits.GetPointerDataToGBKString(commons.stProfile.pArray, commons.stProfile.dwArrayLen));
            System.out.println("诊断设备ID:" + ToolKits.GetPointerDataToGBKString(commons.stDeviceID.pArray, commons.stDeviceID.dwArrayLen));
            System.out.println("诊断通道:" + commons.nVideoChannelID);
            System.out.println("诊断开始时间:" + commons.stStartTime.toStringTime());
            System.out.println("诊断结束时间:" + commons.stEndTime.toStringTime());
            System.out.println("诊断码流:" + commons.emVideoStream);  // 参考  NET_STREAM_TYPE
            System.out.println("诊断结果类型:" + commons.emResultType);  // 参考  NET_VIDEODIAGNOSIS_RESULT_TYPE
            System.out.println("诊断结果:" + commons.bCollectivityState); // 诊断结果, 1-true, 0-false
            System.out.println("失败原因:" + commons.emFailedCause);  // 参考 NET_VIDEODIAGNOSIS_FAIL_TYPE
            System.out.println("失败原因描述:" + new String(commons.szFailedCode).trim());
            System.out.println("诊断结果存放地址:" + new String(commons.szResultAddress).trim());
 
            System.out.println("诊断结果存放地址扩展:" + new String(commons.szResultAddressEx).trim());
            for(int i = 0; i < commons.nBackPic; i++) {
                System.out.println("背景图片路径:" + new String(commons.szBackPicAddressArr[i].szBackPicAddress).trim());
            }
            return 0;
        }
 
    }
 
 
 
    public void RunTest()
    {
        System.out.println("Run Test");
        CaseMenu menu = new CaseMenu();;
        menu.addItem((new CaseMenu.Item(this , "视频诊断参数表" , "VideoDiagnosisProfileConfig")));
        menu.addItem((new CaseMenu.Item(this , "获取诊断任务名称" , "GetVideoDiagnosisTask")));
        menu.addItem((new CaseMenu.Item(this , "视频诊断任务获取" , "VideoDiagnosisTaskGet")));
        menu.addItem((new CaseMenu.Item(this , "视频诊断任务设置" , "VideoDiagnosisTaskSet")));
        menu.addItem((new CaseMenu.Item(this , "获取诊断计划名称" , "GetVideoDiagnosisProject")));
        menu.addItem((new CaseMenu.Item(this , "视频诊断计划获取" , "VideoDiagnosisProjectGet")));
        menu.addItem((new CaseMenu.Item(this , "视频诊断计划设置" , "VideoDiagnosisProjectSet")));
        menu.addItem((new CaseMenu.Item(this , "视频诊断订阅" , "StartVideoDiagnosis")));
        menu.addItem((new CaseMenu.Item(this , "取消视频诊断订阅" , "StopVideoDiagnosis")));
        menu.run();
    }
 
    public static void main(String[] args) {
        StartVideoDiagnosisDemo demo=new StartVideoDiagnosisDemo();
        InitTest("10.38.51.1",37777,"admin","cloud123");
        demo.RunTest();
        LoginOut();
 
    }
 
}