黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
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
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
 
namespace ZigBee.Device
{
    [System.Serializable]
    public class HDLbutton : LightBase
    {
        public HDLbutton()
        {
            this.Type = DeviceType.OnOffSwitch;
        }
 
        //#region 读取按键信息
        /////// <summary>
        /////// 读取按键信息
        /////// <para> gateway:当前网关</para>
        /////// </summary>
        ////public static async System.Threading.Tasks.Task<HdlKeyAllData> GetHdlKeyDataAsync(ZigBee.Device.ZbGateway gateway)
        ////{
        ////    if (gateway == null)
        ////    {
        ////        return null;
        ////    }
        ////    return await System.Threading.Tasks.Task.Run(async () =>
        ////    {
        ////        var d = new HdlKeyAllData { };
        ////        Action<string, string> action = (topic, message) =>
        ////        {
        ////            var gatewayID = topic.Split('/')[0];
        ////            var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
 
        ////            if (topic == gatewayID + "/" + "Error_Respon")
        ////            {
        ////                var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID };
        ////                var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
 
        ////                if (temp == null)
        ////                {
        ////                    d.errorMessageBase = "网关错误回复,且数据是空";
        ////                }
        ////                else
        ////                {
        ////                    d.errorResponData = temp;
        ////                    d.errorMessageBase = ErrorMess(temp.Error);
        ////                }
        ////            }
 
        ////            if (topic == gatewayID + "/" + "hdlButton/GetInfo_Respon")
        ////            {
        ////                var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = gateway.getGatewayBaseInfo.gwID };
        ////                var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<HdlKeyInfo>(jobject["Data"].ToString());
 
        ////                if (tempData == null)
        ////                {
        ////                    d.errorMessageBase = "网关返回的数据为空";
        ////                }
        ////                else
        ////                {
        ////                    d.hdlKeyInfo = tempData;
        ////                }
        ////            }
        ////        };
        ////        gateway.Actions += action;
        ////        System.Console.WriteLine("hdlButton/GetInfo_Actions 启动" + "_" + gateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString());
 
        ////        var jObject = new JObject { { "Cluster_ID", 0 }, { "Command", 92 } };
        ////        gateway.Send("GetZbGwVersion", Common.SecuritySet.Encryption(jObject.ToString()));
        ////        var dateTime = DateTime.Now;
        ////        while ((DateTime.Now - dateTime).TotalMilliseconds < 1000)
        ////        {
        ////            await System.Threading.Tasks.Task.Delay(10);
        ////            if (d.hdlKeyInfo != null)
        ////            {
        ////                break;
        ////            }
        ////        }
        ////        if ((DateTime.Now - dateTime).TotalMilliseconds > 10000)
        ////        {
        ////            d.errorMessageBase = " 回复超时,请重新操作";
        ////        }
        ////        gateway.Actions -= action;
        ////        System.Console.WriteLine("hdlButton/GetInfo_Actions 退出" + System.DateTime.Now.ToString());
 
        ////        return d;
        ////    });
        ////}
 
        /////// <summary>
        /////// 读取按键信息,网关反馈信息
        /////// </summary>
        ////public HdlKeyAllData hdlKeyAllData;
        ////[System.Serializable]
        ////public class HdlKeyAllData
        ////{
        ////    /// <summary>
        ////    /// 错误信息
        ////    /// </summary>
        ////    public string errorMessageBase;
        ////    /// <summary>
        ////    /// 网关信息错误反馈
        ////    /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para>
        ////    /// </summary>
        ////    public ErrorResponData errorResponData;
        ////    /// <summary>
        ////    /// 网关版本信息
        ////    /// </summary>
        ////    public HdlKeyInfo hdlKeyInfo;
        ////}
 
