using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
namespace Shared.Phone
{
///
/// 设备模板数据的逻辑
///
public class HdlTemplateDeviceDataLogic
{
#region ■ 变量声明___________________________
///
/// 设备模板数据的逻辑
///
private static HdlTemplateDeviceDataLogic m_Current = null;
///
/// 设备模板数据的逻辑
///
public static HdlTemplateDeviceDataLogic Current
{
get
{
if (m_Current == null)
{
m_Current = new HdlTemplateDeviceDataLogic();
}
return m_Current;
}
}
#endregion
#region ■ 窗帘手拉控制_______________________
///
/// 添加窗帘手拉控制缓存
///
/// 设备对象
/// 手拉控制状态
/// 设备返回的结果
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);
}
///
/// 获取窗帘手拉控制状态(虚拟使用)
///
///
///
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 ■ 窗帘方向___________________________
///
/// 设置窗帘的方向
///
///
///
/// 设备返回的结果
///
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);
if (memoryData.ListReceiveResult.Count == 1)
{
memoryData.ListReceiveResult.Add(string.Empty);
memoryData.ListReceiveTopic.Add(string.Empty);
memoryData.ListSendTopic.Add(string.Empty);
}
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 ■ 窗帘限位___________________________
///
/// 获取开合帘的限位
///
///
///
///
///
/// 设备返回的结果
///
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;
if (memoryData.ListReceiveResult.Count == 1)
{
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(rollershade.DeviceAddr, rollershade.DeviceEpoint);
return true;
}
///
/// 获取开合帘的限位
///
///
///
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 ■ 空调自定义模式_____________________
///
/// 添加空调自定义模式缓存
///
/// 设备对象
/// 值
/// 设备返回的结果
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);
}
///
/// 获取空调自定义模式(虚拟使用)
///
///
///
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 ■ 空调摆风模式_______________________
///
/// 添加空调摆风模式缓存
///
/// 设备对象
/// 值
/// 设备返回的结果
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);
}
///
/// 获取空调摆风模式(虚拟使用)
///
///
///
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 ■ 设备绑定___________________________
///
/// 获取设备绑定列表的缓存
///
/// 设备对象
///
public List GetDeviceBindList(CommonDevice device)
{
//获取对象
var classData = new ModelDeviceBindData();
var memoryData = (ModelDeviceBindData)this.GetDeviceModelDataClass(device.DeviceAddr, device.DeviceEpoint, ModelDeviceSaveEnum.A设备绑定列表, classData);
return memoryData.BindList;
}
///
/// 添加设备绑定列表的缓存
///
///
/// 设备返回的结果
///
public BindObj.AddedDeviceBindResponseAllData AddDeviceBindList(BindObj.AddBindData addBindData, string receiveResult)
{
var device = HdlDeviceCommonLogic.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;
}
///
/// 删除设备绑定列表的缓存
///
///
///
public BindObj.DelDeviceBindResponseAllData DeleteDeviceBindList(BindObj.DelDeviceBindData delDeviceBindData)
{
var device = HdlDeviceCommonLogic.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;
}
///
/// 删除指定设备的全部绑定
///
///
///
public BindObj.ClearBindInfoResponseAllData ClearDeviceAllBind(CommonDevice device)
{
string mainkey = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
if (HdlTemplateCommonLogic.Current.modelData.dicDeviceTemplateData.ContainsKey(mainkey) == true)
{
//移除全部的 设备绑定列表 数据
var listBind = HdlTemplateCommonLogic.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 }
};
}
///
/// 配置按键的功能模式
///
///
///
///
/// 设备返回的结果
///
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 }
};
}
///
/// 获取按键的功能模式
///
///
///
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传感器__________________________
///
/// 获取Pir传感器的配置
///
///
///
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;
}
///
/// 设置Pir传感器的配置
///
///
///
/// 设备返回的结果
///
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 ■ 面板震动功能_______________________
///
/// 获取面板震动功能
///
///
///
public HdlDevicePanelLogic.PanelVibrationInfo GetPanelVibrationInfo(string deviceMac, int deviceEpoint)
{
//获取对象
var classData = new ModelPanelVibrationInfo();
var memoryData = (ModelPanelVibrationInfo)this.GetDeviceModelDataClass(deviceMac, deviceEpoint, ModelDeviceSaveEnum.A面板震动功能, classData);
var data = new HdlDevicePanelLogic.PanelVibrationInfo();
data.A震动使能 = memoryData.vibrationInfo.A震动使能;
data.A震动强度 = memoryData.vibrationInfo.A震动强度;
data.A震动时间 = memoryData.vibrationInfo.A震动时间;
return data;
}
///
/// 设置面板震动功能
///
///
///
/// 设备返回的结果
///
public bool SetPanelVibrationInfo(string deviceMac, int deviceEpoint, 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 ■ 设备名称___________________________
///
/// 修改设备Mac名称
///
///
///
///
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
}
};
}
///
/// 修改设备端点名称
///
///
///
///
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 ■ 面板背光灯设置_____________________
///
/// 获取设备亮度配置(ui叫亮度调节,使用返回值的panelDirectionsLevel)
///
///
///
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;
}
///
/// 设置设备亮度(ui叫亮度调节)
///
/// 设备对象
/// 0-100(这个是点击后的值)
/// 0-100(这个是点击前的值)
/// 设备返回的结果
///
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;
}
///
/// 获取设备节能模式的配置状态(ui叫节能模式)
///
///
///
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;
}
///
/// 设置设备的节能模式(ui叫节能模式)
///
/// 设备对象
/// 节能模式是否有效
/// 无操作进入节能模式时间 0-255
/// 节能模式亮度:0-100
/// 设备返回的结果
///
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;
}
///
/// 获取按键指示灯开关颜色.
///
///
///
///
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;
}
///
/// 配置按键指示灯颜色
///
///
///
///
/// 设备返回的结果
///
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 ■ 保存设备缓存_______________________
///
/// 保存设备缓存(考虑有的设备用的是200端点,所以这里最好不用设备对象作为参数)
///
///
///
public void SaveDeviceMemmoryData(string deviceMac, int deviceEpoint)
{
//代码移动到别的文件中了
HdlTemplateCommonLogic.Current.SaveDeviceMemmoryData(deviceMac, deviceEpoint);
}
#endregion
#region ■ 一般方法___________________________
///
/// 获取设备保存的模板对象(考虑有的设备用的是200端点,所以这里最好不用设备对象作为参数)
///
///
///
///
///
private TemplateDeviceDataCommon GetDeviceModelDataClass(string deviceMac, int deviceEpoint, ModelDeviceSaveEnum saveEnum, TemplateDeviceDataCommon newClass)
{
//代码移动到别的文件中了
return HdlTemplateCommonLogic.Current.GetDeviceModelDataClass(deviceMac, deviceEpoint, saveEnum, newClass);
}
///
/// 添加双引号
///
///
///
private string SetDouMarks(string i_text)
{
return HdlUserCenterResourse.douMarks + i_text + HdlUserCenterResourse.douMarks;
}
#endregion
}
}