using System; using System.Collections.Generic; using System.Text; using ZigBee.Device; namespace Shared.Phone.UserCenter { /// /// 设备固定信息的逻辑 /// public class HdlDeviceFixedAttributeLogic { #region ■ 变量声明___________________________ /// /// 设备固定信息的逻辑 /// private static HdlDeviceFixedAttributeLogic m_Current = null; /// /// 设备固定信息的逻辑 /// public static HdlDeviceFixedAttributeLogic Current { get { if (m_Current == null) { m_Current = new HdlDeviceFixedAttributeLogic(); } return m_Current; } } #endregion #region ■ 主入口函数_________________________ /// /// 读取以及设置设备固定属性(false:不需要发送命令) /// /// 设备回路 public bool SetAllFixedAttributeToDevice(CommonDevice i_device) { if (i_device == null) { return false; } var localDevice = Common.LocalDevice.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.GetCurtainComand(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; } #endregion #region ■ 获取窗帘命令_______________________ /// /// 获取窗帘命令 /// /// 设备对象 /// 标题数据 /// 属性数据 private void GetCurtainComand(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 } }