wei
2021-02-01 8da70e1a39328e1769b02bb1e05303916bb30eb5
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
using System;
using System.Collections.Generic;
using HDL_ON.Common;
using HDL_ON.DAL.Server;
using HDL_ON.DriverLayer;
using Shared;
 
namespace HDL_ON.Entity
{
    /// <summary>
    /// 读取服务器空间信息返回到数据包
    /// </summary>
    public class DevcieApiPack
    {
        public List<Function> list = new List<Function>();
 
        public string totalCount = "0";
 
        public string totalPage = "0";
 
        public string pageNo = "0";
 
        public string pageSize = "0";
 
    }
 
    /// <summary>
    /// 功能类能满足数据使用要求,子类只是为了方便使用属性
    /// </summary>
    public class Function
    {
        public Function()
        {
        }
 
        #region base info
        /// <summary>
        /// HDL统一协议格式:14bytes
        /// 举例: 来源   厂商代码 通讯方式  产品时间戳   产品类别 物模型类  通道号   大小类别
        ///       1byte    1byte    1byte      4byte        1byte    2byte   2byte   2byte
        /// 来源:00    默认原生态系统数据 、01    网关或者其他A设备、02    调试软件、03    APP应用程序、04    第三方网关或者平台
        /// 厂商代码:01    HDL
        /// 通讯方式:01    HDL Bus、02    Zigbee、03 KNX、04 Z-Wave
        /// 产品时间戳:4bytes    以2020年1月1日算出的时间戳0.1s为单位 
        /// 产品类别:01    调光器、02 继电器、03    干接点模块、04    传感器、05 面板
        /// 物模型类型:
        ///     01    开关类:01 开关、02 插座、03    
        ///     02    照明: 01 开关、02    调光、03    色温、04    LED
        ///     03    遮阳: 01    窗帘电机、02 百叶窗、03 开合帘、04 卷帘
        ///     04    恒温器:01 空调、02 地暖、03 毛细空调
        ///     05    新风        
        ///     06    影音        
        ///     07    音乐        
        ///     08    能源        
        ///     09    安防
        /// 大类别    1bytes    (预留)
        /// 小类别    1byte    (预留)
        /// </summary>
        public string sid = "0301011234567801012301230123";
        /// <summary>
        /// 备注
        /// </summary>
        public string name;
        /// <summary>
        /// 设备ID
        /// 云端负责生成
        /// </summary>
        public string deviceId = "0";
        /// <summary>
        /// 设备spk
        /// </summary>
        public string spk = "";
        ///// <summary>
        ///// 功能类别
        ///// 如:空调类、灯光类、窗帘类
        ///// </summary>
        //public FunctionCategory Spk_Prefix
        //{
        //    get
        //    {
        //        try
        //        {
        //            var _functionCategoryString = sid.Substring(16, 2);
        //            var _functionCategory = Convert.ToInt32(_functionCategoryString, 16);
        //            return (FunctionCategory)Enum.ToObject(typeof(FunctionCategory), _functionCategory);
        //        }
        //        catch (Exception ex)
        //        {
        //            MainPage.Log($"get FunctionCategory error : {ex.Message}");
        //            return FunctionCategory.UnKown;
        //        }
        //    }
        //}
 
        ///// <summary>
        ///// 功能类型
        ///// </summary>
        //public FunctionType spk
        //{
        //    get
        //    {
        //        var _functionTypeString = sid.Substring(16, 4);
        //        return (FunctionType)Enum.ToObject(typeof(FunctionType), Convert.ToInt32(_functionTypeString, 16));
        //    }
        //}
 
        string spk_Prefix;
        /// <summary>
        /// spk前缀
        /// 大类
        /// 功能类别
        /// 如:空调类、灯光类、窗帘类
        /// </summary>
        public string Spk_Prefix
        {
            get
            {
                if (string.IsNullOrEmpty(spk_Prefix))
                {
                    spk_Prefix = spk.Split(".")[0];
                }
                return spk_Prefix;
            }
        }
        string spk_Suffix;
        ///// <summary>
        ///// spk后缀
        ///// 小类
        ///// 功能类型
        ///// </summary>
        //public string spk
        //{
        //    get
        //    {
        //        if (string.IsNullOrEmpty(spk_Suffix))
        //        {
        //            try
        //            {
        //                spk_Suffix = spk.Split(".")[1];
        //            }
        //            catch
        //            {
        //                spk_Suffix = "";
        //            }
        //        }
        //        return spk_Suffix;
        //    }
        //}
 
