HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-09-22 ade5917841b0fdcb1df7353ef7c56b1a1bdc9282
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
using Shared.Phone.UserCenter;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.ModelData
{
    #region ■ 共通模板数据定义___________________
 
    /// <summary>
    /// 模板缓存数据
    /// </summary>
    public class ModelMemoryData
    {
        /// <summary>
        /// 全部的缓存数据
        /// </summary>
        public Dictionary<string, List<ModelDeviceDataCommon>> dicAllData = new Dictionary<string, List<ModelDeviceDataCommon>>();
    }
 
    /// <summary>
    /// 一个设备的模板数据的共通
    /// </summary>
    public class ModelDeviceDataCommon
    {
        /// <summary>
        /// 设备Mac地址
        /// </summary>
        public string DeviceMac = string.Empty;
        /// <summary>
        /// 设备端点
        /// </summary>
        public int DeviceEpoint = -1;
        /// <summary>
        /// 数据保存的区分(不需要再次设置)
        /// </summary>
        public ModelDeviceSaveEnum DataSaveDiv = ModelDeviceSaveEnum.A未定义;
        /// <summary>
        /// 发送模板数据的区分,用以标识是以什么方式发送给网关(需要再次指定)
        /// </summary>
        public ModelDataSendEnum DataSendDiv = ModelDataSendEnum.A未定义;
        /// <summary>
        /// 数据发送成功的返回标识(此变量是给【透传数据】使用,借以让网关知道透传之后,怎么判断成功)
        /// </summary>
        public string SuccessFlage = string.Empty;
        /// <summary>
        /// 主题名字(需要再次指定)
        /// </summary>
        public string TopicName = string.Empty;
 
        /// <summary>
        /// 获取更改设备配置的命令字符(因为有些东西需要考虑镞ID,所以有可能会出现多条命令)
        /// </summary>
        /// <returns></returns>
        public virtual List<string> GetSendGatewayValue()
        {
            return new List<string>();
        }
    }
 
    #endregion
 
    #region ■ 窗帘模板数据定义___________________
 
    /// <summary>
    /// 窗帘手拉控制模板定义
    /// </summary>
    public class ModelCurtainHandPullControl : ModelDeviceDataCommon
    {
        /// <summary>
        /// 状态
        /// </summary>
        public bool Statu = false;
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            var command = HdlDeviceCurtainLogic.Current.GetHandPullControlText(DeviceMac, DeviceEpoint, Statu);
            return new List<string>() { command };
        }
    }
 
    /// <summary>
    /// 窗帘手拉控制模板定义
    /// </summary>
    public class ModelCurtainDirectionAndLimite : ModelDeviceDataCommon
    {
        /// <summary>
        /// false:电机方向正向;true:电机方向反向
        /// </summary>
        public bool Direction = false;
        /// <summary>
        /// 开限位
        /// </summary>
        public int upLimit = 2;
        /// <summary>
        /// 合限位
        /// </summary>
        public int downLimit = 98;
        /// <summary>
        /// 导轨长度
        /// </summary>
        public int curtainLength = 100;
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            //方向
            var command1 = HdlDeviceCurtainLogic.Current.GetCurtainDirectionCommadText(DeviceMac, DeviceEpoint, Direction);
            //限位
            var command2 = HdlDeviceCurtainLogic.Current.GetAutoOpenCurtainLimitPointCommandText(DeviceMac, DeviceEpoint, upLimit, downLimit);
            return new List<string>() { command1, command2 };
        }
    }
 
    #endregion
 
    #region ■ 空调模板数据定义___________________
 
    /// <summary>
    /// 空调自定义模式模板数据定义
    /// </summary>
    public class ModelAcModeSupport : ModelDeviceDataCommon
    {
        /// <summary>
        /// 值
        /// </summary>
        public int data = 0;
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            var command = HdlDeviceAttributeLogic.Current.GetWriteDeviceAttributeText(DeviceMac, DeviceEpoint, 513, 4099, 25, data);
            return new List<string>() { command };
        }
    }
 
    /// <summary>
    /// 空调摆风模式模板数据定义
    /// </summary>
    public class ModelAcSwingModeSupport : ModelDeviceDataCommon
    {
        /// <summary>
        /// 值
        /// </summary>
        public int data = 0;
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            var command = HdlDeviceAttributeLogic.Current.GetWriteDeviceAttributeText(DeviceMac, DeviceEpoint, 513, 4099, 25, data);
            return new List<string>() { command };
        }
    }
 
    #endregion
 
    #region ■ 设备绑定模板数据定义_______________
 
    /// <summary>
    /// 设备绑定模板数据定义
    /// </summary>
    public class ModelDeviceBindData : ModelDeviceDataCommon
    {
        /// <summary>
        /// 按键的功能模式
        /// </summary>
        public ZigBee.Device.Panel.KeyMode keyMode = ZigBee.Device.Panel.KeyMode.Default;
        /// <summary>
        /// 按键的功能模式的镞ID
        /// </summary>
        public int keyModeClusterID = 0;
        /// <summary>
        /// 按键的功能模式的主题
        /// </summary>
        public string TopicName2 = string.Empty;
        /// <summary>
        /// 绑定列表
        /// </summary>
        public List<ZigBee.Device.BindObj.BindListResponseObj> BindList = new List<ZigBee.Device.BindObj.BindListResponseObj>();
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            var addBindData = new ZigBee.Device.BindObj.AddBindData();
            addBindData.DeviceAddr = this.DeviceMac;
            addBindData.Epoint = this.DeviceEpoint;
 
            foreach (var data in BindList)
            {
                var addData = new ZigBee.Device.BindObj.AddBindListObj();
                addBindData.BindList.Add(addData);
                addData.BindCluster = data.BindCluster;
                addData.BindEpoint = data.BindEpoint;
                addData.BindMacAddr = data.BindMacAddr;
                addData.BindScenesId = data.BindScenesId;
                addData.BindType = data.BindType == 0 ? 0 : 1;
            }
            //功能配置
            var command1 = HdlDeviceBindLogic.Current.GetConfigureHdlKeyCommandText(this.DeviceMac, this.DeviceEpoint, keyMode, keyModeClusterID);
            //绑定列表
            var command2 = HdlDeviceBindLogic.Current.GetAddDeviceListBindCommandText(addBindData);
            return new List<string>() { command1, command2 };
        }
    }
 
    #endregion
 
    #region ■ Pir传感器模板数据定义______________
 
    /// <summary>
    /// Pir传感器模板数据定义
    /// </summary>
    public class ModelPirSensorSettion : ModelDeviceDataCommon
    {
        /// <summary>
        /// pir的配置信息
        /// </summary>
        public ZigBee.Device.IASZone.ConfigureParamates pirConfigure = new ZigBee.Device.IASZone.ConfigureParamates();
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            var command = HdlDevicePirSensorLogic.Current.GetPirSensorSettionCommandText(DeviceMac, pirConfigure);
            return new List<string>() { command };
        }
    }
 
    #endregion
 
    #region ■ 面板模板数据定义___________________
 
    /// <summary>
    /// 面板震动功能模板数据定义
    /// </summary>
    public class ModelPanelVibrationInfo : ModelDeviceDataCommon
    {
        /// <summary>
        /// 震动功能
        /// </summary>
        public HdlDevicePanelLogic.PanelVibrationInfo vibrationInfo = new HdlDevicePanelLogic.PanelVibrationInfo();
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            var command = HdlDevicePanelLogic.Current.GetPanelVibrationCommandText(DeviceMac, vibrationInfo);
            return new List<string>() { command };
        }
    }
 
    /// <summary>
    /// 面板背光灯模板数据定义
    /// </summary>
    public class ModelPanelBackLightInfo : ModelDeviceDataCommon
    {
        /// <summary>
        /// 亮度调节的信息
        /// </summary>
        public ModelPanelSwitchLevelInfo linghtLevelInfo = new ModelPanelSwitchLevelInfo();
        /// <summary>
        /// 节能模式
        /// </summary>
        public ZigBee.Device.Panel.PanelSaveEnergyModeInfo energyModeInfo = new ZigBee.Device.Panel.PanelSaveEnergyModeInfo();
        /// <summary>
        /// 按键的颜色数据
        /// </summary>
        public ZigBee.Device.Panel.KeyColorData keyColorData = new ZigBee.Device.Panel.KeyColorData();
        /// <summary>
        /// 和keyColorData一起用的东西
        /// </summary>
        public ZigBee.Device.Panel.KeyNumStatus KeyNum = new ZigBee.Device.Panel.KeyNumStatus();
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            //亮度调节
            var command1 = HdlDevicePanelLogic.Current.GetPanelLevelCommadText(DeviceMac, linghtLevelInfo.panelDirectionsLevel, linghtLevelInfo.panelBacklightLevel);
            //节能模式
            var command2 = HdlDevicePanelLogic.Current.GetDeviceEnergyConservationModeCommandText(DeviceMac, energyModeInfo.enable, energyModeInfo.time, energyModeInfo.level);
            return new List<string>() { command1, command2 };
        }
    }
 
    /// <summary>
    /// 按键指示灯面板开关亮度配置回复
    /// </summary>
    public class ModelPanelSwitchLevelInfo
    {
        /// <summary>
        ///按键开状态(指示)亮度(这个是点击后的值)
        /// </summary>
        public int panelDirectionsLevel = -1;
 
        /// <summary>
        /// 按键关状态(背光)亮度(这个是点击前的值)
        /// </summary>
        public int panelBacklightLevel = -1;
    }
 
    #endregion
 
    #region ■ 设备名称模板数据定义_______________
 
    /// <summary>
    /// 设备端点名称模板数据定义
    /// </summary>
    public class ModelDeviceEpointNameInfo : ModelDeviceDataCommon
    {
        /// <summary>
        /// 设备端点名称
        /// </summary>
        public string deviceEpointName = string.Empty;
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            var command = Common.LocalDevice.Current.GetReDeviceEpointNameCommandText(DeviceMac, DeviceEpoint, deviceEpointName);
            return new List<string>() { command };
        }
    }
 
    /// <summary>
    /// 设备Mac名称模板数据定义
    /// </summary>
    public class ModelDeviceMacNameInfo : ModelDeviceDataCommon
    {
        /// <summary>
        /// 设备Mac名称
        /// </summary>
        public string deviceMacName = string.Empty;
        /// <summary>
        /// 获取更改设备配置的命令字符
        /// </summary>
        /// <returns></returns>
        public override List<string> GetSendGatewayValue()
        {
            var command = Common.LocalDevice.Current.GetReDeviceMacNameCommandText(DeviceMac, DeviceEpoint, deviceMacName);
            return new List<string>() { command };
        }
    }
 
    #endregion
 
    #region ■ 自定义枚举_________________________
 
    /// <summary>
    /// 模板设备保存的区分
    /// </summary>
    public enum ModelDeviceSaveEnum
    {
        A未定义 = -1,
        A设备名称 = 1,
        A端点名称 = 2,
        APir配置 = 3,
        A干接点颜色调节 = 4,
        A干接点亮度调节 = 5,
        A干接点节能模式 = 6,
        A干接点第三级别私有属性 = 7,
        A窗帘方向及限位 = 8,
        A窗帘手拉控制 = 9,
        A空调自定义模式 = 10,
        A面板震动功能 = 11,
        A空调摆风功能 = 12,
        A面板接近感应功能 = 13,
        A设备绑定列表 = 14,
        A面板背光灯 = 15
    }
 
    /// <summary>
    /// 发送模板数据的区分
    /// </summary>
    public enum ModelDataSendEnum
    {
        A未定义 = -1,
        A私有属性 = 1,
        A私有协议 = 2,
        A透传数据 = 3
    }
 
    #endregion
}