old mode 100755
new mode 100644
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.TemplateData
|
| | | {
|
| | | /// <summary>
|
| | | /// 设备模板数据的逻辑
|
| | | /// </summary>
|
| | | public class TemplateDeviceDataLogic
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设备模板数据的逻辑
|
| | | /// </summary>
|
| | | private static TemplateDeviceDataLogic m_Current = null;
|
| | | /// <summary>
|
| | | /// 设备模板数据的逻辑
|
| | | /// </summary>
|
| | | public static TemplateDeviceDataLogic Current
|
| | | {
|
| | | get
|
| | | {
|
| | | if (m_Current == null)
|
| | | {
|
| | | m_Current = new TemplateDeviceDataLogic();
|
| | | }
|
| | | return m_Current;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 窗帘手拉控制_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加窗帘手拉控制缓存
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <param name="bolStatu">手拉控制状态</param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | public void SetCurtainHandPullControl(CommonDevice device, bool bolStatu, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelCurtainHandPullControl();
|
| | | var memoryData = (ModelCurtainHandPullControl)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A窗帘手拉控制, classData);
|
| | |
|
| | | memoryData.Statu = bolStatu;
|
| | | memoryData.ListSendTopic[0] = "SetWritableValue";
|
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | | //保存数据
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取窗帘手拉控制状态(虚拟使用)
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public bool GetCurtainHandPullControl(CommonDevice device)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelCurtainHandPullControl();
|
| | | var memoryData = (ModelCurtainHandPullControl)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A窗帘手拉控制, classData);
|
| | |
|
| | | return memoryData.Statu;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 窗帘方向___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 设置窗帘的方向
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="isDirectionReversed"></param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | /// <returns></returns>
|
| | | public CommonDevice.SetWritableValueResponAllData SetCurtainDirection(CommonDevice device, bool isDirectionReversed, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelCurtainDirectionAndLimite();
|
| | | var memoryData = (ModelCurtainDirectionAndLimite)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A窗帘方向及限位, classData);
|
| | |
|
| | | memoryData.Direction = isDirectionReversed;
|
| | | memoryData.ListSendTopic[0] = "SetWritableValue";
|
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | | //保存数据
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | |
|
| | | return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = new CommonDevice.SetWritableValueResponData { Status = 0 } };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 窗帘限位___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取开合帘的限位
|
| | | /// </summary>
|
| | | /// <param name="rollershade"></param>
|
| | | /// <param name="upLimit"></param>
|
| | | /// <param name="downLimit"></param>
|
| | | /// <param name="curtainLength"></param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | /// <returns></returns>
|
| | | public bool SetCurtainLimitPoint(CommonDevice rollershade, int upLimit, int downLimit, int curtainLength, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelCurtainDirectionAndLimite();
|
| | | var memoryData = (ModelCurtainDirectionAndLimite)this.GetDeviceModelDataClass(rollershade.DeviceAddr, rollershade.DeviceEpoint, ModelDeviceSaveEnum.A窗帘方向及限位, classData);
|
| | | memoryData.curtainLength = curtainLength;
|
| | | memoryData.downLimit = downLimit;
|
| | | memoryData.upLimit = upLimit;
|
| | |
|
| | | memoryData.ListSendTopic[0] = "SetWritableValue";
|
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | |
|
| | | //保存数据
|
| | | this.SaveDeviceMemmoryData(rollershade.DeviceAddr, rollershade.DeviceEpoint);
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取开合帘的限位
|
| | | /// </summary>
|
| | | /// <param name="rollershade"></param>
|
| | | /// <returns></returns>
|
| | | public ModelCurtainDirectionAndLimite GetCurtainLimitPoint(CommonDevice rollershade)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelCurtainDirectionAndLimite();
|
| | | var memoryData = (ModelCurtainDirectionAndLimite)this.GetDeviceModelDataClass(rollershade.DeviceAddr, rollershade.DeviceEpoint, ModelDeviceSaveEnum.A窗帘方向及限位, classData);
|
| | |
|
| | | return memoryData;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 空调自定义模式_____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加空调自定义模式缓存
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <param name="data">值</param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | public void SetAcModeSupport(CommonDevice device, int data, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelAcModeSupport();
|
| | | var memoryData = (ModelAcModeSupport)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A空调自定义模式, classData);
|
| | |
|
| | | memoryData.data = data;
|
| | | memoryData.ListSendTopic[0] = "SetWritableValue";
|
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | | //保存数据
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取空调自定义模式(虚拟使用)
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public int GetAcModeSupport(CommonDevice device)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelAcModeSupport();
|
| | | var memoryData = (ModelAcModeSupport)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A空调自定义模式, classData);
|
| | |
|
| | | return memoryData.data;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 空调摆风模式_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加空调摆风模式缓存
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <param name="data">值</param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | public void SetAcSwingModeSupport(CommonDevice device, int data, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelAcSwingModeSupport();
|
| | | var memoryData = (ModelAcSwingModeSupport)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A空调摆风功能, classData);
|
| | |
|
| | | memoryData.data = data;
|
| | | memoryData.ListSendTopic[0] = "SetWritableValue";
|
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | | //保存数据
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取空调摆风模式(虚拟使用)
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public int GetAcSwingModeSupport(CommonDevice device)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelAcSwingModeSupport();
|
| | | var memoryData = (ModelAcSwingModeSupport)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A空调摆风功能, classData);
|
| | |
|
| | | return memoryData.data;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备绑定___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备绑定列表的缓存
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <returns></returns>
|
| | | public List<BindObj.BindListResponseObj> GetDeviceBindList(CommonDevice device)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelDeviceBindData();
|
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData);
|
| | |
|
| | | return memoryData.BindList;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 添加设备绑定列表的缓存
|
| | | /// </summary>
|
| | | /// <param name="addBindData"></param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | /// <returns></returns>
|
| | | public BindObj.AddedDeviceBindResponseAllData AddDeviceBindList(BindObj.AddBindData addBindData, string receiveResult)
|
| | | {
|
| | | var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint);
|
| | | //获取对象
|
| | | var classData = new ModelDeviceBindData();
|
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData);
|
| | |
|
| | | //清空绑定表的返回值
|
| | | string clearResult = "{"
|
| | | + SetDouMarks("Device_ID") + ":" + (int)device.Type + ","
|
| | | + SetDouMarks("DeviceAddr") + ":" + SetDouMarks(device.DeviceAddr) + ","
|
| | | + SetDouMarks("Epoint") + ":" + device.DeviceEpoint + ","
|
| | | + SetDouMarks("Data_ID") + ":5006,"
|
| | | + SetDouMarks("Data") + ": {"
|
| | | + SetDouMarks("Result") + ": 0,"
|
| | | + SetDouMarks("ResultRemark") + ":" + SetDouMarks("Success") + "}"
|
| | | + "}";
|
| | |
|
| | | if (memoryData.ListReceiveResult.Count == 1)
|
| | | {
|
| | | //设备绑定有三条命令 第一条为清空
|
| | | memoryData.ListReceiveResult.Insert(0, clearResult);
|
| | | memoryData.ListReceiveTopic.Insert(0, "Bind/ClearBindInfo_Respon");
|
| | | memoryData.ListSendTopic.Insert(0, "Bind/ClearBindInfo");
|
| | |
|
| | | memoryData.ListReceiveResult.Add(string.Empty);
|
| | | memoryData.ListReceiveTopic.Add(string.Empty);
|
| | | memoryData.ListSendTopic.Add(string.Empty);
|
| | | }
|
| | | else
|
| | | {
|
| | | memoryData.ListReceiveResult[0] = clearResult;
|
| | | memoryData.ListReceiveTopic[0] = "Bind/ClearBindInfo_Respon";
|
| | | memoryData.ListSendTopic[0] = "Bind/ClearBindInfo";
|
| | | }
|
| | |
|
| | | memoryData.ListSendTopic[2] = "Bind/SetBind";
|
| | | memoryData.ListReceiveTopic[2] = "Bind/SetBind_Respon";
|
| | | memoryData.ListReceiveResult[2] = receiveResult;
|
| | |
|
| | | var reData = new BindObj.AddedDeviceBindResponseAllData();
|
| | | reData.addedDeviceBindResponseData = new BindObj.AddedDeviceBindResponseData();
|
| | | reData.addedDeviceBindResponseData.Result = 0;
|
| | |
|
| | | foreach (var data in addBindData.BindList)
|
| | | {
|
| | | bool canAdd = true;
|
| | | for (int i = 0; i < memoryData.BindList.Count; i++)
|
| | | {
|
| | | var bindData = memoryData.BindList[i];
|
| | | //如果是设备
|
| | | if (bindData.BindType == 0 && data.BindType == 0
|
| | | && bindData.BindMacAddr == data.BindMacAddr
|
| | | && bindData.BindEpoint == data.BindEpoint
|
| | | && bindData.BindCluster == data.BindCluster)
|
| | | {
|
| | | //同一个东西不需要替换
|
| | | canAdd = false;
|
| | | reData.addedDeviceBindResponseData.BindList.Add(bindData);
|
| | | break;
|
| | | }
|
| | | //如果是场景
|
| | | if (bindData.BindType == 2 && data.BindType == 1
|
| | | && bindData.BindScenesId == data.BindScenesId
|
| | | && bindData.BindCluster == data.BindCluster)
|
| | | {
|
| | | //同一个东西不需要替换
|
| | | canAdd = false;
|
| | | reData.addedDeviceBindResponseData.BindList.Add(bindData);
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (canAdd == true)
|
| | | {
|
| | | //添加新的缓存
|
| | | var newData = new BindObj.BindListResponseObj();
|
| | | memoryData.BindList.Add(newData);
|
| | |
|
| | | newData.BindCluster = data.BindCluster;
|
| | | newData.BindEpoint = data.BindEpoint;
|
| | | newData.BindMacAddr = data.BindMacAddr;
|
| | | newData.BindScenesId = data.BindScenesId;
|
| | | newData.BindType = data.BindType == 0 ? 0 : 2;
|
| | | reData.addedDeviceBindResponseData.BindList.Add(newData);
|
| | | }
|
| | | }
|
| | | //保存数据
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | |
|
| | | return reData;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 删除设备绑定列表的缓存
|
| | | /// </summary>
|
| | | /// <param name="delDeviceBindData"></param>
|
| | | /// <returns></returns>
|
| | | public BindObj.DelDeviceBindResponseAllData DeleteDeviceBindList(BindObj.DelDeviceBindData delDeviceBindData)
|
| | | {
|
| | | var device = Common.LocalDevice.Current.GetDevice(delDeviceBindData.DeviceAddr, delDeviceBindData.Epoint);
|
| | | //获取对象
|
| | | var classData = new ModelDeviceBindData();
|
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData);
|
| | |
|
| | | //返回值
|
| | | var reData = new BindObj.DelDeviceBindResponseAllData();
|
| | | reData.removeBindResultResponseData = new BindObj.RemoveBindResultResponseData();
|
| | | reData.removeBindResultResponseData.Result = 0;
|
| | |
|
| | | reData.delDeviceBindResponseData = new BindObj.DelDeviceBindResponseData();
|
| | |
|
| | | foreach (var data in delDeviceBindData.RemoveBindList)
|
| | | {
|
| | | for (int i = 0; i < memoryData.BindList.Count; i++)
|
| | | {
|
| | | var bindData = memoryData.BindList[i];
|
| | | //如果是设备
|
| | | if (bindData.BindType == 0 && data.BindType == 0
|
| | | && bindData.BindMacAddr == data.BindMacAddr
|
| | | && bindData.BindEpoint == data.BindEpoint
|
| | | && bindData.BindCluster == data.BindCluster)
|
| | | {
|
| | | //移除缓存
|
| | | memoryData.BindList.RemoveAt(i);
|
| | | break;
|
| | | }
|
| | | //如果是场景
|
| | | if (bindData.BindType == 2 && data.BindType == 1
|
| | | && bindData.BindScenesId == data.BindScenesId
|
| | | && bindData.BindCluster == data.BindCluster)
|
| | | {
|
| | | //移除缓存
|
| | | memoryData.BindList.RemoveAt(i);
|
| | | break;
|
| | | }
|
| | | }
|
| | | var removeData = new BindObj.RemoveBindListResponseObj();
|
| | | reData.delDeviceBindResponseData.RemoveBindList.Add(removeData);
|
| | | removeData.BindCluster = data.BindCluster;
|
| | | removeData.BindEpoint = data.BindEpoint;
|
| | | removeData.BindMacAddr = data.BindMacAddr;
|
| | | removeData.BindScenesId = data.BindScenesId;
|
| | | removeData.BindType = data.BindType == 0 ? 0 : 2;
|
| | | removeData.Result = 0;
|
| | | }
|
| | | //保存数据
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | | return reData;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 删除指定设备的全部绑定
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public BindObj.ClearBindInfoResponseAllData ClearDeviceAllBind(CommonDevice device)
|
| | | {
|
| | | string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(device);
|
| | | if (TemplateCommonLogic.Current.modelData.dicDeviceTemplateData.ContainsKey(mainkey) == true)
|
| | | {
|
| | | //移除全部的 设备绑定列表 数据
|
| | | var listBind = TemplateCommonLogic.Current.modelData.dicDeviceTemplateData[mainkey];
|
| | | for (int i = 0; i < listBind.Count; i++)
|
| | | {
|
| | | if (listBind[i].DataSaveDiv == ModelDeviceSaveEnum.A设备绑定列表)
|
| | | {
|
| | | ((ModelDeviceBindData)listBind[i]).BindList.Clear();
|
| | | }
|
| | | }
|
| | | }
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | |
|
| | | return new BindObj.ClearBindInfoResponseAllData
|
| | | {
|
| | | clearBindInfoResponseData = new BindObj.ClearBindInfoResponseData { Result = 0 }
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 配置按键的功能模式
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="value"></param>
|
| | | /// <param name="clusterID"></param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | /// <returns></returns>
|
| | | public CommonDevice.SetWritableValueResponAllData ConfigurePanelKeyModel(CommonDevice device, Panel.KeyMode value, int clusterID, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelDeviceBindData();
|
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData);
|
| | | memoryData.keyMode = value;
|
| | | memoryData.keyModeClusterID = clusterID;
|
| | |
|
| | | if (memoryData.ListReceiveResult.Count == 1)
|
| | | {
|
| | | if (memoryData.ListReceiveResult.Count == 1)
|
| | | {
|
| | | //设备绑定有三条命令 第一条为清空
|
| | | memoryData.ListReceiveResult.Insert(0, string.Empty);
|
| | | memoryData.ListReceiveTopic.Insert(0, string.Empty);
|
| | | memoryData.ListSendTopic.Insert(0, string.Empty);
|
| | |
|
| | | memoryData.ListReceiveResult.Add(string.Empty);
|
| | | memoryData.ListReceiveTopic.Add(string.Empty);
|
| | | memoryData.ListSendTopic.Add(string.Empty);
|
| | | }
|
| | | }
|
| | | memoryData.ListSendTopic[1] = "SetWritableValue";
|
| | | memoryData.ListReceiveTopic[1] = "SetWritableValue_Respon";
|
| | | memoryData.ListReceiveResult[1] = receiveResult;
|
| | |
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | |
|
| | | return new CommonDevice.SetWritableValueResponAllData
|
| | | {
|
| | | setWritableValueResponData = new CommonDevice.SetWritableValueResponData { Status = 0 }
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取按键的功能模式
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public Panel.PanelConfigureInfoResponAllData ReadPanelConfigureKeyModel(CommonDevice device)
|
| | | {
|
| | | var classData = new ModelDeviceBindData();
|
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData);
|
| | |
|
| | | var data = new Panel.PanelConfigureInfoResponAllData();
|
| | | data.deviceStatusReportData = new CommonDevice.DeviceStatusReportData { CluterID = memoryData.keyModeClusterID };
|
| | |
|
| | | var dataAttri = new CommonDevice.AttributeDataObj();
|
| | | dataAttri.AttributeId = (int)AttriButeId.HdlKey;
|
| | | dataAttri.AttriButeData = (int)memoryData.keyMode;
|
| | | data.deviceStatusReportData.AttriBute.Add(dataAttri);
|
| | |
|
| | | return data;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ Pir传感器__________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取Pir传感器的配置
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public IASZone.ParamatesInfo GetPirSensorLightSettion(string deviceMac, int deviceEpoint)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPirSensorSettion();
|
| | | var memoryData = (ModelPirSensorSettion)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.APir配置, classData);
|
| | |
|
| | | var localData = new IASZone.ParamatesInfo();
|
| | | localData.configureParamates = new IASZone.ConfigureParamates();
|
| | | localData.configureParamates.controlDevEnable = memoryData.pirConfigure.controlDevEnable;
|
| | | localData.configureParamates.dimmerLevel = memoryData.pirConfigure.dimmerLevel;
|
| | | localData.configureParamates.dimmerOffTime = memoryData.pirConfigure.dimmerOffTime;
|
| | | localData.configureParamates.dimmerOnTime = memoryData.pirConfigure.dimmerOnTime;
|
| | | localData.configureParamates.iasReportPeriod = memoryData.pirConfigure.iasReportPeriod;
|
| | | localData.configureParamates.levelEnable = memoryData.pirConfigure.levelEnable;
|
| | | localData.configureParamates.levelSize = memoryData.pirConfigure.levelSize;
|
| | | localData.configureParamates.mode = memoryData.pirConfigure.mode;
|
| | | localData.configureParamates.transitionTime = memoryData.pirConfigure.transitionTime;
|
| | | localData.configureParamates.type = memoryData.pirConfigure.type;
|
| | |
|
| | | return localData;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置Pir传感器的配置
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="configureParamates"></param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | /// <returns></returns>
|
| | | public IASZone.ResponseAllData SetPirSensorLightSettion(string deviceMac, int deviceEpoint, IASZone.ConfigureParamates configureParamates, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPirSensorSettion();
|
| | | var memoryData = (ModelPirSensorSettion)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.APir配置, classData);
|
| | |
|
| | | memoryData.pirConfigure = configureParamates;
|
| | |
|
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough";
|
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | |
|
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint);
|
| | |
|
| | | return new CommonDevice.ResponseAllData { responseData = new CommonDevice.ResponseData { status = 0 } };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 面板震动功能_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取面板震动功能
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public UserCenter.HdlDevicePanelLogic.PanelVibrationInfo GetPanelVibrationInfo(string deviceMac, int deviceEpoint)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPanelVibrationInfo();
|
| | | var memoryData = (ModelPanelVibrationInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板震动功能, classData);
|
| | |
|
| | | var data = new UserCenter.HdlDevicePanelLogic.PanelVibrationInfo();
|
| | | data.A震动使能 = memoryData.vibrationInfo.A震动使能;
|
| | | data.A震动强度 = memoryData.vibrationInfo.A震动强度;
|
| | | data.A震动时间 = memoryData.vibrationInfo.A震动时间;
|
| | |
|
| | | return data;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置面板震动功能
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="datainfo"></param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | /// <returns></returns>
|
| | | public bool SetPanelVibrationInfo(string deviceMac, int deviceEpoint, UserCenter.HdlDevicePanelLogic.PanelVibrationInfo datainfo, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPanelVibrationInfo();
|
| | | var memoryData = (ModelPanelVibrationInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板震动功能, classData);
|
| | | memoryData.vibrationInfo = datainfo;
|
| | |
|
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough";
|
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | |
|
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint);
|
| | |
|
| | | return true;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 设备名称___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 修改设备Mac名称
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="macName"></param>
|
| | | /// <returns></returns> |
| | | public CommonDevice.RenameDeviceMacNameAllData ReDeviceMacName(CommonDevice device, string macName)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelDeviceMacNameInfo();
|
| | | var memoryData = (ModelDeviceMacNameInfo)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备名称, classData);
|
| | | memoryData.deviceMacName = macName;
|
| | |
|
| | | //设备返回的结果
|
| | | var receiveResult = "{"
|
| | | + SetDouMarks("DeviceAddr") + ": " + SetDouMarks(device.DeviceAddr) + ","
|
| | | + SetDouMarks("Data_ID") + ": 100,"
|
| | | + SetDouMarks("Data") + ": {"
|
| | | + SetDouMarks("Result") + ": 0,"
|
| | | + SetDouMarks("MacName") + ":" + SetDouMarks(macName) + "}"
|
| | | + "}";
|
| | |
|
| | | memoryData.ListSendTopic[0] = "MacRename";
|
| | | memoryData.ListReceiveTopic[0] = "MacRename_Respon";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | |
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | |
|
| | | return new CommonDevice.RenameDeviceMacNameAllData
|
| | | {
|
| | | renameDeviceMacNameData = new CommonDevice.RenameDeviceMacNameData
|
| | | {
|
| | | Result = 0,
|
| | | MacName = macName
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 修改设备端点名称
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="macName"></param>
|
| | | /// <returns></returns>
|
| | | public CommonDevice.DeviceRenameAllData ReDeviceEpointName(CommonDevice device, string deviceName)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelDeviceEpointNameInfo();
|
| | | var memoryData = (ModelDeviceEpointNameInfo)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A端点名称, classData);
|
| | | memoryData.deviceEpointName = deviceName;
|
| | |
|
| | | //设备返回的结果
|
| | | var receiveResult = "{"
|
| | | + SetDouMarks("Device_ID") + ": " + (int)device.Type + ","
|
| | | + SetDouMarks("DeviceAddr") + ": " + SetDouMarks(device.DeviceAddr) + ","
|
| | | + SetDouMarks("Epoint") + ": " + device.DeviceEpoint + ","
|
| | | + SetDouMarks("Data_ID") + ": 96,"
|
| | | + SetDouMarks("Data") + ": {"
|
| | | + SetDouMarks("Result") + ": 0,"
|
| | | + SetDouMarks("DeviceName") + ":" + SetDouMarks(deviceName) + "}"
|
| | | + "}";
|
| | |
|
| | | memoryData.ListSendTopic[0] = "DeviceRename";
|
| | | memoryData.ListReceiveTopic[0] = "DeviceRenameRespon";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | |
|
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint);
|
| | |
|
| | | return new CommonDevice.DeviceRenameAllData
|
| | | {
|
| | | deviceRenameData = new CommonDevice.DeviceRenameResponseData
|
| | | {
|
| | | Result = 0,
|
| | | DeviceName = deviceName
|
| | | }
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 面板背光灯设置_____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备亮度配置(ui叫亮度调节,使用返回值的panelDirectionsLevel)
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public Panel.PanelSwitchLevelInfo GetDeviceLightSettion(string deviceMac, int deviceEpoint)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPanelBrightnessAdjustInfo();
|
| | | var memoryData = (ModelPanelBrightnessAdjustInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板亮度调节, classData);
|
| | |
|
| | | var data = new Panel.PanelSwitchLevelInfo();
|
| | | data.panelBacklightLevel = memoryData.panelBacklightLevel == -1 ? 0 : memoryData.panelBacklightLevel;
|
| | | data.panelDirectionsLevel = memoryData.panelDirectionsLevel == -1 ? 0 : memoryData.panelDirectionsLevel;
|
| | | return data;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置设备亮度(ui叫亮度调节)
|
| | | /// </summary>
|
| | | /// <param name="panel">设备对象</param>
|
| | | /// <param name="directionsLevel">0-100(这个是点击后的值)</param>
|
| | | /// <param name="backlightLevel">0-100(这个是点击前的值)</param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | /// <returns></returns>
|
| | | public bool SetDeviceLightSettion(string deviceMac, int deviceEpoint, int directionsLevel, int backlightLevel, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPanelBrightnessAdjustInfo();
|
| | | var memoryData = (ModelPanelBrightnessAdjustInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板亮度调节, classData);
|
| | | memoryData.panelBacklightLevel = backlightLevel;
|
| | | memoryData.panelDirectionsLevel = directionsLevel;
|
| | |
|
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough";
|
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | |
|
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint);
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备节能模式的配置状态(ui叫节能模式)
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <returns></returns>
|
| | | public Panel.PanelSaveEnergyModeInfo GetDeviceEnergyConservationMode(string deviceMac, int deviceEpoint)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPanelEnergyModeInfo();
|
| | | var memoryData = (ModelPanelEnergyModeInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板节能模式, classData);
|
| | |
|
| | | var data = new Panel.PanelSaveEnergyModeInfo();
|
| | | data.enable = memoryData.energyModeInfo.enable;
|
| | | data.level = memoryData.energyModeInfo.level == -1 ? 0 : memoryData.energyModeInfo.level;
|
| | | data.time = memoryData.energyModeInfo.time == -1 ? 0 : memoryData.energyModeInfo.time;
|
| | | return data;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置设备的节能模式(ui叫节能模式)
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <param name="modeEnable">节能模式是否有效</param>
|
| | | /// <param name="modeTime">无操作进入节能模式时间 0-255</param>
|
| | | /// <param name="level">节能模式亮度:0-100</param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | /// <returns></returns>
|
| | | public bool SetDeviceEnergyConservationMode(string deviceMac, int deviceEpoint, bool modeEnable, int modeTime, int level, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPanelEnergyModeInfo();
|
| | | var memoryData = (ModelPanelEnergyModeInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板节能模式, classData);
|
| | | memoryData.energyModeInfo.enable = modeEnable;
|
| | | memoryData.energyModeInfo.time = modeTime;
|
| | | memoryData.energyModeInfo.level = level;
|
| | |
|
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough";
|
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | |
|
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint);
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取按键指示灯开关颜色.
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="keyNum"></param>
|
| | | /// <returns></returns>
|
| | | public Panel.KeyColorDataResponseAllData GetPanelColorInfo(string deviceMac, int deviceEpoint, Panel.KeyNum keyNum)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPanelIndicatorLightInfo();
|
| | | var memoryData = (ModelPanelIndicatorLightInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板指示灯, classData);
|
| | |
|
| | | var data = new Panel.KeyColorDataResponseAllData();
|
| | | data.keyColorData = new Panel.KeyColorData();
|
| | | data.keyColorData.CloseColorB = string.IsNullOrEmpty(memoryData.keyColorData.CloseColorB) == true ? "0" : memoryData.keyColorData.CloseColorB;
|
| | | data.keyColorData.CloseColorG = string.IsNullOrEmpty(memoryData.keyColorData.CloseColorG) == true ? "0" : memoryData.keyColorData.CloseColorG;
|
| | | data.keyColorData.CloseColorR = string.IsNullOrEmpty(memoryData.keyColorData.CloseColorR) == true ? "0" : memoryData.keyColorData.CloseColorR;
|
| | | data.keyColorData.OpenColorB = string.IsNullOrEmpty(memoryData.keyColorData.OpenColorB) == true ? "0" : memoryData.keyColorData.OpenColorB;
|
| | | data.keyColorData.OpenColorG = string.IsNullOrEmpty(memoryData.keyColorData.OpenColorG) == true ? "0" : memoryData.keyColorData.OpenColorG;
|
| | | data.keyColorData.OpenColorR = string.IsNullOrEmpty(memoryData.keyColorData.OpenColorR) == true ? "0" : memoryData.keyColorData.OpenColorR;
|
| | | data.keyColorData.keyNum = keyNum;
|
| | |
|
| | | return data;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 配置按键指示灯颜色
|
| | | /// </summary>
|
| | | /// <param name="device"></param>
|
| | | /// <param name="keyColorData"></param>
|
| | | /// <param name="keyNumStatus"></param>
|
| | | /// <param name="receiveResult">设备返回的结果</param>
|
| | | /// <returns></returns>
|
| | | public CommonDevice.ResponseAllData SetPanelColorInfo(string deviceMac, int deviceEpoint, Panel.KeyColorData keyColorData, Panel.KeyNumStatus keyNumStatus, string receiveResult)
|
| | | {
|
| | | //获取对象
|
| | | var classData = new ModelPanelIndicatorLightInfo();
|
| | | var memoryData = (ModelPanelIndicatorLightInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板指示灯, classData);
|
| | |
|
| | | memoryData.keyColorData.keyNum = keyColorData.keyNum;
|
| | | memoryData.keyColorData.OpenColorB = keyColorData.OpenColorB;
|
| | | memoryData.keyColorData.OpenColorG = keyColorData.OpenColorG;
|
| | | memoryData.keyColorData.OpenColorR = keyColorData.OpenColorR;
|
| | | memoryData.keyColorData.CloseColorB = keyColorData.CloseColorB;
|
| | | memoryData.keyColorData.CloseColorG = keyColorData.CloseColorG;
|
| | | memoryData.keyColorData.CloseColorR = keyColorData.CloseColorR;
|
| | |
|
| | | memoryData.KeyNum.Key1 = keyNumStatus.Key1;
|
| | | memoryData.KeyNum.Key2 = keyNumStatus.Key2;
|
| | | memoryData.KeyNum.Key3 = keyNumStatus.Key3;
|
| | | memoryData.KeyNum.Key4 = keyNumStatus.Key4;
|
| | | memoryData.KeyNum.Key5 = keyNumStatus.Key5;
|
| | | memoryData.KeyNum.Key6 = keyNumStatus.Key6;
|
| | | memoryData.KeyNum.Key7 = keyNumStatus.Key7;
|
| | | memoryData.KeyNum.Key8 = keyNumStatus.Key8;
|
| | | memoryData.KeyNum.Key9 = keyNumStatus.Key9;
|
| | | memoryData.KeyNum.Key10 = keyNumStatus.Key10;
|
| | | memoryData.KeyNum.Key11 = keyNumStatus.Key11;
|
| | | memoryData.KeyNum.Key12 = keyNumStatus.Key12;
|
| | | memoryData.KeyNum.Key13 = keyNumStatus.Key13;
|
| | | memoryData.KeyNum.Key14 = keyNumStatus.Key14;
|
| | | memoryData.KeyNum.Key15 = keyNumStatus.Key15;
|
| | | memoryData.KeyNum.Key16 = keyNumStatus.Key16;
|
| | |
|
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough";
|
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough";
|
| | | memoryData.ListReceiveResult[0] = receiveResult;
|
| | |
|
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint);
|
| | |
|
| | | return new CommonDevice.ResponseAllData
|
| | | {
|
| | | responseData = new CommonDevice.ResponseData
|
| | | { status = 0 }
|
| | | };
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 保存设备缓存_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 保存设备缓存(考虑有的设备用的是200端点,所以这里最好不用设备对象作为参数)
|
| | | /// </summary>
|
| | | /// <param name="deviceMac"></param>
|
| | | /// <param name="deviceEpoint"></param>
|
| | | public void SaveDeviceMemmoryData(string deviceMac, int deviceEpoint)
|
| | | {
|
| | | //代码移动到别的文件中了
|
| | | TemplateCommonLogic.Current.SaveDeviceMemmoryData(deviceMac, deviceEpoint);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设备保存的模板对象(考虑有的设备用的是200端点,所以这里最好不用设备对象作为参数)
|
| | | /// </summary>
|
| | | /// <param name="deviceMac"></param>
|
| | | /// <param name="deviceEpoint"></param>
|
| | | /// <param name="saveEnum"></param>
|
| | | /// <returns></returns>
|
| | | private TemplateDeviceDataCommon GetDeviceModelDataClass(string deviceMac, int deviceEpoint, ModelDeviceSaveEnum saveEnum, TemplateDeviceDataCommon newClass)
|
| | | {
|
| | | //代码移动到别的文件中了
|
| | | return TemplateCommonLogic.Current.GetDeviceModelDataClass(deviceMac, deviceEpoint, saveEnum, newClass);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 添加双引号
|
| | | /// </summary>
|
| | | /// <param name="i_text"></param>
|
| | | /// <returns></returns>
|
| | | private string SetDouMarks(string i_text)
|
| | | {
|
| | | return UserCenter.UserCenterResourse.douMarks + i_text + UserCenter.UserCenterResourse.douMarks;
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.TemplateData |
| | | { |
| | | /// <summary> |
| | | /// 设备模板数据的逻辑 |
| | | /// </summary> |
| | | public class TemplateDeviceDataLogic |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 设备模板数据的逻辑 |
| | | /// </summary> |
| | | private static TemplateDeviceDataLogic m_Current = null; |
| | | /// <summary> |
| | | /// 设备模板数据的逻辑 |
| | | /// </summary> |
| | | public static TemplateDeviceDataLogic Current |
| | | { |
| | | get |
| | | { |
| | | if (m_Current == null) |
| | | { |
| | | m_Current = new TemplateDeviceDataLogic(); |
| | | } |
| | | return m_Current; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 窗帘手拉控制_______________________ |
| | | |
| | | /// <summary> |
| | | /// 添加窗帘手拉控制缓存 |
| | | /// </summary> |
| | | /// <param name="device">设备对象</param> |
| | | /// <param name="bolStatu">手拉控制状态</param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | public void SetCurtainHandPullControl(CommonDevice device, bool bolStatu, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelCurtainHandPullControl(); |
| | | var memoryData = (ModelCurtainHandPullControl)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A窗帘手拉控制, classData); |
| | | |
| | | memoryData.Statu = bolStatu; |
| | | memoryData.ListSendTopic[0] = "SetWritableValue"; |
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | //保存数据 |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取窗帘手拉控制状态(虚拟使用) |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public bool GetCurtainHandPullControl(CommonDevice device) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelCurtainHandPullControl(); |
| | | var memoryData = (ModelCurtainHandPullControl)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A窗帘手拉控制, classData); |
| | | |
| | | return memoryData.Statu; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 窗帘方向___________________________ |
| | | |
| | | /// <summary> |
| | | /// 设置窗帘的方向 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="isDirectionReversed"></param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | /// <returns></returns> |
| | | public CommonDevice.SetWritableValueResponAllData SetCurtainDirection(CommonDevice device, bool isDirectionReversed, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelCurtainDirectionAndLimite(); |
| | | var memoryData = (ModelCurtainDirectionAndLimite)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A窗帘方向及限位, classData); |
| | | |
| | | memoryData.Direction = isDirectionReversed; |
| | | memoryData.ListSendTopic[0] = "SetWritableValue"; |
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | //保存数据 |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | |
| | | return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = new CommonDevice.SetWritableValueResponData { Status = 0 } }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 窗帘限位___________________________ |
| | | |
| | | /// <summary> |
| | | /// 获取开合帘的限位 |
| | | /// </summary> |
| | | /// <param name="rollershade"></param> |
| | | /// <param name="upLimit"></param> |
| | | /// <param name="downLimit"></param> |
| | | /// <param name="curtainLength"></param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | /// <returns></returns> |
| | | public bool SetCurtainLimitPoint(CommonDevice rollershade, int upLimit, int downLimit, int curtainLength, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelCurtainDirectionAndLimite(); |
| | | var memoryData = (ModelCurtainDirectionAndLimite)this.GetDeviceModelDataClass(rollershade.DeviceAddr, rollershade.DeviceEpoint, ModelDeviceSaveEnum.A窗帘方向及限位, classData); |
| | | memoryData.curtainLength = curtainLength; |
| | | memoryData.downLimit = downLimit; |
| | | memoryData.upLimit = upLimit; |
| | | |
| | | memoryData.ListSendTopic[0] = "SetWritableValue"; |
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | |
| | | //保存数据 |
| | | this.SaveDeviceMemmoryData(rollershade.DeviceAddr, rollershade.DeviceEpoint); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取开合帘的限位 |
| | | /// </summary> |
| | | /// <param name="rollershade"></param> |
| | | /// <returns></returns> |
| | | public ModelCurtainDirectionAndLimite GetCurtainLimitPoint(CommonDevice rollershade) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelCurtainDirectionAndLimite(); |
| | | var memoryData = (ModelCurtainDirectionAndLimite)this.GetDeviceModelDataClass(rollershade.DeviceAddr, rollershade.DeviceEpoint, ModelDeviceSaveEnum.A窗帘方向及限位, classData); |
| | | |
| | | return memoryData; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 空调自定义模式_____________________ |
| | | |
| | | /// <summary> |
| | | /// 添加空调自定义模式缓存 |
| | | /// </summary> |
| | | /// <param name="device">设备对象</param> |
| | | /// <param name="data">值</param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | public void SetAcModeSupport(CommonDevice device, int data, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelAcModeSupport(); |
| | | var memoryData = (ModelAcModeSupport)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A空调自定义模式, classData); |
| | | |
| | | memoryData.data = data; |
| | | memoryData.ListSendTopic[0] = "SetWritableValue"; |
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | //保存数据 |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取空调自定义模式(虚拟使用) |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public int GetAcModeSupport(CommonDevice device) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelAcModeSupport(); |
| | | var memoryData = (ModelAcModeSupport)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A空调自定义模式, classData); |
| | | |
| | | return memoryData.data; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 空调摆风模式_______________________ |
| | | |
| | | /// <summary> |
| | | /// 添加空调摆风模式缓存 |
| | | /// </summary> |
| | | /// <param name="device">设备对象</param> |
| | | /// <param name="data">值</param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | public void SetAcSwingModeSupport(CommonDevice device, int data, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelAcSwingModeSupport(); |
| | | var memoryData = (ModelAcSwingModeSupport)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A空调摆风功能, classData); |
| | | |
| | | memoryData.data = data; |
| | | memoryData.ListSendTopic[0] = "SetWritableValue"; |
| | | memoryData.ListReceiveTopic[0] = "SetWritableValue_Respon"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | //保存数据 |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取空调摆风模式(虚拟使用) |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public int GetAcSwingModeSupport(CommonDevice device) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelAcSwingModeSupport(); |
| | | var memoryData = (ModelAcSwingModeSupport)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A空调摆风功能, classData); |
| | | |
| | | return memoryData.data; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 设备绑定___________________________ |
| | | |
| | | /// <summary> |
| | | /// 获取设备绑定列表的缓存 |
| | | /// </summary> |
| | | /// <param name="device">设备对象</param> |
| | | /// <returns></returns> |
| | | public List<BindObj.BindListResponseObj> GetDeviceBindList(CommonDevice device) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelDeviceBindData(); |
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData); |
| | | |
| | | return memoryData.BindList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加设备绑定列表的缓存 |
| | | /// </summary> |
| | | /// <param name="addBindData"></param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | /// <returns></returns> |
| | | public BindObj.AddedDeviceBindResponseAllData AddDeviceBindList(BindObj.AddBindData addBindData, string receiveResult) |
| | | { |
| | | var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint); |
| | | //获取对象 |
| | | var classData = new ModelDeviceBindData(); |
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData); |
| | | |
| | | //清空绑定表的返回值 |
| | | string clearResult = "{" |
| | | + SetDouMarks("Device_ID") + ":" + (int)device.Type + "," |
| | | + SetDouMarks("DeviceAddr") + ":" + SetDouMarks(device.DeviceAddr) + "," |
| | | + SetDouMarks("Epoint") + ":" + device.DeviceEpoint + "," |
| | | + SetDouMarks("Data_ID") + ":5006," |
| | | + SetDouMarks("Data") + ": {" |
| | | + SetDouMarks("Result") + ": 0," |
| | | + SetDouMarks("ResultRemark") + ":" + SetDouMarks("Success") + "}" |
| | | + "}"; |
| | | |
| | | if (memoryData.ListReceiveResult.Count == 1) |
| | | { |
| | | //设备绑定有三条命令 第一条为清空 |
| | | memoryData.ListReceiveResult.Insert(0, clearResult); |
| | | memoryData.ListReceiveTopic.Insert(0, "Bind/ClearBindInfo_Respon"); |
| | | memoryData.ListSendTopic.Insert(0, "Bind/ClearBindInfo"); |
| | | |
| | | memoryData.ListReceiveResult.Add(string.Empty); |
| | | memoryData.ListReceiveTopic.Add(string.Empty); |
| | | memoryData.ListSendTopic.Add(string.Empty); |
| | | } |
| | | else |
| | | { |
| | | memoryData.ListReceiveResult[0] = clearResult; |
| | | memoryData.ListReceiveTopic[0] = "Bind/ClearBindInfo_Respon"; |
| | | memoryData.ListSendTopic[0] = "Bind/ClearBindInfo"; |
| | | } |
| | | |
| | | memoryData.ListSendTopic[2] = "Bind/SetBind"; |
| | | memoryData.ListReceiveTopic[2] = "Bind/SetBind_Respon"; |
| | | memoryData.ListReceiveResult[2] = receiveResult; |
| | | |
| | | var reData = new BindObj.AddedDeviceBindResponseAllData(); |
| | | reData.addedDeviceBindResponseData = new BindObj.AddedDeviceBindResponseData(); |
| | | reData.addedDeviceBindResponseData.Result = 0; |
| | | |
| | | foreach (var data in addBindData.BindList) |
| | | { |
| | | bool canAdd = true; |
| | | for (int i = 0; i < memoryData.BindList.Count; i++) |
| | | { |
| | | var bindData = memoryData.BindList[i]; |
| | | //如果是设备 |
| | | if (bindData.BindType == 0 && data.BindType == 0 |
| | | && bindData.BindMacAddr == data.BindMacAddr |
| | | && bindData.BindEpoint == data.BindEpoint |
| | | && bindData.BindCluster == data.BindCluster) |
| | | { |
| | | //同一个东西不需要替换 |
| | | canAdd = false; |
| | | reData.addedDeviceBindResponseData.BindList.Add(bindData); |
| | | break; |
| | | } |
| | | //如果是场景 |
| | | if (bindData.BindType == 2 && data.BindType == 1 |
| | | && bindData.BindScenesId == data.BindScenesId |
| | | && bindData.BindCluster == data.BindCluster) |
| | | { |
| | | //同一个东西不需要替换 |
| | | canAdd = false; |
| | | reData.addedDeviceBindResponseData.BindList.Add(bindData); |
| | | break; |
| | | } |
| | | } |
| | | if (canAdd == true) |
| | | { |
| | | //添加新的缓存 |
| | | var newData = new BindObj.BindListResponseObj(); |
| | | memoryData.BindList.Add(newData); |
| | | |
| | | newData.BindCluster = data.BindCluster; |
| | | newData.BindEpoint = data.BindEpoint; |
| | | newData.BindMacAddr = data.BindMacAddr; |
| | | newData.BindScenesId = data.BindScenesId; |
| | | newData.BindType = data.BindType == 0 ? 0 : 2; |
| | | reData.addedDeviceBindResponseData.BindList.Add(newData); |
| | | } |
| | | } |
| | | //保存数据 |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | |
| | | return reData; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除设备绑定列表的缓存 |
| | | /// </summary> |
| | | /// <param name="delDeviceBindData"></param> |
| | | /// <returns></returns> |
| | | public BindObj.DelDeviceBindResponseAllData DeleteDeviceBindList(BindObj.DelDeviceBindData delDeviceBindData) |
| | | { |
| | | var device = Common.LocalDevice.Current.GetDevice(delDeviceBindData.DeviceAddr, delDeviceBindData.Epoint); |
| | | //获取对象 |
| | | var classData = new ModelDeviceBindData(); |
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData); |
| | | |
| | | //返回值 |
| | | var reData = new BindObj.DelDeviceBindResponseAllData(); |
| | | reData.removeBindResultResponseData = new BindObj.RemoveBindResultResponseData(); |
| | | reData.removeBindResultResponseData.Result = 0; |
| | | |
| | | reData.delDeviceBindResponseData = new BindObj.DelDeviceBindResponseData(); |
| | | |
| | | foreach (var data in delDeviceBindData.RemoveBindList) |
| | | { |
| | | for (int i = 0; i < memoryData.BindList.Count; i++) |
| | | { |
| | | var bindData = memoryData.BindList[i]; |
| | | //如果是设备 |
| | | if (bindData.BindType == 0 && data.BindType == 0 |
| | | && bindData.BindMacAddr == data.BindMacAddr |
| | | && bindData.BindEpoint == data.BindEpoint |
| | | && bindData.BindCluster == data.BindCluster) |
| | | { |
| | | //移除缓存 |
| | | memoryData.BindList.RemoveAt(i); |
| | | break; |
| | | } |
| | | //如果是场景 |
| | | if (bindData.BindType == 2 && data.BindType == 1 |
| | | && bindData.BindScenesId == data.BindScenesId |
| | | && bindData.BindCluster == data.BindCluster) |
| | | { |
| | | //移除缓存 |
| | | memoryData.BindList.RemoveAt(i); |
| | | break; |
| | | } |
| | | } |
| | | var removeData = new BindObj.RemoveBindListResponseObj(); |
| | | reData.delDeviceBindResponseData.RemoveBindList.Add(removeData); |
| | | removeData.BindCluster = data.BindCluster; |
| | | removeData.BindEpoint = data.BindEpoint; |
| | | removeData.BindMacAddr = data.BindMacAddr; |
| | | removeData.BindScenesId = data.BindScenesId; |
| | | removeData.BindType = data.BindType == 0 ? 0 : 2; |
| | | removeData.Result = 0; |
| | | } |
| | | //保存数据 |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | return reData; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除指定设备的全部绑定 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public BindObj.ClearBindInfoResponseAllData ClearDeviceAllBind(CommonDevice device) |
| | | { |
| | | string mainkey = Common.LocalDevice.Current.GetDeviceMainKeys(device); |
| | | if (TemplateCommonLogic.Current.modelData.dicDeviceTemplateData.ContainsKey(mainkey) == true) |
| | | { |
| | | //移除全部的 设备绑定列表 数据 |
| | | var listBind = TemplateCommonLogic.Current.modelData.dicDeviceTemplateData[mainkey]; |
| | | for (int i = 0; i < listBind.Count; i++) |
| | | { |
| | | if (listBind[i].DataSaveDiv == ModelDeviceSaveEnum.A设备绑定列表) |
| | | { |
| | | ((ModelDeviceBindData)listBind[i]).BindList.Clear(); |
| | | } |
| | | } |
| | | } |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | |
| | | return new BindObj.ClearBindInfoResponseAllData |
| | | { |
| | | clearBindInfoResponseData = new BindObj.ClearBindInfoResponseData { Result = 0 } |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 配置按键的功能模式 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="value"></param> |
| | | /// <param name="clusterID"></param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | /// <returns></returns> |
| | | public CommonDevice.SetWritableValueResponAllData ConfigurePanelKeyModel(CommonDevice device, Panel.KeyMode value, int clusterID, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelDeviceBindData(); |
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData); |
| | | memoryData.keyMode = value; |
| | | memoryData.keyModeClusterID = clusterID; |
| | | |
| | | if (memoryData.ListReceiveResult.Count == 1) |
| | | { |
| | | if (memoryData.ListReceiveResult.Count == 1) |
| | | { |
| | | //设备绑定有三条命令 第一条为清空 |
| | | memoryData.ListReceiveResult.Insert(0, string.Empty); |
| | | memoryData.ListReceiveTopic.Insert(0, string.Empty); |
| | | memoryData.ListSendTopic.Insert(0, string.Empty); |
| | | |
| | | memoryData.ListReceiveResult.Add(string.Empty); |
| | | memoryData.ListReceiveTopic.Add(string.Empty); |
| | | memoryData.ListSendTopic.Add(string.Empty); |
| | | } |
| | | } |
| | | memoryData.ListSendTopic[1] = "SetWritableValue"; |
| | | memoryData.ListReceiveTopic[1] = "SetWritableValue_Respon"; |
| | | memoryData.ListReceiveResult[1] = receiveResult; |
| | | |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | |
| | | return new CommonDevice.SetWritableValueResponAllData |
| | | { |
| | | setWritableValueResponData = new CommonDevice.SetWritableValueResponData { Status = 0 } |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取按键的功能模式 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public Panel.PanelConfigureInfoResponAllData ReadPanelConfigureKeyModel(CommonDevice device) |
| | | { |
| | | var classData = new ModelDeviceBindData(); |
| | | var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData); |
| | | |
| | | var data = new Panel.PanelConfigureInfoResponAllData(); |
| | | data.deviceStatusReportData = new CommonDevice.DeviceStatusReportData { CluterID = memoryData.keyModeClusterID }; |
| | | |
| | | var dataAttri = new CommonDevice.AttributeDataObj(); |
| | | dataAttri.AttributeId = (int)AttriButeId.HdlKey; |
| | | dataAttri.AttriButeData = (int)memoryData.keyMode; |
| | | data.deviceStatusReportData.AttriBute.Add(dataAttri); |
| | | |
| | | return data; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ Pir传感器__________________________ |
| | | |
| | | /// <summary> |
| | | /// 获取Pir传感器的配置 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public IASZone.ParamatesInfo GetPirSensorLightSettion(string deviceMac, int deviceEpoint) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPirSensorSettion(); |
| | | var memoryData = (ModelPirSensorSettion)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.APir配置, classData); |
| | | |
| | | var localData = new IASZone.ParamatesInfo(); |
| | | localData.configureParamates = new IASZone.ConfigureParamates(); |
| | | localData.configureParamates.controlDevEnable = memoryData.pirConfigure.controlDevEnable; |
| | | localData.configureParamates.dimmerLevel = memoryData.pirConfigure.dimmerLevel; |
| | | localData.configureParamates.dimmerOffTime = memoryData.pirConfigure.dimmerOffTime; |
| | | localData.configureParamates.dimmerOnTime = memoryData.pirConfigure.dimmerOnTime; |
| | | localData.configureParamates.iasReportPeriod = memoryData.pirConfigure.iasReportPeriod; |
| | | localData.configureParamates.levelEnable = memoryData.pirConfigure.levelEnable; |
| | | localData.configureParamates.levelSize = memoryData.pirConfigure.levelSize; |
| | | localData.configureParamates.mode = memoryData.pirConfigure.mode; |
| | | localData.configureParamates.transitionTime = memoryData.pirConfigure.transitionTime; |
| | | localData.configureParamates.type = memoryData.pirConfigure.type; |
| | | |
| | | return localData; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置Pir传感器的配置 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="configureParamates"></param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | /// <returns></returns> |
| | | public IASZone.ResponseAllData SetPirSensorLightSettion(string deviceMac, int deviceEpoint, IASZone.ConfigureParamates configureParamates, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPirSensorSettion(); |
| | | var memoryData = (ModelPirSensorSettion)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.APir配置, classData); |
| | | |
| | | memoryData.pirConfigure = configureParamates; |
| | | |
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough"; |
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | |
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint); |
| | | |
| | | return new CommonDevice.ResponseAllData { responseData = new CommonDevice.ResponseData { status = 0 } }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 面板震动功能_______________________ |
| | | |
| | | /// <summary> |
| | | /// 获取面板震动功能 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public UserCenter.HdlDevicePanelLogic.PanelVibrationInfo GetPanelVibrationInfo(string deviceMac, int deviceEpoint) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPanelVibrationInfo(); |
| | | var memoryData = (ModelPanelVibrationInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板震动功能, classData); |
| | | |
| | | var data = new UserCenter.HdlDevicePanelLogic.PanelVibrationInfo(); |
| | | data.A震动使能 = memoryData.vibrationInfo.A震动使能; |
| | | data.A震动强度 = memoryData.vibrationInfo.A震动强度; |
| | | data.A震动时间 = memoryData.vibrationInfo.A震动时间; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置面板震动功能 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="datainfo"></param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | /// <returns></returns> |
| | | public bool SetPanelVibrationInfo(string deviceMac, int deviceEpoint, UserCenter.HdlDevicePanelLogic.PanelVibrationInfo datainfo, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPanelVibrationInfo(); |
| | | var memoryData = (ModelPanelVibrationInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板震动功能, classData); |
| | | memoryData.vibrationInfo = datainfo; |
| | | |
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough"; |
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | |
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint); |
| | | |
| | | return true; |
| | | } |
| | | #endregion |
| | | |
| | | #region ■ 设备名称___________________________ |
| | | |
| | | /// <summary> |
| | | /// 修改设备Mac名称 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="macName"></param> |
| | | /// <returns></returns> |
| | | public CommonDevice.RenameDeviceMacNameAllData ReDeviceMacName(CommonDevice device, string macName) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelDeviceMacNameInfo(); |
| | | var memoryData = (ModelDeviceMacNameInfo)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备名称, classData); |
| | | memoryData.deviceMacName = macName; |
| | | |
| | | //设备返回的结果 |
| | | var receiveResult = "{" |
| | | + SetDouMarks("DeviceAddr") + ": " + SetDouMarks(device.DeviceAddr) + "," |
| | | + SetDouMarks("Data_ID") + ": 100," |
| | | + SetDouMarks("Data") + ": {" |
| | | + SetDouMarks("Result") + ": 0," |
| | | + SetDouMarks("MacName") + ":" + SetDouMarks(macName) + "}" |
| | | + "}"; |
| | | |
| | | memoryData.ListSendTopic[0] = "MacRename"; |
| | | memoryData.ListReceiveTopic[0] = "MacRename_Respon"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | |
| | | return new CommonDevice.RenameDeviceMacNameAllData |
| | | { |
| | | renameDeviceMacNameData = new CommonDevice.RenameDeviceMacNameData |
| | | { |
| | | Result = 0, |
| | | MacName = macName |
| | | } |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 修改设备端点名称 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="macName"></param> |
| | | /// <returns></returns> |
| | | public CommonDevice.DeviceRenameAllData ReDeviceEpointName(CommonDevice device, string deviceName) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelDeviceEpointNameInfo(); |
| | | var memoryData = (ModelDeviceEpointNameInfo)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A端点名称, classData); |
| | | memoryData.deviceEpointName = deviceName; |
| | | |
| | | //设备返回的结果 |
| | | var receiveResult = "{" |
| | | + SetDouMarks("Device_ID") + ": " + (int)device.Type + "," |
| | | + SetDouMarks("DeviceAddr") + ": " + SetDouMarks(device.DeviceAddr) + "," |
| | | + SetDouMarks("Epoint") + ": " + device.DeviceEpoint + "," |
| | | + SetDouMarks("Data_ID") + ": 96," |
| | | + SetDouMarks("Data") + ": {" |
| | | + SetDouMarks("Result") + ": 0," |
| | | + SetDouMarks("DeviceName") + ":" + SetDouMarks(deviceName) + "}" |
| | | + "}"; |
| | | |
| | | memoryData.ListSendTopic[0] = "DeviceRename"; |
| | | memoryData.ListReceiveTopic[0] = "DeviceRenameRespon"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | |
| | | this.SaveDeviceMemmoryData(device.DeviceAddr, device.DeviceEpoint); |
| | | |
| | | return new CommonDevice.DeviceRenameAllData |
| | | { |
| | | deviceRenameData = new CommonDevice.DeviceRenameResponseData |
| | | { |
| | | Result = 0, |
| | | DeviceName = deviceName |
| | | } |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 面板背光灯设置_____________________ |
| | | |
| | | /// <summary> |
| | | /// 获取设备亮度配置(ui叫亮度调节,使用返回值的panelDirectionsLevel) |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public Panel.PanelSwitchLevelInfo GetDeviceLightSettion(string deviceMac, int deviceEpoint) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPanelBrightnessAdjustInfo(); |
| | | var memoryData = (ModelPanelBrightnessAdjustInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板亮度调节, classData); |
| | | |
| | | var data = new Panel.PanelSwitchLevelInfo(); |
| | | data.panelBacklightLevel = memoryData.panelBacklightLevel == -1 ? 0 : memoryData.panelBacklightLevel; |
| | | data.panelDirectionsLevel = memoryData.panelDirectionsLevel == -1 ? 0 : memoryData.panelDirectionsLevel; |
| | | return data; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置设备亮度(ui叫亮度调节) |
| | | /// </summary> |
| | | /// <param name="panel">设备对象</param> |
| | | /// <param name="directionsLevel">0-100(这个是点击后的值)</param> |
| | | /// <param name="backlightLevel">0-100(这个是点击前的值)</param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | /// <returns></returns> |
| | | public bool SetDeviceLightSettion(string deviceMac, int deviceEpoint, int directionsLevel, int backlightLevel, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPanelBrightnessAdjustInfo(); |
| | | var memoryData = (ModelPanelBrightnessAdjustInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板亮度调节, classData); |
| | | memoryData.panelBacklightLevel = backlightLevel; |
| | | memoryData.panelDirectionsLevel = directionsLevel; |
| | | |
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough"; |
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | |
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取设备节能模式的配置状态(ui叫节能模式) |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <returns></returns> |
| | | public Panel.PanelSaveEnergyModeInfo GetDeviceEnergyConservationMode(string deviceMac, int deviceEpoint) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPanelEnergyModeInfo(); |
| | | var memoryData = (ModelPanelEnergyModeInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板节能模式, classData); |
| | | |
| | | var data = new Panel.PanelSaveEnergyModeInfo(); |
| | | data.enable = memoryData.energyModeInfo.enable; |
| | | data.level = memoryData.energyModeInfo.level == -1 ? 0 : memoryData.energyModeInfo.level; |
| | | data.time = memoryData.energyModeInfo.time == -1 ? 0 : memoryData.energyModeInfo.time; |
| | | return data; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置设备的节能模式(ui叫节能模式) |
| | | /// </summary> |
| | | /// <param name="device">设备对象</param> |
| | | /// <param name="modeEnable">节能模式是否有效</param> |
| | | /// <param name="modeTime">无操作进入节能模式时间 0-255</param> |
| | | /// <param name="level">节能模式亮度:0-100</param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | /// <returns></returns> |
| | | public bool SetDeviceEnergyConservationMode(string deviceMac, int deviceEpoint, bool modeEnable, int modeTime, int level, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPanelEnergyModeInfo(); |
| | | var memoryData = (ModelPanelEnergyModeInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板节能模式, classData); |
| | | memoryData.energyModeInfo.enable = modeEnable; |
| | | memoryData.energyModeInfo.time = modeTime; |
| | | memoryData.energyModeInfo.level = level; |
| | | |
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough"; |
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | |
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取按键指示灯开关颜色. |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="keyNum"></param> |
| | | /// <returns></returns> |
| | | public Panel.KeyColorDataResponseAllData GetPanelColorInfo(string deviceMac, int deviceEpoint, Panel.KeyNum keyNum) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPanelIndicatorLightInfo(); |
| | | var memoryData = (ModelPanelIndicatorLightInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板指示灯, classData); |
| | | |
| | | var data = new Panel.KeyColorDataResponseAllData(); |
| | | data.keyColorData = new Panel.KeyColorData(); |
| | | data.keyColorData.CloseColorB = string.IsNullOrEmpty(memoryData.keyColorData.CloseColorB) == true ? "0" : memoryData.keyColorData.CloseColorB; |
| | | data.keyColorData.CloseColorG = string.IsNullOrEmpty(memoryData.keyColorData.CloseColorG) == true ? "0" : memoryData.keyColorData.CloseColorG; |
| | | data.keyColorData.CloseColorR = string.IsNullOrEmpty(memoryData.keyColorData.CloseColorR) == true ? "0" : memoryData.keyColorData.CloseColorR; |
| | | data.keyColorData.OpenColorB = string.IsNullOrEmpty(memoryData.keyColorData.OpenColorB) == true ? "0" : memoryData.keyColorData.OpenColorB; |
| | | data.keyColorData.OpenColorG = string.IsNullOrEmpty(memoryData.keyColorData.OpenColorG) == true ? "0" : memoryData.keyColorData.OpenColorG; |
| | | data.keyColorData.OpenColorR = string.IsNullOrEmpty(memoryData.keyColorData.OpenColorR) == true ? "0" : memoryData.keyColorData.OpenColorR; |
| | | data.keyColorData.keyNum = keyNum; |
| | | |
| | | return data; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 配置按键指示灯颜色 |
| | | /// </summary> |
| | | /// <param name="device"></param> |
| | | /// <param name="keyColorData"></param> |
| | | /// <param name="keyNumStatus"></param> |
| | | /// <param name="receiveResult">设备返回的结果</param> |
| | | /// <returns></returns> |
| | | public CommonDevice.ResponseAllData SetPanelColorInfo(string deviceMac, int deviceEpoint, Panel.KeyColorData keyColorData, Panel.KeyNumStatus keyNumStatus, string receiveResult) |
| | | { |
| | | //获取对象 |
| | | var classData = new ModelPanelIndicatorLightInfo(); |
| | | var memoryData = (ModelPanelIndicatorLightInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板指示灯, classData); |
| | | |
| | | memoryData.keyColorData.keyNum = keyColorData.keyNum; |
| | | memoryData.keyColorData.OpenColorB = keyColorData.OpenColorB; |
| | | memoryData.keyColorData.OpenColorG = keyColorData.OpenColorG; |
| | | memoryData.keyColorData.OpenColorR = keyColorData.OpenColorR; |
| | | memoryData.keyColorData.CloseColorB = keyColorData.CloseColorB; |
| | | memoryData.keyColorData.CloseColorG = keyColorData.CloseColorG; |
| | | memoryData.keyColorData.CloseColorR = keyColorData.CloseColorR; |
| | | |
| | | memoryData.KeyNum.Key1 = keyNumStatus.Key1; |
| | | memoryData.KeyNum.Key2 = keyNumStatus.Key2; |
| | | memoryData.KeyNum.Key3 = keyNumStatus.Key3; |
| | | memoryData.KeyNum.Key4 = keyNumStatus.Key4; |
| | | memoryData.KeyNum.Key5 = keyNumStatus.Key5; |
| | | memoryData.KeyNum.Key6 = keyNumStatus.Key6; |
| | | memoryData.KeyNum.Key7 = keyNumStatus.Key7; |
| | | memoryData.KeyNum.Key8 = keyNumStatus.Key8; |
| | | memoryData.KeyNum.Key9 = keyNumStatus.Key9; |
| | | memoryData.KeyNum.Key10 = keyNumStatus.Key10; |
| | | memoryData.KeyNum.Key11 = keyNumStatus.Key11; |
| | | memoryData.KeyNum.Key12 = keyNumStatus.Key12; |
| | | memoryData.KeyNum.Key13 = keyNumStatus.Key13; |
| | | memoryData.KeyNum.Key14 = keyNumStatus.Key14; |
| | | memoryData.KeyNum.Key15 = keyNumStatus.Key15; |
| | | memoryData.KeyNum.Key16 = keyNumStatus.Key16; |
| | | |
| | | memoryData.ListSendTopic[0] = "ClientDataPassthrough"; |
| | | memoryData.ListReceiveTopic[0] = "ZbDataPassthrough"; |
| | | memoryData.ListReceiveResult[0] = receiveResult; |
| | | |
| | | this.SaveDeviceMemmoryData(deviceMac, deviceEpoint); |
| | | |
| | | return new CommonDevice.ResponseAllData |
| | | { |
| | | responseData = new CommonDevice.ResponseData |
| | | { status = 0 } |
| | | }; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 保存设备缓存_______________________ |
| | | |
| | | /// <summary> |
| | | /// 保存设备缓存(考虑有的设备用的是200端点,所以这里最好不用设备对象作为参数) |
| | | /// </summary> |
| | | /// <param name="deviceMac"></param> |
| | | /// <param name="deviceEpoint"></param> |
| | | public void SaveDeviceMemmoryData(string deviceMac, int deviceEpoint) |
| | | { |
| | | //代码移动到别的文件中了 |
| | | TemplateCommonLogic.Current.SaveDeviceMemmoryData(deviceMac, deviceEpoint); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 获取设备保存的模板对象(考虑有的设备用的是200端点,所以这里最好不用设备对象作为参数) |
| | | /// </summary> |
| | | /// <param name="deviceMac"></param> |
| | | /// <param name="deviceEpoint"></param> |
| | | /// <param name="saveEnum"></param> |
| | | /// <returns></returns> |
| | | private TemplateDeviceDataCommon GetDeviceModelDataClass(string deviceMac, int deviceEpoint, ModelDeviceSaveEnum saveEnum, TemplateDeviceDataCommon newClass) |
| | | { |
| | | //代码移动到别的文件中了 |
| | | return TemplateCommonLogic.Current.GetDeviceModelDataClass(deviceMac, deviceEpoint, saveEnum, newClass); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加双引号 |
| | | /// </summary> |
| | | /// <param name="i_text"></param> |
| | | /// <returns></returns> |
| | | private string SetDouMarks(string i_text) |
| | | { |
| | | return UserCenter.UserCenterResourse.douMarks + i_text + UserCenter.UserCenterResourse.douMarks; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |