From 99253403b560f761d5f9af8b4f5140496996433a Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期五, 20 十一月 2020 16:49:50 +0800 Subject: [PATCH] 新云端的代码Ver1.0 --- ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceAttributeLogic.cs | 815 ++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 487 insertions(+), 328 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs b/ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceAttributeLogic.cs old mode 100755 new mode 100644 similarity index 74% rename from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs rename to ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceAttributeLogic.cs index ec80f72..9d29cfb --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceAttributeLogic.cs +++ b/ZigbeeApp/Shared/Phone/Common/Logic/HdlDeviceAttributeLogic.cs @@ -1,74 +1,163 @@ -锘縰sing Shared.Common; -using System; -using System.Collections.Generic; -using System.Text; -using ZigBee.Device; - -namespace Shared.Phone.UserCenter -{ - /// <summary> - /// 璁惧灞炴�х殑閫昏緫绫� - /// </summary> - public class HdlDeviceAttributeLogic - { - #region 鈻� 鍙橀噺澹版槑___________________________ - - /// <summary> - /// 灞炴�х殑閫昏緫 +锘縰sing Shared.Common; +using System; +using System.Collections.Generic; +using System.Text; +using ZigBee.Device; + +namespace Shared.Phone +{ + /// <summary> + /// 璁惧灞炴�х殑閫昏緫绫� + /// </summary> + public class HdlDeviceAttributeLogic + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 灞炴�х殑閫昏緫 /// </summary> - private static HdlDeviceAttributeLogic m_Current = null; - /// <summary> - /// 灞炴�х殑閫昏緫 + private static HdlDeviceAttributeLogic m_Current = null; + /// <summary> + /// 灞炴�х殑閫昏緫 /// </summary> - public static HdlDeviceAttributeLogic Current - { - get - { - if (m_Current == null) - { - m_Current = new HdlDeviceAttributeLogic(); - } - return m_Current; - } - set - { - m_Current = value; - } - } - - #endregion - - #region 鈻� 鍐欏叆璁惧灞炴�______________________ - - /// <summary> - /// 鑾峰彇鏇存敼璁惧绉佹湁灞炴�х殑鍛戒护 - /// </summary> - /// <param name="clusterId"></param> - /// <param name="attributeId"></param> - /// <param name="attributeDataType"></param> - /// <param name="attributeData"></param> - /// <returns></returns> - public string GetWriteDeviceAttributeText(string DeviceAddr, int DeviceEpoint, int clusterId, int attributeId, int attributeDataType, object attributeData) - { - var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterId }, { "Command", 120 } }; - Newtonsoft.Json.Linq.JObject data = null; - if (attributeData is int) - { - data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", Convert.ToInt32(attributeData) } }; - } - else - { - data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", attributeData.ToString() } }; - } - jObject.Add("Data", data); - - return jObject.ToString(); - } - - #endregion - + public static HdlDeviceAttributeLogic Current + { + get + { + if (m_Current == null) + { + m_Current = new HdlDeviceAttributeLogic(); + } + return m_Current; + } + set + { + m_Current = value; + } + } + + #endregion + + #region 鈻� 鍐欏叆璁惧灞炴�______________________ + + /// <summary> + /// 鑾峰彇鏇存敼璁惧绉佹湁灞炴�х殑鍛戒护 + /// </summary> + /// <param name="clusterId"></param> + /// <param name="attributeId"></param> + /// <param name="attributeDataType"></param> + /// <param name="attributeData"></param> + /// <returns></returns> + public string GetWriteDeviceAttributeText(string DeviceAddr, int DeviceEpoint, int clusterId, int attributeId, int attributeDataType, object attributeData) + { + var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterId }, { "Command", 120 } }; + Newtonsoft.Json.Linq.JObject data = null; + if (attributeData is int) + { + data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", Convert.ToInt32(attributeData) } }; + } + else + { + data = new Newtonsoft.Json.Linq.JObject { { "Undivided", 0 }, { "AttributeId", attributeId }, { "AttributeDataType", attributeDataType }, { "AttributeData", attributeData.ToString() } }; + } + jObject.Add("Data", data); + + return jObject.ToString(); + } + + #endregion + + #region 鈻� 璇诲彇璁惧纭欢淇℃伅___________________ + + /// <summary> + /// 璇诲彇璁惧纭欢淇℃伅 + /// </summary> + /// <param name="device">璁惧鍥炶矾</param> + public void ReadDeviceAllHardFirmwareInfo(CommonDevice device) + { + if (device == null) + { + return; + } + + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.Basic }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 4}//鐢熶骇鍟嗗悕瀛� + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 5}//鍨嬪彿鐮�(涔熷彨妯″潡ID) + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 6}//鐢熶骇鏃ユ湡 + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 7}//鐢垫簮 + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", 13}//搴忓垪鍙� + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + + HdlGatewayLogic.Current.SendJobjectData(device.CurrentGateWayId, "GetDeviceStatus", jObject.ToString()); + } + + #endregion + + #region 鈻� 鑾峰彇璁惧鍥轰欢鐗堟湰淇℃伅_______________ + + /// <summary> + /// 璇诲彇璁惧鍥轰欢鐗堟湰淇℃伅 + /// </summary> + /// <param name="device"></param> + public void ReadDeviceFirmwareVersion(OTADevice device) + { + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.Ota }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.ImgVersion} + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.mgHWversion} + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.ImgTypeId} + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + + HdlGatewayLogic.Current.SendJobjectData(device.CurrentGateWayId, "GetDeviceStatus", jObject.ToString()); + } + + #endregion + #region 鈻� 绌鸿皟_______________________________ - + /// <summary> /// SendACStatuComand /// </summary> @@ -88,226 +177,226 @@ { IsBackground = true }.Start(); } - /// <summary> - /// SendThermostatStatuComand - /// </summary> - /// <param name="device">璁惧</param> - public void SendThermostatStatuComand(CommonDevice device) - { + /// <summary> + /// SendThermostatStatuComand + /// </summary> + /// <param name="device">璁惧</param> + public void SendThermostatStatuComand(CommonDevice device) + { if (device == null) { return; } - var jObject = new Newtonsoft.Json.Linq.JObject - { - { "DeviceAddr",device.DeviceAddr }, - { "Epoint", device.DeviceEpoint }, - { "Cluster_ID", (int)Cluster_ID.Thermostat }, - { "Command", 108 } - }; - var attriBute = new Newtonsoft.Json.Linq.JArray - { - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.LocalTemperature} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.CoolingSetpoint} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.HeatingSetpoint} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.AutoSetpoint} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.SystemMode} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.AcModeSupport} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.CleanStatu} - } - }; - var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; - jObject.Add("Data", data); - device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.Thermostat }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.LocalTemperature} + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.CoolingSetpoint} + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.HeatingSetpoint} + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.AutoSetpoint} + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.SystemMode} + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.AcModeSupport} + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.CleanStatu} + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); } - /// <summary> - /// SendFanStatuComand - /// </summary> - /// <param name="device">璁惧</param> - private void SendFanStatuComand(CommonDevice device) - { + /// <summary> + /// SendFanStatuComand + /// </summary> + /// <param name="device">璁惧</param> + private void SendFanStatuComand(CommonDevice device) + { if (device == null) { return; } - var jObject = new Newtonsoft.Json.Linq.JObject - { - { "DeviceAddr",device.DeviceAddr }, - { "Epoint", device.DeviceEpoint }, - { "Cluster_ID", (int)Cluster_ID.FanControl }, - { "Command", 108 } - }; - var attriBute = new Newtonsoft.Json.Linq.JArray - { - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.FanMode} - }, - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.FanSwing} - } - }; - var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; - jObject.Add("Data", data); - device.Gateway?.Send("GetDeviceStatus", jObject.ToString()); + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.FanControl }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.FanMode} + }, + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.FanSwing} + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + device.Gateway?.Send("GetDeviceStatus", jObject.ToString()); } #endregion - #region 鈻� 鏂伴_______________________________ - /// <summary> - /// SendFreshAirStatuComand - /// </summary> - /// <param name="device">璁惧</param> - public void SendFreshAirStatuComand(CommonDevice device) - { - if (device == null) - { - return; - } - new System.Threading.Thread(() => - { - SendFreshAirFanStatuComand(device); - System.Threading.Thread.Sleep(300); - }) - { IsBackground = true }.Start(); - } - - /// <summary> - /// SendFanStatuComand - /// </summary> - /// <param name="device">璁惧</param> - private void SendFreshAirFanStatuComand(CommonDevice device) - { - if (device == null) - { - return; - } - var jObject = new Newtonsoft.Json.Linq.JObject - { - { "DeviceAddr",device.DeviceAddr }, - { "Epoint", device.DeviceEpoint }, - { "Cluster_ID", (int)Cluster_ID.FanControl }, - { "Command", 108 } - }; - var attriBute = new Newtonsoft.Json.Linq.JArray - { - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.FanMode} - } - }; - var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; - jObject.Add("Data", data); - device.Gateway?.Send("GetDeviceStatus", jObject.ToString()); - } - + #region 鈻� 鏂伴_______________________________ + /// <summary> + /// SendFreshAirStatuComand + /// </summary> + /// <param name="device">璁惧</param> + public void SendFreshAirStatuComand(CommonDevice device) + { + if (device == null) + { + return; + } + new System.Threading.Thread(() => + { + SendFreshAirFanStatuComand(device); + System.Threading.Thread.Sleep(300); + }) + { IsBackground = true }.Start(); + } + + /// <summary> + /// SendFanStatuComand + /// </summary> + /// <param name="device">璁惧</param> + private void SendFreshAirFanStatuComand(CommonDevice device) + { + if (device == null) + { + return; + } + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.FanControl }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.FanMode} + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + device.Gateway?.Send("GetDeviceStatus", jObject.ToString()); + } + #endregion - #region 鈻� PM2.5_______________________________ - /// <summary> - /// SendPmSensorComand - /// </summary> - /// <param name="device">璁惧</param> - public void SendPmSensorComand(CommonDevice device) - { - if (device == null) - { - return; - } - new System.Threading.Thread(() => - { - SendPmSensorStatuComand(device); - //璇诲彇Pm2.5浼犳劅鍣ㄧ殑娓╁害鏁版嵁 - HdlDeviceAttributeLogic.Current.SendTemperatureStatuComand(device); - //璇诲彇Pm2.5浼犳劅鍣ㄧ殑婀垮害鏁版嵁 - HdlDeviceAttributeLogic.Current.SendHumidityStatuComand(device); - System.Threading.Thread.Sleep(300); - }) - { IsBackground = true }.Start(); - } - - /// <summary> - /// SendFanStatuComand - /// </summary> - /// <param name="device">璁惧</param> - private void SendPmSensorStatuComand(CommonDevice device) - { - if (device == null) - { - return; - } - var jObject = new Newtonsoft.Json.Linq.JObject - { - { "DeviceAddr",device.DeviceAddr }, - { "Epoint", device.DeviceEpoint }, - { "Cluster_ID", (int)Cluster_ID.PmTwoPointFiveMeasurement }, - { "Command", 108 } - }; - var attriBute = new Newtonsoft.Json.Linq.JArray - { - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.MeasuredValue} - } - }; - var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; - jObject.Add("Data", data); - device.Gateway?.Send("GetDeviceStatus", jObject.ToString()); - } - - #endregion - + #region 鈻� PM2.5______________________________ + /// <summary> + /// SendPmSensorComand + /// </summary> + /// <param name="device">璁惧</param> + public void SendPmSensorComand(CommonDevice device) + { + if (device == null) + { + return; + } + new System.Threading.Thread(() => + { + SendPmSensorStatuComand(device); + //璇诲彇Pm2.5浼犳劅鍣ㄧ殑娓╁害鏁版嵁 + HdlDeviceAttributeLogic.Current.SendTemperatureStatuComand(device); + //璇诲彇Pm2.5浼犳劅鍣ㄧ殑婀垮害鏁版嵁 + HdlDeviceAttributeLogic.Current.SendHumidityStatuComand(device); + System.Threading.Thread.Sleep(300); + }) + { IsBackground = true }.Start(); + } + + /// <summary> + /// SendFanStatuComand + /// </summary> + /// <param name="device">璁惧</param> + private void SendPmSensorStatuComand(CommonDevice device) + { + if (device == null) + { + return; + } + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.PmTwoPointFiveMeasurement }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.MeasuredValue} + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + device.Gateway?.Send("GetDeviceStatus", jObject.ToString()); + } + + #endregion + #region 鈻� 绐楀笜_______________________________ - /// <summary> - /// 鍙戦�佽幏鍙栫獥甯樼姸鎬佸懡浠� - /// </summary> - /// <param name="device">绐楀笜</param> - public void SendCurtainStatuComand(CommonDevice device) - { + /// <summary> + /// 鍙戦�佽幏鍙栫獥甯樼姸鎬佸懡浠� + /// </summary> + /// <param name="device">绐楀笜</param> + public void SendCurtainStatuComand(CommonDevice device) + { if (device == null) { return; } - var jObject = new Newtonsoft.Json.Linq.JObject - { - { "DeviceAddr",device.DeviceAddr }, - { "Epoint", device.DeviceEpoint }, - { "Cluster_ID", (int)Cluster_ID.WindowCovering }, - { "Command", 108 } - }; - var attriBute = new Newtonsoft.Json.Linq.JArray - { - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.CurrentPositionLiftPercentage} - } - }; - var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; - jObject.Add("Data", data); - device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.WindowCovering }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.CurrentPositionLiftPercentage} + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); } #endregion @@ -342,68 +431,68 @@ { IsBackground = true }.Start(); } - /// <summary> - /// 鍙戦�佽幏鍙栫伅鍏夌姸鎬佸懡浠� - /// </summary> - /// <param name="device">绐楀笜</param> - private void SendSwitchStatuComand(CommonDevice device) - { + /// <summary> + /// 鍙戦�佽幏鍙栫伅鍏夌姸鎬佸懡浠� + /// </summary> + /// <param name="device">绐楀笜</param> + private void SendSwitchStatuComand(CommonDevice device) + { if (device == null) { return; } - var jObject = new Newtonsoft.Json.Linq.JObject - { - { "DeviceAddr",device.DeviceAddr }, - { "Epoint", device.DeviceEpoint }, - { "Cluster_ID", (int)Cluster_ID.Switch }, - { "Command", 108 } - }; - var attriBute = new Newtonsoft.Json.Linq.JArray - { - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.Switch} - } - }; - var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; - jObject.Add("Data", data); - device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.Switch }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.Switch} + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); } - /// <summary> - /// 鍙戦�佽幏鍙栫伅鍏夌姸鎬佸懡浠� - /// </summary> - /// <param name="device">绐楀笜</param> - public void SendLevelStatuComand(CommonDevice device) - { + /// <summary> + /// 鍙戦�佽幏鍙栫伅鍏夌姸鎬佸懡浠� + /// </summary> + /// <param name="device">绐楀笜</param> + public void SendLevelStatuComand(CommonDevice device) + { if (device == null) { return; } - var jObject = new Newtonsoft.Json.Linq.JObject - { - { "DeviceAddr",device.DeviceAddr }, - { "Epoint", device.DeviceEpoint }, - { "Cluster_ID", (int)Cluster_ID.LevelControl }, - { "Command", 108 } - }; - var attriBute = new Newtonsoft.Json.Linq.JArray - { - new Newtonsoft.Json.Linq.JObject - { - { "AttriButeId", (int)AttriButeId.LevelControl} - } - }; - var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; - jObject.Add("Data", data); - device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); - } - + var jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.LevelControl }, + { "Command", 108 } + }; + var attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.LevelControl} + } + }; + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); + } + #endregion - + #region 鈻� 鑹叉俯鐏痏____________________________ - + /// <summary> /// 鍙戦�佽幏鍙栬壊娓╃伅鐘舵�佸懡浠� /// </summary> @@ -418,15 +507,15 @@ new System.Threading.Thread(() => { colorDevice.ReadOnOffStatus(); - System.Threading.Thread.Sleep(300); - colorDevice.ReadLevel(); - System.Threading.Thread.Sleep(300); + System.Threading.Thread.Sleep(300); + colorDevice.ReadLevel(); + System.Threading.Thread.Sleep(300); colorDevice.ReadColorTemperature(); - if (LocalDevice.Current.IsMiniLight(device) == true) - { - //mini澶滅伅闇�瑕佽鍙栬渹楦e櫒鐘舵�� - System.Threading.Thread.Sleep(300); - colorDevice.ReadBuzzerStatu(); + if (HdlDeviceCommonLogic.Current.IsMiniLight(device) == true) + { + //mini澶滅伅闇�瑕佽鍙栬渹楦e櫒鐘舵�� + System.Threading.Thread.Sleep(300); + colorDevice.ReadBuzzerStatu(); } }) { IsBackground = true }.Start(); @@ -494,6 +583,76 @@ device.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); } - #endregion - } -} + #endregion + + #region 鈻� 璇诲彇璁惧鍥哄畾灞炴�__________________ + + /// <summary> + /// 璇诲彇璁惧鍥哄畾灞炴��(false:涓嶉渶瑕佸彂閫佸懡浠�) + /// </summary> + /// <param name="i_device">璁惧鍥炶矾</param> + public bool ReadDeviceAllFixedAttribute(CommonDevice i_device) + { + if (i_device == null) + { + return false; + } + var localDevice = HdlDeviceCommonLogic.Current.GetDevice(i_device.DeviceAddr, i_device.DeviceEpoint); + if (localDevice == null) + { + //ota涔熶細璺戣繘鏉� + return false; + } + + Newtonsoft.Json.Linq.JObject jObject = null; + Newtonsoft.Json.Linq.JArray attriBute = null; + //绐楀笜 + if (localDevice.Type == DeviceType.WindowCoveringDevice + && ((Rollershade)localDevice).WcdType == -1) + { + this.GetCurtainFixedAttributeComand(localDevice, ref jObject, ref attriBute); + } + if (jObject == null) + { + //涓嶉渶瑕佸彂閫� + return false; + } + //鍙戦�� + var data = new Newtonsoft.Json.Linq.JObject { { "AttriBute", attriBute } }; + jObject.Add("Data", data); + localDevice.Gateway?.Send(("GetDeviceStatus"), jObject.ToString()); + + return true; + } + + #region 鑾峰彇绐楀笜鍥哄畾灞炴�у懡浠_ + + /// <summary> + /// 鑾峰彇绐楀笜鍥哄畾灞炴�у懡浠� + /// </summary> + /// <param name="device">璁惧瀵硅薄</param> + /// <param name="jObject">鏍囬鏁版嵁</param> + /// <param name="attriBute">灞炴�ф暟鎹�</param> + private void GetCurtainFixedAttributeComand(CommonDevice device, ref Newtonsoft.Json.Linq.JObject jObject, ref Newtonsoft.Json.Linq.JArray attriBute) + { + jObject = new Newtonsoft.Json.Linq.JObject + { + { "DeviceAddr",device.DeviceAddr }, + { "Epoint", device.DeviceEpoint }, + { "Cluster_ID", (int)Cluster_ID.WindowCovering }, + { "Command", 108 } + }; + attriBute = new Newtonsoft.Json.Linq.JArray + { + new Newtonsoft.Json.Linq.JObject + { + { "AttriButeId", (int)AttriButeId.WindowCoveringType } + } + }; + } + + #endregion + + #endregion + } +} -- Gitblit v1.8.0