From 71f1df7772feec5cf83feefa851608adac18e005 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期三, 06 十一月 2019 17:45:23 +0800
Subject: [PATCH] 2019.11.6
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlPanelLogic.cs | 730 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 730 insertions(+), 0 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlPanelLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlPanelLogic.cs
new file mode 100755
index 0000000..e1d408c
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlPanelLogic.cs
@@ -0,0 +1,730 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+using System.Threading.Tasks;
+
+namespace Shared.Phone.UserCenter
+{
+ /// <summary>
+ /// 骞叉帴鐐圭殑閫昏緫
+ /// </summary>
+ public class HdlPanelLogic
+ {
+ #region 鈻� 鍙橀噺澹版槑___________________________
+
+ /// <summary>
+ /// 骞叉帴鐐圭殑閫昏緫
+ /// </summary>
+ private static HdlPanelLogic m_Current = null;
+ /// <summary>
+ /// 骞叉帴鐐圭殑閫昏緫
+ /// </summary>
+ public static HdlPanelLogic Current
+ {
+ get
+ {
+ if (m_Current == null)
+ {
+ m_Current = new HdlPanelLogic();
+ }
+ return m_Current;
+ }
+ }
+
+ /// <summary>
+ /// 骞叉帴鐐圭殑绉佹湁灞炴�� keys:璁惧涓婚敭,value:鍚勭骇鍒殑鍊�
+ /// </summary>
+ private Dictionary<string, DryContactFunctionInfo> dicDryContactFunction = new Dictionary<string, DryContactFunctionInfo>();
+
+ #endregion
+
+ #region 鈻� 鍒濆鍖朹____________________________
+
+ /// <summary>
+ /// 鍒濆鍖�
+ /// </summary>
+ public HdlPanelLogic()
+ {
+ //浠庢湰鍦版枃浠惰繕鍘熷共鎺ョ偣鐨勭鏈夊睘鎬�
+ 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(ui鍙寒搴﹁皟鑺�)</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
+ {
+ { "directionsLevel",directionsLevel },
+ { "backlightLevel", backlightLevel }
+ };
+ //澶囦唤璁惧
+ 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
+ {
+ { "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">
+ /// <para>鏂规硶1锛氬綋int[]浼犵┖锛岃繑鍥炲�兼槸鈥滈潰鏉垮叿鏈夌殑鍔熻兘澶х被,鍗宠繑鍥炩�滅涓�绾у埆銆�1024:鐏被锛�256:鎸夐敭绫伙紝768:PIR绫�</para>
+ /// <para>鏂规硶2锛氥�佸綋int[]鍊间负绗竴绾у埆PrivateFuncTypeFir涓�夋嫨涓�涓��</para>
+ /// <para>杩斿洖鍊兼槸鈥滈潰鎸夐敭鍙戦�佸姛鑳界被鈥濓紝鍗宠繑鍥炩�滅浜岀骇鍒��</para>
+ /// <para>100:Switch,寮�鍏筹紙鎸夐敭绫伙級;200:Dimmer,璋冨厜锛堟寜閿被锛�;300:Curtain,绐楀笜锛堟寜閿被锛�</para>
+ /// <para>0:EnergySavingMode,鑺傝兘妯″紡锛堢伅绫伙級;1:SleepMode,鐫$湢妯″紡锛堢伅绫伙級;100:WhiteBalance,鐧藉钩琛★紙鐏被锛�;101:RGBColor,RGB鎸囩ず鐏鑹诧紙鐏被锛�;102:RGBLevel,RGB鎸囩ず鐏寒搴︼紙鐏被锛�</para>
+ /// <para>鏂规硶3锛氬綋int[]鍊间负绗竴绾у埆PrivateFuncTypeFir涓�夋嫨涓�涓紝鎺ョ潃鍐嶉�夌浜岀骇鍒玃rivateFunTypeSec涓�夋嫨涓�涓� </para>
+ /// <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> EditorDryContactFunction(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>
+ /// 浠庣紦瀛樹腑鑾峰彇璁惧鐨勭鏈夊睘鎬�
+ /// </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
+ }
+}
--
Gitblit v1.8.0