| | |
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | | using System.Threading.Tasks;
|
| | | using Newtonsoft.Json.Linq;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | |
| | | /// </summary>
|
| | | /// <param name="panel">按键面板的某一个回路</param>
|
| | | /// <returns></returns>
|
| | | public async Task<Panel.KeyColorData> GetPanelEpointColorInfo(Panel panel)
|
| | | public Panel.KeyColorData GetPanelEpointColorInfo(CommonDevice panel)
|
| | | {
|
| | | Panel.KeyNum keyNum = (Panel.KeyNum)panel.DeviceEpoint;
|
| | | var result = await panel.GetPanelColorInfoAsync(keyNum);
|
| | | var result = this.GetPanelColorInfoAsync(panel, keyNum);
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取面板颜色的信息(出错会返回null)
|
| | | /// </summary>
|
| | | /// <param name="panel">按键面板的某一个回路</param>
|
| | | /// <returns></returns>
|
| | | public Panel.KeyColorData GetPanelColorInfo(CommonDevice panel)
|
| | | {
|
| | | panel.DeviceEpoint = 1;
|
| | | Panel.KeyNum keyNum = (Panel.KeyNum)panel.DeviceEpoint;
|
| | | var result = this.GetPanelColorInfoAsync(panel, keyNum);
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | | {
|
| | | this.ShowErrorMsg(error);
|
| | | return null;
|
| | | }
|
| | |
|
| | | if (result == null || result.keyColorData == null)
|
| | | {
|
| | | //获取按键面板颜色调节信息失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelColorRegulationInfoFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | return null;
|
| | | }
|
| | | return result.keyColorData;
|
| | | }
|
| | |
|
| | | ///<summary >
|
| | | ///获取按键指示灯开关颜色.
|
| | | /// </summary>
|
| | | public Panel.KeyColorDataResponseAllData GetPanelColorInfoAsync(CommonDevice device, Panel.KeyNum keyNum)
|
| | | {
|
| | | //如果当前是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //这里特殊,这里是按回路分的
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.GetPanelColorInfo(device.DeviceAddr, device.DeviceEpoint, keyNum);
|
| | | }
|
| | | //发送数据 keyNum转为16进制 范围:01~10
|
| | | var passData = "0504040101" + Convert.ToString((int)keyNum, 16).ToUpper().PadLeft(2, '0');
|
| | | var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var dataObject = new JObject { { "PassData", passData } };
|
| | | jObject.Add("Data", dataObject);
|
| | |
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, jObject.ToString(), "0405", 24, 9);
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | string data = result.ReceiptData;
|
| | |
|
| | | var tempR = new Panel.KeyColorData();
|
| | | tempR.OpenColorR = data[12].ToString() + data[13].ToString();
|
| | | tempR.OpenColorG = data[14].ToString() + data[15].ToString();
|
| | | tempR.OpenColorB = data[16].ToString() + data[17].ToString();
|
| | | tempR.CloseColorR = data[18].ToString() + data[19].ToString();
|
| | | tempR.CloseColorG = data[20].ToString() + data[21].ToString();
|
| | | tempR.CloseColorB = data[22].ToString() + data[23].ToString();
|
| | |
|
| | | var key = data[10].ToString() + data[11].ToString();
|
| | | int keyEnum1 = Convert.ToInt32(key, 16);
|
| | | tempR.keyNum = (Panel.KeyNum)keyEnum1;
|
| | |
|
| | | return new Panel.KeyColorDataResponseAllData { keyColorData = tempR };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置按键面板指定端点的【指示灯开关颜色】的信息
|
| | | /// </summary>
|
| | | /// <param name="panel">按键面板的某一个回路</param>
|
| | | /// <param name="colorData">开和关的颜色都需要一起设置</param>
|
| | | /// <returns></returns>
|
| | | public async Task<bool> SetPanelEpointColorInfo(Panel panel, Panel.KeyColorData colorData)
|
| | | public bool SetPanelEpointColorInfo(CommonDevice panel, Panel.KeyColorData colorData)
|
| | | {
|
| | | var keyNum = new Panel.KeyNumStatus();
|
| | | Type type = keyNum.GetType();
|
| | | type.InvokeMember("Key" + panel.DeviceEpoint, System.Reflection.BindingFlags.SetField, null, keyNum, new object[] { true });
|
| | |
|
| | | var result = await panel.SetPanelColorInfoAsync(colorData, keyNum);
|
| | | var result = this.SetPanelColorInfoAsync(panel, colorData, keyNum);
|
| | | if (result == null || result.responseData == null)
|
| | | {
|
| | | //设置按键面板指示灯颜色失败
|
| | |
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | //备份设备
|
| | | await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A干接点颜色调节, colorData);
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 设置面板颜色
|
| | | /// </summary>
|
| | | /// <param name="panel">按键面板的</param>
|
| | | /// <param name="colorData">只设置开的颜色</param>
|
| | | /// <returns></returns>
|
| | | public bool SetPanelColorInfo(CommonDevice panel, Panel.KeyColorData colorData)
|
| | | {
|
| | | var keyNum = new Panel.KeyNumStatus();
|
| | | //默认第一个用面板第一个按键颜色作为整个面板的颜色
|
| | | keyNum.Key1 = true;
|
| | | var result = this.SetPanelColorInfoAsync(panel, colorData, keyNum);
|
| | | if (result == null || result.responseData == null)
|
| | | {
|
| | | //设置按键面板指示灯颜色失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetPanelPilolightSettionFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | if (result.responseData.status != 0)
|
| | | {
|
| | | //设置按键面板指示灯颜色失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetPanelPilolightSettionFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | ///<summary >
|
| | | ///配置按键指示灯颜色
|
| | | /// </summary>
|
| | | public CommonDevice.ResponseAllData SetPanelColorInfoAsync(CommonDevice device, Panel.KeyColorData keyColorData, Panel.KeyNumStatus keyNumStatus)
|
| | | {
|
| | | //如果当前是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //这个也是特殊,按回路来分
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.SetPanelColorInfo(device.DeviceAddr, device.DeviceEpoint, keyColorData, keyNumStatus, null);
|
| | | }
|
| | | //获取配置按键指示灯颜色的命令字符
|
| | | var sendData = this.GetPanelColorCommandText(device.DeviceAddr, keyColorData, keyNumStatus);
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 9);
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | var data = result.ReceiptData;
|
| | | var tempD = new CommonDevice.ResponseData();
|
| | | tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
|
| | | tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
|
| | |
|
| | | //添加缓存
|
| | | TemplateData.TemplateDeviceDataLogic.Current.SetPanelColorInfo(device.DeviceAddr, device.DeviceEpoint, keyColorData, keyNumStatus, result.JsonData[0]);
|
| | |
|
| | | return new CommonDevice.ResponseAllData { responseData = tempD };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取配置按键指示灯颜色的命令字符
|
| | | /// </summary>
|
| | | /// <param name="DeviceAddr"></param>
|
| | | /// <param name="keyColorData"></param>
|
| | | /// <param name="keyNumStatus"></param>
|
| | | /// <returns></returns>
|
| | | public string GetPanelColorCommandText(string DeviceAddr, Panel.KeyColorData keyColorData, Panel.KeyNumStatus keyNumStatus)
|
| | | {
|
| | | var passData = this.GetPanelColorPassData(keyColorData, keyNumStatus);
|
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var data = new JObject { { "PassData", passData } };
|
| | | jObject.Add("Data", data);
|
| | |
|
| | | return jObject.ToString();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 配置按键指示灯颜色数据
|
| | | /// <para>发配置按键指示灯颜色命令时,此时为发送到网关的透传数据</para>
|
| | | /// </summary>
|
| | | /// <returns>The passthorugh data.</returns>
|
| | | /// <param name="keyColorData">Key color data.</param>
|
| | | /// <param name="keyNum">Key number.</param>
|
| | | private string GetPanelColorPassData(Panel.KeyColorData keyColorData, Panel.KeyNumStatus keyNumStatus)
|
| | | {
|
| | | string data = "";
|
| | | string dataLength = "0c";
|
| | | string dataComand1 = "01";
|
| | | string dataComand2 = "04";
|
| | | string dataSerialNum = "01";
|
| | | string addDataLength = "08";
|
| | | int attributeData = 0;
|
| | |
|
| | | try
|
| | | {
|
| | | for (int i = 1; i <= 16; i++)
|
| | | {
|
| | | Type type = keyNumStatus.GetType();
|
| | | var obj = type.InvokeMember("Key" + i, System.Reflection.BindingFlags.GetField, null, keyNumStatus, null);
|
| | | int value0 = 0;
|
| | | if (Convert.ToBoolean(obj) == true)
|
| | | {
|
| | | value0 = 1;
|
| | | }
|
| | | int v = (int)Math.Pow(2, i - 1);
|
| | | attributeData += value0 * v;
|
| | | }
|
| | |
|
| | | string td = attributeData.ToString("X4");
|
| | | char[] td1 = td.ToCharArray();
|
| | | string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString());
|
| | | string temp = "";
|
| | | var tempColor1 = keyColorData.OpenColorR.ToString();
|
| | | var sbString1 = new System.Text.StringBuilder();
|
| | | switch (tempColor1.Length)
|
| | | {
|
| | | case 1:
|
| | | temp = "0" + tempColor1;
|
| | | break;
|
| | | case 2:
|
| | | temp = tempColor1;
|
| | | break;
|
| | | }
|
| | | sbString1.Append(temp.ToUpper());
|
| | |
|
| | | var tempColor2 = keyColorData.OpenColorG.ToString();
|
| | | var sbString2 = new System.Text.StringBuilder();
|
| | | switch (tempColor2.Length)
|
| | | {
|
| | | case 1:
|
| | | temp = "0" + tempColor2;
|
| | | break;
|
| | | case 2:
|
| | | temp = tempColor2;
|
| | | break;
|
| | | }
|
| | | sbString2.Append(temp.ToUpper());
|
| | |
|
| | | var tempColor3 = keyColorData.OpenColorB.ToString();
|
| | | var sbString3 = new System.Text.StringBuilder();
|
| | | switch (tempColor3.Length)
|
| | | {
|
| | | case 1:
|
| | | temp = "0" + tempColor3;
|
| | | break;
|
| | | case 2:
|
| | | temp = tempColor3;
|
| | | break;
|
| | | }
|
| | | sbString3.Append(temp.ToUpper());
|
| | |
|
| | | var tempColor4 = keyColorData.CloseColorR.ToString();
|
| | | var sbString4 = new System.Text.StringBuilder();
|
| | | switch (tempColor3.Length)
|
| | | {
|
| | | case 1:
|
| | | temp = "0" + tempColor4;
|
| | | break;
|
| | | case 2:
|
| | | temp = tempColor4;
|
| | | break;
|
| | | }
|
| | | sbString4.Append(temp.ToUpper());
|
| | |
|
| | | var tempColor5 = keyColorData.CloseColorG.ToString();
|
| | | var sbString5 = new System.Text.StringBuilder();
|
| | | switch (tempColor5.Length)
|
| | | {
|
| | | case 1:
|
| | | temp = "0" + tempColor5;
|
| | | break;
|
| | | case 2:
|
| | | temp = tempColor5;
|
| | | break;
|
| | | }
|
| | | sbString5.Append(temp.ToUpper());
|
| | |
|
| | | var tempColor6 = keyColorData.CloseColorB.ToString();
|
| | | var sbString6 = new System.Text.StringBuilder();
|
| | | switch (tempColor6.Length)
|
| | | {
|
| | | case 1:
|
| | | temp = "0" + tempColor6;
|
| | | break;
|
| | | case 2:
|
| | | temp = tempColor6;
|
| | | break;
|
| | | }
|
| | | sbString6.Append(temp.ToUpper());
|
| | |
|
| | | if (keyColorData != null)
|
| | | {
|
| | | data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
|
| | | tempAttributeData + sbString1 + sbString2 + sbString3 +
|
| | | sbString4 + sbString5 + sbString6;
|
| | | }
|
| | | }
|
| | | catch { };
|
| | |
|
| | | return data;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 亮度调节___________________________
|
| | | /// <summary>
|
| | | /// 获取设备亮度配置(ui叫亮度调节,使用返回值的panelDirectionsLevel)
|
| | |
|
| | | ///<summary >
|
| | | ///获取设备亮度配置(ui叫亮度调节,使用返回值的panelDirectionsLevel)
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <returns></returns>
|
| | | public async Task<Panel.PanelSwitchLevelInfo> GetDeviceLightSettion(CommonDevice device)
|
| | | public Panel.PanelSwitchLevelInfo GetDeviceLightSettion(CommonDevice device)
|
| | | {
|
| | | //借用它的函数
|
| | | var panel = new Panel();
|
| | | panel.DeviceAddr = device.DeviceAddr;
|
| | | panel.DeviceEpoint = device.DeviceEpoint;
|
| | | panel.CurrentGateWayId = device.CurrentGateWayId;
|
| | |
|
| | | var result = await panel.GetPanelSwitchLevelAsync();
|
| | | panel = null;
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | | //如果当前是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | this.ShowErrorMsg(error);
|
| | | return null;
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.GetDeviceLightSettion(device.DeviceAddr, 200);
|
| | | }
|
| | | //获取发送的命令字符
|
| | | var passData = "050604010101";
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "PassData", passData } };
|
| | | jObject.Add("Data", data);
|
| | | var sendData = jObject.ToString();
|
| | |
|
| | | if (result == null || string.IsNullOrEmpty(result.errorMessageBase) == false)
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0407", 14, 9);
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | //获取按键面板亮度调节信息失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelLightRegulationInfoFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | return null;
|
| | | }
|
| | | return result;
|
| | | var receiptData = result.ReceiptData;
|
| | | var level1 = Convert.ToInt32(receiptData[10].ToString() + receiptData[11].ToString(), 16);
|
| | | var level2 = Convert.ToInt32(receiptData[12].ToString() + receiptData[13].ToString(), 16);
|
| | |
|
| | | return new Panel.PanelSwitchLevelInfo { panelDirectionsLevel = level1, panelBacklightLevel = level2 };
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="directionsLevel">0-100(这个是点击后的值)</param>
|
| | | /// <param name="backlightLevel">0-100(这个是点击前的值)</param>
|
| | | /// <returns></returns>
|
| | | public async Task<bool> SetDeviceLightSettion(CommonDevice device, int directionsLevel, int backlightLevel)
|
| | | public bool SetDeviceLightSettion(CommonDevice device, int directionsLevel, int backlightLevel)
|
| | | {
|
| | | //借用它的函数
|
| | | var panel = new Panel();
|
| | | panel.DeviceAddr = device.DeviceAddr;
|
| | | panel.DeviceEpoint = device.DeviceEpoint;
|
| | | panel.CurrentGateWayId = device.CurrentGateWayId;
|
| | |
|
| | | var result = await panel.SetKeyLevelAsync(directionsLevel, backlightLevel);
|
| | | panel = null;
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | | //如果当前是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | this.ShowTipMsg(error);
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.SetDeviceLightSettion(device.DeviceAddr, 200, directionsLevel, backlightLevel, null);
|
| | | }
|
| | | //获取修改面板的亮度调节的命令字符
|
| | | var sendData = this.GetPanelLevelCommadText(device.DeviceAddr, directionsLevel, backlightLevel);
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 9);
|
| | | if (result.ErrorMsg != null)
|
| | | {
|
| | | this.ShowTipMsg(result.ErrorMsg);
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (result == null || result.responseData == null)
|
| | | if (result.ErrorMsgDiv == 0)
|
| | | {
|
| | | //设置亮度调节失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetLightRegulationFail);
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | if (result.responseData.status != 0)
|
| | | //这里还有一个 0402
|
| | | //tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
|
| | |
|
| | | var status = Convert.ToInt32(result.ReceiptData[14].ToString() + result.ReceiptData[15].ToString(), 16);
|
| | | if (status != 0)
|
| | | {
|
| | | //设置亮度调节失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetLightRegulationFail);
|
| | | this.ShowTipMsg(msg);
|
| | | return false;
|
| | | }
|
| | | //备份设备
|
| | | var backData = new Newtonsoft.Json.Linq.JObject
|
| | | { |
| | | { "directionsLevel",directionsLevel }, |
| | | { "backlightLevel", backlightLevel } |
| | | };
|
| | | //备份设备
|
| | | await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A干接点亮度调节, backData);
|
| | |
|
| | | //修改缓存
|
| | | TemplateData.TemplateDeviceDataLogic.Current.SetDeviceLightSettion(device.DeviceAddr, 200, directionsLevel, backlightLevel, result.JsonData[0]);
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取修改面板的亮度调节的命令字符
|
| | | /// </summary>
|
| | | /// <param name="DeviceAddr"></param>
|
| | | /// <param name="directionsLevel">0-100(这个是点击后的值)</param>
|
| | | /// <param name="backlightLevel">0-100(这个是点击前的值)</param>
|
| | | /// <returns></returns>
|
| | | public string GetPanelLevelCommadText(string DeviceAddr, int directionsLevel, int backlightLevel)
|
| | | {
|
| | | var passData = this.GetSetPanelLevelPassData(directionsLevel, backlightLevel);
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "PassData", passData } };
|
| | | jObject.Add("Data", data);
|
| | |
|
| | | return jObject.ToString();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取配置按键指示灯面板亮度的命令字符
|
| | | /// </summary>
|
| | | private string GetSetPanelLevelPassData(int level1, int level2)
|
| | | {
|
| | | string data = "";
|
| | | string dataLength = "06";
|
| | | string dataComand1 = "02";
|
| | | string dataComand2 = "04";
|
| | | string dataSerialNum = "01";
|
| | | string addDataLength = "02";
|
| | | string l1 = "";
|
| | | string l2 = "";
|
| | | try
|
| | | { |
| | | var sbString1 = new System.Text.StringBuilder(); |
| | | var sbString2 = new System.Text.StringBuilder(); |
| | | string temp1 = Convert.ToString(level1, 16);
|
| | | string temp2 = Convert.ToString(level2, 16);
|
| | |
|
| | | switch (temp1.Length)
|
| | | {
|
| | | case 1:
|
| | | l1 = "0" + temp1;
|
| | | break;
|
| | | case 2:
|
| | | l1 = temp1;
|
| | | break;
|
| | | }
|
| | | switch (temp2.Length)
|
| | | {
|
| | | case 1:
|
| | | l2 = "0" + temp2;
|
| | | break;
|
| | | case 2:
|
| | | l2 = temp2;
|
| | | break;
|
| | | }
|
| | | sbString1.Append(l1.ToString().ToUpper());
|
| | | sbString2.Append(l2.ToString().ToUpper());
|
| | | data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
|
| | | sbString1 + sbString2;
|
| | | }
|
| | | catch { };
|
| | |
|
| | | return data;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 节能模式___________________________
|
| | | #region ■ 接近感应___________________________
|
| | | /// <summary>
|
| | | /// 获取设备节能模式的配置状态(ui叫节能模式)
|
| | | /// 获取接近感应配置(ui叫接近感应,使用返回值的panelProximitySensorInfo)
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <returns></returns>
|
| | | public async Task<Panel.PanelSaveEnergyModeInfo> GetDeviceEnergyConservationMode(CommonDevice device)
|
| | | public async Task<Panel.PanelProximitySensorInfo> GetDeviceProximitySensorsSettion(CommonDevice device)
|
| | | {
|
| | | //借用它的函数
|
| | | var panel = new Panel();
|
| | |
| | | panel.DeviceEpoint = device.DeviceEpoint;
|
| | | panel.CurrentGateWayId = device.CurrentGateWayId;
|
| | |
|
| | | var result = await panel.GetPanelSaveEnergyModeAsync();
|
| | | var result = await panel.GetProximitySensorAsync();
|
| | | panel = null;
|
| | |
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | |
| | | this.ShowErrorMsg(error);
|
| | | return null;
|
| | | }
|
| | | if (result == null || result.panelProximitySensorInfo == null || string.IsNullOrEmpty(result.errorMessageBase) == false)
|
| | | {
|
| | | //获取接近感应信息失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.GetPanelProximityFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | return null;
|
| | | }
|
| | | return result.panelProximitySensorInfo;
|
| | | }
|
| | |
|
| | | if (result == null || result.panelSaveEnergyModeInfo == null)
|
| | |
|
| | | /// <summary>
|
| | | /// 配置接近传感
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <para>sensorEnable:传感器使能</para> |
| | | /// <returns></returns>
|
| | | public async Task<bool> SetProximitySensorStatus(CommonDevice device, bool sensorEnable)
|
| | | {
|
| | | //借用它的函数
|
| | | var panel = new Panel();
|
| | | panel.DeviceAddr = device.DeviceAddr;
|
| | | panel.DeviceEpoint = device.DeviceEpoint;
|
| | | panel.CurrentGateWayId = device.CurrentGateWayId;
|
| | |
|
| | | var result = await panel.SetProximitySensor(sensorEnable);
|
| | | panel = null;
|
| | |
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | | {
|
| | | this.ShowErrorMsg(error);
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (result == null || result.responseData == null)
|
| | | {
|
| | | //接近传感配置失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.SetPannelProximityFail);
|
| | | //拼接上【网关回复超时】的Msg
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
|
| | |
|
| | | this.ShowTipMsg(msg);
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region ■ 校正温度___________________________ |
| | | /// <summary>
|
| | | /// 校正温度
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <param name="correctValue">校正温度值</param>
|
| | | /// <param name="direction">补偿方向0不补偿 1:正向;2:反向</param>
|
| | | /// <param name="type">0 温度 ;1 湿度</param>
|
| | | /// <returns></returns> |
| | | public async Task<bool> CorrectTemperature(CommonDevice device, double correctValue, int direction = 0, int type = 0)
|
| | | {
|
| | | //借用它的函t
|
| | | var panel = new Panel();
|
| | | panel.DeviceAddr = device.DeviceAddr;
|
| | | panel.DeviceEpoint = 200;
|
| | | panel.CurrentGateWayId = device.CurrentGateWayId;
|
| | |
|
| | | var result = await panel.CorrectTemperature(correctValue, direction, type);
|
| | | panel = null;
|
| | |
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | | {
|
| | | this.ShowErrorMsg(error);
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (result == null || result.responseData == null)
|
| | | {
|
| | | //矫正温度失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.DataCorrectionFailed);
|
| | | //拼接上【网关回复超时】的Msg
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
|
| | |
|
| | | this.ShowTipMsg(msg);
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | | #endregion |
| | |
|
| | | #region ■ 节能模式___________________________
|
| | | /// <summary>
|
| | | /// 获取设备节能模式的配置状态(ui叫节能模式)
|
| | | /// </summary>
|
| | | /// <param name="device">设备对象</param>
|
| | | /// <returns></returns>
|
| | | public Panel.PanelSaveEnergyModeInfo GetDeviceEnergyConservationMode(CommonDevice device)
|
| | | {
|
| | | //如果当前住宅是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.GetDeviceEnergyConservationMode(device.DeviceAddr, 200);
|
| | | }
|
| | | //发送命令
|
| | | string passData = "050804010101";
|
| | | var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var data = new JObject { { "PassData", passData } };
|
| | | jObject.Add("Data", data);
|
| | | //16:旧版本 18:新版本
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, jObject.ToString(), "0409", 16, 9, new List<int> { 18 });
|
| | | if (result.ErrorMsg != null)
|
| | | {
|
| | | this.ShowTipMsg(result.ErrorMsg);
|
| | | return null;
|
| | | }
|
| | | if (result.ErrorMsgDiv == 0)
|
| | | {
|
| | | //获取按键面板节能模式信息失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelEnergyConservationInfoFail);
|
| | |
| | | this.ShowErrorMsg(msg);
|
| | | return null;
|
| | | }
|
| | | return result.panelSaveEnergyModeInfo;
|
| | |
|
| | | var energyInfo = new Panel.PanelSaveEnergyModeInfo();
|
| | |
|
| | | if (result.ReceiptData[10].ToString() + result.ReceiptData[11].ToString() == "01")
|
| | | {
|
| | | energyInfo.enable = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | energyInfo.enable = false;
|
| | | }
|
| | |
|
| | | //新版本:07 0904 11 04 01 3C00 32
|
| | | if (result.ReceiptData.Length == 18)
|
| | | {
|
| | | energyInfo.time = Convert.ToInt32(result.ReceiptData[14].ToString() + result.ReceiptData[15].ToString() +
|
| | | result.ReceiptData[12].ToString() + result.ReceiptData[13].ToString(), 16);
|
| | |
|
| | | energyInfo.level = Convert.ToInt32(result.ReceiptData[16].ToString() + result.ReceiptData[17].ToString(), 16); |
| | | }
|
| | | //旧版本:07 0904 11 03 01 3C 32
|
| | | else
|
| | | {
|
| | | energyInfo.time = Convert.ToInt32(result.ReceiptData[12].ToString() + result.ReceiptData[13].ToString(), 16);
|
| | | energyInfo.level = Convert.ToInt32(result.ReceiptData[14].ToString() + result.ReceiptData[15].ToString(), 16);
|
| | | }
|
| | | return energyInfo;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <param name="modeTime">无操作进入节能模式时间 0-255</param>
|
| | | /// <param name="level">节能模式亮度:0-100</param>
|
| | | /// <returns></returns>
|
| | | public async Task<bool> SetDeviceEnergyConservationMode(CommonDevice device, bool modeEnable, int modeTime, int level)
|
| | | public bool SetDeviceEnergyConservationMode(CommonDevice device, bool modeEnable, int modeTime, int level)
|
| | | {
|
| | | //借用它的函数
|
| | | var panel = new Panel();
|
| | | panel.DeviceAddr = device.DeviceAddr;
|
| | | panel.DeviceEpoint = device.DeviceEpoint;
|
| | | panel.CurrentGateWayId = device.CurrentGateWayId;
|
| | |
|
| | | var result = await panel.SetKeyModeAsync(modeEnable, modeTime, level);
|
| | | panel = null;
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | | //如果当前是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | this.ShowErrorMsg(error);
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.SetDeviceEnergyConservationMode(device.DeviceAddr, 200, modeEnable, modeTime, level, null);
|
| | | }
|
| | | //获取设置设备的节能模式的命令字符
|
| | | var sendData = this.GetDeviceEnergyConservationModeCommandText(device.DeviceAddr, modeEnable, modeTime, level);
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 9);
|
| | | if (result.ErrorMsg != null)
|
| | | {
|
| | | this.ShowTipMsg(result.ErrorMsg);
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (result == null || result.responseData == null)
|
| | | if (result.ErrorMsgDiv == 0)
|
| | | {
|
| | | //节能模式配置失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail);
|
| | |
| | | this.ShowTipMsg(msg);
|
| | | return false;
|
| | | }
|
| | |
|
| | | if (result.responseData.status != 0)
|
| | | var status = Convert.ToInt32(result.ReceiptData[14].ToString() + result.ReceiptData[15].ToString(), 16);
|
| | | if (status != 0)
|
| | | {
|
| | | //节能模式配置失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail);
|
| | | this.ShowTipMsg(msg);
|
| | | return false;
|
| | | }
|
| | | //备份设备
|
| | | var backData = new Newtonsoft.Json.Linq.JObject
|
| | | { |
| | | { "modeEnable",modeEnable }, |
| | | { "modeTime", modeTime }, |
| | | { "level", level } |
| | | };
|
| | | //备份设备
|
| | | await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A干接点节能模式, backData);
|
| | |
|
| | | //修改缓存
|
| | | TemplateData.TemplateDeviceDataLogic.Current.SetDeviceEnergyConservationMode(device.DeviceAddr, 200, modeEnable, modeTime, level, result.JsonData[0]);
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设置设备的节能模式的命令字符
|
| | | /// </summary>
|
| | | /// <param name="DeviceAddr"></param>
|
| | | /// <param name="modeEnable"></param>
|
| | | /// <param name="modeTime"></param>
|
| | | /// <param name="level"></param>
|
| | | /// <returns></returns>
|
| | | public string GetDeviceEnergyConservationModeCommandText(string DeviceAddr, bool modeEnable, int modeTime, int level)
|
| | | {
|
| | | var passData = this.GetPanelModeModePassData(modeEnable, modeTime, level);
|
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var data = new JObject { { "PassData", passData } };
|
| | | jObject.Add("Data", data);
|
| | |
|
| | | return jObject.ToString();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取设置设备的节能模式的命令字符
|
| | | /// </summary>
|
| | | private string GetPanelModeModePassData(bool modeEnable, int modeTime, int modelevel)
|
| | | {
|
| | | string data = "";
|
| | | string dataLength = "08";
|
| | | string dataComand1 = "03";
|
| | | string dataComand2 = "04";
|
| | | string dataSerialNum = "01";
|
| | | string addDataLength = "04";
|
| | | string mode = "";
|
| | | string time = "";
|
| | | string level = "";
|
| | | try
|
| | | { |
| | | if (modeEnable) |
| | | { |
| | | mode = "01";
|
| | | }
|
| | | else
|
| | | {
|
| | | mode = "00";
|
| | | }
|
| | |
|
| | | if (modeTime == -1)
|
| | | {
|
| | | //当节能模式没有给时间,默认给60秒
|
| | | modeTime = 60;
|
| | | }
|
| | |
|
| | | var tempBytes = new byte[2];
|
| | | for (int i = 0; i < 2; i++)
|
| | | {
|
| | | tempBytes[i] = (byte)(modeTime >> (i * 8) & 0xff);
|
| | | }
|
| | | var time1 = Convert.ToString(tempBytes[0], 16);
|
| | | var time2 = Convert.ToString(tempBytes[1], 16);
|
| | | if (time1.Length == 1)
|
| | | {
|
| | | time1 = "0" + time1;
|
| | | }
|
| | | if (time2.Length == 1)
|
| | | {
|
| | | time2 = "0" + time2;
|
| | | }
|
| | |
|
| | | time = (time1 + time2).ToUpper();
|
| | |
|
| | | var sbString2 = new System.Text.StringBuilder();
|
| | | string temp2 = Convert.ToString(modelevel, 16);
|
| | | switch (temp2.Length)
|
| | | {
|
| | | case 1:
|
| | | level = "0" + temp2; |
| | | break;
|
| | | case 2:
|
| | | level = temp2;
|
| | | break;
|
| | | }
|
| | |
|
| | | sbString2.Append(level.ToUpper());
|
| | | data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
|
| | | mode + time + sbString2;
|
| | | }
|
| | | catch { };
|
| | |
|
| | | return data;
|
| | | }
|
| | |
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// </summary>
|
| | | /// <param name="panel">干接点对象</param>
|
| | | /// <returns></returns>
|
| | | public async Task<List<CommonDevice.AttributeDataObj>> GetDryContactConfigureInfo(CommonDevice device)
|
| | | public List<CommonDevice.AttributeDataObj> GetDryContactConfigureInfo(CommonDevice device)
|
| | | {
|
| | | //借用它的函数
|
| | | var panel = new Panel();
|
| | | panel.DeviceAddr = device.DeviceAddr;
|
| | | panel.DeviceEpoint = device.DeviceEpoint;
|
| | | panel.CurrentGateWayId = device.CurrentGateWayId;
|
| | |
|
| | | var result = await panel.ReadPanelConfigureInfoAsync();
|
| | | panel = null;
|
| | | var result = HdlDeviceBindLogic.Current.ReadPanelConfigureInfoAsync(device);
|
| | |
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | |
| | | #region ■ 修改干接点私有属性_________________
|
| | |
|
| | | /// <summary>
|
| | | /// 修改干接点私有属性
|
| | | /// 修改干接点第三级别的私有属性
|
| | | /// </summary>
|
| | | /// <param name="panel">干接点对象</param>
|
| | | /// <param name="i_value">干接点的第三级别属性的值,具体请参照第三级别属性</param>
|
| | | /// <returns></returns>
|
| | | public async Task<bool> EditorDryContactFunction(Panel panel, int i_value)
|
| | | public bool EditorDryContactThirdFunction(Panel panel, int i_value)
|
| | | {
|
| | | var result = await panel.ConfigureHdlKeyValueAsync((Panel.KeyMode)i_value);
|
| | | var result = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(panel, (Panel.KeyMode)i_value);
|
| | | //共通错误检测
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
|
| | | if (error != null)
|
| | |
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | //备份设备
|
| | | await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A干接点私有属性, i_value);
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | |
| | | /// </summary>
|
| | | /// <param name="device">某一回路</param>
|
| | | /// <returns></returns>
|
| | | public VibrationInfo GetPanelVibrationData(CommonDevice device)
|
| | | public PanelVibrationInfo GetPanelVibrationData(CommonDevice device)
|
| | | {
|
| | | var returnData = new VibrationInfo();
|
| | | var gateway = device.Gateway;
|
| | | if (gateway == null)
|
| | | //如果是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //错误:网关对象丢失
|
| | | this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg));
|
| | | return null;
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.GetPanelVibrationInfo(device.DeviceAddr, 200);
|
| | | }
|
| | | string checkTopic = HdlGatewayLogic.Current.GetGatewayId(gateway) + "/" + "ZbDataPassthrough";
|
| | | bool canBreak = false;
|
| | |
|
| | | Action<string, string> action = (topic, message) =>
|
| | | {
|
| | | if (topic == checkTopic)
|
| | | {
|
| | | try
|
| | | {
|
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
|
| | | string PassData = jobject["Data"]["PassData"].ToString();
|
| | | if (PassData.Length != 18)
|
| | | {
|
| | | return;
|
| | | }
|
| | | string mytopic = PassData[4].ToString() + PassData[5].ToString() + PassData[2].ToString() + PassData[3].ToString();
|
| | | if (mytopic != "0802")
|
| | | {
|
| | | return;
|
| | | }
|
| | | returnData.A震动使能 = PassData.Substring(10, 2) == "01" ? true : false;
|
| | | returnData.A震动强度 = Convert.ToInt32(PassData.Substring(12, 2), 16);
|
| | | returnData.A震动时间 = Convert.ToInt32(PassData.Substring(14, 4), 16);
|
| | |
|
| | | canBreak = true;
|
| | | }
|
| | | catch { }
|
| | | }
|
| | | };
|
| | | gateway.Actions += action;
|
| | | try
|
| | | {
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "PassData", "050108110101" } };
|
| | | jObject.Add("Data", data);
|
| | | gateway.Send(("ClientDataPassthrough"), jObject.ToString());
|
| | | }
|
| | | catch { }
|
| | |
|
| | | int TimeOut = 0;
|
| | | while (canBreak == false && TimeOut < 60)
|
| | | {
|
| | | System.Threading.Thread.Sleep(100);
|
| | | TimeOut++;
|
| | | }
|
| | | gateway.Actions -= action;
|
| | |
|
| | | if (TimeOut >= 60)
|
| | | //发送数据
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "PassData", "050108110101" } };
|
| | | jObject.Add("Data", data);
|
| | | var sendData = jObject.ToString();
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0802", 18, 6);
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | //获取震动反馈配置信息失败
|
| | | string errorMsg = Language.StringByID(R.MyInternationalizationString.uGetVibrationFeedbackSettionFail);
|
| | |
| | | this.ShowTipMsg(errorMsg);
|
| | | return null;
|
| | | }
|
| | | var returnData = new PanelVibrationInfo();
|
| | | returnData.A震动使能 = result.ReceiptData.Substring(10, 2) == "01" ? true : false;
|
| | | returnData.A震动强度 = Convert.ToInt32(result.ReceiptData.Substring(12, 2), 16);
|
| | | returnData.A震动时间 = Convert.ToInt32(result.ReceiptData.Substring(14, 4), 16);
|
| | |
|
| | | return returnData;
|
| | | }
|
| | |
|
| | |
| | | /// <param name="device">某一回路</param>
|
| | | /// <param name="datainfo">设置的信息</param>
|
| | | /// <returns></returns>
|
| | | public bool SetPanelVibrationData(CommonDevice device, VibrationInfo datainfo)
|
| | | public bool SetPanelVibrationData(CommonDevice device, PanelVibrationInfo datainfo)
|
| | | {
|
| | | var gateway = device.Gateway;
|
| | | if (gateway == null)
|
| | | //如果是虚拟住宅
|
| | | if (Common.Config.Instance.Home.IsVirtually == true)
|
| | | {
|
| | | //错误:网关对象丢失
|
| | | this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg));
|
| | | return false;
|
| | | return TemplateData.TemplateDeviceDataLogic.Current.SetPanelVibrationInfo(device.DeviceAddr, 200, datainfo, null);
|
| | | }
|
| | | string checkTopic = HdlGatewayLogic.Current.GetGatewayId(gateway) + "/" + "ZbDataPassthrough";
|
| | | bool canBreak = false;
|
| | |
|
| | | bool success = false;
|
| | | Action<string, string> action = (topic, message) =>
|
| | | {
|
| | | if (topic == checkTopic)
|
| | | {
|
| | | try
|
| | | {
|
| | | var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
|
| | | if (jobject["DeviceAddr"].ToString() != device.DeviceAddr)
|
| | | {
|
| | | //不是同一个东西
|
| | | return;
|
| | | }
|
| | | string PassData = jobject["Data"]["PassData"].ToString();
|
| | | if (PassData.Length != 16)
|
| | | {
|
| | | return;
|
| | | }
|
| | | string mytopic = PassData[4].ToString() + PassData[5].ToString() + PassData[2].ToString() + PassData[3].ToString();
|
| | | if (mytopic != "0002")
|
| | | {
|
| | | return;
|
| | | }
|
| | | int command = Convert.ToInt32(PassData[10].ToString() + PassData[11].ToString() + PassData[12].ToString() + PassData[13].ToString(), 16);
|
| | | int status = Convert.ToInt32(PassData[14].ToString() + PassData[15].ToString(), 16);
|
| | | if (status == 0)
|
| | | {
|
| | | //成功
|
| | | success = true;
|
| | | }
|
| | | canBreak = true;
|
| | | }
|
| | | catch { }
|
| | | }
|
| | | };
|
| | | gateway.Actions += action;
|
| | | try
|
| | | {
|
| | | string passData = "0800081104";
|
| | | passData += datainfo.A震动使能 ? "01" : "00";
|
| | | passData += Convert.ToString(datainfo.A震动强度, 16).PadLeft(2, '0');
|
| | | string time = Convert.ToString(datainfo.A震动时间, 16).PadLeft(4, '0');
|
| | | //低位在前,高位在后
|
| | | passData += time.Substring(2, 2);
|
| | | passData += time.Substring(0, 2);
|
| | |
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "PassData", passData } };
|
| | | jObject.Add("Data", data);
|
| | | gateway.Send(("ClientDataPassthrough"), jObject.ToString());
|
| | | }
|
| | | catch { }
|
| | |
|
| | | int TimeOut = 0;
|
| | | while (canBreak == false && TimeOut < 60)
|
| | | {
|
| | | System.Threading.Thread.Sleep(100);
|
| | | TimeOut++;
|
| | | }
|
| | | gateway.Actions -= action;
|
| | |
|
| | | if (success == false)
|
| | | //获取编辑面板震动功能的命令字符
|
| | | var sendData = this.GetPanelVibrationCommandText(device.DeviceAddr, datainfo);
|
| | | var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway2(device, sendData, "0002", 16, 6);
|
| | | if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
|
| | | {
|
| | | //设置震动反馈配置信息失败
|
| | | string errorMsg = Language.StringByID(R.MyInternationalizationString.uSetVibrationFeedbackSettionFail);
|
| | | if (TimeOut >= 60)
|
| | | {
|
| | | errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "回复超时", false);
|
| | | }
|
| | | errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "回复超时", false);
|
| | | this.ShowTipMsg(errorMsg);
|
| | | return false;
|
| | | }
|
| | | //添加缓存
|
| | | TemplateData.TemplateDeviceDataLogic.Current.SetPanelVibrationInfo(device.DeviceAddr, 200, datainfo, result.JsonData[0]);
|
| | |
|
| | | return success;
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取编辑面板震动功能的命令字符
|
| | | /// </summary>
|
| | | /// <param name="DeviceAddr"></param>
|
| | | /// <param name="datainfo"></param>
|
| | | /// <returns></returns>
|
| | | public string GetPanelVibrationCommandText(string DeviceAddr, PanelVibrationInfo datainfo)
|
| | | {
|
| | | string passData = "0800081104";
|
| | | passData += datainfo.A震动使能 ? "01" : "00";
|
| | | passData += Convert.ToString(datainfo.A震动强度, 16).PadLeft(2, '0');
|
| | | string time = Convert.ToString(datainfo.A震动时间, 16).PadLeft(4, '0');
|
| | | //低位在前,高位在后
|
| | | passData += time.Substring(2, 2);
|
| | | passData += time.Substring(0, 2);
|
| | |
|
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject { { "PassData", passData } };
|
| | | jObject.Add("Data", data);
|
| | | return jObject.ToString();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 简约面板震动功能信息
|
| | | /// </summary>
|
| | | public class VibrationInfo
|
| | | public class PanelVibrationInfo
|
| | | {
|
| | | /// <summary>
|
| | | /// 震动使能
|
| | |
| | | /// </summary>
|
| | | private void SaveDryContactFunctionToLocaltion()
|
| | | {
|
| | | var file = Newtonsoft.Json.JsonConvert.SerializeObject(dicDryContactFunction);
|
| | |
|
| | | var bytes = System.Text.Encoding.UTF8.GetBytes(file);
|
| | | Common.Global.WriteFileByBytesByHomeId(DirNameResourse.DryContactFunctionFile, bytes);
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DryContactFunctionFile, dicDryContactFunction);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | private void LoadDryContactFunctionFromLocaltion()
|
| | | {
|
| | | if (Common.Global.IsExistsByHomeId(DirNameResourse.DryContactFunctionFile) == false)
|
| | | this.dicDryContactFunction = new Dictionary<string, DryContactFunctionInfo>();
|
| | | byte[] filebyte = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.DryContactFunctionFile);
|
| | | if (filebyte == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | byte[] filebyte = Common.Global.ReadFileByHomeId(DirNameResourse.DryContactFunctionFile);
|
| | | string strvalue = System.Text.Encoding.UTF8.GetString(filebyte);
|
| | | this.dicDryContactFunction = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, DryContactFunctionInfo>>(strvalue);
|
| | | }
|