        /////// <summary>
        /////// 读取按键信息
        /////// </summary>
        ////public HdlKeyInfo hdlButtonGetInfoData;
        ////[System.Serializable]
        ////public class HdlKeyInfo
        ////{
        ////    /// <summary>
        ////    /// 按键号对应相应的端点号,用来匹配源端点
        ////    /// </summary>
        ////    public int Endpoint;
        ////    /// <summary>
        ////    ///按键号类型
        ////    ///<para>Bit0-触摸开关,可位或</para>
        ////    ///<para>Bit1-机械开关,可位或</para>
        ////    ///<para>Bit2-弹性开关,可位或</para>
        ////    /// </summary>
        ////    public int ButtonType;
        ////    /// <summary>
        ////    ///按键号功能类型
        ////    ///<para>Bit0-绑定功能,可位或</para>
        ////    ///<para>Bit1-条件逻辑功能,可位或</para>
        ////    /// </summary>
        ////    public int Function;
        ////    /// <summary>
        ////    ///按键号模式 
        ////    ///<para>Bit0-仅单击,可位或</para>
        ////    ///<para>Bit1-前单击,可位或</para>
        ////    ///<para>Bit2-后单击,可位或</para>
        ////    ///<para>Bit3-仅双击,可位或</para>
        ////    ///<para>Bit4-前双击,可位或</para>
        ////    ///<para>Bit5-后双击,可位或</para>
        ////    ///<para>Bit6-仅长按,可位或</para>
        ////    ///<para>Bit7-前长按,可位或</para>
        ////    ///<para>Bit8-后长按,可位或</para>
        ////    ///<para>Bit9-长按释放,可位或</para>
        ////    /// </summary>
        ////    public int ButtonMode;
        ////    /// <summary>
        ////    ///按键物理应用功能
        ////    ///Bit0-是否支持锁键(0:否;1:是),可位或
        ////    ///Bit1-是否支持本地互斥(0:否;1:是),可位或
        ////    /// </summary>
        ////    public int PhyFunction;
        ////}
        //#endregion
 
        ///// <summary>
        ///// 绑定的场景列表
        ///// </summary>
        //[Newtonsoft.Json.JsonIgnore]
        //public System.Collections.Generic.Dictionary<string, List<CommonDevice>> BindedDeviceFilePathList = new Dictionary<string, List<CommonDevice>>();
  
        ///// <summary>
        ///// 获取所有绑定(用于主网关)
        ///// </summary>
        //public hdlButtonGetAllBind hdlButtonGetAllBindData;
        //[System.Serializable]
        //public class hdlButtonGetAllBind
        //{
        //    /// <summary>
        //    ///绑定信息总量
        //    /// 当BindSum大于0时 ,下面字段才存在
        //    /// </summary>
        //    public int BindSum;
        //    /// <summary>
        //    ///当前发送的绑定信息序号。BindNum从1开始,每发送一条绑定信息将自加1,直到BindNum等于BindSum表示所有绑定信息发送完毕。
        //    /// </summary>
        //    public int BindNum;
        //    /// <summary>
        //    ///绑定名称
        //    /// </summary>
        //    public string BindName;
        //    /// <summary>
        //    ///按键设备Mac地址
        //    /// </summary>
        //    public string ButtonMacAddr;
        //    /// <summary>
        //    ///按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    ///16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///按键号类型:
        //    ///Bit0-触摸开关,不可位或
        //    ///Bit1-机械开关,不可位或
        //    ///Bit2-弹性开关,不可位或
        //    /// </summary>
        //    public int ButtonType;
        //    /// <summary>
        //    ///绑定的簇id 
        //    /// </summary>
        //    public int BindClusterId;
        //    /// <summary>
        //    ///绑定设备的命令id 
        //    /// </summary>
        //    public int BindCmdId;
        //    /// <summary>
        //    ///参数列表
        //    /// </summary>
        //    public List<ParameterObj> ParameterList = new List<ParameterObj>();
        //    /// <summary>
        //    ///绑定列表 ,当Status=0时存在
        //    /// </summary>
        //    public List<GetAllBindListObj> ButtonList = new List<GetAllBindListObj>();
        //}
 
        ///// <summary>
        ///// 参数列表参数
        ///// </summary>
        //public class ParameterObj//协议格式顺序有错
        //{
        //    /// <summary>
        //    /// 参数长度,占用的字节数。
        //    /// </summary>
        //    public int Length { get; set; }
        //    /// <summary>
        //    ///参数值
        //    /// </summary>
        //    public int Value { get; set; }
 
