| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Threading.Tasks; |
| | | using MQTTnet; |
| | | using Newtonsoft.Json.Linq; |
| | | using Shared.Common; |
| | | |
| | | namespace ZigBee.Device |
| | | { |
| | |
| | | /// <summary> |
| | | /// 按键模式(私有功能) |
| | | /// </summary> |
| | | public int panelMode = -1; |
| | | public int panelMode = 65535; |
| | | /// <summary> |
| | | ///按键开状态(指示)亮度 |
| | | /// </summary> |
| | |
| | | public int panelBacklightLevel = -1; |
| | | |
| | | /// <summary> |
| | | /// 当前选择模式 |
| | | /// </summary> |
| | | public string currentKeySelectModeText = ""; |
| | | /// <summary> |
| | | /// 当前选择的楼层ID |
| | | /// </summary> |
| | | public string currentSelectFloorId = string.Empty; |
| | | /// <summary> |
| | | /// 当前开关模式 |
| | | /// </summary> |
| | | public string CurrentSwitchMode = ""; |
| | | /// <summary> |
| | | /// 当前属性模式 |
| | | /// </summary> |
| | | public int currentClusterID; |
| | | |
| | | /// <summary> |
| | | /// 当前调光模式 |
| | | /// </summary> |
| | | public string CurrentDimmerMode = ""; |
| | | |
| | | /// <summary> |
| | | /// 当前遮阳模式 |
| | | /// </summary> |
| | | public string CurrentCurtainMode = ""; |
| | | |
| | | /// <summary> |
| | | /// 当前房间ID |
| | | /// </summary> |
| | | public string RoomId = ""; |
| | | |
| | | /// <summary> |
| | | /// 当前房间ID |
| | | /// </summary> |
| | | public string curSelectSceneID = ""; |
| | | |
| | | /// <summary> |
| | | /// 本地楼层房间绑定列表 |
| | | /// </summary> |
| | | public Dictionary<int, FloorRoomBindObj> FloorRoomBindObjList = new Dictionary<int, FloorRoomBindObj> { }; |
| | | /// <summary> |
| | | /// 绑定的楼层房间信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class FloorRoomBindObj |
| | | { |
| | | /// <summary> |
| | | /// 楼层ID |
| | | /// </summary> |
| | | public string floodID; |
| | | /// <summary> |
| | | /// 楼层名称 |
| | | /// </summary> |
| | | public string floodName; |
| | | /// <summary> |
| | | /// 房间ID |
| | | /// </summary> |
| | | public string roomID; |
| | | /// <summary> |
| | | /// 房间名称 |
| | | /// </summary> |
| | | public string roomName; |
| | | /// <summary> |
| | | /// 绑定目标ID |
| | | /// </summary> |
| | | public string BindID; |
| | | /// <summary> |
| | | /// 绑定目标名称 |
| | | /// </summary> |
| | | public string BindName; |
| | | /// <summary> |
| | | /// 图片路径 |
| | | /// </summary> |
| | | public string IconPath = ""; |
| | | |
| | | } |
| | | |
| | | // <summary> |
| | | /// 按键中被绑定的目标列表 |
| | | /// </summary> |
| | | public System.Collections.Generic.List<BindListResponseObj> bindList = new System.Collections.Generic.List<BindListResponseObj> { }; |
| | | |
| | | /// <summary> |
| | | /// 按键支持的私有模式列表 |
| | | /// </summary> |
| | | public System.Collections.Generic.List<string> priFunList = new System.Collections.Generic.List<string> { }; |
| | | public System.Collections.Generic.Dictionary<int, string> priDeviceModeFunList = new System.Collections.Generic.Dictionary<int, string> { };
|
| | | |
| | | /// <summary> |
| | | /// 私有功能类 |
| | | /// <para>256:Key,按键类类 </para> |
| | | /// <para>768:PIR,PIR类</para> |
| | | /// <para>1024:Light,灯类</para> |
| | | /// </summary> |
| | | public List<int> privateFuncFirstLevelList = new List<int>(); |
| | | |
| | | /// <summary> |
| | | /// 第二级信息 |
| | | /// <para>1:特殊功能</para> |
| | | /// <para>100:Switch,开关(按键类)</para> |
| | | /// <para>200:Dimmer,调光(按键类)</para> |
| | | /// <para>300:Curtain,窗帘(按键类)</para> |
| | | /// <para>0:EnergySavingMode,节能模式(灯类)</para> |
| | | /// <para>1:SleepMode,睡眠模式(灯类)</para> |
| | | /// <para>100:WhiteBalance,白平衡(灯类)</para> |
| | | /// <para>101:RGBColor,RGB指示灯颜色(灯类)</para> |
| | | /// <para>102:RGBLevel,RGB指示灯亮度(灯类)</para> |
| | | /// </summary> |
| | | public List<int> privateFuncSecondLevelList = new List<int>(); |
| | | |
| | | /// <summary> |
| | | /// 第三级信息 |
| | | /// <para>1:场景触发(特殊功能)</para> |
| | | /// <para>65535:禁止发送功能(特殊功能)</para> |
| | | /// <para>100:SwitchOpen,开关开(按键类)</para> |
| | | /// <para>101:SwitchClose,开关关(按键类)</para> |
| | | /// <para>102:SwitchChange,开关切换(按键类)</para> |
| | | /// <para>200:DimmerStepUp,增大调光(按键类)</para> |
| | | /// <para>201:DimmerStepDown,降低调光(按键类)</para> |
| | | /// <para>202:DimmerStepChange,调光切换(按键类)</para> |
| | | /// <para>300:CurtainOpen,窗帘开(按键类)</para> |
| | | /// <para>301:CurtainClose,窗帘关(按键类)</para> |
| | | /// <para>302:CurtainStop,窗帘停</para> |
| | | /// <para>303:CurtainUpStop,窗帘上升停</para> |
| | | /// <para>304:CurtainDownstop,窗帘下降停</para> |
| | | /// </summary> |
| | | public List<int> privateFuncThirdLevelList = new List<int>(); |
| | | #region 获取面板的私有信息. |
| | | /// <summary> |
| | | ///获取面板的私有信息 |
| | |
| | | { |
| | | int curIndex = 4 * j; |
| | | tempD.privateFuncTypeLevelFirstList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //if (privateFuncFirstLevelList.Contains(256) == false) |
| | | //{ |
| | | // privateFuncFirstLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | |
| | | //} |
| | | } |
| | | break; |
| | | case 2: |
| | |
| | | if (j == 0) |
| | | { |
| | | tempD.privateFuncTypeLevelFirstList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //if (privateFuncFirstLevelList.Contains(256) == false) |
| | | //{ |
| | | // privateFuncFirstLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | tempD.privateFuncTypeLevelSecondList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //if (privateFuncSecondLevelList.Contains(1) == false || privateFuncSecondLevelList.Contains(100) == false || privateFuncSecondLevelList.Contains(200) == false || privateFuncSecondLevelList.Contains(300) == false) |
| | | //{ |
| | | // privateFuncSecondLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //} |
| | | } |
| | | |
| | | } |
| | | break; |
| | | case 3: |
| | |
| | | if (j == 0) |
| | | { |
| | | tempD.privateFuncTypeLevelFirstList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //if (privateFuncFirstLevelList.Contains(256) == false) |
| | | //{ |
| | | // privateFuncFirstLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //} |
| | | } |
| | | else if (j == 1) |
| | | { |
| | | tempD.privateFuncTypeLevelSecondList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //if (privateFuncSecondLevelList.Contains(1) == false || privateFuncSecondLevelList.Contains(100) == false || privateFuncSecondLevelList.Contains(200) == false || privateFuncSecondLevelList.Contains(300) == false) |
| | | //{ |
| | | // privateFuncSecondLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //} |
| | | } |
| | | else |
| | | { |
| | | tempD.privateFuncTypeLevelThirdList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); |
| | | //if (privateFuncThirdLevelList.Contains(1) == false || privateFuncThirdLevelList.Contains(65535) == false || privateFuncThirdLevelList.Contains(100) == false || privateFuncThirdLevelList.Contains(101) == false || privateFuncThirdLevelList.Contains(102) == false || privateFuncThirdLevelList.Contains(200) == false || privateFuncThirdLevelList.Contains(201) == false || privateFuncThirdLevelList.Contains(202) == false || privateFuncThirdLevelList.Contains(300) == false || privateFuncThirdLevelList.Contains(301) == false || privateFuncThirdLevelList.Contains(302) == false || privateFuncThirdLevelList.Contains(303) == false || privateFuncThirdLevelList.Contains(304) == false) |
| | | //{ |
| | | // privateFuncThirdLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); ; |
| | | //} |
| | | } |
| | | } |
| | | break; |
| | |
| | | |
| | | try |
| | | { |
| | | OpenPassthroughControl(Gateway); |
| | | var passData = SendPanelPrivateFunctions(args); |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; |
| | | var data = new JObject { { "PassData", passData } }; |
| | | jObject.Add("Data", data); |
| | | jObject.Add("Data", data);
|
| | | Gateway.Send("ClientDataPassthrough", jObject.ToString()); |
| | | } |
| | | catch { } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// PIR配置参数回复 |
| | | /// 配置参数回复 |
| | | /// </summary> |
| | | public PanelPrivateFunctionsResponseInfo panelPrivateFunctionsResponseInfo; |
| | | [System.Serializable] |
| | |
| | | /// <para>2:第二级别</para> |
| | | /// <para>3:第三级别</para> |
| | | /// </summary> |
| | | public int funLevel = -1; |
| | | |
| | | public int funLevel = -1;
|
| | |
|
| | | /// <summary> |
| | | /// 私有功能类 |
| | | /// <para>256:Key,按键类类 </para> |
| | |
| | | /// <para>303:CurtainUpStop,窗帘上升停</para> |
| | | /// <para>304:CurtainDownstop,窗帘下降停</para> |
| | | /// </summary> |
| | | public List<int> privateFuncTypeLevelThirdList = new List<int>(); |
| | | |
| | | public List<int> privateFuncTypeLevelThirdList = new List<int>();
|
| | |
|
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | string addDataLength = ""; |
| | | string value0 = ""; |
| | | string value1 = ""; |
| | | string value2 = ""; |
| | | string value2 = "";
|
| | | try |
| | | { |
| | | |
| | |
| | | { |
| | | dataLength = string.Concat(0, 2 * args.Length + 5); |
| | | } |
| | | else |
| | | { |
| | | else
|
| | | {
|
| | | dataLength = Convert.ToString(2 * args.Length + 5, 16); |
| | | } |
| | | |
| | | |
| | | }
|
| | |
|
| | |
|
| | | if (Convert.ToString(2 * args.Length, 16).Length == 1) |
| | | { |
| | | addDataLength = string.Concat(0, 2 * args.Length + 1); |
| | | } |
| | | else |
| | | { |
| | | {
|
| | | addDataLength = Convert.ToString(2 * args.Length + 1, 16); |
| | | } |
| | | |
| | |
| | | switch (args.Length) |
| | | { |
| | | case 1: |
| | | value0 = "02"; |
| | | value0 = "02";
|
| | | switch (args[0]) |
| | | { |
| | | case 1024: |
| | |
| | | case 768: |
| | | value1 = "0003"; |
| | | break; |
| | | } |
| | | |
| | | break; |
| | | } |
| | | }
|
| | |
|
| | | break;
|
| | | }
|
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | }
|
| | | else
|
| | | {
|
| | | dataLength = "05"; |
| | | addDataLength = "01"; |
| | | value0 = "01"; |
| | |
| | | data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + |
| | | value0 + value1 + value2; |
| | | } |
| | | catch { }; |
| | | |
| | | catch { };
|
| | |
|
| | | return data; |
| | | } |
| | | |
| | |
| | | /// <para>768:PIR,PIR类</para> |
| | | /// <para>1024:Light,灯类</para> |
| | | /// </summary> |
| | | public int privateFuncTypeOne; |
| | | public int privateFuncTypeOne;
|
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <para>102:RGBLevel,RGB指示灯亮度(灯类)</para> |
| | | /// </summary> |
| | | public int privateFuncTypeTwo; |
| | | } |
| | | |
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 私有功能类(第三级别)信息 |
| | | /// </summary> |
| | |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | return result.panelPrivateFunctionsResponseInfo.privateFuncTypeLevelFirstList; |
| | | } |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | OpenPassthroughControl(Gateway); |
| | | var passData = ControlKeyData(keyNum, keyStatus); |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; |
| | | var data = new JObject { { "PassData", passData } }; |
| | | jObject.Add("Data", data); |
| | | jObject.Add("Data", data);
|
| | | Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); |
| | | } |
| | | catch { } |
| | |
| | | |
| | | string td = attributeData.ToString("X4"); |
| | | char[] td1 = td.ToCharArray(); |
| | | string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString()); |
| | | |
| | | string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString());
|
| | |
|
| | | switch (keyStatus) |
| | | { |
| | | case KeyStatus.close: |
| | |
| | | |
| | | try |
| | | { |
| | | OpenPassthroughControl(Gateway); |
| | | var passData = SetPanelColorData(keyColorData, keyNumStatus); |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; |
| | | var data = new JObject { { "PassData", passData } }; |
| | | jObject.Add("Data", data); |
| | | jObject.Add("Data", data);
|
| | | Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); |
| | | } |
| | | catch { } |
| | |
| | | Type type = keyNumStatus.GetType(); |
| | | var obj = type.InvokeMember("Key" + i, System.Reflection.BindingFlags.GetField, null, keyNumStatus, null); |
| | | int value0 = 0; |
| | | if (Convert.ToBoolean(obj) == true) |
| | | { |
| | | if (Convert.ToBoolean(obj) == true)
|
| | | {
|
| | | value0 = 1; |
| | | } |
| | | int v = (int)Math.Pow(2, i - 1); |
| | | attributeData += value0 * v; |
| | | } |
| | | |
| | | }
|
| | |
|
| | | string td = attributeData.ToString("X4"); |
| | | char[] td1 = td.ToCharArray(); |
| | | string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString()); |
| | |
| | | #region 配置按键指示灯面板亮度属性. |
| | | ///<summary > |
| | | ///配置按键指示灯面板亮度属性 |
| | | /// <para>directionsLevel:指示灯亮度 0-100</para> |
| | | /// <para>backlightLevel:背光灯亮度 0-100</para> |
| | | /// <para>directionsLevel:指示灯亮度 0-100(这个是点击后的值)</para> |
| | | /// <para>backlightLevel:背光灯亮度 0-100(这个是点击前的值)</para> |
| | | /// </summary> |
| | | public async System.Threading.Tasks.Task<ResponseAllData> SetKeyLevelAsync(int directionsLevel, int backlightLevel) |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | OpenPassthroughControl(Gateway); |
| | | var passData = SetPanelLevelData(directionsLevel, backlightLevel); |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; |
| | | var data = new JObject { { "PassData", passData } }; |
| | | jObject.Add("Data", data); |
| | | jObject.Add("Data", data);
|
| | | Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); |
| | | } |
| | | catch { } |
| | |
| | | |
| | | try |
| | | { |
| | | OpenPassthroughControl(Gateway); |
| | | var passData = SetPanelModeModeData(modeEnable, modeTime, level); |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; |
| | | var data = new JObject { { "PassData", passData } }; |
| | | jObject.Add("Data", data); |
| | | jObject.Add("Data", data);
|
| | | Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); |
| | | } |
| | | catch { } |
| | |
| | | string addDataLength = "03"; |
| | | string mode = ""; |
| | | string time = ""; |
| | | string level = ""; |
| | | string level = "";
|
| | | try |
| | | { |
| | | if (modeEnable) |
| | |
| | | level = temp2; |
| | | break; |
| | | } |
| | | |
| | |
|
| | | sbString1.Append(time.ToUpper()); |
| | | sbString2.Append(level.ToUpper()); |
| | | data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + |
| | |
| | | |
| | | try |
| | | { |
| | | OpenPassthroughControl(Gateway); |
| | | var passData = GetkeyColorData(keyNum); |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; |
| | | var data = new JObject { { "PassData", passData } }; |
| | | jObject.Add("Data", data); |
| | | jObject.Add("Data", data);
|
| | | Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); |
| | | } |
| | | catch { } |
| | |
| | | |
| | | try |
| | | { |
| | | OpenPassthroughControl(Gateway); |
| | | var passData = SendPanelSwitchLevelData(reserve); |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; |
| | | var data = new JObject { { "PassData", passData } }; |
| | | jObject.Add("Data", data); |
| | | jObject.Add("Data", data);
|
| | | Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); |
| | | } |
| | | catch { } |
| | |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | ///按键开状态(指示)亮度 |
| | | ///按键开状态(指示)亮度(这个是点击后的值) |
| | | /// </summary> |
| | | public int panelDirectionsLevel = -1; |
| | | |
| | | /// <summary> |
| | | /// 按键关状态(背光)亮度 |
| | | /// 按键关状态(背光)亮度(这个是点击前的值) |
| | | /// </summary> |
| | | public int panelBacklightLevel = -1; |
| | | } |
| | |
| | | }; |
| | | |
| | | Gateway.Actions += action; |
| | | System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString()); |
| | | |
| | | System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
| | |
|
| | | try |
| | | { |
| | | OpenPassthroughControl(Gateway); |
| | | var passData = SendPanelSaveEnergyModeData(reserve); |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; |
| | | var data = new JObject { { "PassData", passData } }; |
| | | jObject.Add("Data", data); |
| | | jObject.Add("Data", data);
|
| | | Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); |
| | | } |
| | | catch { } |
| | |
| | | /// 节能模式亮度(0-100) |
| | | /// </summary> |
| | | public int level = -1; |
| | | } |
| | | }
|
| | | #endregion |
| | | |
| | |
|
| | | #region 配置按键指示灯睡眠组分(暂时不做) |
| | | ///<summary > |
| | | ///获取按键指示灯睡眠组 |
| | | ///<para>sleepGroup:睡眠组号</para> |
| | | /// </summary> |
| | | //public async System.Threading.Tasks.Task<PanelSleepGroupResponseAllData> GetPanelSleepGroupAsync(SleepGroup sleepGroup) |
| | | //{ |
| | | // PanelSleepGroupResponseAllData result = null; |
| | | // if (Gateway == null) |
| | | // { |
| | | // result = new PanelSleepGroupResponseAllData { errorMessageBase = "当前没有网关" }; |
| | | // return result; |
| | | // } |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // 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) |
| | | // { |
| | | // result = new PanelSleepGroupResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | // } |
| | | |
| | | // else |
| | | // { |
| | | // result = new PanelSleepGroupResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | // } |
| | | // } |
| | | // if (topic == gatewayID + "/" + "ZbDataPassthrough") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") }; |
| | | // gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString()); |
| | | |
| | | // if (gatewayTemp.clientDataPassthroughResponseData == null) |
| | | // { |
| | | // result = new PanelSleepGroupResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null) |
| | | // { |
| | | // var data = gatewayTemp.clientDataPassthroughResponseData.PassData; |
| | | // if (data.Length == 14) |
| | | // { |
| | | // var tempR = new PanelSleepGroupResponseData(); |
| | | // tempR.status = int.Parse(data[12].ToString() + data[13].ToString()); |
| | | // switch (data[10].ToString() + data[11].ToString()) |
| | | // { |
| | | // case "01": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group1; |
| | | // break; |
| | | // case "02": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group2; |
| | | // break; |
| | | // case "03": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group3; |
| | | // break; |
| | | // case "04": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group4; |
| | | // break; |
| | | // case "05": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group5; |
| | | // break; |
| | | // case "06": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group6; |
| | | // break; |
| | | // case "07": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group7; |
| | | // break; |
| | | // case "08": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group8; |
| | | // break; |
| | | // case "09": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group9; |
| | | // break; |
| | | // case "0a": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group10; |
| | | // break; |
| | | // case "0b": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group11; |
| | | // break; |
| | | // case "0c": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group12; |
| | | // break; |
| | | // case "0d": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group13; |
| | | // break; |
| | | // case "0e": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group14; |
| | | // break; |
| | | // case "0f": |
| | | // tempR.sleepGroupNum = SleepGroupNum.Group15; |
| | | // break; |
| | | // } |
| | | // result = new PanelSleepGroupResponseAllData { panelSleepGroupResponseData = tempR }; |
| | | // } |
| | | // } |
| | | // System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | |
| | | // Gateway.Actions += action; |
| | | // System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString()); |
| | | |
| | | // try |
| | | // { |
| | | // OpenPassthroughControl(Gateway); |
| | | // var passData = SetPanelSleepGroupData(sleepGroup); |
| | | // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } }; |
| | | // var data = new JObject { { "PassData", passData } }; |
| | | // jObject.Add("Data", data); |
| | | // CurrentGateWayId = Gateway.getGatewayBaseInfo?.gwID; |
| | | // Gateway.Send(("ClientDataPassthrough"), jObject.ToString()); |
| | | // } |
| | | // catch { } |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // if (result != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) |
| | | // { |
| | | // result = new PanelSleepGroupResponseAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | // } |
| | | // Gateway.Actions -= action; |
| | | // System.Console.WriteLine("ClientDataPassthrough_Actions 退出" + System.DateTime.Now.ToString()); |
| | | |
| | | // return result; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 绑定设备信息,网关反馈信息 |
| | | ///// </summary> |
| | | //public PanelSleepGroupResponseAllData panelSleepGroupResponseAllData; |
| | | //[System.Serializable] |
| | | //public class PanelSleepGroupResponseAllData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// 绑定设备信息 |
| | | // /// </summary> |
| | | // public PanelSleepGroupResponseData panelSleepGroupResponseData; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 绑定设备信息,网关反馈信息 |
| | | ///// </summary> |
| | | //public PanelSleepGroupResponseData panelSleepGroupResponseData; |
| | | //[System.Serializable] |
| | | //public class PanelSleepGroupResponseData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 睡眠组号 |
| | | // /// </summary> |
| | | // public SleepGroupNum sleepGroupNum; |
| | | // /// <summary> |
| | | // /// 状态 |
| | | // /// <para>0--执行 1—唤醒</para> |
| | | // /// </summary> |
| | | // public int status; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 配置按键指示灯睡眠组分区 |
| | | ///// </summary> |
| | | //string SetPanelSleepGroupData(SleepGroup sleepGroup) |
| | | //{ |
| | | // string data = ""; |
| | | // string dataLength = "06"; |
| | | // string dataComand1 = "0a"; |
| | | // string dataComand2 = "04"; |
| | | // string dataSerialNum = "01"; |
| | | // string addDataLength = "02"; |
| | | // int attributeData = 0; |
| | | |
| | | // try |
| | | // { |
| | | // int bit0 = 0, bit1 = 0, bit2 = 0, bit3 = 0, bit4 = 0, bit5 = 0, bit6 = 0, bit7 = 0, bit8 = 0, bit9 = 0, bit10 = 0, bit11 = 0, bit12 = 0, bit13 = 0, bit14 = 0, bit15 = 0; |
| | | // if (sleepGroup != null) |
| | | // { |
| | | // if (sleepGroup.bit0) |
| | | // { |
| | | // bit0 = 1; |
| | | // } |
| | | // if (sleepGroup.bit1) |
| | | // { |
| | | // bit1 = 1; |
| | | // } |
| | | // if (sleepGroup.bit2) |
| | | // { |
| | | // bit2 = 1; |
| | | // } |
| | | // if (sleepGroup.bit3) |
| | | // { |
| | | // bit3 = 1; |
| | | // } |
| | | // if (sleepGroup.bit4) |
| | | // { |
| | | // bit4 = 1; |
| | | // } |
| | | // if (sleepGroup.bit5) |
| | | // { |
| | | // bit5 = 1; |
| | | // } |
| | | // if (sleepGroup.bit6) |
| | | // { |
| | | // bit6 = 1; |
| | | // } |
| | | // if (sleepGroup.bit7) |
| | | // { |
| | | // bit7 = 1; |
| | | // } |
| | | // if (sleepGroup.bit8) |
| | | // { |
| | | // bit8 = 1; |
| | | // } |
| | | // if (sleepGroup.bit9) |
| | | // { |
| | | // bit9 = 1; |
| | | // } |
| | | // if (sleepGroup.bit10) |
| | | // { |
| | | // bit10 = 1; |
| | | // } |
| | | // if (sleepGroup.bit11) |
| | | // { |
| | | // bit11 = 1; |
| | | // } |
| | | // if (sleepGroup.bit12) |
| | | // { |
| | | // bit12 = 1; |
| | | // } |
| | | // if (sleepGroup.bit13) |
| | | // { |
| | | // bit13 = 1; |
| | | // } |
| | | // if (sleepGroup.bit14) |
| | | // { |
| | | // bit14 = 1; |
| | | // } |
| | | // if (sleepGroup.bit15) |
| | | // { |
| | | // bit15 = 1; |
| | | // } |
| | | // attributeData = bit0 * 1 + bit1 * 2 + bit2 * 4 + bit3 * 8 + bit4 * 16 + bit5 * 32 + bit6 * 64 + bit7 * 128 + bit8 * 256 + bit9 * 512 + bit10 * 1024 + bit11 * 2048 + bit12 * 4096 + bit13 * 8192 + bit14 * 16384 + bit15 * 32768; |
| | | // } |
| | | // string tempAttributeData = attributeData.ToString("X4"); |
| | | |
| | | // if (sleepGroup != null) |
| | | // { |
| | | // data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + |
| | | // tempAttributeData; |
| | | // } |
| | | // } |
| | | // catch { }; |
| | | |
| | | // return data; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 睡眠组号(可位或) |
| | | ///// </summary> |
| | | //public class SleepGroup |
| | | //{ |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit0; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit1; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit2; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit3; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit4; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit5; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit6; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit7; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit8; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit9; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit10; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit11; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit12; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit13; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit14; |
| | | // /// <summary> |
| | | // /// false:关 |
| | | // /// true:开 |
| | | // /// </summary> |
| | | // public bool bit15; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 执行按键指示灯睡眠组 |
| | | ///// </summary> |
| | | //public enum SleepGroupNum |
| | | //{ |
| | | // Group1 = 1, |
| | | // Group2 = 2, |
| | | // Group3 = 3, |
| | | // Group4 = 4, |
| | | // Group5 = 5, |
| | | // Group6 = 6, |
| | | // Group7 = 7, |
| | | // Group8 = 8, |
| | | // Group9 = 9, |
| | | // Group10 = 10, |
| | | // Group11 = 11, |
| | | // Group12 = 12, |
| | | // Group13 = 13, |
| | | // Group14 = 14, |
| | | // Group15 = 15, |
| | | // Group16 = 16, |
| | | //} |
| | | //public async System.Threading.Tasks.Task<PanelSleepGroupResponseAllData> GetPanelSleepGroupAsync(SleepGroup sleepGroup)
|
| | | //{
|
| | | // PanelSleepGroupResponseAllData result = null;
|
| | | // if (Gateway == null)
|
| | | // {
|
| | | // result = new PanelSleepGroupResponseAllData { errorMessageBase = "当前没有网关" };
|
| | | // return result;
|
| | | // }
|
| | | // return await System.Threading.Tasks.Task.Run(async () =>
|
| | | // {
|
| | | // 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)
|
| | | // {
|
| | | // result = new PanelSleepGroupResponseAllData { errorMessageBase = "网关错误回复,且数据是空" };
|
| | | // }
|
| | |
|
| | | // else
|
| | | // {
|
| | | // result = new PanelSleepGroupResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
|
| | | // }
|
| | | // }
|
| | | // if (topic == gatewayID + "/" + "ZbDataPassthrough")
|
| | | // {
|
| | | // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
|
| | | // gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
|
| | |
|
| | | // if (gatewayTemp.clientDataPassthroughResponseData == null)
|
| | | // {
|
| | | // result = new PanelSleepGroupResponseAllData { errorMessageBase = "网关返回的数据为空" };
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
|
| | | // {
|
| | | // var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
|
| | | // if (data.Length == 14)
|
| | | // {
|
| | | // var tempR = new PanelSleepGroupResponseData();
|
| | | // tempR.status = int.Parse(data[12].ToString() + data[13].ToString());
|
| | | // switch (data[10].ToString() + data[11].ToString())
|
| | | // {
|
| | | // case "01":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group1;
|
| | | // break;
|
| | | // case "02":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group2;
|
| | | // break;
|
| | | // case "03":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group3;
|
| | | // break;
|
| | | // case "04":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group4;
|
| | | // break;
|
| | | // case "05":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group5;
|
| | | // break;
|
| | | // case "06":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group6;
|
| | | // break;
|
| | | // case "07":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group7;
|
| | | // break;
|
| | | // case "08":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group8;
|
| | | // break;
|
| | | // case "09":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group9;
|
| | | // break;
|
| | | // case "0a":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group10;
|
| | | // break;
|
| | | // case "0b":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group11;
|
| | | // break;
|
| | | // case "0c":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group12;
|
| | | // break;
|
| | | // case "0d":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group13;
|
| | | // break;
|
| | | // case "0e":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group14;
|
| | | // break;
|
| | | // case "0f":
|
| | | // tempR.sleepGroupNum = SleepGroupNum.Group15;
|
| | | // break;
|
| | | // }
|
| | | // result = new PanelSleepGroupResponseAllData { panelSleepGroupResponseData = tempR };
|
| | | // }
|
| | | // }
|
| | | // System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
|
| | | // }
|
| | | // }
|
| | | // };
|
| | |
|
| | | // Gateway.Actions += action;
|
| | | // System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
| | |
|
| | | // try
|
| | | // {
|
| | | // OpenPassthroughControl(Gateway);
|
| | | // var passData = SetPanelSleepGroupData(sleepGroup);
|
| | | // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | // var data = new JObject { { "PassData", passData } };
|
| | | // jObject.Add("Data", data);
|
| | | // CurrentGateWayId = Gateway.getGatewayBaseInfo?.gwID;
|
| | | // Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
|
| | | // }
|
| | | // catch { }
|
| | |
|
| | | // var dateTime = DateTime.Now;
|
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
|
| | | // {
|
| | | // await System.Threading.Tasks.Task.Delay(10);
|
| | | // if (result != null)
|
| | | // {
|
| | | // break;
|
| | | // }
|
| | | // }
|
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
|
| | | // {
|
| | | // result = new PanelSleepGroupResponseAllData { errorMessageBase = " 回复超时,请重新操作" };
|
| | | // }
|
| | | // Gateway.Actions -= action;
|
| | | // System.Console.WriteLine("ClientDataPassthrough_Actions 退出" + System.DateTime.Now.ToString());
|
| | |
|
| | | // return result;
|
| | | // });
|
| | | //}
|
| | |
|
| | | ///// <summary>
|
| | | ///// 绑定设备信息,网关反馈信息
|
| | | ///// </summary>
|
| | | //public PanelSleepGroupResponseAllData panelSleepGroupResponseAllData;
|
| | | //[System.Serializable]
|
| | | //public class PanelSleepGroupResponseAllData
|
| | | //{
|
| | | // /// <summary>
|
| | | // /// 错误信息
|
| | | // /// </summary>
|
| | | // public string errorMessageBase;
|
| | | // /// <summary>
|
| | | // /// 网关信息错误反馈
|
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para>
|
| | | // /// </summary>
|
| | | // public ErrorResponData errorResponData;
|
| | | // /// <summary>
|
| | | // /// 绑定设备信息
|
| | | // /// </summary>
|
| | | // public PanelSleepGroupResponseData panelSleepGroupResponseData;
|
| | | //}
|
| | |
|
| | | ///// <summary>
|
| | | ///// 绑定设备信息,网关反馈信息
|
| | | ///// </summary>
|
| | | //public PanelSleepGroupResponseData panelSleepGroupResponseData;
|
| | | //[System.Serializable]
|
| | | //public class PanelSleepGroupResponseData
|
| | | //{
|
| | | // /// <summary>
|
| | | // /// 睡眠组号
|
| | | // /// </summary>
|
| | | // public SleepGroupNum sleepGroupNum;
|
| | | // /// <summary>
|
| | | // /// 状态
|
| | | // /// <para>0--执行 1—唤醒</para>
|
| | | // /// </summary>
|
| | | // public int status;
|
| | | //}
|
| | |
|
| | | ///// <summary>
|
| | | ///// 配置按键指示灯睡眠组分区
|
| | | ///// </summary>
|
| | | //string SetPanelSleepGroupData(SleepGroup sleepGroup)
|
| | | //{
|
| | | // string data = "";
|
| | | // string dataLength = "06";
|
| | | // string dataComand1 = "0a";
|
| | | // string dataComand2 = "04";
|
| | | // string dataSerialNum = "01";
|
| | | // string addDataLength = "02";
|
| | | // int attributeData = 0;
|
| | |
|
| | | // try
|
| | | // {
|
| | | // int bit0 = 0, bit1 = 0, bit2 = 0, bit3 = 0, bit4 = 0, bit5 = 0, bit6 = 0, bit7 = 0, bit8 = 0, bit9 = 0, bit10 = 0, bit11 = 0, bit12 = 0, bit13 = 0, bit14 = 0, bit15 = 0;
|
| | | // if (sleepGroup != null)
|
| | | // {
|
| | | // if (sleepGroup.bit0)
|
| | | // {
|
| | | // bit0 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit1)
|
| | | // {
|
| | | // bit1 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit2)
|
| | | // {
|
| | | // bit2 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit3)
|
| | | // {
|
| | | // bit3 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit4)
|
| | | // {
|
| | | // bit4 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit5)
|
| | | // {
|
| | | // bit5 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit6)
|
| | | // {
|
| | | // bit6 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit7)
|
| | | // {
|
| | | // bit7 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit8)
|
| | | // {
|
| | | // bit8 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit9)
|
| | | // {
|
| | | // bit9 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit10)
|
| | | // {
|
| | | // bit10 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit11)
|
| | | // {
|
| | | // bit11 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit12)
|
| | | // {
|
| | | // bit12 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit13)
|
| | | // {
|
| | | // bit13 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit14)
|
| | | // {
|
| | | // bit14 = 1;
|
| | | // }
|
| | | // if (sleepGroup.bit15)
|
| | | // {
|
| | | // bit15 = 1;
|
| | | // }
|
| | | // attributeData = bit0 * 1 + bit1 * 2 + bit2 * 4 + bit3 * 8 + bit4 * 16 + bit5 * 32 + bit6 * 64 + bit7 * 128 + bit8 * 256 + bit9 * 512 + bit10 * 1024 + bit11 * 2048 + bit12 * 4096 + bit13 * 8192 + bit14 * 16384 + bit15 * 32768;
|
| | | // }
|
| | | // string tempAttributeData = attributeData.ToString("X4");
|
| | |
|
| | | // if (sleepGroup != null)
|
| | | // {
|
| | | // data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
|
| | | // tempAttributeData;
|
| | | // }
|
| | | // }
|
| | | // catch { };
|
| | |
|
| | | // return data;
|
| | | //}
|
| | |
|
| | | ///// <summary>
|
| | | ///// 睡眠组号(可位或)
|
| | | ///// </summary>
|
| | | //public class SleepGroup
|
| | | //{
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit0;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit1;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit2;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit3;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit4;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit5;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit6;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit7;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit8;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit9;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit10;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit11;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit12;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit13;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit14;
|
| | | // /// <summary>
|
| | | // /// false:关
|
| | | // /// true:开
|
| | | // /// </summary>
|
| | | // public bool bit15;
|
| | | //}
|
| | |
|
| | | ///// <summary>
|
| | | ///// 执行按键指示灯睡眠组
|
| | | ///// </summary>
|
| | | //public enum SleepGroupNum
|
| | | //{
|
| | | // Group1 = 1,
|
| | | // Group2 = 2,
|
| | | // Group3 = 3,
|
| | | // Group4 = 4,
|
| | | // Group5 = 5,
|
| | | // Group6 = 6,
|
| | | // Group7 = 7,
|
| | | // Group8 = 8,
|
| | | // Group9 = 9,
|
| | | // Group10 = 10,
|
| | | // Group11 = 11,
|
| | | // Group12 = 12,
|
| | | // Group13 = 13,
|
| | | // Group14 = 14,
|
| | | // Group15 = 15,
|
| | | // Group16 = 16,
|
| | | //}
|
| | | #endregion |
| | | |
| | |
|
| | | #region 配置面板功能 |
| | | ///<summary > |
| | | ///配置面板功能 |
| | | ///<para>value:给面板配置的模式</para> |
| | | /// </summary> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> ConfigureHdlKeyValueAsync(KeyMode value) |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> ConfigureHdlKeyValueAsync(KeyMode value, int clusterID = 6) |
| | | { |
| | | if (Gateway == null) |
| | | { |
| | |
| | | System.Console.WriteLine("SetWritableValue_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | try |
| | | { |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 6 }, { "Command", 120 } }; |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterID }, { "Command", 120 } }; |
| | | var data = new JObject { { "Undivided", 0 }, { "AttributeId", 6533 }, { "AttributeDataType", 33 }, { "AttributeData", (int)value } }; |
| | | jObject.Add("Data", data); |
| | | jObject.Add("Data", data);
|
| | | Gateway.Send("SetWritableValue", jObject.ToString()); |
| | | } |
| | | catch { } |
| | |
| | | /// 开关类型——取反. |
| | | /// </summary> |
| | | OnOff_OnOff = 102, |
| | | |
| | | /// <summary> |
| | | /// 亮度类型——调大. |
| | | /// 亮度类型——按等级调大. |
| | | /// </summary> |
| | | Level_Step_Up = 200, |
| | | /// <summary> |
| | | /// 亮度类型——调小. |
| | | /// 亮度类型——按等级调小. |
| | | /// </summary> |
| | | Level_Step_Down = 201, |
| | | /// <summary> |
| | | /// 亮度类型——取反. |
| | | /// 亮度类型——按等级取反. |
| | | /// </summary> |
| | | Level_Step_Up_Down = 202, |
| | | |
| | | /// <summary> |
| | | /// 亮度类型——取反. |
| | | /// </summary> |
| | | Level_Up = 203, |
| | | /// <summary> |
| | | /// 亮度类型——取反. |
| | | /// </summary> |
| | | Level_Down = 204, |
| | | /// <summary> |
| | | /// 亮度类型——取反. |
| | | /// </summary> |
| | | Level_Up_Down = 205, |
| | | /// <summary> |
| | | /// 窗帘类型——开. |
| | | /// </summary> |
| | |
| | | /// 窗帘类型——下降停止. |
| | | /// </summary> |
| | | Wcd_Down_Stop = 304, |
| | | /// <summary> |
| | | /// 窗帘类型——下降停止. |
| | | /// </summary> |
| | | Default = 65535, |
| | | } |
| | | #endregion |
| | | |
| | |
| | | } |
| | | }; |
| | | var data = new JObject { { "AttriBute", attriBute } }; |
| | | JObject.Add("Data", data); |
| | | JObject.Add("Data", data);
|
| | | Gateway?.Send(("GetDeviceStatus"), JObject.ToString()); |
| | | } |
| | | catch |
| | |
| | | |
| | | return d; |
| | | }); |
| | | } |
| | | |
| | | }
|
| | |
|
| | | /// <summary> |
| | | /// 网关恢复出厂设置返回数据 |
| | | /// </summary> |
| | |
| | | } |
| | | #endregion |
| | | |
| | | //#region 设备绑定 |
| | | ///// <summary> |
| | | /////设备绑定 |
| | | ///// </summary> |
| | | //public async System.Threading.Tasks.Task<AddedDeviceBindResponseAllData> AddDeviceBindAsync(AddBindData addBindData) |
| | | //{ |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // var result = new AddedDeviceBindResponseAllData(); |
| | | // var mainGateway = ZbGateway.MainGateWay; |
| | | // if (mainGateway == null) |
| | | // { |
| | | // result.errorMessageBase = "当前没有主网关"; |
| | | // return result; |
| | | // } |
| | | // Action<string, string> action = (topic, message) => |
| | | // { |
| | | // System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | // 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 = mainGateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); |
| | | #region 获取网关中的场景 |
| | | /// <summary> |
| | | /// 只能获取场景信息,没有场景中的设备信息 |
| | | /// </summary> |
| | | /// <returns></rxeturns> |
| | | public async System.Threading.Tasks.Task<GetOnlySceneAllData> GetSceneInfoAsync() |
| | | { |
| | | GetOnlySceneAllData result = null; |
| | | if (ZbGateway.MainGateWay == null) |
| | | { |
| | | result = new GetOnlySceneAllData { errorMessageBase = "没有主网关" }; |
| | | } |
| | | return await System.Threading.Tasks.Task.Run(async () => |
| | | { |
| | | 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 tempResult = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString()); |
| | | if (tempResult == null) |
| | | { |
| | | result = new GetOnlySceneAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | result = new GetOnlySceneAllData { errorResponData = tempResult }; |
| | | } |
| | | } |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // result.errorMessageBase = "网关错误回复,且数据是空"; |
| | | // } |
| | | // else |
| | | // { |
| | | // result.errorResponData = temp; |
| | | // result.errorMessageBase = ErrorMess(temp.Error); |
| | | // } |
| | | // } |
| | | // else if (topic == gatewayID + "/" + "Bind/SetBind_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 = mainGateway.getGatewayBaseInfo.gwID }; |
| | | // //var tempBindName = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(jobject["Data"]["BindName"].ToString()); |
| | | // var tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString()); |
| | | // if (tempBindList == null) |
| | | // { |
| | | // result.errorMessageBase = "网关返回的数据为空"; |
| | | // } |
| | | // else |
| | | // { |
| | | // var dataBindRes = new AddedDeviceBindResponseData(); |
| | | // for (int m = 0; tempBindList != null && m < tempBindList.Count; m++) |
| | | // { |
| | | // var tempBind = tempBindList[m]; |
| | | // dataBindRes.BindList.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<AddBindListResponseObj>(tempBind.ToString())); |
| | | // } |
| | | // if (dataBindRes != null) |
| | | // { |
| | | // result.addedDeviceBindResponseData = dataBindRes; |
| | | // System.Console.WriteLine($"UI收到通知后的主题_{topic}"); |
| | | // } |
| | | // } |
| | | // } |
| | | // else if (topic == gatewayID + "/" + "Bind/BindResult") |
| | | // { |
| | | // 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 = mainGateway.getGatewayBaseInfo.gwID }; |
| | | // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<AddBindResultResponseData>(jobject["Data"].ToString()); |
| | | if (topic == gatewayID + "/" + "Scene/GetInfo_Respon") |
| | | { |
| | | var getSceneInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSceneInfo>(jobject["Data"].ToString()); |
| | | if (getSceneInfo == null) |
| | | { |
| | | result = new GetOnlySceneAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | else |
| | | { |
| | | result = new GetOnlySceneAllData { getSceneInfo = getSceneInfo }; |
| | | } |
| | | } |
| | | }; |
| | | ZbGateway.MainGateWay.Actions += action; |
| | | System.Console.WriteLine("Scene/GetInfo_Actions 启动" + System.DateTime.Now.ToString()); |
| | | var jobjectData = new JObject { { "Cluster_ID", 0 }, { "Command", 805 } }; |
| | | await ZbGateway.MainGateWay.Send(("Scene/GetInfo"), System.Text.Encoding.UTF8.GetBytes(jobjectData.ToString())); |
| | | |
| | | // if (tempData != null) |
| | | // { |
| | | // result.addBindResultResponseData = tempData; |
| | | // } |
| | | // } |
| | | // }; |
| | | // mainGateway.Actions += action; |
| | | // System.Console.WriteLine("Bind/SetBind_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | // try |
| | | // { |
| | | // if (addBindData != null) |
| | | // { |
| | | // var jObject = new JObject { { "DeviceAddr", addBindData.DeviceAddr }, { "Epoint", addBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5001 } }; |
| | | // var bindList = new JArray { }; |
| | | // foreach (var bindInfo in addBindData.BindList) |
| | | // { |
| | | // if (bindInfo.BindType == 0) |
| | | // { |
| | | // var dInfo = new JObject{ |
| | | // { "BindMacAddr",bindInfo.BindMacAddr}, |
| | | // { "BindEpoint", bindInfo.BindEpoint} , |
| | | // { "BindCluster", bindInfo.BindCluster} , |
| | | // { "BindType",bindInfo.BindType} |
| | | // }; |
| | | // bindList.Add(dInfo); |
| | | // } |
| | | // else if (bindInfo.BindType == 1) |
| | | // { |
| | | // var dInfo = new JObject{ |
| | | // { "BindCluster", bindInfo.BindCluster} , |
| | | // { "BindType",bindInfo.BindType}, |
| | | // { "BindScenesId", bindInfo.BindScenesId} |
| | | // }; |
| | | // bindList.Add(dInfo); |
| | | // } |
| | | // } |
| | | // var data = new JObject{ |
| | | // {"BindName",addBindData.BindName}, |
| | | // { "BindList", bindList } |
| | | // }; |
| | | // jObject.Add("Data", data); |
| | | // mainGateway.Send("Bind/SetBind", jObject.ToString()); |
| | | // } |
| | | // } |
| | | // catch |
| | | // { |
| | | // } |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(100); |
| | | // if (result == null || result.addedDeviceBindResponseData == null) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // if (0 < result.addedDeviceBindResponseData.BindList.FindAll((obj) => obj.BindType == 0).Count) |
| | | // { |
| | | // if (result.addBindResultResponseData != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) |
| | | // { |
| | | // result.errorMessageBase = " 回复超时,请重新操作"; |
| | | // } |
| | | // mainGateway.Actions -= action; |
| | | // System.Console.WriteLine($"Bind/SetBind_Actions 退出 {System.DateTime.Now}"); |
| | | // return result; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 绑定设备信息,网关反馈信息 |
| | | ///// </summary> |
| | | //public AddedDeviceBindResponseAllData addedDeviceBindResponseAllData; |
| | | //[System.Serializable] |
| | | //public class AddedDeviceBindResponseAllData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// 网关直接反馈绑定设备信息 |
| | | // /// </summary> |
| | | // public AddedDeviceBindResponseData addedDeviceBindResponseData; |
| | | // /// <summary> |
| | | // /// 按键设备的确认反馈绑定设备信息 |
| | | // /// </summary> |
| | | // public AddBindResultResponseData addBindResultResponseData; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 绑定设备信息 |
| | | ///// </summary> |
| | | //public AddedDeviceBindResponseData addedDeviceBindResponseData; |
| | | //[System.Serializable] |
| | | //public class AddedDeviceBindResponseData |
| | | //{ |
| | | // /// <summary> |
| | | // ///绑定名称 |
| | | // /// </summary> |
| | | // public string BindName; |
| | | // /// <summary> |
| | | // ///绑定列表 ,当Status=0时存在 |
| | | // /// </summary> |
| | | // public List<AddBindListResponseObj> BindList = new List<AddBindListResponseObj>(); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 绑定列表的信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class AddBindListResponseObj : BindListResponseObj |
| | | //{ |
| | | // /// <summary> |
| | | // /// 0:加入成功(该状态只适用用于跨网关绑定和绑定场景。同网关设备间的绑定需要节点设备的确认成功信息,不会直接反馈成功。) |
| | | // ///<para>1:失败,节点设备或场景不存在。</para> |
| | | // ///<para>2:未知,由节点设备反馈发送“Bind/BindResult”主题消息确定是否成功。</para> |
| | | // ///<para>3:绑定已经存在。</para> |
| | | // /// </summary> |
| | | // public int Result; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 按键设备的确认的信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class AddBindResultResponseData |
| | | //{ |
| | | // /// <summary> |
| | | // ///绑定结果 |
| | | // ///<para>0:成功</para> |
| | | // ///<para>140:失败,控制设备的绑定列表已满</para> |
| | | // ///<para>其他:失败</para> |
| | | // /// </summary> |
| | | // public int Result; |
| | | // /// <summary> |
| | | // /// 绑定的cluster |
| | | // /// </summary> |
| | | // public int BindCluster; |
| | | // /// <summary> |
| | | // /// 绑定设备Mac地址, 当BindType=0时存在 |
| | | // /// </summary> |
| | | // public string BindMacAddr; |
| | | // /// <summary> |
| | | // /// 绑定设备的端口号,当BindType=0时存在 |
| | | // /// </summary> |
| | | // public int BindEpoint; |
| | | // /// <summary> |
| | | // /// 绑定场景,当BindType=2时存在 |
| | | // /// </summary> |
| | | // public int BindScenesId; |
| | | // /// <summary> |
| | | // /// 绑定设备的名称 |
| | | // /// </summary> |
| | | // public string DeviceName; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 绑定设备的数据 |
| | | ///// </summary> |
| | | //public AddBindData addBindData; |
| | | //[System.Serializable] |
| | | //public class AddBindData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 控制设备节点的mac地址 |
| | | // /// </summary> |
| | | // public string DeviceAddr; |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public int Epoint; |
| | | // /// <summary> |
| | | // ///绑定名称,不修改名称时忽略该选项 |
| | | // /// </summary> |
| | | // public string BindName; |
| | | // /// <summary> |
| | | // ///绑定列表,不修改绑定列表时忽略该选项。 |
| | | // /// </summary> |
| | | // public List<AddBindListObj> BindList = new List<AddBindListObj>(); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 控制设备绑定的信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class AddBindListObj |
| | | //{ |
| | | // /// <summary> |
| | | // /// 绑定类型 |
| | | // ///<para>0:绑定设备 </para> |
| | | // ///<para>1:绑定场景</para> |
| | | // /// </summary> |
| | | // public int BindType; |
| | | // /// <summary> |
| | | // /// 绑定的cluster,需要控制设备的OutCluster列表中存在该cluster。 |
| | | // ///如绑定某个设备的on/off,为6。 |
| | | // /// </summary> |
| | | // public int BindCluster; |
| | | // /// <summary> |
| | | // /// 绑定设备Mac地址, 当BindType=0时存在 |
| | | // /// </summary> |
| | | // public string BindMacAddr; |
| | | // /// <summary> |
| | | // /// 绑定设备的端口号,当BindType=0时存在 |
| | | // /// </summary> |
| | | // public int BindEpoint; |
| | | // /// <summary> |
| | | // /// 绑定场景,当BindType=1时存在 |
| | | // /// </summary> |
| | | // public int BindScenesId; |
| | | //} |
| | | //#endregion |
| | | |
| | | //#region 解除绑定 |
| | | ///// <summary> |
| | | ///// 解除绑定 |
| | | ///// </summary> |
| | | //public async System.Threading.Tasks.Task<DelDeviceBindResponseAllData> DelDeviceBindAsync(DelDeviceBindData delDeviceBindData) |
| | | //{ |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // var responseData = new DelDeviceBindResponseAllData(); |
| | | // var mainGateway = ZbGateway.MainGateWay; |
| | | // if (mainGateway == null) |
| | | // { |
| | | // responseData.errorMessageBase = "当前没有主网关"; |
| | | // return responseData; |
| | | // } |
| | | |
| | | // 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 = mainGateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // responseData.errorMessageBase = "网关错误回复,且数据是空"; |
| | | // } |
| | | // else |
| | | // { |
| | | // responseData.errorResponData = temp; |
| | | // responseData.errorMessageBase = ErrorMess(temp.Error); |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "Bind/RemoveBind_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<DelDeviceBindResponseData>(jobject["Data"].ToString()); |
| | | |
| | | // if (tempData == null) |
| | | // { |
| | | // responseData.errorMessageBase = "网关返回的数据为空"; |
| | | |
| | | // } |
| | | // else |
| | | // { |
| | | // responseData.delDeviceBindResponseData = tempData; |
| | | // System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "Bind/RemoveBindResult") |
| | | // { |
| | | // 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 = mainGateway.getGatewayBaseInfo.gwID }; |
| | | // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveBindResultResponseData>(jobject["Data"].ToString()); |
| | | |
| | | // if (tempData != null) |
| | | // { |
| | | // responseData.removeBindResultResponseData = tempData; |
| | | // System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | // mainGateway.Actions += action; |
| | | // System.Console.WriteLine("DeviceBind/DelBind_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | // try |
| | | // { |
| | | // if (delDeviceBindData != null) |
| | | // { |
| | | // var jObject = new JObject { { "DeviceAddr", delDeviceBindData.DeviceAddr }, { "Epoint", delDeviceBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5003 } }; |
| | | // var removeBindList = new JArray { }; |
| | | // foreach (var removeBindInfo in delDeviceBindData.RemoveBindList) |
| | | // { |
| | | // if (removeBindInfo.BindType == 0) |
| | | // { |
| | | // var dInfo = new JObject{ |
| | | // { "BindMacAddr",removeBindInfo.BindMacAddr}, |
| | | // { "BindEpoint", removeBindInfo.BindEpoint} , |
| | | // { "BindCluster", removeBindInfo.BindCluster} , |
| | | // { "BindType",removeBindInfo.BindType} |
| | | // }; |
| | | // removeBindList.Add(dInfo); |
| | | // } |
| | | // else if (removeBindInfo.BindType == 1) |
| | | // { |
| | | // var dInfo = new JObject{ |
| | | // { "BindCluster", removeBindInfo.BindCluster} , |
| | | // { "BindType",removeBindInfo.BindType}, |
| | | // { "BindScenesId", removeBindInfo.BindScenesId} |
| | | // }; |
| | | // removeBindList.Add(dInfo); |
| | | // } |
| | | // } |
| | | // var data = new JObject { |
| | | // {"RemoveBindList",removeBindList} |
| | | // }; |
| | | // jObject.Add("Data", data); |
| | | // mainGateway.Send("Bind/RemoveBind", jObject.ToString()); |
| | | // } |
| | | // } |
| | | // catch { } |
| | | |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(100); |
| | | // if (responseData == null || responseData.delDeviceBindResponseData == null) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0).Count) |
| | | // { |
| | | // if (responseData.removeBindResultResponseData != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) |
| | | // { |
| | | // responseData.errorMessageBase = "回复超时,请重新操作"; |
| | | // } |
| | | // mainGateway.Actions -= action; |
| | | // System.Console.WriteLine("DeviceBind/DelBind_Actions 退出" + System.DateTime.Now.ToString()); |
| | | |
| | | // return responseData; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | /////解除绑定数据,网关反馈信息 |
| | | ///// </summary> |
| | | //public DelDeviceBindResponseAllData delDeviceBindResponseAllData; |
| | | ///// <summary> |
| | | /////解除绑定数据,网关反馈信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class DelDeviceBindResponseAllData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// 解除绑定数据信息 |
| | | // /// </summary> |
| | | // public DelDeviceBindResponseData delDeviceBindResponseData; |
| | | |
| | | // /// <summary> |
| | | // /// 解除绑定按键确认数据信息 |
| | | // /// </summary> |
| | | // public RemoveBindResultResponseData removeBindResultResponseData; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 解除绑定数据 |
| | | ///// </summary> |
| | | //public DelDeviceBindResponseData delDeviceBindResponseData; |
| | | ///// <summary> |
| | | ///// 解除绑定数据 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class DelDeviceBindResponseData |
| | | //{ |
| | | // /// <summary> |
| | | // ///绑定列表 ,当Status=0时存在 |
| | | // /// </summary> |
| | | // public List<RemoveBindListResponseObj> RemoveBindList = new List<RemoveBindListResponseObj>(); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 移除设备绑定的信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class RemoveBindListResponseObj : BindListResponseObj |
| | | //{ |
| | | // /// <summary> |
| | | // /// 0:移除成功(该状态只适用用于跨网关绑定、绑定场景、失效设备(设备已经从网关的设备列表中删除)。同网关设备间的解除绑定需要节点设备的确认成功信息,不会直接反馈成功。) |
| | | // ///<para>1:失败,设备不在绑定列表中</para> |
| | | // ///<para>3:失败,在等待节点设备确认是否解除绑定成功(当网关还在等待某节点设备确认是否解除绑定成功的反馈信息时,客户端再次发送解除绑定该节点设备的指令,将反馈该状态。)</para> |
| | | // ///<para>4:未知,由节点设备反馈发送“Bind/RemoveBindResult”主题消息确定是否成功。</para> |
| | | // /// </summary> |
| | | // public int Result; |
| | | |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 移除设备绑定按键确认的信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class RemoveBindResultResponseData |
| | | //{ |
| | | // /// <summary> |
| | | // ///绑定结果 |
| | | // ///<para>0:成功</para> |
| | | // ///<para>136:控制设备本地绑定列表中无此绑定</para> |
| | | // ///<para>其他:失败</para> |
| | | // /// </summary> |
| | | // public int Result; |
| | | |
| | | // /// <summary> |
| | | // /// 绑定设备Mac地址 |
| | | // /// </summary> |
| | | // public string BindMacAddr; |
| | | // /// <summary> |
| | | // /// 绑定设备的端口号 |
| | | // /// </summary> |
| | | // public int BindEpoint; |
| | | // /// <summary> |
| | | // /// 绑定的cluster |
| | | // /// </summary> |
| | | // public int BindCluster; |
| | | // /// <summary> |
| | | // /// 绑定设备名称 |
| | | // /// </summary> |
| | | // public string DeviceName; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 解除绑定数据 |
| | | ///// </summary> |
| | | //public DelDeviceBindData delDeviceBindData; |
| | | ///// <summary> |
| | | ///// 解除绑定数据 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class DelDeviceBindData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 控制设备节点的mac地址 |
| | | // /// </summary> |
| | | // public string DeviceAddr; |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public int Epoint; |
| | | // /// <summary> |
| | | // ///绑定列表 ,当Status=0时存在 |
| | | // /// </summary> |
| | | // public List<RemoveBindListObj> RemoveBindList = new List<RemoveBindListObj>(); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 移除设备绑定的信息 |
| | | ///// </summary> |
| | | //[System.Serializable] |
| | | //public class RemoveBindListObj |
| | | //{ |
| | | |
| | | // /// <summary> |
| | | // /// 绑定类型 |
| | | // ///<para>0:移除设备 </para> |
| | | // ///<para>1:移除场景</para> |
| | | // /// </summary> |
| | | // public int BindType; |
| | | // /// <summary> |
| | | // /// 绑定的cluster |
| | | // /// </summary> |
| | | // public int BindCluster; |
| | | // /// <summary> |
| | | // /// 绑定设备Mac地址, 当BindType=0时存在 |
| | | // /// </summary> |
| | | // public string BindMacAddr; |
| | | // /// <summary> |
| | | // /// 绑定设备的端口号,当BindType=0时存在 |
| | | // /// </summary> |
| | | // public int BindEpoint; |
| | | // /// <summary> |
| | | // /// 绑定场景,当BindType=1时存在 |
| | | // /// </summary> |
| | | // public int BindScenesId; |
| | | //} |
| | | //#endregion |
| | | |
| | | //#region 获取所有绑定 |
| | | ///// <summary> |
| | | /////获取所有绑定 |
| | | ///// </summary> |
| | | //public async System.Threading.Tasks.Task<GetDeviceBindResponseAllData> GetDeviceBindAsyncAsync() |
| | | //{ |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // GetDeviceBindResponseAllData d = null; |
| | | // var mainGateway = ZbGateway.MainGateWay; |
| | | // if (mainGateway == null) |
| | | // { |
| | | // d = new GetDeviceBindResponseAllData { errorMessageBase = "当前没有主网关" }; |
| | | // return d; |
| | | // } |
| | | |
| | | // 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 = mainGateway.getGatewayBaseInfo.gwID }; |
| | | // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // d = new GetDeviceBindResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new GetDeviceBindResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "Bind/GetDeviceBind_Respon") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID }; |
| | | // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDeviceBindResponseData>(jobject["Data"].ToString()); |
| | | // //var tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString()); |
| | | // if (tempData == null) |
| | | // { |
| | | // d = new GetDeviceBindResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new GetDeviceBindResponseAllData { getAllBindResponseData = tempData }; |
| | | // System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | // mainGateway.Actions += action; |
| | | |
| | | // try |
| | | // { |
| | | // System.Console.WriteLine("Bind/GetDeviceBind_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } }; |
| | | // mainGateway.Send("Bind/GetDeviceBind", jObject.ToString()); |
| | | // } |
| | | // catch { } |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // if (d != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) |
| | | // { |
| | | // d = new GetDeviceBindResponseAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | // } |
| | | // mainGateway.Actions -= action; |
| | | // System.Console.WriteLine("Bind/GetDeviceBind_Actions 退出" + System.DateTime.Now.ToString()); |
| | | |
| | | // return d; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | /////获取所有绑定数据,网关反馈信息 |
| | | ///// </summary> |
| | | //public GetDeviceBindResponseAllData getAllBindResponseAllData; |
| | | //[System.Serializable] |
| | | //public class GetDeviceBindResponseAllData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// 控制设备绑定的设备列表回复数据 |
| | | // /// </summary> |
| | | // public GetDeviceBindResponseData getAllBindResponseData; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 获取所有绑定回复的数据 |
| | | ///// </summary> |
| | | //public GetDeviceBindResponseData getAllBindResponseData; |
| | | //[System.Serializable] |
| | | //public class GetDeviceBindResponseData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 0:成功 |
| | | // ///<para>1:绑定不存在</para> |
| | | // /// </summary> |
| | | // public int Result; |
| | | // /// <summary> |
| | | // /// 绑定列表 ,当Status=0时存在。 |
| | | // /// </summary> |
| | | // public List<BindListResponseObj> BindList = new List<BindListResponseObj>(); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 获取所有绑定的信息 |
| | | ///// </summary> |
| | | //public class BindListResponseObj |
| | | //{ |
| | | // /// <summary> |
| | | // /// 绑定类型 |
| | | // ///<para>0:移除设备,同网关设备间的移除</para> |
| | | // ///<para>1:移除设备,跨网关设备间的移除</para> |
| | | // ///<para>2:移除绑定场景</para> |
| | | // /// </summary> |
| | | // public int BindType; |
| | | // /// <summary> |
| | | // /// 绑定的cluster |
| | | // /// </summary> |
| | | // public int BindCluster; |
| | | // /// <summary> |
| | | // /// 绑定设备Mac地址, 当BindType=0时存在 |
| | | // /// </summary> |
| | | // public string BindMacAddr; |
| | | // /// <summary> |
| | | // /// 绑定设备的端口号,当BindType=0时存在 |
| | | // /// </summary> |
| | | // public int BindEpoint; |
| | | // /// <summary> |
| | | // /// 绑定场景,当BindType=1时存在 |
| | | // /// </summary> |
| | | // public int BindScenesId; |
| | | // /// <summary> |
| | | // /// 绑定的设备或场景名称 |
| | | // /// </summary> |
| | | // public string ESName; |
| | | //} |
| | | //#endregion |
| | | |
| | | //#region 删除一个控制设备所有绑定信息 |
| | | ///// <summary> |
| | | /////删除一个控制设备所有绑定信息 |
| | | ///// </summary> |
| | | //public async System.Threading.Tasks.Task<ClearBindInfoResponseAllData> ClearBindInfoAsync() |
| | | //{ |
| | | // if (Gateway == null) |
| | | // { |
| | | // return null; |
| | | // } |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // ClearBindInfoResponseAllData d = null; |
| | | // 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 = new ClearBindInfoResponseAllData { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new ClearBindInfoResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) }; |
| | | // } |
| | | // } |
| | | |
| | | // if (topic == gatewayID + "/" + "Bind/ClearBindInfo_Respon") |
| | | // { |
| | | // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; |
| | | // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClearBindInfoResponseData>(jobject["Data"].ToString()); |
| | | // if (tempData == null) |
| | | // { |
| | | // d = new ClearBindInfoResponseAllData { errorMessageBase = "网关返回的数据为空" }; |
| | | // } |
| | | // else |
| | | // { |
| | | // d = new ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData }; |
| | | // System.Console.WriteLine($"UI收到通知后的主题_{ topic}"); |
| | | // } |
| | | // } |
| | | // }; |
| | | // Gateway.Actions += action; |
| | | // System.Console.WriteLine("Bind/ClearBindInfo_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | |
| | | // try |
| | | // { |
| | | // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } }; |
| | | // Gateway.Send("Bind/ClearBindInfo", jObject.ToString()); |
| | | // } |
| | | // catch { } |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // if (d != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) |
| | | // { |
| | | // d = new ClearBindInfoResponseAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | // } |
| | | // Gateway.Actions -= action; |
| | | // System.Console.WriteLine("Bind/ClearBindInfo_Actions 退出" + System.DateTime.Now.ToString()); |
| | | |
| | | // return d; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | /////删除一个控制设备所有绑定数据,网关反馈信息 |
| | | ///// </summary> |
| | | //public ClearBindInfoResponseAllData clearBindInfoResponseAllData; |
| | | //[System.Serializable] |
| | | //public class ClearBindInfoResponseAllData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// 控制设备绑定的设备列表回复数据 |
| | | // /// </summary> |
| | | // public ClearBindInfoResponseData clearBindInfoResponseData; |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 删除一个控制设备所有绑定信息回复的数据 |
| | | ///// </summary> |
| | | //public ClearBindInfoResponseData clearBindInfoResponseData; |
| | | //[System.Serializable] |
| | | //public class ClearBindInfoResponseData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 0:成功 |
| | | // ///<para>1:绑定信息不存在</para> |
| | | // /// </summary> |
| | | // public int Result; |
| | | //} |
| | | |
| | | //#endregion |
| | | var dateTime = DateTime.Now; |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime) |
| | | { |
| | | await System.Threading.Tasks.Task.Delay(10); |
| | | if (result != null) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime) |
| | | { |
| | | result = new GetOnlySceneAllData { errorMessageBase = " 回复超时,请重新操作" }; |
| | | } |
| | | return result; |
| | | }); |
| | | } |
| | | /// <summary> |
| | | ///获取场景信息,网关反馈信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class GetOnlySceneAllData |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// 获取场景信息 |
| | | /// </summary> |
| | | public GetSceneInfo getSceneInfo; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 读取面板的配置信息(信息存到当前的对象具体值中) |
| | | /// 获取场景信息 |
| | | /// </summary> |
| | | //public void ReadPanelConfigureInfo() |
| | | //{ |
| | | // ReadAttri(Device.Cluster_ID.HdlKey, AttriButeId.HdlKey); |
| | | //} |
| | | public GetSceneInfo sceneGetInfo; |
| | | /// <summary> |
| | | /// 获取场景信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class GetSceneInfo |
| | | { |
| | | /// <summary> |
| | | ///场景总数 |
| | | /// </summary> |
| | | public int ScenesSum; |
| | | |
| | | //#region 获取所有做了绑定的控制设备 |
| | | ///// <summary> |
| | | /////获取所有做了绑定的控制设备 |
| | | ///// </summary> |
| | | //public async System.Threading.Tasks.Task<GetControlDeviceBindResponseAllData> GetControlDeviceAsync() |
| | | //{ |
| | | // if (Gateway == null) |
| | | // { |
| | | // return null; |
| | | // } |
| | | // return await System.Threading.Tasks.Task.Run(async () => |
| | | // { |
| | | // var d = new GetControlDeviceBindResponseAllData { }; |
| | | // Action<string, string> action = (topic, message) => |
| | | // { |
| | | // var gatewayID = topic.Split('/')[0]; |
| | | // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); |
| | | /// <summary> |
| | | /// 场景列表 |
| | | /// </summary> |
| | | public List<ScenesListInfo> ScenesList = new List<ScenesListInfo>(); |
| | | } |
| | | |
| | | // 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()); |
| | | /// <summary> |
| | | /// 场景列表中的具体信息 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class ScenesListInfo |
| | | { |
| | | /// <summary> |
| | | /// 场景ID |
| | | /// </summary> |
| | | public int ScenesId; |
| | | |
| | | // if (temp == null) |
| | | // { |
| | | // d.errorMessageBase = "网关错误回复,且数据是空"; |
| | | // } |
| | | // else |
| | | // { |
| | | // d.errorResponData = temp; |
| | | // d.errorMessageBase = ErrorMess(temp.Error); |
| | | // } |
| | | // } |
| | | /// <summary> |
| | | /// 名称 |
| | | /// </summary> |
| | | public string ScenesName; |
| | | |
| | | // if (topic == gatewayID + "/" + "DeviceBind_AddBind_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<GetControlDeviceBindResponseData>(jobject["Data"].ToString()); |
| | | |
| | | // if (tempData == null) |
| | | // { |
| | | // d.errorMessageBase = "网关返回的数据为空"; |
| | | // } |
| | | // else |
| | | // { |
| | | // d.getControlDeviceBindResponseData = tempData; |
| | | // } |
| | | // } |
| | | // }; |
| | | // Gateway.Actions += action; |
| | | // System.Console.WriteLine("GetControlDevice_Actions 启动" + "_" + Gateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString()); |
| | | |
| | | // var jObject = new JObject {{ "Cluster_ID", 0 }, { "Command", 154 } }; |
| | | // Gateway.Send("DeviceBind/GetControlDevice", jObject.ToString()); |
| | | |
| | | // var dateTime = DateTime.Now; |
| | | // while ((DateTime.Now - dateTime).TotalMilliseconds < 1000) |
| | | // { |
| | | // await System.Threading.Tasks.Task.Delay(10); |
| | | // if (d.getControlDeviceBindResponseData != null) |
| | | // { |
| | | // break; |
| | | // } |
| | | // } |
| | | // if ((DateTime.Now - dateTime).TotalMilliseconds > 10000) |
| | | // { |
| | | // d.errorMessageBase = " 回复超时,请重新操作"; |
| | | // } |
| | | // Gateway.Actions -= action; |
| | | // System.Console.WriteLine("GetControlDevice_Actions 退出" + System.DateTime.Now.ToString()); |
| | | |
| | | // return d; |
| | | // }); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 获取所有做了绑定的控制设备数据,网关反馈信息 |
| | | ///// </summary> |
| | | //public GetControlDeviceBindResponseAllData getControlDeviceBindResponseAllData; |
| | | //[System.Serializable] |
| | | //public class GetControlDeviceBindResponseAllData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 错误信息 |
| | | // /// </summary> |
| | | // public string errorMessageBase; |
| | | // /// <summary> |
| | | // /// 网关信息错误反馈 |
| | | // /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | // /// </summary> |
| | | // public ErrorResponData errorResponData; |
| | | // /// <summary> |
| | | // /// 获取所有做了绑定的控制设备数据 |
| | | // /// </summary> |
| | | // public GetControlDeviceBindResponseData getControlDeviceBindResponseData; |
| | | //} |
| | | |
| | | |
| | | ///// <summary> |
| | | ///// 获取所有做了绑定的控制设备数据 |
| | | ///// </summary> |
| | | //public GetControlDeviceBindResponseData getControlDeviceBindResponseData; |
| | | //[System.Serializable] |
| | | //public class GetControlDeviceBindResponseData |
| | | //{ |
| | | // /// <summary> |
| | | // /// 设备属性列表 |
| | | // /// </summary> |
| | | // public List<DeviceObj> DeviceObj = new List<DeviceObj>(); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// Command数组 |
| | | ///// </summary> |
| | | //public class DeviceObj |
| | | //{ |
| | | // /// <summary> |
| | | // /// 控制设备的mac地址 |
| | | // /// </summary> |
| | | // public string DeviceAddr; |
| | | |
| | | // /// <summary> |
| | | // /// 控制设备的端口号 |
| | | // /// </summary> |
| | | // public int Epoint; |
| | | //} |
| | | //#endregion |
| | | /// <summary> |
| | | /// 是否处于开启状态 |
| | | ///0:场景没有被开启 |
| | | ///1:场景处于开启状态 |
| | | /// </summary> |
| | | public int IsOpen; |
| | | } |
| | | #endregion |
| | | } |
| | | } |