From bff8993501334c4f3c5f902216fe03253be747f8 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期三, 15 四月 2020 16:59:01 +0800
Subject: [PATCH] 合并新代码
---
ZigbeeApp20200414/Shared/Phone/ZigBee/Device/CommonDevice.cs | 748 ---------------------------------------------------------
1 files changed, 2 insertions(+), 746 deletions(-)
diff --git a/ZigbeeApp20200414/Shared/Phone/ZigBee/Device/CommonDevice.cs b/ZigbeeApp20200414/Shared/Phone/ZigBee/Device/CommonDevice.cs
old mode 100644
new mode 100755
index 493a26f..f73ef01
--- a/ZigbeeApp20200414/Shared/Phone/ZigBee/Device/CommonDevice.cs
+++ b/ZigbeeApp20200414/Shared/Phone/ZigBee/Device/CommonDevice.cs
@@ -1293,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;
@@ -1861,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--;
- // }
- //}
}
}
};
@@ -1984,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 璁惧灞炴�х姸鎬佷笂鎶�
@@ -3382,37 +2669,6 @@
public List<OTADeviceList> DeviceList = new List<OTADeviceList>();
}
- #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 瀹㈡埛绔悜鑺傜偣璁惧閫忎紶鏁版嵁.
--
Gitblit v1.8.0