        //}
 
        ///// <summary>
        ///// hdl按键绑定列表参数
        ///// </summary>
        //public class GetAllBindListObj:CommonDevice
        //{
        //    /// <summary>
        //    /// 绑定类型
        //    ///0:绑定设备,同网关设备间的绑定
        //    ///1:绑定设备,跨网关设备间的绑定
        //    ///2:绑定场景
        //    /// </summary>
        //    public int BindType { get; set; }
        //    /// <summary>
        //    ///绑定设备Mac地址, 当BindType=0或1时存在
        //    /// </summary>
        //    public string BindMacAddr { get; set; }
        //    /// <summary>
        //    /// 绑定设备的端口号,当BindType=0或1时存在
        //    /// </summary>
        //    public int BindEpoint { get; set; }
        //    /// <summary>
        //    /// 绑定场景,当BindType=2时存在
        //    /// </summary>
        //    public int BindScenesId { get; set; }
        //    /// <summary>
        //    ///绑定的设备或场景名称
        //    /// </summary>
        //    public string ESName{ get; set; }
        //}
 
        ///// <summary>
        ///// 读取按键信息
        ///// </summary>
        //public hdlButtonGetInfo hdlButtonGetInfoData;
        //[System.Serializable]
        //public class hdlButtonGetInfo
        //{
        //    public int ButtonMode;
        //    /// <summary>
        //    ///按键物理应用功能
        //    ///Bit0-是否支持锁键(0:否;1:是),可位或
        //    ///Bit1-是否支持本地互斥(0:否;1:是),可位或
        //    /// </summary>
        //    public int PhyFunction;
        //    /// <summary>
        //    ///按键号对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int Endpoint;
        //    /// <summary>
        //    ///按键号类型
        //    //Bit0-触摸开关,可位或
        //    ///Bit1-机械开关,可位或
        //    ///Bit2-弹性开关,可位或
        //    /// </summary>
        //    public int ButtonType;
        //    /// <summary>
        //    ///按键号功能类型
        //    /// Bit0-绑定功能,可位或
        //    ///Bit1-条件逻辑功能,可位或
        //    /// </summary>
        //    public int Function;
        //    /// <summary>
        //    ///按键号模式 
        //    ///Bit0-仅单击,可位或
        //    ///Bit1-前单击,可位或
        //    ///Bit2-后单击,可位或
        //    ///Bit3-仅双击,可位或
        //    ///Bit4-前双击,可位或
        //    ///Bit5-后双击,可位或
        //    ///Bit6-仅长按,可位或
        //    ///Bit7-前长按,可位或
        //    ///Bit8-后长按,可位或
        //    ///Bit9-长按释放,可位或
        //    /// </summary>
        //}
 
        ///// <summary>
        ///// 配置绑定属性(用于主网关)
        ///// </summary>
        //public hdlButtonSetBindAttribute hdlButtonSetBindAttributeData;
        //[System.Serializable]
        //public class hdlButtonSetBindAttribute
        //{
        //    /// <summary>
        //    ///按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号类型
        //    //按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    ///16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///按键号类型:
        //    /// Bit0-触摸开关,不可位或
        //    ///Bit1-机械开关,不可位或
        //    ///Bit2-弹性开关,不可位或
 
        //    /// </summary>
        //    public int ButtonType;
        //    /// <summary>
        //    ///绑定名称,最大32个字符
        //    /// </summary>
        //    public string BindName;
        //    /// <summary>
        //    ///0:未知,需要按键设备对修改结果进行确认。
        //    ///1:失败,当前网关不是主网关,无法进行属性配置。
        //    /// </summary>
        //    public int Result;
        //}
 
        ///// <summary>
        ///// 按键设备配置绑定属性上报
        ///// </summary>
        //public hdlButtonBindAttributeConfig hdlButtonBindAttributeConfigData;
        //[System.Serializable]
        //public class hdlButtonBindAttributeConfig
        //{
        //    /// <summary>
        //    ///0:未知,需要按键设备对修改结果进行确认。
        //    ///1:失败,当前网关不是主网关,无法进行属性配置。
        //    /// </summary>
        //    public int Result;
        //    /// <summary>
        //    ///按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号类型
        //    //按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    ///16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///按键号类型:
        //    /// Bit0-触摸开关,不可位或
        //    ///Bit1-机械开关,不可位或
        //    ///Bit2-弹性开关,不可位或
        //    /// </summary>
        //    public int ButtonType;
        //    /// <summary>
        //    ///绑定名称,最大32个字符
        //    /// </summary>
        //    public string BindName;
        //    /// <summary>
        //    ///绑定的簇id 
        //    /// </summary>
        //    public int BindClusterId;
        //    /// <summary>
        //    ///按键号类型
        //    ///绑定设备的命令id
        //    /// </summary>
        //    public int BindCmdId;
        //    /// <summary>
        //    ///参数列表
        //    /// </summary>
        //    public List<ParameterObj> ParameterList = new List<ParameterObj>();
        //}
 
        ///// <summary>
        ///// 设备绑定,(用于主网关)
        ///// 绑定失败、跨网关设备间的绑定,场景绑定的结果将直接由网关反馈
        ///// </summary>
        //public hdlButtonSetBind hdlButtonSetBindData;
        //[System.Serializable]
        //public class hdlButtonSetBind
        //{
        //    /// <summary>
        //    ///按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    ///  /// 16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///按键号类型:
        //    /// 按键号类型:
        //    /// Bit0-触摸开关,不可位或
        //    ///Bit1-机械开关,不可位或
        //    ///Bit2-弹性开关,不可位或
        //    /// </summary>
        //    public int ButtonType;
        //    /// <summary>
        //    /// Status
        //    ///0:正常
        //    ///1:不可绑定,需先对按键在指定按键模式下配置绑定属性方可创建绑定。
        //    ///2:当前网关不是主网关。不能创建绑定。
        //    /// </summary>
        //    public int Status;
        //    /// <summary>
        //    ///绑定列表 ,当Status=0时存在
        //    /// </summary>
        //    public List<BindListObj> BindList = new List<BindListObj>();
        //}
 
        ///// <summary>
        ///// hdl按键绑定列表参数
        ///// </summary>
        //public class BindListObj//协议格式顺序有错
        //{
        //    /// <summary>
        //    ///绑定设备Mac地址, 当BindType=0或1时存在
        //    /// </summary>
        //    public string BindMacAddr { get; set; }
        //    /// <summary>
        //    /// 绑定设备的端口号,当BindType=0或1时存在
        //    /// </summary>
        //    public int BindEpoint { get; set; }
        //    /// <summary>
        //    /// 绑定类型
        //    ///0:绑定设备,同网关设备间的绑定
        //    ///1:绑定设备,跨网关设备间的绑定
        //    ///2:绑定场景
        //    /// </summary>
        //    public int BindType { get; set; }
        //    /// <summary>
        //    /// 0:加入成功(该状态只适用用于跨网关绑定和绑定场景。同网关设备间的绑定需要节点设备的确认成功信息,不会直接反馈成功。)
        //    ///1:失败,设备已在绑定列表中
        //    ///2:失败,节点设备或场景不存在。
        //    ///3:失败,在等待节点设备确认是否绑定成功(当网关还在等待某节点设备确认是否绑定成功的反馈信息时,客户端再次发送绑定该节点设备的指令,将反馈该状态。)
        //    ///4:未知,由节点设备反馈发送“hdlButton/BindResult”主题消息确定是否成功。
        //    /// </summary>
        //    public int Result { get; set; }
 
        //    /// <summary>
        //    /// 绑定场景,当BindType=1时存在
        //    /// </summary>
        //    public int BindScenesId { get; set; }
 
        //    /// <summary>
        //    ///绑定的设备或场景的名称
        //    /// </summary>
        //    public string ESName { get; set; }
        //}
 