        /// <summary>
        /// A协议功能的特性
        /// 如:是AC功能:特性:on_off,mode,fan,temperature
        /// attri
        /// </summary>
        public List<FunctionAttributes> attributes = new List<FunctionAttributes>();
 
        /// <summary>
        /// 房间ID列表
        /// 该功能添加到到房间列表
        /// </summary>
        public List<string> roomIds = new List<string>();
 
        /// <summary>
        /// bus协议数据格式
        /// 使用A协议控制时,改属性为空
        /// </summary>
        public BusData bus;
        /// <summary>
        /// 是否收藏
        /// </summary>
        public bool collect = false;
        /// <summary>
        /// 是否在线
        /// </summary>
        public bool online = true;
        /// <summary>
        /// 云端数据创建的时间
        /// </summary>
        public string createTime = "";
        /// <summary>
        /// 云端数据修改的最后时间
        /// </summary>
        public string modifyTime = "";
        /// <summary>
        /// 删除标记
        /// 需要删除数据时,标记为:true
        /// 由云端删除成功之后,返回数据再清除本地数据
        /// </summary>
        public bool DeleteSign = false;
 
        #endregion
        /// <summary>
        /// 延时
        /// </summary>
        public int delay = 0;
        /// <summary>
        /// 最后控制的一次状态
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string lastState = "";
 
        FunctionAttributes _trait_on_off;
        [Newtonsoft.Json.JsonIgnore]
        public FunctionAttributes trait_on_off
        {
            get
            {
                if (_trait_on_off == null)
                {
                    _trait_on_off = attributes.Find((obj) => obj.key == FunctionAttributeKey.OnOff);
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_on_off == null)
                    {
                        _trait_on_off = new FunctionAttributes()
                        {
                            key = "on_off",
                            value = new List<string> { "on", "off" },
                            max = 1,
                            min = 0,
                        };
                        _trait_on_off.curValue = "off";
                    }
                }
                if(_trait_on_off.curValue.ToString() != "on"&& _trait_on_off.curValue.ToString() != "off" && _trait_on_off.curValue.ToString() != "stop")
                {
                    _trait_on_off.curValue = "off";
                }
                return _trait_on_off;
            }
        }
 
        /// <summary>
        /// 使用次数
        /// </summary>
        public double controlCounter = 0;
        /// <summary>
        /// 使用频率
        /// </summary>
        public double usageFrequency
        {
            get
            {
                return controlCounter / 7;
            }
        }
        /// <summary>
        /// 固定的序号
        /// </summary>
        public int fixedSerialNumber = int.MaxValue;
 
