From 431fa50555fca6730b1100bb9a2d9eacbbf74d21 Mon Sep 17 00:00:00 2001
From: chenqiyang <1406175257@qq.com>
Date: 星期五, 26 八月 2022 13:04:05 +0800
Subject: [PATCH] 1.更改build版本 2.替换全视通dll包
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs | 2354 ++++++++++++++++++++++++++++++++++------------------------
1 files changed, 1,362 insertions(+), 992 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs
old mode 100755
new mode 100644
index 90a72cc..c8bc35a
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDevicePanelLogic.cs
@@ -1,522 +1,984 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Text;
-using ZigBee.Device;
-using System.Threading.Tasks;
-
-namespace Shared.Phone.UserCenter
-{
- /// <summary>
- /// 骞叉帴鐐圭殑閫昏緫
- /// </summary>
- public class HdlDevicePanelLogic
- {
- #region 鈻� 鍙橀噺澹版槑___________________________
-
- /// <summary>
- /// 骞叉帴鐐圭殑閫昏緫
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+using System.Threading.Tasks;
+using Newtonsoft.Json.Linq;
+
+namespace Shared.Phone.UserCenter
+{
+ /// <summary>
+ /// 骞叉帴鐐圭殑閫昏緫
+ /// </summary>
+ public class HdlDevicePanelLogic
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 骞叉帴鐐圭殑閫昏緫
/// </summary>
private static HdlDevicePanelLogic m_Current = null;
- /// <summary>
- /// 骞叉帴鐐圭殑閫昏緫
+ /// <summary>
+ /// 骞叉帴鐐圭殑閫昏緫
/// </summary>
- public static HdlDevicePanelLogic Current
- {
- get
- {
- if (m_Current == null)
- {
- m_Current = new HdlDevicePanelLogic();
- }
- return m_Current;
- }
- }
-
- /// <summary>
- /// 骞叉帴鐐圭殑绉佹湁灞炴�� keys:璁惧涓婚敭,value:鍚勭骇鍒殑鍊�
- /// </summary>
- private Dictionary<string, DryContactFunctionInfo> dicDryContactFunction = new Dictionary<string, DryContactFunctionInfo>();
-
- #endregion
-
- #region 鈻� 鍒濆鍖朹____________________________
-
- /// <summary>
- /// 鍒濆鍖�
- /// </summary>
- public HdlDevicePanelLogic()
- {
- //浠庢湰鍦版枃浠惰繕鍘熷共鎺ョ偣鐨勭鏈夊睘鎬�
- this.LoadDryContactFunctionFromLocaltion();
- }
-
- #endregion
-
- #region 鈻� 棰滆壊璋冭妭___________________________
-
- /// <summary>
- /// 鑾峰彇鎸夐敭闈㈡澘鎸囧畾绔偣鐨勩�愭寚绀虹伅寮�鍏抽鑹层�戠殑淇℃伅(鍑洪敊浼氳繑鍥瀗ull)
- /// </summary>
- /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param>
- /// <returns></returns>
- public async Task<Panel.KeyColorData> GetPanelEpointColorInfo(Panel panel)
- {
- Panel.KeyNum keyNum = (Panel.KeyNum)panel.DeviceEpoint;
- var result = await panel.GetPanelColorInfoAsync(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>
- /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param>
- /// <param name="colorData">寮�鍜屽叧鐨勯鑹查兘闇�瑕佷竴璧疯缃�</param>
- /// <returns></returns>
- public async Task<bool> SetPanelEpointColorInfo(Panel 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);
- 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;
- }
- //澶囦唤璁惧
- await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A骞叉帴鐐归鑹茶皟鑺�, colorData);
- return true;
- }
-
- #endregion
-
- #region 鈻� 浜害璋冭妭___________________________
- /// <summary>
- /// 鑾峰彇璁惧浜害閰嶇疆锛坲i鍙寒搴﹁皟鑺�,浣跨敤杩斿洖鍊肩殑panelDirectionsLevel锛�
- /// </summary>
- /// <param name="device">璁惧瀵硅薄</param>
- /// <returns></returns>
- public async Task<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)
- {
- this.ShowErrorMsg(error);
- return null;
- }
-
- if (result == null || string.IsNullOrEmpty(result.errorMessageBase) == false)
- {
- //鑾峰彇鎸夐敭闈㈡澘浜害璋冭妭淇℃伅澶辫触
- string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelLightRegulationInfoFail);
- this.ShowErrorMsg(msg);
- return null;
- }
- return result;
- }
-
- /// <summary>
- /// 璁剧疆璁惧浜害锛坲i鍙寒搴﹁皟鑺傦級
- /// </summary>
- /// <param name="panel">璁惧瀵硅薄</param>
- /// <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)
- {
- //鍊熺敤瀹冪殑鍑芥暟
- 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)
- {
- this.ShowTipMsg(error);
- return false;
- }
-
- if (result == null || result.responseData == null)
- {
- //璁剧疆浜害璋冭妭澶辫触
- string msg = Language.StringByID(R.MyInternationalizationString.uSetLightRegulationFail);
- //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
- msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-
- this.ShowTipMsg(msg);
- return false;
- }
-
- if (result.responseData.status != 0)
- {
- //璁剧疆浜害璋冭妭澶辫触
- string msg = Language.StringByID(R.MyInternationalizationString.uSetLightRegulationFail);
- this.ShowTipMsg(msg);
- return false;
- }
- //澶囦唤璁惧
- var backData = new Newtonsoft.Json.Linq.JObject
+ public static HdlDevicePanelLogic Current
+ {
+ get
{
- { "directionsLevel",directionsLevel },
- { "backlightLevel", backlightLevel }
- };
- //澶囦唤璁惧
- await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A骞叉帴鐐逛寒搴﹁皟鑺�, backData);
- return true;
- }
-
- #endregion
-
- #region 鈻� 鎺ヨ繎鎰熷簲___________________________
- /// <summary>
- /// 鑾峰彇鎺ヨ繎鎰熷簲閰嶇疆锛坲i鍙帴杩戞劅搴�,浣跨敤杩斿洖鍊肩殑panelProximitySensorInfo锛�
- /// </summary>
- /// <param name="device">璁惧瀵硅薄</param>
- /// <returns></returns>
- public async Task<Panel.PanelProximitySensorInfo> GetDeviceProximitySensorsSettion(CommonDevice device)
- {
- //鍊熺敤瀹冪殑鍑芥暟
- var panel = new Panel();
- panel.DeviceAddr = device.DeviceAddr;
- panel.DeviceEpoint = device.DeviceEpoint;
- panel.CurrentGateWayId = device.CurrentGateWayId;
-
- 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;
- }
-
-
- /// <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;
- }
-
- // 澶囦唤璁惧
- var backData = new Newtonsoft.Json.Linq.JObject
- {
- { "sensorEnable",sensorEnable }
- };
- //澶囦唤璁惧
- await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A闈㈡澘鎺ヨ繎鎰熷簲鍔熻兘, backData);
- return true;
- }
- #endregion
-
- #region 鈻� 鑺傝兘妯″紡___________________________
- /// <summary>
- /// 鑾峰彇璁惧鑺傝兘妯″紡鐨勯厤缃姸鎬�(ui鍙妭鑳芥ā寮�)
- /// </summary>
- /// <param name="device">璁惧瀵硅薄</param>
- /// <returns></returns>
- public async Task<Panel.PanelSaveEnergyModeInfo> GetDeviceEnergyConservationMode(CommonDevice device)
- {
- //鍊熺敤瀹冪殑鍑芥暟
- var panel = new Panel();
- panel.DeviceAddr = device.DeviceAddr;
- panel.DeviceEpoint = device.DeviceEpoint;
- panel.CurrentGateWayId = device.CurrentGateWayId;
-
- var result = await panel.GetPanelSaveEnergyModeAsync();
- panel = null;
-
- //鍏遍�氶敊璇娴�
- string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
- if (error != null)
- {
- this.ShowErrorMsg(error);
- return null;
- }
-
- if (result == null || result.panelSaveEnergyModeInfo == null)
- {
- //鑾峰彇鎸夐敭闈㈡澘鑺傝兘妯″紡淇℃伅澶辫触
- string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelEnergyConservationInfoFail);
- //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
- msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-
- this.ShowErrorMsg(msg);
- return null;
- }
- return result.panelSaveEnergyModeInfo;
- }
-
- /// <summary>
- /// 璁剧疆璁惧鐨勮妭鑳芥ā寮�(ui鍙妭鑳芥ā寮�)
- /// </summary>
- /// <param name="device">璁惧瀵硅薄</param>
- /// <param name="modeEnable">鑺傝兘妯″紡鏄惁鏈夋晥</param>
- /// <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)
- {
- //鍊熺敤瀹冪殑鍑芥暟
- 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)
- {
- this.ShowErrorMsg(error);
- return false;
- }
-
- if (result == null || result.responseData == null)
- {
- //鑺傝兘妯″紡閰嶇疆澶辫触
- string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail);
- //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
- msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-
- this.ShowTipMsg(msg);
- return false;
- }
-
- if (result.responseData.status != 0)
- {
- //鑺傝兘妯″紡閰嶇疆澶辫触
- string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail);
- this.ShowTipMsg(msg);
- return false;
- }
- //澶囦唤璁惧
- var backData = new Newtonsoft.Json.Linq.JObject
+ if (m_Current == null)
+ {
+ m_Current = new HdlDevicePanelLogic();
+ }
+ return m_Current;
+ }
+ }
+
+ /// <summary>
+ /// 骞叉帴鐐圭殑绉佹湁灞炴�� keys:璁惧涓婚敭,value:鍚勭骇鍒殑鍊�
+ /// </summary>
+ private Dictionary<string, DryContactFunctionInfo> dicDryContactFunction = new Dictionary<string, DryContactFunctionInfo>();
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// 鍒濆鍖�
+ /// </summary>
+ public HdlDevicePanelLogic()
+ {
+ //浠庢湰鍦版枃浠惰繕鍘熷共鎺ョ偣鐨勭鏈夊睘鎬�
+ this.LoadDryContactFunctionFromLocaltion();
+ }
+
+ #endregion
+
+ #region 鈻� 棰滆壊璋冭妭___________________________
+
+ /// <summary>
+ /// 鑾峰彇鎸夐敭闈㈡澘鎸囧畾绔偣鐨勩�愭寚绀虹伅寮�鍏抽鑹层�戠殑淇℃伅(鍑洪敊浼氳繑鍥瀗ull)
+ /// </summary>
+ /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param>
+ /// <returns></returns>
+ public Panel.KeyColorData GetPanelEpointColorInfo(CommonDevice panel)
+ {
+ Panel.KeyNum keyNum = (Panel.KeyNum)panel.DeviceEpoint;
+ var result = this.GetPanelColorInfoAsync(panel, keyNum);
+ //鍏遍�氶敊璇娴�
+ string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
+ if (error != null)
{
- { "modeEnable",modeEnable },
- { "modeTime", modeTime },
- { "level", level }
- };
- //澶囦唤璁惧
- await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A骞叉帴鐐硅妭鑳芥ā寮�, backData);
- return true;
- }
-
- #endregion
-
- #region 鈻� 鑾峰彇骞叉帴鐐归厤缃俊鎭痏________________
-
- /// <summary>
- /// 鑾峰彇骞叉帴鐐归厤缃俊鎭�
- /// </summary>
- /// <param name="panel">骞叉帴鐐瑰璞�</param>
- /// <returns></returns>
- public async Task<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;
-
- //鍏遍�氶敊璇娴�
- string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
- if (error != null)
- {
- this.ShowErrorMsg(error);
- return null;
- }
-
- if (result == null || result.deviceStatusReportData == null)
- {
- //鑾峰彇璁惧閰嶇疆淇℃伅澶辫触
- string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceConfigureInfoFail);
- //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
- msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-
- this.ShowErrorMsg(msg);
- return null;
- }
- //濡傛灉涓嶆槸6鐨勮瘽锛岃繖涓暟鎹槸涓嶅鐨�
- if (result.deviceStatusReportData.CluterID != 6)
- {
- return new List<CommonDevice.AttributeDataObj>();
- }
- return result.deviceStatusReportData.AttriBute;
- }
-
- #endregion
-
- #region 鈻� 鑾峰彇骞叉帴鐐瑰姛鑳界郴___________________
-
- /// <summary>
- /// <para>鑾峰彇骞叉帴鐐瑰姛鑳界郴(寮傚父鏃惰繑鍥瀗ull,鎴栬�呭畠娌℃湁鎸囧畾鍔熻兘,涔熶細杩斿洖null)</para>
- /// <para>绗竴绾у埆(鍙傛暟鍏ㄩ儴鐪佺暐鏃�):</para>
- /// <para> 1024:鐏被锝�256:鎸夐敭绫伙綔768:PIR绫�</para>
- /// <para>绗簩绾у埆:</para>
- /// <para> 1:鐗规畩鍔熻兘锝�100:Switch,寮�鍏筹紙鎸夐敭绫伙級</para>
- /// <para> 200:Dimmer,璋冨厜锛堟寜閿被锛夛綔300:Curtain,绐楀笜锛堟寜閿被锛�</para>
- /// <para> 0:EnergySavingMode,鑺傝兘妯″紡锛堢伅绫伙級锝�1:SleepMode,鐫$湢妯″紡锛堢伅绫伙級</para>
- /// <para> 100:WhiteBalance,鐧藉钩琛★紙鐏被锛夛綔101:RGBColor,RGB鎸囩ず鐏鑹诧紙鐏被锛�</para>
- /// <para> 102:RGBLevel,RGB鎸囩ず鐏寒搴︼紙鐏被锛�</para>
- /// <para>绗笁绾у埆:</para>
- /// <para>1:鍦烘櫙瑙﹀彂锝�65535:绂佹鍙戦�佸姛鑳�</para>
- /// <para>100:SwitchOpen,寮�鍏冲紑锛堟寜閿被锛夛綔101:SwitchClose,寮�鍏冲叧锛堟寜閿被锛�</para>
- /// <para>102:SwitchChange,寮�鍏冲垏鎹紙鎸夐敭绫伙級锝�200:DimmerStepUp,澧炲ぇ璋冨厜锛堟寜閿被锛�</para>
- /// <para>201:DimmerStepDown,闄嶄綆璋冨厜锛堟寜閿被锛夛綔202:DimmerStepChange,璋冨厜鍒囨崲锛堟寜閿被锛�</para>
- /// <para>300:CurtainOpen,绐楀笜寮�锛堟寜閿被锛夛綔301:CurtainClose,绐楀笜鍏筹紙鎸夐敭绫伙級</para>
- /// <para>302:CurtainStop,绐楀笜鍋滐綔303:CurtainUpStop,绐楀笜涓婂崌鍋�</para>
- /// <para>304:CurtainDownstop,绐楀笜涓嬮檷鍋�</para>
- /// </summary>
- /// <param name="panel">骞叉帴鐐瑰璞�</param>
- /// <param name="level1">璇峰弬鐓х涓�绾у埆鐨勫弬鏁帮紝鐪佺暐鏃惰繑鍥炵涓�绾у埆鍒楄〃锛岃缃椂杩斿洖绗簩绾у埆鍒楄〃</param>
- /// <param name="level2">璇峰弬鐓х浜岀骇鍒殑鍙傛暟锛岀渷鐣ユ椂杩斿洖绗簩绾у埆鍒楄〃锛岃缃椂杩斿洖绗笁绾у埆鍒楄〃</param>
- /// <param name="reLevel3">閲嶆柊鑾峰彇绗笁绾у埆鐨勬暟鎹�</param>
- /// <returns></returns>
- public async Task<List<int>> GetDryContactFunction(Panel panel, int level1 = -1, int level2 = -1, bool reLevel3 = false)
- {
- string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(panel);
- if (dicDryContactFunction.ContainsKey(mainkeys) == false)
- {
- //鍒涘缓瀵硅薄
- dicDryContactFunction[mainkeys] = new DryContactFunctionInfo();
- }
- var functionInfo = dicDryContactFunction[mainkeys];
-
- //鑾峰彇绗竴绾у埆(灞炴�у簲璇ヤ笉浼氭敼鍙�)
- Panel.PanelPrivateFunctionsResponseInfo result = null;
- if (functionInfo.listLevel1 == null)
- {
- result = await this.GetDryContactFunctionInterface(panel);
- if (result == null)
- {
- return null;
- }
- //淇濆瓨灞炴��
- this.SetDryContactFunctionToMemory(panel, result.privateFuncTypeLevelFirstList, -1, -1);
- if (level1 == -1)
- {
- return result.privateFuncTypeLevelFirstList;
- }
- }
-
- //鑾峰彇绗簩绾у埆(灞炴�у簲璇ヤ笉浼氭敼鍙�)
- if (functionInfo.dicLevel2.ContainsKey(level1) == false)
- {
- result = await this.GetDryContactFunctionInterface(panel, new int[] { level1 });
- if (result == null)
- {
- return null;
- }
- //淇濆瓨灞炴��
- this.SetDryContactFunctionToMemory(panel, result.privateFuncTypeLevelSecondList, level1, -1);
- if (level2 == -1)
- {
- return result.privateFuncTypeLevelSecondList;
- }
- }
-
- //鑾峰彇绗笁绾у埆(灞炴�ф湁鍙兘浼氭敼鍙�)
- if (reLevel3 == true || functionInfo.dicLevel3.ContainsKey(level2) == false)
- {
- result = await this.GetDryContactFunctionInterface(panel, new int[] { level1, level2 });
- if (result == null)
- {
- return null;
- }
- //淇濆瓨灞炴��
- this.SetDryContactFunctionToMemory(panel, result.privateFuncTypeLevelThirdList, level1, level2);
- }
- //浠庢湰鍦扮紦瀛樺綋涓幏鍙栧畠鐨勭鏈夊睘鎬�
- return this.GetDryContactFunctionFromLocation(panel, level1, level2);
- }
-
- /// <summary>
- /// 鑾峰彇鎸夐敭闈㈡澘鐨勫姛鑳�
- /// </summary>
- /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param>
- /// <param name="parameter">
+ 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>
+ /// 鑾峰彇闈㈡澘棰滆壊鐨勪俊鎭�(鍑洪敊浼氳繑鍥瀗ull)
+ /// </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 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 = 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>
+ /// <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 >
+ ///鑾峰彇璁惧浜害閰嶇疆锛坲i鍙寒搴﹁皟鑺�,浣跨敤杩斿洖鍊肩殑panelDirectionsLevel锛�
+ /// </summary>
+ public Panel.PanelSwitchLevelInfo GetDeviceLightSettion(CommonDevice device)
+ {
+ //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+ if (Common.Config.Instance.Home.IsVirtually == true)
+ {
+ 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();
+
+ 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;
+ }
+ 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>
+ /// 璁剧疆璁惧浜害锛坲i鍙寒搴﹁皟鑺傦級
+ /// </summary>
+ /// <param name="panel">璁惧瀵硅薄</param>
+ /// <param name="directionsLevel">0-100(杩欎釜鏄偣鍑诲悗鐨勫��)</param>
+ /// <param name="backlightLevel">0-100(杩欎釜鏄偣鍑诲墠鐨勫��)</param>
+ /// <returns></returns>
+ public bool SetDeviceLightSettion(CommonDevice device, int directionsLevel, int backlightLevel)
+ {
+ //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+ if (Common.Config.Instance.Home.IsVirtually == true)
+ {
+ 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.ErrorMsgDiv == 0)
+ {
+ //璁剧疆浜害璋冭妭澶辫触
+ string msg = Language.StringByID(R.MyInternationalizationString.uSetLightRegulationFail);
+ //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+ this.ShowTipMsg(msg);
+ return false;
+ }
+
+ //杩欓噷杩樻湁涓�涓� 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;
+ }
+
+ //淇敼缂撳瓨
+ 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 鈻� 鎺ヨ繎鎰熷簲___________________________
+ /// <summary>
+ /// 鑾峰彇鎺ヨ繎鎰熷簲閰嶇疆锛坲i鍙帴杩戞劅搴�,浣跨敤杩斿洖鍊肩殑panelProximitySensorInfo锛�
+ /// </summary>
+ /// <param name="device">璁惧瀵硅薄</param>
+ /// <returns></returns>
+ public async Task<Panel.PanelProximitySensorInfo> GetDeviceProximitySensorsSettion(CommonDevice device)
+ {
+ //鍊熺敤瀹冪殑鍑芥暟
+ var panel = new Panel();
+ panel.DeviceAddr = device.DeviceAddr;
+ panel.DeviceEpoint = device.DeviceEpoint;
+ panel.CurrentGateWayId = device.CurrentGateWayId;
+
+ 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;
+ }
+
+
+ /// <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)
+ {
+ //鍊熺敤瀹冪殑鍑絫
+ 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);
+ //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+ this.ShowErrorMsg(msg);
+ return null;
+ }
+
+ 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>
+ /// 璁剧疆璁惧鐨勮妭鑳芥ā寮�(ui鍙妭鑳芥ā寮�)
+ /// </summary>
+ /// <param name="device">璁惧瀵硅薄</param>
+ /// <param name="modeEnable">鑺傝兘妯″紡鏄惁鏈夋晥</param>
+ /// <param name="modeTime">鏃犳搷浣滆繘鍏ヨ妭鑳芥ā寮忔椂闂� 0-255</param>
+ /// <param name="level">鑺傝兘妯″紡浜害:0-100</param>
+ /// <returns></returns>
+ public bool SetDeviceEnergyConservationMode(CommonDevice device, bool modeEnable, int modeTime, int level)
+ {
+ //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+ if (Common.Config.Instance.Home.IsVirtually == true)
+ {
+ 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.ErrorMsgDiv == 0)
+ {
+ //鑺傝兘妯″紡閰嶇疆澶辫触
+ string msg = Language.StringByID(R.MyInternationalizationString.uSetEnergyConservationFail);
+ //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+ this.ShowTipMsg(msg);
+ return false;
+ }
+ 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;
+ }
+
+ //淇敼缂撳瓨
+ 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
+
+ #region 鈻� 鑾峰彇骞叉帴鐐归厤缃俊鎭痏________________
+
+ /// <summary>
+ /// 鑾峰彇骞叉帴鐐归厤缃俊鎭�
+ /// </summary>
+ /// <param name="panel">骞叉帴鐐瑰璞�</param>
+ /// <returns></returns>
+ public List<CommonDevice.AttributeDataObj> GetDryContactConfigureInfo(CommonDevice device)
+ {
+ var result = HdlDeviceBindLogic.Current.ReadPanelConfigureInfoAsync(device);
+
+ //鍏遍�氶敊璇娴�
+ string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
+ if (error != null)
+ {
+ this.ShowErrorMsg(error);
+ return null;
+ }
+
+ if (result == null || result.deviceStatusReportData == null)
+ {
+ //鑾峰彇璁惧閰嶇疆淇℃伅澶辫触
+ string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceConfigureInfoFail);
+ //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+ this.ShowErrorMsg(msg);
+ return null;
+ }
+ //濡傛灉涓嶆槸6鐨勮瘽锛岃繖涓暟鎹槸涓嶅鐨�
+ if (result.deviceStatusReportData.CluterID != 6)
+ {
+ return new List<CommonDevice.AttributeDataObj>();
+ }
+ return result.deviceStatusReportData.AttriBute;
+ }
+
+ #endregion
+
+ #region 鈻� 鑾峰彇骞叉帴鐐瑰姛鑳界郴___________________
+
+ /// <summary>
+ /// <para>鑾峰彇骞叉帴鐐瑰姛鑳界郴(寮傚父鏃惰繑鍥瀗ull,鎴栬�呭畠娌℃湁鎸囧畾鍔熻兘,涔熶細杩斿洖null)</para>
+ /// <para>绗竴绾у埆(鍙傛暟鍏ㄩ儴鐪佺暐鏃�):</para>
+ /// <para> 1024:鐏被锝�256:鎸夐敭绫伙綔768:PIR绫�</para>
+ /// <para>绗簩绾у埆:</para>
+ /// <para> 1:鐗规畩鍔熻兘锝�100:Switch,寮�鍏筹紙鎸夐敭绫伙級</para>
+ /// <para> 200:Dimmer,璋冨厜锛堟寜閿被锛夛綔300:Curtain,绐楀笜锛堟寜閿被锛�</para>
+ /// <para> 0:EnergySavingMode,鑺傝兘妯″紡锛堢伅绫伙級锝�1:SleepMode,鐫$湢妯″紡锛堢伅绫伙級</para>
+ /// <para> 100:WhiteBalance,鐧藉钩琛★紙鐏被锛夛綔101:RGBColor,RGB鎸囩ず鐏鑹诧紙鐏被锛�</para>
+ /// <para> 102:RGBLevel,RGB鎸囩ず鐏寒搴︼紙鐏被锛�</para>
+ /// <para>绗笁绾у埆:</para>
+ /// <para>1:鍦烘櫙瑙﹀彂锝�65535:绂佹鍙戦�佸姛鑳�</para>
+ /// <para>100:SwitchOpen,寮�鍏冲紑锛堟寜閿被锛夛綔101:SwitchClose,寮�鍏冲叧锛堟寜閿被锛�</para>
+ /// <para>102:SwitchChange,寮�鍏冲垏鎹紙鎸夐敭绫伙級锝�200:DimmerStepUp,澧炲ぇ璋冨厜锛堟寜閿被锛�</para>
+ /// <para>201:DimmerStepDown,闄嶄綆璋冨厜锛堟寜閿被锛夛綔202:DimmerStepChange,璋冨厜鍒囨崲锛堟寜閿被锛�</para>
+ /// <para>300:CurtainOpen,绐楀笜寮�锛堟寜閿被锛夛綔301:CurtainClose,绐楀笜鍏筹紙鎸夐敭绫伙級</para>
+ /// <para>302:CurtainStop,绐楀笜鍋滐綔303:CurtainUpStop,绐楀笜涓婂崌鍋�</para>
+ /// <para>304:CurtainDownstop,绐楀笜涓嬮檷鍋�</para>
+ /// </summary>
+ /// <param name="panel">骞叉帴鐐瑰璞�</param>
+ /// <param name="level1">璇峰弬鐓х涓�绾у埆鐨勫弬鏁帮紝鐪佺暐鏃惰繑鍥炵涓�绾у埆鍒楄〃锛岃缃椂杩斿洖绗簩绾у埆鍒楄〃</param>
+ /// <param name="level2">璇峰弬鐓х浜岀骇鍒殑鍙傛暟锛岀渷鐣ユ椂杩斿洖绗簩绾у埆鍒楄〃锛岃缃椂杩斿洖绗笁绾у埆鍒楄〃</param>
+ /// <param name="reLevel3">閲嶆柊鑾峰彇绗笁绾у埆鐨勬暟鎹�</param>
+ /// <returns></returns>
+ public async Task<List<int>> GetDryContactFunction(Panel panel, int level1 = -1, int level2 = -1, bool reLevel3 = false)
+ {
+ string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(panel);
+ if (dicDryContactFunction.ContainsKey(mainkeys) == false)
+ {
+ //鍒涘缓瀵硅薄
+ dicDryContactFunction[mainkeys] = new DryContactFunctionInfo();
+ }
+ var functionInfo = dicDryContactFunction[mainkeys];
+
+ //鑾峰彇绗竴绾у埆(灞炴�у簲璇ヤ笉浼氭敼鍙�)
+ Panel.PanelPrivateFunctionsResponseInfo result = null;
+ if (functionInfo.listLevel1 == null)
+ {
+ result = await this.GetDryContactFunctionInterface(panel);
+ if (result == null)
+ {
+ return null;
+ }
+ //淇濆瓨灞炴��
+ this.SetDryContactFunctionToMemory(panel, result.privateFuncTypeLevelFirstList, -1, -1);
+ if (level1 == -1)
+ {
+ return result.privateFuncTypeLevelFirstList;
+ }
+ }
+
+ //鑾峰彇绗簩绾у埆(灞炴�у簲璇ヤ笉浼氭敼鍙�)
+ if (functionInfo.dicLevel2.ContainsKey(level1) == false)
+ {
+ result = await this.GetDryContactFunctionInterface(panel, new int[] { level1 });
+ if (result == null)
+ {
+ return null;
+ }
+ //淇濆瓨灞炴��
+ this.SetDryContactFunctionToMemory(panel, result.privateFuncTypeLevelSecondList, level1, -1);
+ if (level2 == -1)
+ {
+ return result.privateFuncTypeLevelSecondList;
+ }
+ }
+
+ //鑾峰彇绗笁绾у埆(灞炴�ф湁鍙兘浼氭敼鍙�)
+ if (reLevel3 == true || functionInfo.dicLevel3.ContainsKey(level2) == false)
+ {
+ result = await this.GetDryContactFunctionInterface(panel, new int[] { level1, level2 });
+ if (result == null)
+ {
+ return null;
+ }
+ //淇濆瓨灞炴��
+ this.SetDryContactFunctionToMemory(panel, result.privateFuncTypeLevelThirdList, level1, level2);
+ }
+ //浠庢湰鍦扮紦瀛樺綋涓幏鍙栧畠鐨勭鏈夊睘鎬�
+ return this.GetDryContactFunctionFromLocation(panel, level1, level2);
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎸夐敭闈㈡澘鐨勫姛鑳�
+ /// </summary>
+ /// <param name="panel">鎸夐敭闈㈡澘鐨勬煇涓�涓洖璺�</param>
+ /// <param name="parameter">
/// <para>鏂规硶1锛氬綋int[]浼犵┖锛岃繑鍥炲�兼槸鈥滈潰鏉垮叿鏈夌殑鍔熻兘澶х被,鍗宠繑鍥炩�滅涓�绾у埆銆�1024:鐏被锛�256:鎸夐敭绫伙紝768:PIR绫�</para>
/// <para>鏂规硶2锛氥�佸綋int[]鍊间负绗竴绾у埆PrivateFuncTypeFir涓�夋嫨涓�涓��</para>
/// <para>杩斿洖鍊兼槸鈥滈潰鎸夐敭鍙戦�佸姛鑳界被鈥濓紝鍗宠繑鍥炩�滅浜岀骇鍒��</para>
@@ -526,481 +988,389 @@
/// <para>杩斿洖鍊兼槸鈥滈潰鎸夐敭鍏蜂綋鍔熻兘閰嶇疆鈥濓紝鍗宠繑鍥炩�滅浜岀骇鍒��</para>
/// <para>100:SwitchOpen,寮�鍏冲紑锛堟寜閿被锛�;101:SwitchClose,寮�鍏冲叧锛堟寜閿被锛�;102:SwitchChange,寮�鍏冲垏鎹紙鎸夐敭绫伙級</para>
/// <para>200:DimmerStepUp,澧炲ぇ璋冨厜锛堟寜閿被锛�;201:DimmerStepDown,闄嶄綆璋冨厜锛堟寜閿被锛�;202:DimmerStepChange,璋冨厜鍒囨崲锛堟寜閿被锛�</para>
- /// <para>300:CurtainOpen,绐楀笜寮�锛堟寜閿被锛�;301:CurtainClose,绐楀笜鍏筹紙鎸夐敭绫伙級;302:CurtainStop,绐楀笜鍋�;303:CurtainUpStop,绐楀笜涓婂崌鍋�;304:CurtainDownstop,绐楀笜涓嬮檷鍋�</para>
- /// </param>
- /// <returns></returns>
- private async Task<Panel.PanelPrivateFunctionsResponseInfo> GetDryContactFunctionInterface(Panel panel, params int[] parameter)
- {
- var result = await panel.GetPanelPrivateFunctionsAsync(parameter);
- //鍏遍�氶敊璇娴�
- string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
- if (error != null)
- {
- this.ShowErrorMsg(error);
- return null;
- }
-
- if (result == null || result.panelPrivateFunctionsResponseInfo == null)
- {
- //鑾峰彇鎸夐敭鍔熻兘绫讳俊鎭け璐�
- string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelFunctionInfoFail);
- //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
- msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-
- this.ShowErrorMsg(msg);
- return null;
- }
-
- return result.panelPrivateFunctionsResponseInfo;
- }
-
-
- #endregion
-
- #region 鈻� 淇敼骞叉帴鐐圭鏈夊睘鎬________________
-
- /// <summary>
- /// 淇敼骞叉帴鐐圭涓夌骇鍒殑绉佹湁灞炴��
- /// </summary>
- /// <param name="panel">骞叉帴鐐瑰璞�</param>
- /// <param name="i_value">骞叉帴鐐圭殑绗笁绾у埆灞炴�х殑鍊�,鍏蜂綋璇峰弬鐓х涓夌骇鍒睘鎬�</param>
- /// <returns></returns>
- public async Task<bool> EditorDryContactThirdFunction(Panel panel, int i_value)
- {
- var result = await panel.ConfigureHdlKeyValueAsync((Panel.KeyMode)i_value);
- //鍏遍�氶敊璇娴�
- string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
- if (error != null)
- {
- this.ShowErrorMsg(error);
- return false;
- }
-
- if (result == null || result.setWritableValueResponData == null)
- {
- //璁惧灞炴�у彉鏇村け璐�
- string msg = Language.StringByID(R.MyInternationalizationString.uDeviceAttributeChangedFail);
- //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
- msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-
- this.ShowErrorMsg(msg);
- return false;
- }
- if (result.setWritableValueResponData.Status == 134)
- {
- //璁惧涓嶆敮鎸佹灞炴��(XXX)
- string msg = Language.StringByID(R.MyInternationalizationString.uDeviceNotSupportTheAttribute);
- msg += "(" + i_value + ")";
- this.ShowErrorMsg(msg);
- return false;
- }
- if (result.setWritableValueResponData.Status == 135)
- {
- //鏃犳晥鐨勮澶囧睘鎬у��(XXX)
- string msg = Language.StringByID(R.MyInternationalizationString.uDeviceAttributeIsIneffectiveness);
- msg += "(" + i_value + ")";
- this.ShowErrorMsg(msg);
- return false;
- }
- if (result.setWritableValueResponData.Status == 141)
- {
- //鏃犳晥鐨勬暟鎹被鍨�(XXX)
- string msg = Language.StringByID(R.MyInternationalizationString.uDataTypeIsIneffectiveness);
- msg += "(" + i_value + ")";
- this.ShowErrorMsg(msg);
- return false;
- }
- if (result.setWritableValueResponData.Status != 0)
- {
- //璁惧灞炴�у彉鏇村け璐�
- string msg = Language.StringByID(R.MyInternationalizationString.uDeviceAttributeChangedFail);
- this.ShowErrorMsg(msg);
- return false;
- }
- //澶囦唤璁惧
- await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(panel, GatewayBackupEnum.A骞叉帴鐐圭涓夌骇鍒鏈夊睘鎬�, i_value);
-
- return true;
- }
-
- #endregion
-
- #region 鈻� 绠�绾﹂潰鏉块渿鍔ㄥ姛鑳絖__________________
-
- /// <summary>
- /// 鑾峰彇绠�绾﹂潰鏉块渿鍔ㄥ姛鑳界殑淇℃伅(null琛ㄧず鍑洪敊)
- /// </summary>
- /// <param name="device">鏌愪竴鍥炶矾</param>
- /// <returns></returns>
- public VibrationInfo GetPanelVibrationData(CommonDevice device)
- {
- var returnData = new VibrationInfo();
- var gateway = device.Gateway;
- if (gateway == null)
- {
- //閿欒:缃戝叧瀵硅薄涓㈠け
- this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg));
- return null;
- }
- 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)
- {
- //鑾峰彇闇囧姩鍙嶉閰嶇疆淇℃伅澶辫触
- string errorMsg = Language.StringByID(R.MyInternationalizationString.uGetVibrationFeedbackSettionFail);
- errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "鍥炲瓒呮椂", false);
- this.ShowTipMsg(errorMsg);
- return null;
- }
- return returnData;
- }
-
- /// <summary>
- /// 璁剧疆绠�绾﹂潰鏉块渿鍔ㄥ姛鑳界殑淇℃伅
- /// </summary>
- /// <param name="device">鏌愪竴鍥炶矾</param>
- /// <param name="datainfo">璁剧疆鐨勪俊鎭�</param>
- /// <returns></returns>
- public bool SetPanelVibrationData(CommonDevice device, VibrationInfo datainfo)
- {
- var gateway = device.Gateway;
- if (gateway == null)
- {
- //閿欒:缃戝叧瀵硅薄涓㈠け
- this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg));
- return false;
- }
- 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)
- {
- //璁剧疆闇囧姩鍙嶉閰嶇疆淇℃伅澶辫触
- string errorMsg = Language.StringByID(R.MyInternationalizationString.uSetVibrationFeedbackSettionFail);
- if (TimeOut >= 60)
- {
- errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "鍥炲瓒呮椂", false);
- }
- this.ShowTipMsg(errorMsg);
- return false;
- }
- //澶囦唤璁惧
- HdlThreadLogic.Current.RunThread(async () =>
- {
- await HdlGatewayLogic.Current.UpLoadDeviceBackupDataToGateway(device, GatewayBackupEnum.A绠�绾﹂潰鏉块渿鍔ㄥ姛鑳�, datainfo);
- }, ShowErrorMode.NO);
-
- return success;
- }
-
- /// <summary>
- /// 绠�绾﹂潰鏉块渿鍔ㄥ姛鑳戒俊鎭�
- /// </summary>
- public class VibrationInfo
- {
- /// <summary>
- /// 闇囧姩浣胯兘
- /// </summary>
- public bool A闇囧姩浣胯兘 = false;
- /// <summary>
- /// 闇囧姩寮哄害(鍗佽繘鍒�)
- /// </summary>
- public int A闇囧姩寮哄害 = 0;
- /// <summary>
- /// 闇囧姩鏃堕棿(鍗佽繘鍒�)
- /// </summary>
- public int A闇囧姩鏃堕棿 = 0;
- }
-
- #endregion
-
- #region 鈻� 缂撳瓨涓殑璁惧绉佹湁灞炴�______________
-
- /// <summary>
- /// 浠庣紦瀛樹腑鑾峰彇璁惧鐨勭鏈夊睘鎬�
- /// </summary>
- /// <param name="panel"></param>
- /// <param name="level1"></param>
- /// <param name="level2"></param>
- /// <returns></returns>
- private List<int> GetDryContactFunctionFromLocation(Panel panel, int level1 = -1, int level2 = -1)
- {
- string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(panel);
- if (dicDryContactFunction.ContainsKey(mainkeys) == false)
- {
- return null;
- }
- var listLevel = new List<int>();
- var functionInfo = dicDryContactFunction[mainkeys];
-
- //绗竴绾у埆
- if (level1 == -1)
- {
- if (functionInfo.listLevel1 == null)
- {
- //绗竴绾у埆浠庢潵閮芥病鏈夎幏鍙栬繃
- return null;
- }
- listLevel.AddRange(functionInfo.listLevel1);
- }
- //绗簩绾у埆
- else if (level2 == -1)
- {
- if (functionInfo.dicLevel2.ContainsKey(level1) == false)
- {
- //绗簩绾у埆浠庢潵閮芥病鏈夎幏鍙栬繃
- return null;
- }
- listLevel.AddRange(functionInfo.dicLevel2[level1]);
- }
- //绗笁绾у埆
- else
- {
- if (functionInfo.dicLevel3.ContainsKey(level2) == false)
- {
- //绗笁绾у埆浠庢潵閮芥病鏈夎幏鍙栬繃
- return null;
- }
- listLevel.AddRange(functionInfo.dicLevel3[level2]);
- }
- return listLevel;
- }
-
- /// <summary>
- /// 灏嗚澶囩殑绉佹湁灞炴�у瓨鍏ョ紦瀛樹腑
- /// </summary>
- /// <param name="panel"></param>
- /// <param name="listLevel"></param>
- /// <param name="level1"></param>
- /// <param name="level2"></param>
- private void SetDryContactFunctionToMemory(Panel panel, List<int> listLevel, int level1, int level2)
- {
- string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(panel);
- if (dicDryContactFunction.ContainsKey(mainkeys) == false)
- {
- //鍒涘缓瀵硅薄
- dicDryContactFunction[mainkeys] = new DryContactFunctionInfo();
- }
- var functionInfo = dicDryContactFunction[mainkeys];
-
- //绗竴绾у埆
- if (level1 == -1)
- {
- //杩欎釜灞炴�у簲璇ユ槸涓嶄細鍙樼殑
- functionInfo.listLevel1 = new List<int>();
- functionInfo.listLevel1.AddRange(listLevel);
- }
- //绗簩绾у埆
- else if (level2 == -1)
- {
- if (functionInfo.dicLevel2.ContainsKey(level1) == false)
- {
- functionInfo.dicLevel2[level1] = new List<int>();
- }
- functionInfo.dicLevel2[level1].Clear();
- functionInfo.dicLevel2[level1].AddRange(listLevel);
- }
- //绗笁绾у埆
- else
- {
- if (functionInfo.dicLevel3.ContainsKey(level2) == false)
- {
- //鍒濆鍖栧鍣�
- functionInfo.dicLevel3[level2] = new List<int>();
- }
- //绗笁绾у埆鐨勫睘鎬ф湁鍙兘浼氬彉鏇�
- functionInfo.dicLevel3[level2].Clear();
- functionInfo.dicLevel3[level2].AddRange(listLevel);
- }
- //淇濆瓨鐜伴樁娈电殑骞叉帴鐐圭殑绉佹湁灞炴�у埌鏈湴鏂囦欢
- this.SaveDryContactFunctionToLocaltion();
- }
-
- /// <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);
- }
-
- /// <summary>
- /// 浠庢湰鍦版枃浠惰繕鍘熷共鎺ョ偣鐨勭鏈夊睘鎬�
- /// </summary>
- private void LoadDryContactFunctionFromLocaltion()
- {
- if (Common.Global.IsExistsByHomeId(DirNameResourse.DryContactFunctionFile) == false)
- {
- 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);
- }
-
- #endregion
-
- #region 鈻� 涓�鑸柟娉昣__________________________
-
- /// <summary>
- /// 鏄剧ず閿欒淇℃伅绐楀彛
- /// </summary>
- /// <param name="msg"></param>
- private void ShowErrorMsg(string msg)
- {
- Application.RunOnMainThread(() =>
- {
- var contr = new ShowMsgControl(ShowMsgType.Error, msg);
- contr.Show();
- });
- }
-
- /// <summary>
- /// 鏄剧ずTip淇℃伅绐楀彛
- /// </summary>
- /// <param name="msg"></param>
- private void ShowTipMsg(string msg)
- {
- Application.RunOnMainThread(() =>
- {
- var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
- contr.Show();
- });
- }
-
- #endregion
-
- #region 鈻� 缁撴瀯浣揰____________________________
-
- /// <summary>
- /// 骞叉帴鐐瑰姛鑳戒俊鎭�
- /// </summary>
- private class DryContactFunctionInfo
- {
- /// <summary>
- /// 绗竴绾у埆(娉ㄦ剰,杩欎釜涓滆タ鍜屻�恉icLevel2,dicLevel3銆戜笉鍚屾,鍥犱负瀹冮伒浠庝簬鑾峰彇鍚庢墠淇濆瓨鐨勫師鍒�)
- /// </summary>
- public List<int> listLevel1 = null;
- /// <summary>
- /// 绗簩绾у埆(涓婚敭涓虹涓�绾у埆銆傛敞鎰�,杩欎釜涓滆タ鍜屻�恖istLevel1,dicLevel3銆戜笉鍚屾,鍥犱负瀹冮伒浠庝簬鑾峰彇鍚庢墠淇濆瓨鐨勫師鍒�)
- /// </summary>
- public Dictionary<int, List<int>> dicLevel2 = new Dictionary<int, List<int>>();
- /// <summary>
- /// 绗笁绾у埆(涓婚敭涓虹浜岀骇鍒�傛敞鎰�,杩欎釜涓滆タ鍜屻�恖istLevel1,dicLevel2銆戜笉鍚屾,鍥犱负瀹冮伒浠庝簬鑾峰彇鍚庢墠淇濆瓨鐨勫師鍒�)
- /// </summary>
- public Dictionary<int, List<int>> dicLevel3 = new Dictionary<int, List<int>>();
- }
-
- #endregion
- }
-}
+ /// <para>300:CurtainOpen,绐楀笜寮�锛堟寜閿被锛�;301:CurtainClose,绐楀笜鍏筹紙鎸夐敭绫伙級;302:CurtainStop,绐楀笜鍋�;303:CurtainUpStop,绐楀笜涓婂崌鍋�;304:CurtainDownstop,绐楀笜涓嬮檷鍋�</para>
+ /// </param>
+ /// <returns></returns>
+ private async Task<Panel.PanelPrivateFunctionsResponseInfo> GetDryContactFunctionInterface(Panel panel, params int[] parameter)
+ {
+ var result = await panel.GetPanelPrivateFunctionsAsync(parameter);
+ //鍏遍�氶敊璇娴�
+ string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
+ if (error != null)
+ {
+ this.ShowErrorMsg(error);
+ return null;
+ }
+
+ if (result == null || result.panelPrivateFunctionsResponseInfo == null)
+ {
+ //鑾峰彇鎸夐敭鍔熻兘绫讳俊鎭け璐�
+ string msg = Language.StringByID(R.MyInternationalizationString.uGetPanelFunctionInfoFail);
+ //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+ this.ShowErrorMsg(msg);
+ return null;
+ }
+
+ return result.panelPrivateFunctionsResponseInfo;
+ }
+
+
+ #endregion
+
+ #region 鈻� 淇敼骞叉帴鐐圭鏈夊睘鎬________________
+
+ /// <summary>
+ /// 淇敼骞叉帴鐐圭涓夌骇鍒殑绉佹湁灞炴��
+ /// </summary>
+ /// <param name="panel">骞叉帴鐐瑰璞�</param>
+ /// <param name="i_value">骞叉帴鐐圭殑绗笁绾у埆灞炴�х殑鍊�,鍏蜂綋璇峰弬鐓х涓夌骇鍒睘鎬�</param>
+ /// <returns></returns>
+ public bool EditorDryContactThirdFunction(Panel panel, int i_value)
+ {
+ var result = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(panel, (Panel.KeyMode)i_value);
+ //鍏遍�氶敊璇娴�
+ string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
+ if (error != null)
+ {
+ this.ShowErrorMsg(error);
+ return false;
+ }
+
+ if (result == null || result.setWritableValueResponData == null)
+ {
+ //璁惧灞炴�у彉鏇村け璐�
+ string msg = Language.StringByID(R.MyInternationalizationString.uDeviceAttributeChangedFail);
+ //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+ this.ShowErrorMsg(msg);
+ return false;
+ }
+ if (result.setWritableValueResponData.Status == 134)
+ {
+ //璁惧涓嶆敮鎸佹灞炴��(XXX)
+ string msg = Language.StringByID(R.MyInternationalizationString.uDeviceNotSupportTheAttribute);
+ msg += "(" + i_value + ")";
+ this.ShowErrorMsg(msg);
+ return false;
+ }
+ if (result.setWritableValueResponData.Status == 135)
+ {
+ //鏃犳晥鐨勮澶囧睘鎬у��(XXX)
+ string msg = Language.StringByID(R.MyInternationalizationString.uDeviceAttributeIsIneffectiveness);
+ msg += "(" + i_value + ")";
+ this.ShowErrorMsg(msg);
+ return false;
+ }
+ if (result.setWritableValueResponData.Status == 141)
+ {
+ //鏃犳晥鐨勬暟鎹被鍨�(XXX)
+ string msg = Language.StringByID(R.MyInternationalizationString.uDataTypeIsIneffectiveness);
+ msg += "(" + i_value + ")";
+ this.ShowErrorMsg(msg);
+ return false;
+ }
+ if (result.setWritableValueResponData.Status != 0)
+ {
+ //璁惧灞炴�у彉鏇村け璐�
+ string msg = Language.StringByID(R.MyInternationalizationString.uDeviceAttributeChangedFail);
+ this.ShowErrorMsg(msg);
+ return false;
+ }
+ return true;
+ }
+
+ #endregion
+
+ #region 鈻� 绠�绾﹂潰鏉块渿鍔ㄥ姛鑳絖__________________
+
+ /// <summary>
+ /// 鑾峰彇绠�绾﹂潰鏉块渿鍔ㄥ姛鑳界殑淇℃伅(null琛ㄧず鍑洪敊)
+ /// </summary>
+ /// <param name="device">鏌愪竴鍥炶矾</param>
+ /// <returns></returns>
+ public PanelVibrationInfo GetPanelVibrationData(CommonDevice device)
+ {
+ //濡傛灉鏄櫄鎷熶綇瀹�
+ if (Common.Config.Instance.Home.IsVirtually == true)
+ {
+ return TemplateData.TemplateDeviceDataLogic.Current.GetPanelVibrationInfo(device.DeviceAddr, 200);
+ }
+ //鍙戦�佹暟鎹�
+ 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);
+ errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "鍥炲瓒呮椂", false);
+ 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;
+ }
+
+ /// <summary>
+ /// 璁剧疆绠�绾﹂潰鏉块渿鍔ㄥ姛鑳界殑淇℃伅
+ /// </summary>
+ /// <param name="device">鏌愪竴鍥炶矾</param>
+ /// <param name="datainfo">璁剧疆鐨勪俊鎭�</param>
+ /// <returns></returns>
+ public bool SetPanelVibrationData(CommonDevice device, PanelVibrationInfo datainfo)
+ {
+ //濡傛灉鏄櫄鎷熶綇瀹�
+ if (Common.Config.Instance.Home.IsVirtually == true)
+ {
+ return TemplateData.TemplateDeviceDataLogic.Current.SetPanelVibrationInfo(device.DeviceAddr, 200, datainfo, null);
+ }
+ //鑾峰彇缂栬緫闈㈡澘闇囧姩鍔熻兘鐨勫懡浠ゅ瓧绗�
+ 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);
+ errorMsg = UserCenterLogic.CombineGatewayTimeOutMsg(errorMsg, null, "鍥炲瓒呮椂", false);
+ this.ShowTipMsg(errorMsg);
+ return false;
+ }
+ //娣诲姞缂撳瓨
+ TemplateData.TemplateDeviceDataLogic.Current.SetPanelVibrationInfo(device.DeviceAddr, 200, datainfo, result.JsonData[0]);
+
+ 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 PanelVibrationInfo
+ {
+ /// <summary>
+ /// 闇囧姩浣胯兘
+ /// </summary>
+ public bool A闇囧姩浣胯兘 = false;
+ /// <summary>
+ /// 闇囧姩寮哄害(鍗佽繘鍒�)
+ /// </summary>
+ public int A闇囧姩寮哄害 = 0;
+ /// <summary>
+ /// 闇囧姩鏃堕棿(鍗佽繘鍒�)
+ /// </summary>
+ public int A闇囧姩鏃堕棿 = 0;
+ }
+
+ #endregion
+
+ #region 鈻� 缂撳瓨涓殑璁惧绉佹湁灞炴�______________
+
+ /// <summary>
+ /// 浠庣紦瀛樹腑鑾峰彇璁惧鐨勭鏈夊睘鎬�
+ /// </summary>
+ /// <param name="panel"></param>
+ /// <param name="level1"></param>
+ /// <param name="level2"></param>
+ /// <returns></returns>
+ private List<int> GetDryContactFunctionFromLocation(Panel panel, int level1 = -1, int level2 = -1)
+ {
+ string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(panel);
+ if (dicDryContactFunction.ContainsKey(mainkeys) == false)
+ {
+ return null;
+ }
+ var listLevel = new List<int>();
+ var functionInfo = dicDryContactFunction[mainkeys];
+
+ //绗竴绾у埆
+ if (level1 == -1)
+ {
+ if (functionInfo.listLevel1 == null)
+ {
+ //绗竴绾у埆浠庢潵閮芥病鏈夎幏鍙栬繃
+ return null;
+ }
+ listLevel.AddRange(functionInfo.listLevel1);
+ }
+ //绗簩绾у埆
+ else if (level2 == -1)
+ {
+ if (functionInfo.dicLevel2.ContainsKey(level1) == false)
+ {
+ //绗簩绾у埆浠庢潵閮芥病鏈夎幏鍙栬繃
+ return null;
+ }
+ listLevel.AddRange(functionInfo.dicLevel2[level1]);
+ }
+ //绗笁绾у埆
+ else
+ {
+ if (functionInfo.dicLevel3.ContainsKey(level2) == false)
+ {
+ //绗笁绾у埆浠庢潵閮芥病鏈夎幏鍙栬繃
+ return null;
+ }
+ listLevel.AddRange(functionInfo.dicLevel3[level2]);
+ }
+ return listLevel;
+ }
+
+ /// <summary>
+ /// 灏嗚澶囩殑绉佹湁灞炴�у瓨鍏ョ紦瀛樹腑
+ /// </summary>
+ /// <param name="panel"></param>
+ /// <param name="listLevel"></param>
+ /// <param name="level1"></param>
+ /// <param name="level2"></param>
+ private void SetDryContactFunctionToMemory(Panel panel, List<int> listLevel, int level1, int level2)
+ {
+ string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(panel);
+ if (dicDryContactFunction.ContainsKey(mainkeys) == false)
+ {
+ //鍒涘缓瀵硅薄
+ dicDryContactFunction[mainkeys] = new DryContactFunctionInfo();
+ }
+ var functionInfo = dicDryContactFunction[mainkeys];
+
+ //绗竴绾у埆
+ if (level1 == -1)
+ {
+ //杩欎釜灞炴�у簲璇ユ槸涓嶄細鍙樼殑
+ functionInfo.listLevel1 = new List<int>();
+ functionInfo.listLevel1.AddRange(listLevel);
+ }
+ //绗簩绾у埆
+ else if (level2 == -1)
+ {
+ if (functionInfo.dicLevel2.ContainsKey(level1) == false)
+ {
+ functionInfo.dicLevel2[level1] = new List<int>();
+ }
+ functionInfo.dicLevel2[level1].Clear();
+ functionInfo.dicLevel2[level1].AddRange(listLevel);
+ }
+ //绗笁绾у埆
+ else
+ {
+ if (functionInfo.dicLevel3.ContainsKey(level2) == false)
+ {
+ //鍒濆鍖栧鍣�
+ functionInfo.dicLevel3[level2] = new List<int>();
+ }
+ //绗笁绾у埆鐨勫睘鎬ф湁鍙兘浼氬彉鏇�
+ functionInfo.dicLevel3[level2].Clear();
+ functionInfo.dicLevel3[level2].AddRange(listLevel);
+ }
+ //淇濆瓨鐜伴樁娈电殑骞叉帴鐐圭殑绉佹湁灞炴�у埌鏈湴鏂囦欢
+ this.SaveDryContactFunctionToLocaltion();
+ }
+
+ /// <summary>
+ /// 淇濆瓨鐜伴樁娈电殑骞叉帴鐐圭殑绉佹湁灞炴�у埌鏈湴鏂囦欢
+ /// </summary>
+ private void SaveDryContactFunctionToLocaltion()
+ {
+ HdlFileLogic.Current.SaveFileContent(DirNameResourse.DryContactFunctionFile, dicDryContactFunction);
+ }
+
+ /// <summary>
+ /// 浠庢湰鍦版枃浠惰繕鍘熷共鎺ョ偣鐨勭鏈夊睘鎬�
+ /// </summary>
+ private void LoadDryContactFunctionFromLocaltion()
+ {
+ this.dicDryContactFunction = new Dictionary<string, DryContactFunctionInfo>();
+ byte[] filebyte = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.DryContactFunctionFile);
+ if (filebyte == null)
+ {
+ return;
+ }
+ string strvalue = System.Text.Encoding.UTF8.GetString(filebyte);
+ this.dicDryContactFunction = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, DryContactFunctionInfo>>(strvalue);
+ }
+
+ #endregion
+
+ #region 鈻� 涓�鑸柟娉昣__________________________
+
+ /// <summary>
+ /// 鏄剧ず閿欒淇℃伅绐楀彛
+ /// </summary>
+ /// <param name="msg"></param>
+ private void ShowErrorMsg(string msg)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ var contr = new ShowMsgControl(ShowMsgType.Error, msg);
+ contr.Show();
+ });
+ }
+
+ /// <summary>
+ /// 鏄剧ずTip淇℃伅绐楀彛
+ /// </summary>
+ /// <param name="msg"></param>
+ private void ShowTipMsg(string msg)
+ {
+ Application.RunOnMainThread(() =>
+ {
+ var contr = new ShowMsgControl(ShowMsgType.Tip, msg);
+ contr.Show();
+ });
+ }
+
+ #endregion
+
+ #region 鈻� 缁撴瀯浣揰____________________________
+
+ /// <summary>
+ /// 骞叉帴鐐瑰姛鑳戒俊鎭�
+ /// </summary>
+ private class DryContactFunctionInfo
+ {
+ /// <summary>
+ /// 绗竴绾у埆(娉ㄦ剰,杩欎釜涓滆タ鍜屻�恉icLevel2,dicLevel3銆戜笉鍚屾,鍥犱负瀹冮伒浠庝簬鑾峰彇鍚庢墠淇濆瓨鐨勫師鍒�)
+ /// </summary>
+ public List<int> listLevel1 = null;
+ /// <summary>
+ /// 绗簩绾у埆(涓婚敭涓虹涓�绾у埆銆傛敞鎰�,杩欎釜涓滆タ鍜屻�恖istLevel1,dicLevel3銆戜笉鍚屾,鍥犱负瀹冮伒浠庝簬鑾峰彇鍚庢墠淇濆瓨鐨勫師鍒�)
+ /// </summary>
+ public Dictionary<int, List<int>> dicLevel2 = new Dictionary<int, List<int>>();
+ /// <summary>
+ /// 绗笁绾у埆(涓婚敭涓虹浜岀骇鍒�傛敞鎰�,杩欎釜涓滆タ鍜屻�恖istLevel1,dicLevel2銆戜笉鍚屾,鍥犱负瀹冮伒浠庝簬鑾峰彇鍚庢墠淇濆瓨鐨勫師鍒�)
+ /// </summary>
+ public Dictionary<int, List<int>> dicLevel3 = new Dictionary<int, List<int>>();
+ }
+
+ #endregion
+ }
+}
--
Gitblit v1.8.0