        ///// <summary>
        ///// 设备绑定,用于主网关)
        ///// 本地设备间的绑定 ,是否成功需要等待hdl按键设备的确认
        ///// </summary>
        //public hdlButtonBindResult hdlButtonBindResultData;
        //[System.Serializable]
        //public class hdlButtonBindResult
 
        //{
        //    /// <summary>
        //    ///按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    /// 16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///绑定结果
        //    ///0:成功
        //    ///1:失败
        //    ///2:无效
        //    /// </summary>
        //    public int Result;
        //    /// <summary>
        //    ///绑定设备Mac地址
        //    /// </summary>
        //    public string BindMacAddr;
        //    /// <summary>
        //    /// 绑定设备的端口号
        //    /// </summary>
        //    public int BindEpoint;
        //}
 
        ///// <summary>
        ///// 移除绑定(用于主网关)
        ///// </summary>
        //public hdlButtonRemoveBind hdlButtonRemoveBindData;
        //[System.Serializable]
        //public class hdlButtonRemoveBind
        //{
        //    /// <summary>
        //    ///0:正常
        //    ///1:绑定不存在
        //    ///2:当前网关不是主网关。不能解除绑定。
        //    /// </summary>
        //    public int Status;
        //    /// <summary>
        //    ///按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    ///  /// 16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///按键号类型:
        //    /// 按键号类型:
        //    /// Bit0-触摸开关,不可位或
        //    ///Bit1-机械开关,不可位或
        //    ///Bit2-弹性开关,不可位或
        //    /// </summary>
        //    public int ButtonType;
 
        //    /// <summary>
        //    ///绑定列表 ,当Status=0时存在。
        //    /// </summary>
        //    public List<RemoveBindListObj> RemoveBindList = new List<RemoveBindListObj>();
        //}
 
        ///// <summary>
        ///// 移除绑定(用于主网关)
        ///// </summary>
        //public hdlButtonRemoveBindResult hdlButtonRemoveBindResultData;
        //[System.Serializable]
        //public class hdlButtonRemoveBindResult
        //{
        //     /// <summary>
        //    ///按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    ///  /// 16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///按键号类型:
        //    /// 按键号类型:
        //    /// Bit0-触摸开关,不可位或
        //    ///Bit1-机械开关,不可位或
        //    ///Bit2-弹性开关,不可位或
        //    /// </summary>
        //    public int ButtonType;
        //    /// <summary>
        //    ///0:成功
        //    ///1:失败
        //    ///2:无效
        //    /// </summary>
        //    public int Result;
        //    /// <summary>
        //    ///绑定设备Mac地址
        //    /// </summary>
        //    public string BindMacAddr;
        //    /// <summary>
        //    /// 绑定设备的端口号
        //    /// </summary>
        //    public int BindEpoint;
        // }
 
        ///// <summary>
        ///// hdl按键绑定列表参数
        ///// </summary>
        //public class RemoveBindListObj//协议格式顺序有错
        //{
        //    /// <summary>
        //    ///0:移除成功(该状态只适用用于跨网关绑定、绑定场景、失效设备(设备已经从网关的设备列表中删除)。同网关设备间的解除绑定需要节点设备的确认成功信息,不会直接反馈成功。)
        //    ///1:失败,设备不在绑定列表中
        //    ///3:失败,在等待节点设备确认是否解除绑定成功(当网关还在等待某节点设备确认是否解除绑定成功的反馈信息时,客户端再次发送解除绑定该节点设备的指令,将反馈该状态。)
        //    ///4:未知,由节点设备反馈发送“hdlButton/RemoveBindResult”主题消息确定是否成功。
        //    /// </summary>
        //    public int Result { get; set; }
        //    /// <summary>
        //    /// 绑定类型
        //    ///0:移除设备,同网关设备间的移除
        //    ///1:移除设备,跨网关设备间的移除
        //    ///2:移除绑定场景
        //    /// </summary>
        //    public int BindType { get; set; }
        //    /// <summary>
        //    ///绑定设备Mac地址, 当BindType=0或1时存在
        //    /// </summary>
        //    public string BindMacAddr { get; set; }
        //    /// <summary>
        //    /// 绑定设备的端口号,当BindType=0或1时存在
        //    /// </summary>
        //    public int BindEpoint { get; set; }
 