        /// <summary>
        /// 收藏功能
        /// </summary>
        public void CollectFunction()
        {
            var result = "";
            //var waitPage = new Loading();
 
            new System.Threading.Thread(() =>
            {
                if (collect)
                {
                    result = ApiUtlis.Ins.HttpRequest.CollectDevice(deviceId).Code;
                }
                else
                {
                    result = ApiUtlis.Ins.HttpRequest.CancelCollectDevice(deviceId).Code;
                }
                //提示错误
                if (result != StateCode.SUCCESS)
                {
                    Application.RunOnMainThread(() =>
                    {
                        collect = !collect;
                        IMessageCommon.Current.ShowErrorInfoAlter(result);
                    });
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 编辑功能绑定房间信息
        /// </summary>
        public void EditBindRoomInfo(string roomId)
        {
            var result = "";
 
            new System.Threading.Thread(() =>
            {
                if (collect)
                {
                    result = ApiUtlis.Ins.HttpRequest.BindDeviceToRoom(new List<string>() { deviceId }, new List<string>() { roomId }).Code;
                }
                else
                {
                    result = ApiUtlis.Ins.HttpRequest.UnbindDeviceToRoom(deviceId,roomId);
                }
                //提示错误
                if (result != StateCode.SUCCESS)
                {
                    Application.RunOnMainThread(() =>
                    {
                        collect = !collect;
                        IMessageCommon.Current.ShowErrorInfoAlter(result);
                    });
                }
            })
            { IsBackground = true }.Start();
        }
 
        public string GetBusId()
        {
            string busId = "";
            if (bus != null)
            {
                busId = bus.SubnetID + "_" + bus.DeviceID + "_" + bus.LoopId;
            }
            return busId;
        }
 
        /// <summary>
        /// 获取设备添加到房间的房间名称
        /// </summary>
        /// <returns></returns>
        public string GetRoomListName()
        {
            string roomNameList = "";
            foreach (var roomId in roomIds)
            {
                var findRoom = SpatialInfo.CurrentSpatial.RoomList.Find(obj => obj.roomId == roomId);
                if (findRoom == null)
                {
                    continue;
                }
                if (roomNameList != "")
                {
                    roomNameList += ",";
                }
                roomNameList += findRoom.floorName +"-"+ findRoom.roomName;
            }
            if (roomNameList == "" )
            {
                roomNameList = Language.StringByID(StringId.WholeZone);
            }
            return roomNameList;
        }
        /// <summary>
        /// 数据存储文件名
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string savePath
        {
            get
            {
                return "FunctionData_" + sid;
            }
        }
 
        /// <summary>
        /// 保存功能文件
        /// </summary>
        public void SaveFunctionFile()
        {
            var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
            FileUtlis.Files.WriteFileByBytes(savePath, ssd);
        }
        /// <summary>
        /// 保存房间绑定信息
        /// </summary>
        public void UpdataRoomIds()
        {
            new System.Threading.Thread(() =>
            {
                var pack = ApiUtlis.Ins.HttpRequest.UpdataDevcieBindRoomInfo(this);
                //直接保存本地,
                SaveFunctionFile();
                if (pack.Code == StateCode.SUCCESS)
                {
                }
                else
                {
                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 更新功能信息
        /// </summary>
        public void UpdataFuncitonInfo()
        {
            new System.Threading.Thread(() =>
            {
                var pm = new HttpServerRequest();
                var pack = pm.UpdataDevcieInfo(this);
                SaveFunctionFile();
                if (pack.Code == StateCode.SUCCESS)
                {
                }
                else
                {
                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 更新功能名称
        /// </summary>
        public void UpdataFunctionName()
        {
            new System.Threading.Thread(() =>
            {
                var pm = new HttpServerRequest();
                var pack = pm.UpdataDevcieInfo(this);
                SaveFunctionFile();
                if (pack.Code == StateCode.SUCCESS)
                {
                }
                else
                {
                    IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 保存功能数据
        /// </summary>
        //public void SaveFunctionData(bool upSevser)
        //{
        //    if (upSevser)
        //    {
        //        new System.Threading.Thread(() =>
        //        {
        //            var pm = new HttpServerRequest();
        //            var pack = pm.UpdataDevcieInfo(this);
        //            if (pack.Code == StateCode.SUCCESS)
        //            {
        //                var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
        //                FileUtlis.Files.WriteFileByBytes(savePath, ssd);
        //            }
        //            else
        //            {
        //                IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
        //            }
        //        })
        //        { IsBackground = true }.Start();
        //    }
        //    else
        //    {
        //        var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
        //        FileUtlis.Files.WriteFileByBytes(savePath, ssd);
        //    }
        //}
 
 
        /// <summary>
        /// 转换成场景功能对象
        /// </summary>
        /// <returns></returns>
        public SceneFunction ConvertSceneFunction()
        {
            var sFunc = new SceneFunction();
            foreach (var attr in attributes)
            {
                switch (attr.key)
                {
                    case FunctionAttributeKey.OnOff:
                    case FunctionAttributeKey.Brightness:
                    case FunctionAttributeKey.Mode:
                    case FunctionAttributeKey.SetTemp:
                    case FunctionAttributeKey.FanSpeed:
                    case FunctionAttributeKey.Percent:
                    //case FunctionAttributeKey.FadeTime:
                        if (attr.curValue.ToString() == "{}")
                        {
                            if (attr.key == FunctionAttributeKey.OnOff)
                            {
                                attr.curValue = "off";
                            }
                            else
                            {
                                attr.curValue = "0";
                            }
                        }
                        if (attr.key == FunctionAttributeKey.SetTemp)
                        {
                            double vv = 16;
                            Double.TryParse(attr.curValue.ToString(), out vv);
                            sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = Convert.ToInt32(vv).ToString() });
                        }
                        else
                        {
                            sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() });
                        }
                        break;
                }
            }
            sFunc.sid = this.sid;
            return sFunc;
        }
 
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime refreshTime = DateTime.MinValue;
 
        /// <summary>
        /// 获取本地控制数据
        /// </summary>
        public AlinkFunctionStatusObj GetGatewayAlinkControlData(Dictionary<string, string> commandDictionary)
        {
            var sendDataObj = new AlinkFunctionStatusObj();
            sendDataObj.id = Control.Ins.msg_id.ToString();
            sendDataObj.time_stamp = Control.Ins.Get_TimeStamp();
 
 
            var acd = new AlinkControlData();
            acd.sid = sid;
            foreach (var dic in commandDictionary)
            {
                var aca = new AlinkControlAttributes();
                aca.key = dic.Key;
                aca.value = dic.Value;
                acd.status.Add(aca);
            }
 
            sendDataObj.objects.Add(acd);
 
            return sendDataObj;
        }
        /// <summary>
        /// 获取Api控制数据
        /// </summary>
        /// <returns></returns>
        public ApiAlinkControlActionObj GetApiControlData(Dictionary<string, string> keyValues)
        {
            ApiAlinkControlActionObj aaao = new ApiAlinkControlActionObj();
            aaao.deviceId = this.deviceId;
            aaao.spk = this.spk;
            aaao.bus = this.bus;
            foreach (var kv in keyValues)
            {
                aaao.attributes.Add(new AlinkControlAttributes()
                {
                    key = kv.Key,
                    value = kv.Value,
                });
            }
            return aaao;
        }
    }
 
    /// <summary>
    /// 远程控制
    /// api a协议控制动作对象
    /// </summary>
    public class ApiAlinkControlActionObj
    {
        /// <summary>
        /// 设备ID
        /// </summary>
        public string deviceId = "0";
        /// <summary>
        /// spk
        /// 列:light.switch
        /// </summary>
        public string spk = "";
 
        public List<AlinkControlAttributes> attributes = new List<AlinkControlAttributes>();
        //[Newtonsoft.Json.JsonIgnore]
        public BusData bus = new BusData();
    }
 
    /// <summary>
    /// A协议控制数据的对象
    /// </summary>
    public class AlinkFunctionStatusObj
    {
        public List<AlinkControlData> objects = new List<AlinkControlData>();
 
        public string time_stamp = "";
        public string id = "";
    }
    /// <summary>
    /// 本地状态读取
    /// A协议状态读取格式对象
    /// </summary>
    public class AlinkReadFunctionStatusObj
    {
        public string id = "0";
        public List<Dictionary<string, string>> objects = new List<Dictionary<string, string>>();
        public string time_stamp = "";
    }
    /// <summary>
    /// A协议控制数据
    /// </summary>
    public class AlinkControlData
    {
        public string sid = "";
        public List<AlinkControlAttributes> status = new List<AlinkControlAttributes>();
    }
    /// <summary>
    /// a协议控制动作数据
    /// </summary>
    public class AlinkControlAttributes
    {
        /// <summary>
        /// 属性名
        /// 列:on_off
        /// </summary>
        public string key = "";
        /// <summary>
        /// 属性值
        /// 列:on
        /// </summary>
        public string value = "";
    }
 
    /// <summary>
    /// 功能属性
    /// 属性字段解析:attri :属性内容,value 属性的值,max 最大值 min 最小值
    /// </summary>
    [System.Serializable]
    public class FunctionAttributes
    {
        /// <summary>
        /// 属性键名
        /// </summary>
        public string key;
        /// <summary>
        /// 属性的值列表
        /// </summary>
        public List<string> value = new List<string>();
        /// <summary>
        /// 最大值
        /// </summary>
        public int max = 100;
        /// <summary>
        /// 最小值
        /// </summary>
        public int min = 0;
        /// <summary>
        /// 数据类型
        /// </summary>
        public string data_type = "";
        /// <summary>
        /// 当前值
        /// </summary>
        public object curValue = new object();
        /// <summary>
        /// curValue的翻译值,最坏的结果也只会返回string.Empty
        /// </summary>
        public string realValue
        {
            get
            {
                var myValue = curValue.ToString();
                //沙雕定义的object类型
                if (myValue.Contains("{") == true) { return string.Empty; }
                return myValue;
            }
        }
    }
    /// <summary>
    /// 功能属性键名列表
    /// </summary>
    public static class FunctionAttributeKey
    {
        /// <summary>
        /// 开关
        /// </summary>
        public const string OnOff = "on_off";
        /// <summary>
        /// 亮度
        /// </summary>
        public const string Brightness = "brightness";
        /// <summary>
        /// 颜色
        /// </summary>
        public const string RGB = "rgb";
        /// <summary>
        /// 渐变时间
        /// </summary>
        public const string FadeTime = "fade_time";
        /// <summary>
        /// 模式
        /// </summary>
        public const string Mode = "mode";
        /// <summary>
        /// 风速
        /// </summary>
        public const string FanSpeed = "fan";
        /// <summary>
        /// 设置温度
        /// </summary>
        public const string SetTemp = "set_temp";
        /// <summary>
        /// 延时
        /// </summary>
        public const string Delay = "delay";
        /// <summary>
        /// 色温
        /// </summary>
        public const string CCT = "cct";
        /// <summary>
        /// 百分比
        /// </summary>
        public const string Percent = "percent";
        /// <summary>
        /// 室内温度
        /// </summary>
        public const string IndoorTemp = "room_temp";
        /// <summary>
        /// value
        /// </summary>
        public const string Value = "value";
    }
    /// <summary>
    /// 设备功能oid
    /// </summary>
    public class FunctionOid
    {
        public string oid;
        public string name;
        public string machine_id;
        public string net_id;
        public string dev_id;
        public string channels;
    }
 
    /// <summary>
    /// 兼容旧协议控制
    /// </summary>
    public class BusData
    {
        public string addresses = "FFFF";
        [Newtonsoft.Json.JsonIgnore]
        public byte SubnetID
        {
            get
            {
                return Convert.ToByte(addresses.Substring(0, 2), 16);
            }
        }
        [Newtonsoft.Json.JsonIgnore]
        public byte DeviceID
        {
            get
            {
                return Convert.ToByte(addresses.Substring(2, 2), 16);
            }
        }
        public byte LoopId
        {
            get
            {
                return Convert.ToByte(loopId, 16);
            }
        }
 
        public string loopId;
    }
 
    public static class SPK
    {
        /// <summary>
        /// (开关灯)
        /// </summary>
        public const string LightSwitch = "light.switch";
        /// <summary>
        /// (调光灯)
        /// </summary>
        public const string LightDimming = "light.dimming";
        /// <summary>
        /// (RGB灯)
        /// </summary>
        public const string LightRGB = "light.rgb";
        /// <summary>
        /// (RGBW灯)
        /// </summary>
        public const string LightRGBW = "light.rgbw";
        /// <summary>
        /// (CCT灯)
        /// </summary>
        public const string LightCCT = "light.cct";
        /// <summary>
        /// (开关窗帘)
        /// </summary>
        public const string CurtainSwitch = "curtain.switch";
        /// <summary>
        /// (开合帘)
        /// </summary>
        public const string CurtainTrietex = "curtain.trietex";
        /// <summary>
        /// (百叶帘)
        /// </summary>
        public const string CurtainShades = "curtain.shades";
        /// <summary>
        /// (卷帘)
        /// </summary>
        public const string CurtainRoller = "curtain.roller";
        /// <summary>
        /// (空调)
        /// </summary>
        public const string AcStandard = "ac.standard";
        /// <summary>
        /// (地热)
        /// </summary>
        public const string FloorHeatStandard = "floorHeat.standard";
        /// <summary>
        /// (新风)
        /// </summary>
        public const string AirFreshStandard = "airFresh.standard";
        /// <summary>
        /// (音乐)
        /// </summary>
        public const string MusicStandard = "music.standard";
        /// <summary>
        /// (亮度传感器)
        /// </summary>
        public const string SensorLight = "sensor.light";
        /// <summary>
        /// (温度传感器)
        /// </summary>
        public const string SensorTemperature = "sensor.temperature";
        /// <summary>
        /// (红外移动传感器)
        /// </summary>
        public const string SensorPir = "sensor.pir";
        /// <summary>
        /// (门窗传感器)
        /// </summary>
        public const string SensorDoorWindow = "sensor.doorwindow";
        /// <summary>
        /// (PM2.5传感器)
        /// </summary>
        public const string SensorPm25 = "sensor.pm25";
        /// <summary>
        /// co2传感器
        /// </summary>
        public const string SensorCO2 = "sensor.co2";
        /// <summary>
        /// tvoc传感器
        /// </summary>
        public const string SensorTVOC = "sensor.tvoc";
        /// <summary>
        /// 湿度传感器
        /// </summary>
        public const string SensorHumidity = "sensor.humidity";
 
        /// <summary>
        /// 烟雾传感器
        /// </summary>
        public const string SensorSmoke = "sensor.smoke";
        /// <summary>
        /// 水浸传感器
        /// </summary>
        public const string SensorWater = "sensor.water";
        /// <summary>
        /// 燃气传感器
        /// </summary>
        public const string SensorGas= "sensor.gas";
        /// <summary>
        /// 红外珊栏传感器      
        /// </summary>
        public const string SensorShanLan = "sensor.shanlan";
        /// <summary>
        /// 红外对射传感器
        /// </summary>
        public const string SensorDuiShe = "sensor.duishe";
        /// <summary>
        /// 超声波传感器
        /// </summary>
        public const string SensoruUtrasonic = "sensor.ultrasonic";
 
        /// <summary>
        /// (干接点)
        /// </summary>
        public const string SensorDryContact = "sensor.dryContact";
        /// <summary>
        /// 家电、插座
        /// </summary>
        public const string ElectricSocket = "electrical.socket";
        /// <summary>
        /// 家电、电视
        /// </summary>
        public const string ElectricTV = "electrical.tv";
        /// <summary>
        /// 家电、风扇
        /// </summary>
        public const string ElectricFan = "electrical.fan";
        /// <summary>
        /// 家电、涂鸦空气净化器
        /// </summary>
        public const string ElectricTuyaAirCleaner = "electrical.Q1RsefNf91tIXyyQ";
        /// <summary>
        /// 家电、涂鸦电风扇
        /// </summary>
        public const string ElectricTuyaFan = "electrical.tyqborgovyzytytz";
        /// <summary>
        /// 家电、涂鸦扫地机器人
        /// </summary>
        public const string ElectricTuyaWeepRobot = "electrical.ai6HtccKFIw3dxo3";
        /// <summary>
        /// 家电、涂鸦水阀
        /// </summary>
        public const string ElectricTuyaWaterValve = "electrical.koiGhMKwLf2ZP81g";
 
    }
 
 
    /// <summary>
    /// 功能类别
    /// </summary>
    public static class FunctionCategory
    {
        /// <summary>
        ///(灯)
        /// </summary>
        public const string Light = "light";
        /// <summary>
        /// (窗帘)
        /// </summary>
        public const string Curtain = "curtain";
        /// <summary>
        /// (空调)
        /// </summary>
        public const string AC = "ac";
        /// <summary>
        /// (地热)
        /// </summary>
        public const string FloorHeat = "floorHeat";
        /// <summary>
        /// (新风)
        /// </summary>
        public const string AirFresh = "airFresh";
        /// <summary>
        /// (音乐)
        /// </summary>
        public const string Music = "music";
        /// <summary>
        /// (传感器)
        /// </summary>
        public const string Sensor = "sensor";
        /// <summary>
        /// (干接点)
        /// </summary>
        public const string DryContact = "dryContact";
        /// <summary>
        /// 家电
        /// </summary>
        public const string Electric = "electrical";
 
        //Music = 0x09,
    }
 
 
}