From 7b60238359b94125d591678eff105ae2bf47843f Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 15 十一月 2019 13:16:21 +0800
Subject: [PATCH] 2019.11.15
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs | 504 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 448 insertions(+), 56 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
index 20c6cb8..168cc2b 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
@@ -15,11 +15,11 @@
#region 鈻� 鍙橀噺澹版槑___________________________
/// <summary>
- /// 澶囦唤涓氬姟鐨勯�昏緫
+ /// 缃戝叧涓氬姟鐨勯�昏緫绫�
/// </summary>
private static HdlGatewayLogic m_Current = null;
/// <summary>
- /// 澶囦唤涓氬姟鐨勯�昏緫
+ /// 缃戝叧涓氬姟鐨勯�昏緫绫�
/// </summary>
public static HdlGatewayLogic Current
{
@@ -179,20 +179,34 @@
#region 鈻� 娣诲姞缃戝叧___________________________
/// <summary>
- /// 娣诲姞鏂扮綉鍏�(浠呴檺杩藉姞鏂扮殑缃戝叧 1:姝e父 -1:寮傚父 0:褰撳墠鐨勭綉鍏崇粦瀹氬湪浜嗗綋鍓嶈处鍙蜂笅鐨勪笉鍚屼綇瀹呴噷闈�)
+ /// 娣诲姞鏂扮綉鍏�(浠呴檺杩藉姞鏂扮殑缃戝叧)
/// </summary>
/// <param name="zbGateway">缃戝叧</param>
/// <param name="mode">鏄惁鏄剧ず閿欒</param>
- public async Task<int> AddNewGateway(ZbGateway zbGateway, ShowErrorMode mode)
+ public async Task<bool> AddNewGateway(ZbGateway zbGateway, ShowErrorMode mode)
{
//鎵ц娣诲姞缃戝叧鍒板唴瀛�
var result = await this.DoAddGatewayToMemory(zbGateway, mode);
+ //鍓嶇殑缃戝叧缁戝畾鍦ㄤ簡褰撳墠璐﹀彿涓嬬殑涓嶅悓浣忓畢閲岄潰
+ if (result == 0)
+ {
+ if (mode == ShowErrorMode.YES)
+ {
+ //缃戝叧缁戝畾鍦ㄥ綋鍓嶈处鍙蜂笅鐨勫叾浠栦綇瀹呴噷\r\n璇疯В闄ょ粦瀹氬悗鍐嶈瘯
+ string msg = Language.StringByID(R.MyInternationalizationString.uTheGatewayInOtherResidenceMsg);
+ if (msg.Contains("{0}") == true)
+ {
+ msg = string.Format(msg, "\r\n");
+ }
+ this.ShowTipMsg(msg);
+ }
+ return false;
+ }
if (result != 1)
{
- return result;
+ return false;
}
-
- return 1;
+ return true;
}
/// <summary>
@@ -548,8 +562,104 @@
HdlAutoBackupLogic.AddOrEditorFile(zbGateway.FilePath);
return true;
- }
-
+ }
+
+ #endregion
+
+ #region 鈻� 缃戝叧鍒囨崲___________________________
+
+ /// <summary>
+ /// 鎵ц鍒囨崲缃戝叧鎿嶄綔
+ /// </summary>
+ /// <param name="gatewayId"></param>
+ public async Task<bool> DoSwitchGateway(string gatewayId)
+ {
+ var zbGateway = this.GetLocalGateway(gatewayId);
+ if (this.CheckGatewayOnlineByFlag(zbGateway) == true)
+ {
+ //閲嶆柊鑾峰彇鍦ㄧ嚎缃戝叧鐨勪俊鎭�
+ var result = await this.GetOnlineGatewayInfo(gatewayId);
+ if (result == false)
+ {
+ return false;
+ }
+ }
+ //鍒囨崲缃戝叧,淇濆瓨缂撳瓨
+ this.SaveGatewayIdToLocation(gatewayId);
+ return true;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鍦ㄧ嚎缃戝叧淇℃伅
+ /// </summary>
+ /// <param name="gatewayId"></param>
+ /// <returns></returns>
+ private async Task<bool> GetOnlineGatewayInfo(string gatewayId)
+ {
+ //鏄剧ず杩涘害鏉�
+ ProgressBar.Show();
+
+ //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D
+ ZbGateway realWay = null;
+ bool getGatewayInfo = true;
+ if (this.GetRealGateway(ref realWay, gatewayId) == true)
+ {
+ //閲嶆柊璁剧疆浣忓畢ID(杩欎釜搴旇鏄笉缁忚繃APP,鐩存帴鎶婄綉鍏虫仮澶嶄簡鍑哄巶璁剧疆)
+ if (this.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true)
+ {
+ int result2 = await this.ReBindNewGateway(realWay);
+ if (result2 == 0)
+ {
+ //鍑虹幇鏈煡閿欒,璇风◢鍚庡啀璇�
+ this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndResetAgain));
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+ }
+ else if (result2 == -1)
+ {
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+ return false;
+ }
+ //閲嶆柊缁戝畾缃戝叧閲岄潰宸茬粡閲嶆柊鑾峰彇浜嗙綉鍏充俊鎭�
+ getGatewayInfo = false;
+ }
+ }
+
+ if (getGatewayInfo == true)
+ {
+ //鑾峰彇缃戝叧淇℃伅
+ var info = await this.GetGatewayNewInfoAsync(realWay);
+ if (info == null)
+ {
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+ return false;
+ }
+ }
+
+ //鑾峰彇鍏ㄩ儴璁惧
+ bool result = LocalDevice.Current.SetDeviceToMemmoryByGateway(realWay);
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+ if (result == false)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// 淇濆瓨閫夋嫨鐨勭綉鍏矷D鍒版湰鍦�
+ /// </summary>
+ /// <param name="gatewayId"></param>
+ public void SaveGatewayIdToLocation(string gatewayId)
+ {
+ GatewayResourse.AppOldSelectGatewayId = gatewayId;
+ byte[] data = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(GatewayResourse.AppOldSelectGatewayId));
+ Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AppOldSelectGatewayFile, data);
+ }
+
#endregion
#region 鈻� 鍒犻櫎缃戝叧___________________________
@@ -688,8 +798,8 @@
if (waitTime == true)
{
- //杩欐槸绗竴閬撳潕,寮哄埗妫�鏌IFI:绛夊緟3绉�(鍥犱负wifi鐨勬椂鍊欙紝瀹冧細鑷姩鍘诲埛鏂癴lage)
- System.Threading.Thread.Sleep(3000);
+ //杩欐槸绗竴閬撳潕,寮哄埗妫�鏌IFI:绛夊緟2绉�(鍥犱负wifi鐨勬椂鍊欙紝瀹冧細鑷姩鍘诲埛鏂癴lage)
+ System.Threading.Thread.Sleep(2000);
//妫�鏌ユ槸鍚︽嫢鏈夌綉鍏冲瓨鍦ㄤ簬WIFi涓�
if (this.CheckHadGatewayInWifi(listRealWay) == false)
{
@@ -917,6 +1027,198 @@
#endregion
+ #region 鈻� 鑾峰彇鍗忚皟鍣ㄥ綋鍓嶄俊閬揰________________
+
+ /// <summary>
+ /// 鑾峰彇鍗忚皟鍣ㄥ綋鍓嶄俊閬�(浼氭湁绛夊緟寤惰繜,杩斿洖-1浠h〃閿欒)
+ /// </summary>
+ /// <param name="zbGateway"></param>
+ /// <returns></returns>
+ public int GetGatewayChannelId(ZbGateway zbGateway)
+ {
+ ZbGateway realWay = null;
+ if (this.GetRealGateway(ref realWay, zbGateway) == false)
+ {
+ //閿欒:缃戝叧瀵硅薄涓㈠け
+ this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg));
+ return -1;
+ }
+ ChannelIdInfo data = null;
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ if (topic == gatewayID + "/" + "ZbGw/GetChannel_Respon")
+ {
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+ data = Newtonsoft.Json.JsonConvert.DeserializeObject<ChannelIdInfo>(jobject["Data"].ToString());
+ }
+ };
+ realWay.Actions += action;
+
+ var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 64512 }, { "Command", 8 } };
+ realWay.Send("ZbGw/GetChannel", jObject.ToString());
+
+ int TimeOut = 0;
+ while (data == null && TimeOut < 30)
+ {
+ System.Threading.Thread.Sleep(100);
+ TimeOut++;
+ }
+
+ realWay.Actions -= action;
+ if (data == null)
+ {
+ //鑾峰彇鍗忚皟鍣ㄤ俊閬撳け璐�
+ string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayChannelIdFail);
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂");
+ this.ShowTipMsg(msg);
+ return -1;
+ }
+
+ return data.Channel;
+ }
+
+ /// <summary>
+ /// 缃戝叧淇¢亾淇℃伅
+ /// </summary>
+ private class ChannelIdInfo
+ {
+ /// <summary>
+ /// 缃戝叧淇¢亾
+ /// </summary>
+ public int Channel = -1;
+ }
+
+ #endregion
+
+ #region 鈻� 鑾峰彇鍗忚皟鍣∕AC______________________
+
+ /// <summary>
+ /// 鑾峰彇鍗忚皟鍣∕AC鍦板潃(浼氭湁绛夊緟寤惰繜,杩斿洖null浠h〃閿欒)
+ /// </summary>
+ /// <param name="zbGateway"></param>
+ /// <returns></returns>
+ public string GetGatewayCoordinatorMac(ZbGateway zbGateway)
+ {
+ ZbGateway realWay = null;
+ if (this.GetRealGateway(ref realWay, zbGateway) == false)
+ {
+ //閿欒:缃戝叧瀵硅薄涓㈠け
+ this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg));
+ return null;
+ }
+ CoordinatorMacInfo data = null;
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ if (topic == gatewayID + "/" + "ZbGw/GetMac_Respon")
+ {
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+ data = Newtonsoft.Json.JsonConvert.DeserializeObject<CoordinatorMacInfo>(jobject["Data"].ToString());
+ }
+ };
+ realWay.Actions += action;
+
+ var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 64512 }, { "Command", 13 } };
+ realWay.Send("ZbGw/GetMac", jObject.ToString());
+
+ int TimeOut = 0;
+ while (data == null && TimeOut < 30)
+ {
+ System.Threading.Thread.Sleep(100);
+ TimeOut++;
+ }
+
+ realWay.Actions -= action;
+ if (data == null)
+ {
+ //鑾峰彇鍗忚皟鍣∕ac澶辫触
+ string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayCoordinatorMacFail);
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂");
+ this.ShowTipMsg(msg);
+ return null;
+ }
+
+ return data.MacAddr;
+ }
+
+ /// <summary>
+ /// 缃戝叧鍗忚皟鍣∕ac淇℃伅
+ /// </summary>
+ private class CoordinatorMacInfo
+ {
+ /// <summary>
+ /// 璋冨櫒Mac
+ /// </summary>
+ public string MacAddr = string.Empty;
+ }
+
+ #endregion
+
+ #region 鈻� 鑾峰彇鍗忚皟鍣≒anID____________________
+
+ /// <summary>
+ /// 鑾峰彇鍗忚皟鍣≒anID(浼氭湁绛夊緟寤惰繜,杩斿洖-1浠h〃閿欒)
+ /// </summary>
+ /// <param name="zbGateway"></param>
+ /// <returns></returns>
+ public int GetGatewayPanId(ZbGateway zbGateway)
+ {
+ ZbGateway realWay = null;
+ if (this.GetRealGateway(ref realWay, zbGateway) == false)
+ {
+ //閿欒:缃戝叧瀵硅薄涓㈠け
+ this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg));
+ return -1;
+ }
+ PanIdInfo data = null;
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ if (topic == gatewayID + "/" + "ZbGw/GetPanId_Respon")
+ {
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+ data = Newtonsoft.Json.JsonConvert.DeserializeObject<PanIdInfo>(jobject["Data"].ToString());
+ }
+ };
+ realWay.Actions += action;
+
+ var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 64512 }, { "Command", 12 } };
+ realWay.Send("ZbGw/GetPanId", jObject.ToString());
+
+ int TimeOut = 0;
+ while (data == null && TimeOut < 30)
+ {
+ System.Threading.Thread.Sleep(100);
+ TimeOut++;
+ }
+
+ realWay.Actions -= action;
+ if (data == null)
+ {
+ //鑾峰彇鍗忚皟鍣≒anID澶辫触
+ string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayPanIDFail);
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂");
+ this.ShowTipMsg(msg);
+ return -1;
+ }
+
+ return data.PANID;
+ }
+
+ /// <summary>
+ /// 缃戝叧PanId淇℃伅
+ /// </summary>
+ private class PanIdInfo
+ {
+ /// <summary>
+ /// PanId
+ /// </summary>
+ public int PANID = -1;
+ }
+
+ #endregion
+
#region 鈻� 鑾峰彇缃戝叧GwInfo閲岄潰鐨勫睘鎬__________
/// <summary>
@@ -948,44 +1250,6 @@
{
//鑾峰彇鏈湴鐨勫睘鎬�
objValue = localWay.getGwInfo.GetType().InvokeMember(attributeName, System.Reflection.BindingFlags.GetField, null, localWay.getGwInfo, null);
- }
-
- if (objValue == null)
- {
- return defult;
- }
- return objValue;
- }
-
- /// <summary>
- /// 鑾峰彇缃戝叧GatewayBaseInfo閲岄潰鐨勫睘鎬�
- /// </summary>
- /// <param name="zbGateway">缃戝叧瀵硅薄</param>
- /// <param name="attributeName">GatewayBaseInfo閲岄潰灞炴�х殑鍚嶅瓧</param>
- /// <param name="defult">濡傛灉鑾峰彇涓嶅埌鏃讹紝璁剧疆鐨勯粯璁ゅ��</param>
- /// <returns></returns>
- public object GetGatewayBaseInfoAttribute(ZbGateway zbGateway, string attributeName, string defult = "")
- {
- string gwID = this.GetGatewayId(zbGateway);
- var localWay = this.GetLocalGateway(gwID);
-
- object objValue = null;
- if (localWay == null || localWay.getGatewayBaseInfo == null)
- {
- //鏈湴娌℃湁璁板綍鏈夎繖涓笢瑗�,鍒欑洿鎺ヨ繑鍥炲弬鏁扮殑鏁版嵁
- if (zbGateway.getGatewayBaseInfo != null)
- {
- objValue = zbGateway.getGatewayBaseInfo.GetType().InvokeMember(attributeName, System.Reflection.BindingFlags.GetField, null, zbGateway.getGatewayBaseInfo, null);
- }
- else
- {
- return defult;
- }
- }
- else
- {
- //鑾峰彇鏈湴灞炴��
- objValue = localWay.getGatewayBaseInfo.GetType().InvokeMember(attributeName, System.Reflection.BindingFlags.GetField, null, localWay.getGatewayBaseInfo, null);
}
if (objValue == null)
@@ -1870,6 +2134,74 @@
#endregion
+ #region 鈻� 璁剧疆缃戝叧缁忕含搴____________________
+
+ /// <summary>
+ /// 璁剧疆缃戝叧缁忕含搴�
+ /// </summary>
+ /// <param name="gateway">缃戝叧瀵硅薄</param>
+ /// <param name="Longitude">缁忓害</param>
+ /// <param name="Latitude">缁村害</param>
+ /// <returns></returns>
+ public bool SetGatewaySite(ZbGateway gateway, double Longitude, double Latitude)
+ {
+ ZbGateway realWay = null;
+ if (this.GetRealGateway(ref realWay, gateway) == false)
+ {
+ //閿欒:缃戝叧瀵硅薄涓㈠け
+ string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
+ this.ShowTipMsg(msg);
+ return false;
+ }
+
+ int result = -1;
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ if (topic == gatewayID + "/" + "Logic/SetSite_Respon")
+ {
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+ result = Convert.ToInt32(jobject["Data"]["Result"].ToString());
+ }
+ };
+ realWay.Actions += action;
+ //涓や綅灏忔暟
+ Longitude = Math.Round(Longitude, 2);
+ Latitude = Math.Round(Latitude, 2);
+
+ int intLongitude = Convert.ToInt32(Longitude.ToString().Replace(".", string.Empty));
+ int intLatitude = Convert.ToInt32(Latitude.ToString().Replace(".", string.Empty));
+
+ var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 2013 } };
+ var data = new Newtonsoft.Json.Linq.JObject { { "Longitude", intLongitude }, { "Latitude", intLatitude } };
+ jObject.Add("Data", data);
+ realWay.Send("Logic/SetSite", jObject.ToString());
+
+ int TimeOut = 0;
+ while (result == -1 && TimeOut < 30)
+ {
+ System.Threading.Thread.Sleep(100);
+ TimeOut++;
+ }
+
+ realWay.Actions -= action;
+ if (result != 0)
+ {
+ //璁剧疆缃戝叧缁忕含搴﹀け璐�
+ string msg = Language.StringByID(R.MyInternationalizationString.uSetGatewaySiteFail);
+ if (result == -1)
+ {
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂");
+ }
+ this.ShowTipMsg(msg);
+ return false;
+ }
+
+ return true;
+ }
+
+ #endregion
+
#region 鈻� 瑙g粦浜戠缃戝叧_______________________
/// <summary>
@@ -2024,6 +2356,7 @@
{
//鑾峰彇浠庝簯绔偅閲屽緱鏉ョ殑鍏ㄩ儴鏂囦欢
var listBackFile = HdlAutoBackupLogic.GetFileFromDirectory(UserCenterLogic.CombinePath(backDirectory));
+ listBackFile.Sort();
//娣诲姞闄勫姞鎯呮姤:杩樺師璁惧閰嶇疆
ProgressBar.SetAppendText(Language.StringByID(R.MyInternationalizationString.uRecoverDeviceSettion));
ProgressBar.SetMaxValue(listBackFile.Count);
@@ -2032,7 +2365,7 @@
var listSaveFile = new HashSet<string>();
foreach (string fileName in listBackFile)
{
- if (fileName.Length < 10 || fileName.StartsWith(Common.LocalDevice.deviceFirstName) == false)
+ if (fileName.Length < 10 || fileName.StartsWith("Device_") == false)
{
//涓嶆槸璁惧澶囦唤鏂囦欢
continue;
@@ -2092,7 +2425,7 @@
if (deleteFile.Length > 12)
{
string deviceFileName = deleteFile.Substring(5);
- if (deviceFileName.StartsWith(Common.LocalDevice.deviceFirstName) == false)
+ if (deviceFileName.StartsWith("Device_") == false)
{
//涓嶆槸璁惧鏂囦欢
continue;
@@ -2151,19 +2484,19 @@
else if (backType == GatewayBackupEnum.APir鐏厜閰嶇疆)
{
var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.ConfigureParamates>(System.Text.Encoding.UTF8.GetString(byteData));
- result = await HdlPirSensorLogic.Current.SetPirSensorLightSettion((IASZone)device, recoverData);
+ result = await HdlDevicePirSensorLogic.Current.SetPirSensorLightSettion((IASZone)device, recoverData);
}
else if (backType == GatewayBackupEnum.A骞叉帴鐐归鑹茶皟鑺�)
{
var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.KeyColorData>(System.Text.Encoding.UTF8.GetString(byteData));
- result = await HdlPanelLogic.Current.SetPanelEpointColorInfo((Panel)device, recoverData);
+ result = await HdlDevicePanelLogic.Current.SetPanelEpointColorInfo((Panel)device, recoverData);
}
else if (backType == GatewayBackupEnum.A骞叉帴鐐逛寒搴﹁皟鑺�)
{
var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(System.Text.Encoding.UTF8.GetString(byteData));
int directionsLevel = Convert.ToInt32(recoverData["directionsLevel"]);
int backlightLevel = Convert.ToInt32(recoverData["backlightLevel"]);
- result = await HdlPanelLogic.Current.SetDeviceLightSettion((Panel)device, directionsLevel, backlightLevel);
+ result = await HdlDevicePanelLogic.Current.SetDeviceLightSettion((Panel)device, directionsLevel, backlightLevel);
}
else if (backType == GatewayBackupEnum.A骞叉帴鐐硅妭鑳芥ā寮�)
{
@@ -2171,12 +2504,71 @@
bool modeEnable = Convert.ToBoolean(recoverData["modeEnable"]);
int modeTime = Convert.ToInt32(recoverData["modeTime"]);
int level = Convert.ToInt32(recoverData["level"]);
- result = await HdlPanelLogic.Current.SetDeviceEnergyConservationMode((Panel)device, modeEnable, modeTime, level);
+ result = await HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode((Panel)device, modeEnable, modeTime, level);
}
else if (backType == GatewayBackupEnum.A骞叉帴鐐圭鏈夊睘鎬�)
{
var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(System.Text.Encoding.UTF8.GetString(byteData));
- result = await HdlPanelLogic.Current.EditorDryContactFunction((Panel)device, recoverData);
+ result = await HdlDevicePanelLogic.Current.EditorDryContactFunction((Panel)device, recoverData);
+ }
+ else if (backType == GatewayBackupEnum.A绐楀笜鏂瑰悜)
+ {
+ var statu = Newtonsoft.Json.JsonConvert.DeserializeObject<bool>(System.Text.Encoding.UTF8.GetString(byteData));
+ result = await HdlDeviceCurtainLogic.Current.SetCurtainDirection((Rollershade)device, statu);
+ }
+ else if (backType == GatewayBackupEnum.A绐楀笜鎵嬫媺鎺у埗)
+ {
+ var statu = Newtonsoft.Json.JsonConvert.DeserializeObject<bool>(System.Text.Encoding.UTF8.GetString(byteData));
+ result = await HdlDeviceCurtainLogic.Current.SetHandPullControl((Rollershade)device, statu);
+ }
+ else if (backType == GatewayBackupEnum.A绐楀笜涓婁笅闄愪綅)
+ {
+ var curtainDevice = (Rollershade)device;
+ var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(System.Text.Encoding.UTF8.GetString(byteData));
+ int upLimit = Convert.ToInt32(recoverData["upLimit"]);
+ int downLimit = Convert.ToInt32(recoverData["downLimit"]);
+ //鍏堥噸缃獥甯�
+ result = await HdlDeviceCurtainLogic.Current.RestoreCurtain(curtainDevice);
+ if (result == false) { return -1; }
+ await Task.Delay(5000);
+ //閲嶇疆涓婇檺浣�
+ result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.UpLimit);
+ if (result == false) { return -1; }
+ //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣�
+ curtainDevice.WcdGoToTiltValue(upLimit);
+ await Task.Delay(3000);
+ //鎵ц纭鍙婅鐩栫獥甯橀檺浣嶇偣
+ result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.UpLimit, -1, -1);
+ if (result == false) { return -1; }
+
+ await Task.Delay(2000);
+ //閲嶇疆涓嬮檺浣�
+ result = await HdlDeviceCurtainLogic.Current.DeleteCurtainLimitPoint(curtainDevice, Rollershade.LimiType.DownLimit);
+ if (result == false) { return -1; }
+ //灏嗙獥甯樿皟鏁村埌鎸囧畾鐧惧垎姣�
+ curtainDevice.WcdGoToTiltValue(downLimit);
+ await Task.Delay(3000);
+ //鎵ц纭鍙婅鐩栫獥甯橀檺浣嶇偣
+ result = await HdlDeviceCurtainLogic.Current.CommitCurtainLimitPoint(curtainDevice, Rollershade.CurtainPrivateInstalledLimi.DownLimit, -1, -1);
+ }
+ else if (backType == GatewayBackupEnum.A绌鸿皟鑷畾涔夋ā寮�)
+ {
+ var data = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(System.Text.Encoding.UTF8.GetString(byteData));
+ result = await HdlDeviceAirConditionerLogic.Current.SetAcModeSupport((AC)device, data);
+ if (result == true)
+ {
+ //杞崲涓轰簩杩涘埗
+ var value = Convert.ToString(data, 2).PadLeft(16, '0');
+ //杩欎簲涓缃槸鏀惧湪鍚庨潰鐨�
+ var fixValue = value.Substring(0, value.Length - 5);
+ var reportValue = value.Substring(fixValue.Length);
+ //鏇存敼缂撳瓨
+ for (int i = 0; i < reportValue.Length; i++)
+ {
+ ((AC)device).listSupportMode[i] = Convert.ToInt32(reportValue[i]);
+ }
+ device.ReSave();
+ }
}
return result == true ? 1 : -1;
}
--
Gitblit v1.8.0