        //    /// <summary>
        //    /// 绑定场景,当BindType=1时存在
        //    /// </summary>
        //    public int BindScenesId { get; set; }
        //    /// <summary>
        //    ///绑定的设备或场景名称
        //    /// </summary>
        //    public string ESName;
        //}
 
        ///// <summary>
        ///// 删除按键功能(用于主网关)
        ///// </summary>
        //public hdlButtonDelButtonFunction hdlButtonDelButtonFunctionData;
        //[System.Serializable]
        //public class hdlButtonDelButtonFunction
        //{
        //    /// <summary>
        //    ///按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    ///  /// 16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///结果:
        //    ///0:成功,当该按键设备已经失效(按键设备已经从网关的设备列表删除)将直接删除该按键功能。
        //    ///1:失败,当前网关不是主网关不能进行此操作。
        //    ///2: 未知,需由按键设备对删除结果进行确认 
        //    /// </summary>
        //    public int Result;
        //}
 
        ///// <summary>
        ///// 按键设备删除功能确认信息上报
        ///// </summary>
        //public hdlButtonDelButtonFunctionResult hdlButtonDelButtonFunctionResultData;
        //[System.Serializable]
        //public class hdlButtonDelButtonFunctionResult
        //{
        //    /// <summary>
        //    ///按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    ///  /// 16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///结果:
        //    ///0:成功。
        //    ///1:失败
        //    /// </summary>
        //    public int Result;
        //}
 
        ///// <summary>
        ///// 修改绑定名称(用于主网关)
        ///// </summary>
        //public hdlButtonBindRename hdlButtonBindRenameData;
        //[System.Serializable]
        //public class hdlButtonBindRename
        //{
        //    /// <summary>
        //    ///0:成功。
        //    ///1:失败,当前网关不是主网关,无法进行属性配置。
        //    ///2:失败,绑定不存在。
        //    /// </summary>
        //    public int Result;
        //    /// <summary>
        //    ///绑定设备Mac地址
        //    /// </summary>
        //    public string ButtonMacAddr;
        //    /// <summary>
        //    /// 按键号,对应相应的端点号,
        //    ///用来匹配源端点
        //    /// </summary>
        //    public int ButtonEpoint;
        //    /// <summary>
        //    ///按键号模式 
        //    ///1:点击 2:前点击 4:后单击 8:仅双击
        //    ///16:前双击 32:后双击 64:仅长按 
        //    ///128:前长按 256:后长按 512:长按释放
 
        //    /// </summary>
        //    public int ButtonMode;
        //    /// <summary>
        //    ///按键号类型:
        //    ///Bit0-触摸开关,不可位或
        //    ///Bit1-机械开关,不可位或
        //    ///Bit2-弹性开关,不可位或
        //    /// </summary>
        //    public int ButtonType;
        //    /// <summary>
        //    ///绑定名称,最大32个字符
        //    /// </summary>
        //    public string BindName;
        //}
 
        ///// <summary>
        ///// hdl按键绑定列表参数
        ///// </summary>
        //public class BindListDeviceInfo//协议格式顺序有错
        //{
        //    /// <summary>
        //    /// 绑定类型
        //    ///0:绑定设备,同网关设备间的绑定
        //    ///1:绑定设备,跨网关设备间的绑定
        //    ///2:绑定场景
        //    /// </summary>
        //    public int BindType { get; set; }
        //    /// <summary>
        //    ///绑定设备Mac地址, 当BindType=0或1时存在
        //    /// </summary>
        //    public string BindMacAddr { get; set; }
        //    /// <summary>
        //    /// 绑定设备的端口号,当BindType=0或1时存在
        //    /// </summary>
        //    public int BindEpoint { get; set; }
 
        //}
 
