From 6fa9d69da922c8049f5acfcbb9ce9fd26811024c Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 16 四月 2020 17:10:57 +0800 Subject: [PATCH] 请合并代码 --- ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs | 1175 +--------------------------------------------------------- 1 files changed, 29 insertions(+), 1,146 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs index a7af65e..f73ef01 100755 --- a/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs +++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/CommonDevice.cs @@ -10,6 +10,11 @@ { [Newtonsoft.Json.JsonIgnore] public DateTime LastDateTime = DateTime.MinValue; + /// <summary> + /// 鏄惁宸茬粡璇诲彇浜嗚澶囩姸鎬�(姝ゅ睘鎬ф槸缁欎富椤典娇鐢ㄧ殑) + /// </summary> + [Newtonsoft.Json.JsonIgnore] + public bool HadReadDeviceStatu = false; /// <summary> /// 璋冭瘯鏃舵墦寮�鎵撳嵃淇℃伅锛宼rue:鎵撳嵃锛宖alse:涓嶆墦鍗� @@ -18,6 +23,7 @@ /// <param name="flage">If set to <c>true</c> flage.</param> public static void DebugPrintLog(string msg, bool flage = true) { +#if DEBUG if (flage == true) { if (msg.Contains("DeviceStatusReport") == false) @@ -25,6 +31,7 @@ System.Console.WriteLine(msg + " " + System.DateTime.Now.ToLongTimeString() + " " + System.DateTime.Now.Millisecond); } } +#endif } /// <summary> @@ -167,6 +174,14 @@ { return Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor>(strDeviceByte); } + else if (strDeviceType == ZigBee.Device.DeviceType.FreshAirHumiditySensor.ToString()) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject<HumiditySensor>(strDeviceByte); + } + else if (strDeviceType == ZigBee.Device.DeviceType.FreshAir.ToString()) + { + return Newtonsoft.Json.JsonConvert.DeserializeObject<FreshAir>(strDeviceByte); + } return null; } @@ -223,10 +238,16 @@ //缁х數鍣� IconPath = "Device/RelayEpoint.png"; } - else if (this.Type == DeviceType.Thermostat) + else if (this.Type == DeviceType.Thermostat || this.Type == DeviceType.FreshAir) { //绌鸿皟 + //鏂伴鍜岀┖璋冨浘鏍囩浉鍚� IconPath = "Device/AirConditionerEpoint.png"; + } + else if (this.Type == DeviceType.FreshAirHumiditySensor) + { + //婀垮害浼犳劅鍣� + IconPath = "Device/SensorHumidity.png"; } else if (this.Type == DeviceType.TemperatureSensor) { @@ -246,7 +267,7 @@ //鍏朵粬鐨勫浘鏍囨湁鐐圭壒娈� string unSelectPic = string.Empty; string selectPic = string.Empty; - Shared.Common.LocalDevice.Current.GetDeviceBeloneIcon(new List<CommonDevice> { this }, ref unSelectPic, ref selectPic); + Shared.Common.LocalDevice.Current.GetDeviceObjectIcon(new List<CommonDevice> { this }, ref unSelectPic, ref selectPic); IconPath = unSelectPic; } Shared.Common.Global.WriteFileByBytesByHomeId(FilePath, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); @@ -1000,7 +1021,7 @@ /// <summary> /// 璁惧鎵�鍦ㄧ綉鍏崇殑缃戝叧id /// </summary> - public int GwId; + public string GwId; /// <summary> /// 璁惧鍚� /// </summary> @@ -1149,198 +1170,8 @@ if (topic == gatewayID + "/" + "DeviceRenameRespon") { - var deviceID = jobject.Value<int>("Device_ID"); - switch ((DeviceType)(deviceID)) - { - case DeviceType.OnOffOutput: - var toggleLight = new ToggleLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - toggleLight.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceRenameResponseData>(jobject["Data"].ToString()); - - if (toggleLight.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = toggleLight.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var infoToggleLight = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint); - if (infoToggleLight != null) - { - infoToggleLight.DeviceEpointName = toggleLight.renameDeviceData.DeviceName; - } - } - break; - case DeviceType.AirSwitch: - var airSwitch = new AirSwitch() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - airSwitch.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.DeviceRenameResponseData>(jobject["Data"].ToString()); - - if (airSwitch.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = airSwitch.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var infoAirSwitch = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint); - if (infoAirSwitch != null) - { - infoAirSwitch.DeviceEpointName = airSwitch.renameDeviceData.DeviceName; - //infoAirSwitch.ReSave(); - } - } - break; - case DeviceType.OnOffSwitch: - var panelObj = new Panel() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - panelObj.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceRenameResponseData>(jobject["Data"].ToString()); - if (panelObj.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = panelObj.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var infoPanel = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint); - if (infoPanel != null) - { - infoPanel.DeviceEpointName = panelObj.renameDeviceData.DeviceName; - //infoPanel.ReSave(); - } - } - break; - case DeviceType.WindowCoveringDevice: - var windowCovering = new Rollershade() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - windowCovering.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceRenameResponseData>(jobject["Data"].ToString()); - if (windowCovering.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = windowCovering.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}"); - var wc = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint); - if (wc != null) - { - wc.DeviceEpointName = windowCovering.renameDeviceData.DeviceName; - } - } - - break; - case DeviceType.IASZone: - var ias = new IASZone() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - ias.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceRenameResponseData>(jobject["Data"].ToString()); - if (ias.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = ias.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}"); - - var zone = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint); - if (zone != null) - { - zone.DeviceEpointName = ias.renameDeviceData.DeviceName; - } - } - break; - case DeviceType.DimmableLight: - var dimmableLight = new DimmableLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - dimmableLight.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.DeviceRenameResponseData>(jobject["Data"].ToString()); - - if (dimmableLight.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = dimmableLight.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint); - if (info != null) - { - info.DeviceEpointName = dimmableLight.renameDeviceData.DeviceName; - } - } - break; - case DeviceType.Repeater: - var repeater = new Repeater() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - repeater.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.DeviceRenameResponseData>(jobject["Data"].ToString()); - - if (repeater.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = repeater.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint); - if (info != null) - { - info.DeviceEpointName = repeater.renameDeviceData.DeviceName; - } - } - break; - case DeviceType.Thermostat: - var ac = new AC() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - ac.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.DeviceRenameResponseData>(jobject["Data"].ToString()); - if (ac.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = ac.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint); - if (info != null) - { - info.DeviceEpointName = ac.renameDeviceData.DeviceName; - } - } - break; - case DeviceType.Transverter: - var transverter = new Transverter() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - transverter.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.DeviceRenameResponseData>(jobject["Data"].ToString()); - if (transverter.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = transverter.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint); - if (info != null) - { - info.DeviceEpointName = transverter.renameDeviceData.DeviceName; - } - } - break; - case DeviceType.DoorLock: - var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - doorLock.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.DeviceRenameResponseData>(jobject["Data"].ToString()); - if (doorLock.renameDeviceData == null) - { - d = new DeviceRenameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new DeviceRenameAllData { deviceRenameData = doorLock.renameDeviceData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint); - if (info != null) - { - info.DeviceEpointName = doorLock.renameDeviceData.DeviceName; - } - } - break; - } + var receiptData = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceRenameResponseData>(jobject["Data"].ToString()); + d = new DeviceRenameAllData { deviceRenameData = receiptData }; } }; Gateway.Actions += action; @@ -1462,217 +1293,8 @@ if (topic == gatewayID + "/" + "MacRename_Respon") { - var deviceID = jobject.Value<int>("Device_ID"); - switch ((DeviceType)(deviceID)) - { - case DeviceType.OnOffOutput: - var toggleLight = new ToggleLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - toggleLight.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RenameDeviceMacNameData>(jobject["Data"].ToString()); - - if (toggleLight.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = toggleLight.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var infoToggleLight = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint); - if (infoToggleLight != null) - { - infoToggleLight.DeviceName = toggleLight.renameDeviceMacNameData.MacName; - } - } - break; - case DeviceType.AirSwitch: - var airSwitch = new AirSwitch() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - airSwitch.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.RenameDeviceMacNameData>(jobject["Data"].ToString()); - - if (airSwitch.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = airSwitch.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - var infoAirSwitch = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint); - if (infoAirSwitch != null) - { - infoAirSwitch.DeviceName = airSwitch.renameDeviceMacNameData.MacName; - } - } - break; - case DeviceType.OnOffSwitch: - var panelObj = new Panel() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - panelObj.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RenameDeviceMacNameData>(jobject["Data"].ToString()); - if (panelObj.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = panelObj.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}"); - var infoPanel = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint); - if (infoPanel != null) - { - infoPanel.DeviceName = panelObj.renameDeviceMacNameData.MacName; - } - } - break; - case DeviceType.WindowCoveringDevice: - var windowCovering = new Rollershade() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - windowCovering.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.RenameDeviceMacNameData>(jobject["Data"].ToString()); - if (windowCovering.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = windowCovering.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}"); - var wc = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == windowCovering.DeviceID && obj.DeviceAddr == windowCovering.DeviceAddr && obj.DeviceEpoint == windowCovering.DeviceEpoint); - if (wc != null) - { - wc.DeviceName = windowCovering.renameDeviceMacNameData.MacName; - } - } - break; - case DeviceType.IASZone: - var ias = new IASZone() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - ias.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RenameDeviceMacNameData>(jobject["Data"].ToString()); - - if (ias.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = ias.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint); - if (info != null) - { - info.DeviceName = ias.renameDeviceMacNameData.MacName; - } - } - break; - case DeviceType.DimmableLight: - var dimmableLight = new DimmableLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - dimmableLight.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RenameDeviceMacNameData>(jobject["Data"].ToString()); - - if (dimmableLight.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = dimmableLight.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint); - if (info != null) - { - info.DeviceName = dimmableLight.renameDeviceMacNameData.MacName; - } - } - break; - case DeviceType.Repeater: - var repeater = new DimmableLight() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - repeater.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.RenameDeviceMacNameData>(jobject["Data"].ToString()); - - if (repeater.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = repeater.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint); - if (info != null) - { - info.DeviceName = repeater.renameDeviceMacNameData.MacName; - } - } - break; - case DeviceType.Thermostat: - var ac = new AC() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - ac.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.RenameDeviceMacNameData>(jobject["Data"].ToString()); - - if (ac.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = ac.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint); - if (info != null) - { - info.DeviceName = ac.renameDeviceMacNameData.MacName; - } - } - break; - case DeviceType.Transverter: - var transverter = new Transverter() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - transverter.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.RenameDeviceMacNameData>(jobject["Data"].ToString()); - - if (transverter.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = transverter.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint); - if (info != null) - { - info.DeviceName = transverter.renameDeviceMacNameData.MacName; - } - } - break; - case DeviceType.DoorLock: - var doorLock = new DoorLock() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - doorLock.renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.RenameDeviceMacNameData>(jobject["Data"].ToString()); - - if (doorLock.renameDeviceMacNameData == null) - { - d = new RenameDeviceMacNameAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" }; - } - else - { - d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = doorLock.renameDeviceMacNameData }; - System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}_鏀跺埌閫氱煡鍚庣殑鏁版嵁_{ d.renameDeviceMacNameData.ToString()}"); - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint); - if (info != null) - { - info.DeviceName = doorLock.renameDeviceMacNameData.MacName; - } - } - break; - //case DeviceType.TemperatureSensor: - // var temperatureSensor = new TemperatureSensor() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - // temperatureSensor.renameDeviceData = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor.DeviceRenameResponseData>(jobject["Data"].ToString()); - // if (temperatureSensor.renameDeviceData == null) - // { - // d.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�"; - // } - // else - // { - // d.deviceRenameData = temperatureSensor.renameDeviceData; - // } - // var ts = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == temperatureSensor.DeviceID && obj.DeviceEpoint == temperatureSensor.DeviceEpoint && obj.DeviceEpoint == temperatureSensor.DeviceEpoint); - // if (ts == null) - // { - // ts.DeviceName = temperatureSensor.renameDeviceData.DeviceName; - // IO.LocalFileUtils.SaveDeviceInfo(ts, ts.DeviceEpoint.ToString()); - - // } - // break; - } + var deviceID = jobject.Value<int>("Device_ID"); + d = new RenameDeviceMacNameAllData { renameDeviceMacNameData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RenameDeviceMacNameData>(jobject["Data"].ToString()) }; } }; Gateway.Actions += action; @@ -1833,210 +1455,6 @@ { d = new RemoveDeviceResponseAllData { removeDeviceResponseData = gatewayTemp.removeDeviceResponseData }; System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - try - { - if (gatewayTemp.removeDeviceResponseData.Result == 0) - { - foreach (var delD in gatewayTemp.removeDeviceResponseData.DeviceList) - { - var deviceID = delD.Device_ID; - switch ((DeviceType)(deviceID)) - { - case DeviceType.OnOffOutput: - var toggleLight = new ToggleLight() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - toggleLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (toggleLight.removeDeviceResponseData == null) - { - return; - } - else - { - if (toggleLight.removeDeviceResponseData.Result == 0) - { - var infoToggleLight = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == toggleLight.DeviceID && obj.DeviceAddr == toggleLight.DeviceAddr && obj.DeviceEpoint == toggleLight.DeviceEpoint); - if (infoToggleLight != null) - { - Gateway.DeviceList.Remove(infoToggleLight); - } - } - } - break; - case DeviceType.AirSwitch: - var airSwitch = new AirSwitch() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - airSwitch.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AirSwitch.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (airSwitch.removeDeviceResponseData == null) - { - return; - } - else - { - if (airSwitch.removeDeviceResponseData.Result == 0) - { - var infoAirSwitch = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == airSwitch.DeviceID && obj.DeviceAddr == airSwitch.DeviceAddr && obj.DeviceEpoint == airSwitch.DeviceEpoint); - if (infoAirSwitch != null) - { - Gateway.DeviceList.Remove(infoAirSwitch); - } - } - } - break; - case DeviceType.OnOffSwitch: - var panelObj = new Panel() { 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 }; - panelObj.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (panelObj.removeDeviceResponseData == null) - { - return; - } - else - { - if (panelObj.removeDeviceResponseData.Result == 0) - { - var infoPanel = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == panelObj.DeviceID && obj.DeviceAddr == panelObj.DeviceAddr && obj.DeviceEpoint == panelObj.DeviceEpoint); - if (infoPanel != null) - { - Gateway.DeviceList.Remove(infoPanel); - } - } - } - break; - case DeviceType.WindowCoveringDevice: - var rollershade = new Rollershade() { 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 }; - rollershade.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (rollershade.removeDeviceResponseData == null) - { - return; - } - else - { - if (rollershade.removeDeviceResponseData.Result == 0) - { - var infoRoller = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == rollershade.DeviceID && obj.DeviceAddr == rollershade.DeviceAddr && obj.DeviceEpoint == rollershade.DeviceEpoint); - if (infoRoller != null) - { - Gateway.DeviceList.Remove(infoRoller); - } - } - } - break; - case DeviceType.IASZone: - var ias = new IASZone() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - ias.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (ias.removeDeviceResponseData == null) - { - return; - } - else - { - if (ias.removeDeviceResponseData.Result == 0) - { - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ias.DeviceID && obj.DeviceAddr == ias.DeviceAddr && obj.DeviceEpoint == ias.DeviceEpoint); - if (info != null) - { - Gateway.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.DimmableLight: - var dimmableLight = new DimmableLight() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - dimmableLight.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DimmableLight.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (dimmableLight.removeDeviceResponseData == null) - { - return; - } - else - { - if (dimmableLight.removeDeviceResponseData.Result == 0) - { - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == dimmableLight.DeviceID && obj.DeviceAddr == dimmableLight.DeviceAddr && obj.DeviceEpoint == dimmableLight.DeviceEpoint); - if (info != null) - { - Gateway.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.Repeater: - var repeater = new Repeater() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - repeater.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Repeater.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (repeater.removeDeviceResponseData == null) - { - return; - } - else - { - if (repeater.removeDeviceResponseData.Result == 0) - { - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == repeater.DeviceID && obj.DeviceAddr == repeater.DeviceAddr && obj.DeviceEpoint == repeater.DeviceEpoint); - if (info != null) - { - Gateway.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.Thermostat: - var ac = new AC() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - ac.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<AC.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (ac.removeDeviceResponseData == null) - { - return; - } - else - { - if (ac.removeDeviceResponseData.Result == 0) - { - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == ac.DeviceID && obj.DeviceAddr == ac.DeviceAddr && obj.DeviceEpoint == ac.DeviceEpoint); - if (info != null) - { - Gateway.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.Transverter: - var transverter = new Transverter() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - transverter.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<Transverter.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (transverter.removeDeviceResponseData == null) - { - return; - } - else - { - if (transverter.removeDeviceResponseData.Result == 0) - { - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == transverter.DeviceID && obj.DeviceAddr == transverter.DeviceAddr && obj.DeviceEpoint == transverter.DeviceEpoint); - if (info != null) - { - Gateway.DeviceList.Remove(info); - } - } - } - break; - case DeviceType.DoorLock: - var doorLock = new DoorLock() { DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - doorLock.removeDeviceResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<DoorLock.RemoveDeviceResponseData>(jobject["Data"].ToString()); - if (doorLock.removeDeviceResponseData == null) - { - return; - } - else - { - if (doorLock.removeDeviceResponseData.Result == 0) - { - var info = Gateway.DeviceList.Find((CommonDevice obj) => obj.DeviceID == doorLock.DeviceID && obj.DeviceAddr == doorLock.DeviceAddr && obj.DeviceEpoint == doorLock.DeviceEpoint); - if (info != null) - { - Gateway.DeviceList.Remove(info); - } - } - } - break; - } - } - } - } - catch { } } } }; @@ -2234,16 +1652,6 @@ { d = new RemoveGatewayDeviceListAllData { removeGatewayDeviceListData = gatewayTemp.removeGatewayDeviceListData }; System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - - //for (int listCount = 0; listCount < Gateway.AllGatewayDeviceList.Count; listCount++) - //{ - // var dev = Gateway.AllGatewayDeviceList[listCount]; - // if (gatewayTemp.removeGatewayDeviceListData.GwId == dev.Gateway.CurrentGateWayId) - // { - // ZigBee.Device.ZbGateway.LogicList.RemoveAt(listCount); - // listCount--; - // } - //} } } }; @@ -2357,500 +1765,6 @@ System.Console.WriteLine("Identify_Actions 閫�鍑�" + System.DateTime.Now.ToString()); } - #endregion - - #region 璁惧涓婃姤杩斿洖鏁版嵁锛岀綉鍏冲洖澶嶄俊鎭� - ///// <summary> - ///// 璁惧涓婃姤杩斿洖鏁版嵁锛岀綉鍏冲洖澶嶄俊鎭� - ///// </summary> - //public DeviceReportResponAllData deviceReportResponAllData; - ///// <summary> - ///// 缃戝叧鎭㈠鍑哄巶璁剧疆杩斿洖鏁版嵁 - ///// </summary> - //[System.Serializable] - //public class DeviceReportResponAllData - //{ - // /// <summary> - // /// 閿欒淇℃伅 - // /// </summary> - // public string errorMessageBase; - // /// <summary> - // /// 缃戝叧淇℃伅閿欒鍙嶉 - // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para> - // /// </summary> - // public ErrorResponData errorResponData; - // ///<summary > - // ///璁惧鏁版嵁 - // /// </summary> - // public DeviceStatusReportData deviceStatusReportData; - //} - - ///// <summary> - ///// 璇诲彇鎶ュ憡灞炴�ч厤缃�,寮傛鑾峰彇鏁版嵁 - ///// </summary> - ///// <param name="clusterID">Cluster identifier.</param> - ///// <param name="attriButeId">Attri bute identifier.</param> - //public async System.Threading.Tasks.Task<DeviceReportResponAllData> ReadAttriAsync(Cluster_ID clusterID, AttriButeId attriButeId) - //{ - //if (Gateway == null) - //{ - // return null; - //} - ////string result = null; - - //return await System.Threading.Tasks.Task.Run(async () => - //{ - //var d = new DeviceReportResponAllData(); - //Action<string, string> action = (topic, message) => - //{ - //var gatewayID = topic.Split('/')[0]; - //var jobject = Newtonsoft.Json.Linq.JObject.Parse(message); - - //if (topic == gatewayID + "/" + "Error_Respon") - //{ - // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID }; - // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString()); - - // if (temp == null) - // { - // d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - // } - // else - // { - // d.errorResponData = temp; - // d.errorMessageBase = ErrorMess(temp.Error); - // } - //} - - //if (topic == gatewayID + "/" + "DeviceStatusReport" + "/" + DeviceAddr + "/" + DeviceEpoint + "/" + (int)clusterID + "/" + (int)attriButeId) - //{ - //var deviceID = jobject.Value<int>("Device_ID"); - //var deviceAddr = jobject.Value<string>("DeviceAddr"); - //var ep = jobject.Value<int>("Epoint"); - - //var device = Gateway.DeviceList.Find((obj) => obj.DeviceID == deviceID && obj.DeviceAddr == deviceAddr && obj.DeviceEpoint == ep); - //if (device == null) - //{ - // return; - //} - - //switch ((DeviceType)(deviceID)) - //{ - // case DeviceType.ColorDimmableLight: - // device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ColorDimmableLight.DeviceStatusReportData>(jobject["Data"].ToString()); - // if (device.DeviceStatusReport == null) - // { - // d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - // } - // else - // { - // d.deviceStatusReportData = device.DeviceStatusReport; - // System.Console.WriteLine($"鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // var light = device as ColorDimmableLight; - // if (device.DeviceStatusReport.CluterID == 8) - // { - // var attriButeList = device.DeviceStatusReport.AttriBute; - // foreach (var attriBute1 in attriButeList) - // { - // light.Level = attriBute1.AttriButeData; - // } - // light.ReSave(); - // ZigBee.Device.ZbGateway.UpdateDeviceStatus(light); - // } - // else if (device.DeviceStatusReport.CluterID == 6) - // { - // var attriButeList = device.DeviceStatusReport.AttriBute; - // foreach (var attriBute1 in attriButeList) - // { - // light.OnOffStatus = attriBute1.AttriButeData; - - // var key = light.DeviceAddr + "_" + light.DeviceEpoint; - // Gateway.sceneTaskInfoList.Remove(key); - // var st = new Scene.TaskListInfo() - // { - // TaskType = 1, - // Data1 = attriBute1.AttriButeData, - // Data2 = 0, - // }; - // Gateway.sceneTaskInfoList.Add(key, st); - // } - // light.ReSave(); - // ZigBee.Device.ZbGateway.UpdateDeviceStatus(light); - // } - // else if (device.DeviceStatusReport.CluterID == 768) - // { - // var attriButeList = device.DeviceStatusReport.AttriBute; - // //foreach (var attriBute1 in attriButeList) - // //{ - // // if (attriBute1.AttriButeId == 0) - // // { - // // light.Hue = attriBute1.AttriButeData.ToString(); - // // } - // // else if ((attriBute1.AttriButeId == 1)) - // // { - // // light.Saturation = attriBute1.AttriButeData.ToString(); - - // // } - // // else if ((attriBute1.AttriButeId == 16394)) - // // { - // // light.ColorCapabilities = attriBute1.AttriButeData.ToString(); - // // } - // // else if ((attriBute1.AttriButeId == 16384)) - // // { - // // light.EnhancedCurrentHue = attriBute1.AttriButeData.ToString(); - // // } - // //} - // light.ReSave(); - // ZigBee.Device.ZbGateway.UpdateDeviceStatus(light); - // } - // } - // break; - // case DeviceType.OnOffSwitch: - // device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString()); - // if (device.DeviceStatusReport == null) - // { - // d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - // } - // else - // { - // d.deviceStatusReportData = device.DeviceStatusReport; - // System.Console.WriteLine($"鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - - // var panelObj = device as Panel; - // foreach (var common in Gateway.DeviceList) - // { - // if (common.DeviceAddr != panelObj.DeviceAddr || common.DeviceEpoint != panelObj.DeviceEpoint) - // { - // continue; - // } - // if (common.Type == DeviceType.OnOffSwitch) - // { - // if (device.DeviceStatusReport.CluterID == 6) - // { - // var attriButeList = device.DeviceStatusReport.AttriBute; - // foreach (var attriBute1 in attriButeList) - // { - // panelObj.panelMode = attriBute1.AttriButeData; - // } - - // } - // } - // panelObj.ReSave(); - // ZigBee.Device.ZbGateway.UpdateDeviceStatus(panelObj); - // } - // } - // break; - //case DeviceType.OnOffOutput: - // device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ToggleLight.DeviceStatusReportData>(jobject["Data"].ToString()); - // //if (device.DeviceStatusReport != null) - // //{ - // // result = "鎴愬姛"; - // //} - // if (device.DeviceStatusReport == null) - // { - // d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - // } - // else - // { - // d.deviceStatusReportData = device.DeviceStatusReport; - // System.Console.WriteLine($"鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - - // var lighttoggle = device as ToggleLight; - // foreach (var common in Gateway.DeviceList) - // { - // if (common.DeviceAddr != lighttoggle.DeviceAddr || common.DeviceEpoint != lighttoggle.DeviceEpoint) - // { - // continue; - // } - // if (common.Type == DeviceType.OnOffOutput) - // { - // if (device.DeviceStatusReport.CluterID == 6) - // { - // var attriButeList = device.DeviceStatusReport.AttriBute; - // foreach (var attriBute1 in attriButeList) - // { - // lighttoggle.OnOffStatus = attriBute1.AttriButeData; - // System.Console.WriteLine("褰撳墠寮�鍏崇姸鎬�" + "_" + attriBute1.AttriButeData.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString()); - // } - // } - // } - // lighttoggle.ReSave(); - // ZigBee.Device.ZbGateway.UpdateDeviceStatus(lighttoggle); - // } - // } - // break; - - //case DeviceType.WindowCoveringDevice: - // device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Rollershade.DeviceStatusReportData>(jobject["Data"].ToString()); - // if (device.DeviceStatusReport == null) - // { - // d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖"; - // } - // else - // { - // d.deviceStatusReportData = device.DeviceStatusReport; - // System.Console.WriteLine($"鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}"); - // var curtain = device as Rollershade; - // foreach (var common in Gateway.DeviceList) - // { - // if (common.DeviceAddr != curtain.DeviceAddr || common.DeviceEpoint != curtain.DeviceEpoint) - // { - // continue; - // } - // if (common.Type == DeviceType.WindowCoveringDevice) - // { - // if (device.DeviceStatusReport.CluterID == 258) - // { - // foreach (var attriBute1 in curtain.DeviceStatusReport.AttriBute) - // { - // switch (attriBute1.AttributeId) - // { - // case 0: - // curtain.WcdType = attriBute1.AttriButeData; - // System.Console.WriteLine("褰撳墠绐楀笜鐨勭被鍨�" + "_" + curtain.WcdType.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString()); - // break; - // case 3: - // curtain.WcdCurrentPositionLift = attriBute1.AttriButeData; - // System.Console.WriteLine("绐楀笜褰撳墠楂樺害" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString()); - // break; - // case 8: - // curtain.WcdCurrentPositionLiftPercentage = attriBute1.AttriButeData; - // System.Console.WriteLine("褰撳墠绐楀笜鎵�鍦ㄧ殑杩涘害锛堢櫨鍒嗭級浣嶇疆" + "_" + curtain.WcdCurrentPositionLiftPercentage.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString()); - // break; - // case 16: - // curtain.WcdInstalledOpenLimitLift = attriBute1.AttriButeData; - // System.Console.WriteLine("绐楀笜鍏ㄥ紑鎵�鍦ㄧ殑浣嶇疆" + "_" + curtain.WcdInstalledOpenLimitLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString()); - // break; - // case 17: - // curtain.WcdInstalledClosedLimitLift = attriBute1.AttriButeData; - // System.Console.WriteLine("绐楀笜鍏ㄥ叧鎵�鍦ㄧ殑浣嶇疆" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString()); - // break; - // case 18: - // curtain.WcdInstalledOpenLimitTilt = attriBute1.AttriButeData; - // System.Console.WriteLine("绐楀笜鍏ㄥ紑鎵�鍦ㄧ殑瑙掑害" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString()); - // break; - // case 19: - // curtain.WcdInstalledClosedLimitTilt = attriBute1.AttriButeData; - // System.Console.WriteLine("绐楀笜鍏ㄥ叧鎵�鍦ㄧ殑瑙掑害" + "_" + curtain.WcdCurrentPositionLift.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString()); - // break; - // case 23: - // curtain.WcdCurrentMode = attriBute1.AttriButeData; - // System.Console.WriteLine("绐楀笜褰撳墠妯″紡" + "_" + curtain.WcdCurrentMode.ToString() + "_" + Gateway.getGatewayBaseInfo.gwID + "_" + System.DateTime.Now.ToString()); - // break; - // default: - // break; - // } - // } - // curtain.ReSave(); - // ZigBee.Device.ZbGateway.UpdateDeviceStatus(curtain); - // } - // } - // } - // } - // break; - //case DeviceType.IASZone: - //device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.DeviceStatusReportData>(jobject["Data"].ToString()); - //var ias = device as IASZone; - //foreach (var common in Gateway.DeviceList) - //{ - // if (common.DeviceAddr != ias.DeviceAddr || common.DeviceEpoint != ias.DeviceEpoint) - // { - // continue; - // } - // if (common.Type == DeviceType.IASZone) - // { - // ias.ReSave(); - // ZigBee.Device.ZbGateway.UpdateDeviceStatus(ias); - // } - //} - //ias.ReSave(); - //break; - //case DeviceType.Thermostat: - //device.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<ThermostatObj.DeviceStatusReportData>(jobject["Data"].ToString()); - //var ther = device as ThermostatObj; - //if (ther.DeviceStatusReport.CluterID == 514) - //{ - // foreach (var attriBute1 in ther.DeviceStatusReport.AttriBute) - // { - // if (attriBute1.AttributeId == 0) - // { - // ther.CurentFanControlMode = attriBute1.AttriButeData; - // } - // } - //} - - //if (ther.DeviceStatusReport.CluterID == 513) - //{ - // foreach (var attriBute1 in ther.DeviceStatusReport.AttriBute) - // { - // if (attriBute1.AttributeId == 0) - // { - // ther.LocalThermostat = attriBute1.AttriButeData / 100; - // } - // else if (attriBute1.AttributeId == 17) - // { - // ther.CurentCoolingSetpoint = attriBute1.AttriButeData / 100; - // } - // else if (attriBute1.AttributeId == 18) - // { - // ther.CurentHeatingSetpoint = attriBute1.AttriButeData / 100; - // } - // else if (attriBute1.AttributeId == 28) - // { - // ther.CurentSystemMode = attriBute1.AttriButeData; - // } - // } - //} - - //ZigBee.Device.ZbGateway.UpdateDeviceStatus(ther); - //break; - //case DeviceType.TemperatureSensor: - //var sensor = new TemperatureSensor() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.CurrentGateWayId }; - //sensor.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<TemperatureSensor.DeviceStatusReportData>(jobject["Data"].ToString()); - //ZigBee.Device.ZbGateway.UpdateDeviceStatus(sensor); - - //if (sensor.DeviceStatusReport.CluterID == 1026) - //{ - // foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute) - // { - // if (attriBute1.AttributeId == 0) - // { - // sensor.CurentTemperature = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 1) - // { - // sensor.MaxTemperature = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 2) - // { - // sensor.MinTemperature = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 3) - // { - // sensor.TorleranceTemperature = attriBute1.AttriButeData; - // } - // IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString()); - // } - //} - //else if (sensor.DeviceStatusReport.CluterID == 1029) - //{ - // foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute) - // { - // if (attriBute1.AttributeId == 0) - // { - // sensor.CurentHumidity = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 1) - // { - // sensor.MaxHumidity = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 2) - // { - // sensor.MinHumidity = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 3) - // { - // sensor.ToleranceHumidity = attriBute1.AttriButeData; - // } - // IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString()); - // } - //} - - //var sen = Gateway.SensorInfoList.Find(obj => obj.DeviceAddr == sensor.DeviceAddr && obj.DeviceEpoint == sensor.DeviceEpoint); - //if (sen == null) - //{ - // Gateway.SensorInfoList.Add(sensor); - //} - //else - //{ - // if (sensor.DeviceStatusReport.CluterID == 1026) - // { - // foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute) - // { - // if (attriBute1.AttributeId == 0) - // { - // sen.CurentTemperature = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 1) - // { - // sen.MaxTemperature = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 2) - // { - // sen.MinTemperature = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 3) - // { - // sen.TorleranceTemperature = attriBute1.AttriButeData; - // } - // IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString()); - // } - // } - // else if (sensor.DeviceStatusReport.CluterID == 1029) - // { - // foreach (var attriBute1 in sensor.DeviceStatusReport.AttriBute) - // { - // if (attriBute1.AttributeId == 0) - // { - // sen.CurentHumidity = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 1) - // { - // sen.MaxHumidity = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 2) - // { - // sen.MinHumidity = attriBute1.AttriButeData; - // } - // else if (attriBute1.AttributeId == 3) - // { - // sen.ToleranceHumidity = attriBute1.AttriButeData; - // } - // IO.LocalFileUtils.SaveDeviceInfo(sensor, sensor.DeviceEpoint.ToString()); - // } - // } - //} - //break; - // } - // } - // }; - - // Gateway.Actions += action; - - // var JObject = new JObject { - // { "DeviceAddr",DeviceAddr }, - // { "Epoint", DeviceEpoint }, - // { "Cluster_ID", (int)clusterID }, - // { "Command", 108 } - // }; - // var attriBute = new JArray{ - // new JObject { - // { "AttriButeId", (int)attriButeId} - // } - // }; - // var data = new JObject { { "AttriBute", attriBute } }; - // JObject.Add("Data", data); - // Gateway?.Send(("GetDeviceStatus"), Common.SecuritySet.Encryption((JObject.ToString()))); - - // var dateTime = DateTime.Now; - // while ((DateTime.Now - dateTime).TotalMilliseconds < 5000) - // { - // await System.Threading.Tasks.Task.Delay(10); - // if (d.deviceStatusReportData != null) - // { - // break; - // } - // } - // if ((DateTime.Now - dateTime).TotalMilliseconds > 10000) - // { - // d.errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔"; - // } - // Gateway.Actions -= action; - // return d; - - // }); - - //} #endregion #region 璁惧灞炴�х姸鎬佷笂鎶� @@ -3757,37 +2671,6 @@ #endregion - #region 鍚敤鎴栧叧闂妭鐐硅澶囬�忎紶鏁版嵁涓婁紶鎺ュ彛 - /// <summary> - /// 鑺傜偣璁惧閫忎紶鏁版嵁鍒板鎴风 - /// <para>缃戝叧绋嬪簭榛樿鏄叧闂�忎紶鏁版嵁涓婁紶鐨勶紝鍙互閫氳繃浠ヤ笅鎸囦护寮�鍚�忎紶鏁版嵁涓婁紶銆傞�忎紶鏁版嵁涓婁紶寮�鍚悗锛岄噸鍚綉鍏崇▼搴忛�忎紶鏁版嵁涓婁紶灏嗚繕鍘熸垚鍏抽棴鐘舵��</para> - /// <para>isOn 0锛氬叧闂�忎紶鏁版嵁涓婁紶</para> - /// <para>isOn 1锛氬紑鍚�忎紶鏁版嵁涓婁紶</para> - /// </summary> - //public void OpenPassthroughControl(ZigBee.Device.ZbGateway gateway, int isOn = 1) - //{ - // if (Gateway == null) - // { - // return; - // } - // Action<string, string> action = (topic, message) => { }; - // Gateway.Actions += action; - // System.Console.WriteLine("OnZbDataPassthrough_Actions 鍚姩" + "_" + System.DateTime.Now.ToString()); - - // try - // { - // var jObject = new JObject { { "Cluster_ID", 64513 }, { "Command", 1 } }; - // var data = new JObject { { "IsOn", isOn } }; - // jObject.Add("Data", data); - // gateway.Send(("OnZbDataPassthrough"), jObject.ToString()); - // } - // catch { } - - // Gateway.Actions -= action; - // System.Console.WriteLine("OnZbDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString()); - //} - #endregion - #region 瀹㈡埛绔悜鑺傜偣璁惧閫忎紶鏁版嵁. /// <summary> /// 瀹㈡埛绔悜鑺傜偣璁惧閫忎紶鏁版嵁 @@ -4267,7 +3150,7 @@ /// <summary> ///鍝嶅簲鎿嶄綔鐮侊紙0-ffff锛� /// </summary> - public int command = -1; + public string command; /// <summary> /// 鐘舵�佸�� /// <para>0--鎴愬姛 1--澶辫触 ff--鏃犳晥</para> -- Gitblit v1.8.0