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