        ///// <summary>
        ///// hdl按键绑定列表参数
        ///// </summary>
        //public class BindSceneInfo//协议格式顺序有错
        //{
        //    /// <summary>
        //    /// 绑定类型
        //    ///0:绑定设备,同网关设备间的绑定
        //    ///1:绑定设备,跨网关设备间的绑定
        //    ///2:绑定场景
        //    /// </summary>
        //    public int BindType { get; set; }
        //    /// <summary>
        //    /// 绑定场景,当BindType=1时存在
        //    /// </summary> 
        //    public int BindScenesId { get; set; }
        //}
 
        ///// <summary>
        ///// hdl按键绑定列表参数
        ///// </summary>
        //public class RemoveBindListInfo
        //{
        //    /// <summary>
        //    /// 绑定类型
        //    ///0:移除设备,同网关设备间的移除
        //    ///1:移除设备,跨网关设备间的移除
        //    ///2:移除绑定场景
        //    /// </summary>
        //    public int BindType { get; set; }
        //    /// <summary>
        //    ///绑定设备Mac地址, 当BindType=0或1时存在
        //    /// </summary>
        //    public string BindMacAddr { get; set; }
        //    /// <summary>
        //    /// 绑定设备的端口号,当BindType=0或1时存在
        //    /// </summary>
        //    public int BindEpoint { get; set; }
 
        //}
 
        ///// <summary>
        ///// hdl按键绑定列表参数
        ///// </summary>
        //public class RemoveSceneBindListInfo
        //{
        //    /// <summary>
        //    /// 绑定类型
        //    ///0:移除设备,同网关设备间的移除
        //    ///1:移除设备,跨网关设备间的移除
        //    ///2:移除绑定场景
        //    /// </summary>
        //    public int BindType { get; set; }
        //    /// <summary>
        //    ///绑定场景,当BindType=1时存在
        //    /// </summary>
        //    public int BindScenesId { get; set; }
 
        //}
 
        //#region Hdl按键
        /////<summary>
        /////获取所有绑定(用于主网关)
        ///// </summary>
        //public void GetAllBindPublish()
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64528 }, { "Command", 10 } };
        //    CurrentGateWayId = Gateway?.CurrentGateWayId;
        //    Gateway?.Send(("hdlButton/BindInfo"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary>
        /////读取按键信息
        ///// </summary>
        //public void GetInfoPublish(ZigBee.Device.ZbGateway gateway, string buttonMacAddr, int epoint, int endpoint)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", epoint }, { "Cluster_ID", 64528 }, { "Command", 3 } };
        //    var data = new JObject { { "Endpoint", endpoint } };
        //    jobject.Add("Data", data);
        //    Gateway?.Send(("hdlButton/GetInfo"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary>
        /////配置锁键
        ///// IsLock
        ///// 0:不锁
        /////1:锁
        ///// </summary>
        //public void LockPublish(int endpoint, int isLock)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 64528 }, { "Command", 5 } };
        //    var data = new JObject { { "Endpoint", endpoint }, { "IsLock", isLock } };
        //    jobject.Add("Data", data);
        //    Gateway?.Send(("hdlButton/Lock"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary>
        /////配置绑定属性(用于主网关)
        ///// IsLock
        ///// 0:不锁
        /////1:锁
        ///// </summary>
        //public void SetBindAttributePublish(int buttonMode, int buttonType, string bindName, int bindClusterId, int bindCmdId)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 64528 }, { "Command", 4 } };
 
        //    var ParameterList = new JArray{
        //        new JObject {}
        //    };
 
        //    var data = new JObject { { "ButtonEpoint", DeviceEpoint },
        //        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        //        { "BindName", bindName },
        //        { "BindClusterId", bindClusterId },{ "BindCmdId", bindCmdId },
        //        { "ParameterList", ParameterList },
        //     };
        //    jobject.Add("Data", data);
        //    Gateway?.Send(("hdlButton/SetBindAttribute"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary>
        /////设备绑定(用于主网关)
        ///// 绑定设备
        ///// </summary>
        //public void SetBindPublish(BindListDeviceInfo bindListObj,int buttonMode, int buttonType)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 64528 }, { "Command", 6 } };
 
        //    var bindList = new JArray{
        //        new JObject {{ "BindType", bindListObj.BindType},{ "BindMacAddr", bindListObj.BindMacAddr},{ "BindEpoint", bindListObj.BindEpoint }}
        //    };
        //    var data = new JObject { { "ButtonEpoint", DeviceEpoint },
        //        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        //        { "BindList", bindList }
        //     };
 
        //    jobject.Add("Data", data);
        //    Gateway?.Send(("hdlButton/SetBind"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary>
        /////设备绑定(用于主网关)
        ///// 绑定场景,当BindType=1时存在
        ///// </summary>
        //public void SetSceneBindPublish(BindSceneInfo bindListObj,int buttonMode, int buttonType)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 64528 }, { "Command", 6 } };
 
        //    var bindList = new JArray{
        //        new JObject {{ "BindType", bindListObj.BindType},{ "BindScenesId", bindListObj.BindScenesId}}
        //    };
        //    var data = new JObject { { "ButtonEpoint", DeviceEpoint },
        //        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        //        { "BindList", bindList }
        //     };
 
        //    jobject.Add("Data", data);
        //    Gateway?.Send(("hdlButton/SetBind"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary>
        /////移除绑定(用于主网关)
        ///// /// BindScenesId,绑定场景,当BindType=1时存在
        ///// </summary>
        //public void RemoveBindPublish(RemoveBindListInfo removeListObj,int buttonMode, int buttonType)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 64528 }, { "Command", 7 } };
 
        //    var removeBindList = new JArray{
        //        new JObject {{ "BindType", removeListObj.BindType},{ "BindMacAddr", removeListObj.BindMacAddr},{ "BindEpoint", removeListObj.BindEpoint}}
        //    };
        //    var data = new JObject { { "ButtonEpoint", DeviceEpoint },
        //        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        //        { "RemoveBindList", removeBindList }
        //     };
 
        //    jobject.Add("Data", data);
        //    Gateway?.Send(("hdlButton/RemoveBind"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
 
        /////<summary>
        /////移除绑定(用于主网关)
        ///// /// BindScenesId,绑定场景,当BindType=1时存在
        ///// </summary>
        //public void RemoveSceneBindPublish(RemoveSceneBindListInfo removeListObj,int buttonMode, int buttonType)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 64528 }, { "Command", 7 } };
 
        //    var removeBindList = new JArray{
        //        new JObject {{ "BindType", removeListObj.BindType},{ "BindScenesId", removeListObj.BindScenesId}}
        //    };
        //    var data = new JObject { { "ButtonEpoint", DeviceEpoint },
        //        { "ButtonMode", buttonMode },{ "ButtonType", buttonType },
        //        { "RemoveBindList", removeBindList }
        //     };
 
        //    jobject.Add("Data", data);
        //    Gateway?.Send(("hdlButton/RemoveBind"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary>
        /////删除按键功能(用于主网关)
        ///// buttonMode设为0xffff  65536 ,直接清除按键号下所有按键模式的绑定
        ///// </summary>
        //public void DelButtonFunctionPublish(int buttonMode)
        //{
        //    var jobject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 64528 }, { "Command", 8 } };
        //    var data = new JObject { { "ButtonEpoint", DeviceEpoint},
        //        { "ButtonMode", buttonMode }
        //    };
        //    jobject.Add("Data", data);
        //    Gateway?.Send(("hdlButton/DelButtonFunction"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
 
        /////<summary>
        /////修改绑定名称(用于主网关)
        ///// </summary>
        //public void BindRenamePublish(int buttonMode, int buttonType, string bindName)
        //{
        //    var jobject = new JObject { { "Cluster_ID", 64528 }, { "Command", 9 } };
        //    var data = new JObject { { "ButtonMacAddr", DeviceAddr },
        //        { "ButtonEpoint", DeviceEpoint },{ "ButtonMode", buttonMode },
        //        { "ButtonType", buttonType },
        //        { "BindName", bindName }
        //    };
        //    jobject.Add("Data", data);
        //    Gateway?.Send(("hdlButton/BindRename"), Common.SecuritySet.Encryption((jobject.ToString())));
        //}
        //#endregion
    
    }
}