From 610a6a826a00d47320b17478cb5ca5f60abfa291 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 24 五月 2022 17:25:16 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wjc' into Dev-Branch
---
HDL_ON/DAL/DriverLayer/Control.cs | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 169 insertions(+), 11 deletions(-)
diff --git a/HDL_ON/DAL/DriverLayer/Control.cs b/HDL_ON/DAL/DriverLayer/Control.cs
index 17cc7b5..5672c7a 100644
--- a/HDL_ON/DAL/DriverLayer/Control.cs
+++ b/HDL_ON/DAL/DriverLayer/Control.cs
@@ -94,7 +94,7 @@
}
set
{
- if (_GatewayOnline_Local != value)
+ //if (_GatewayOnline_Local != value)
{
_GatewayOnline_Local = value;
if (value)
@@ -129,7 +129,7 @@
}
set
{
- if (_GatewayOnline_Cloud != value)
+ //if (_GatewayOnline_Cloud != value)
{
_GatewayOnline_Cloud = value;
if(GatewayOnline_Local)
@@ -360,10 +360,11 @@
/// <param name="function"></param>
/// <param name="useRemote">鏄惁鐩存帴浣跨敤杩滅▼鍙戦��</param>
/// <returns></returns>
- public void SendWriteCommand(Function function, Dictionary<string, string> commandDictionary, bool useRemote = false,int resend = 3)
+ public bool SendWriteCommand(Function function, Dictionary<string, string> commandDictionary, bool useRemote = false,int resend = 3)
{
function.controlCounter++;
function.refreshTime = DateTime.Now;
+
//濡傛灉鏄帶鍒惰皟鍏夌殑寮�鏃讹紝浜害鍊间笉鑳戒负0
if (commandDictionary.Count > 2)
@@ -404,7 +405,7 @@
upDataObj.objects.Add(asd);
revString = Newtonsoft.Json.JsonConvert.SerializeObject(upDataObj);
UpdataFunctionStatus(revString, null, true);
- return;
+ return true;
}
@@ -459,6 +460,7 @@
var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson);
new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id,resend);
MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
+ //Control.Ins.MsgInfoList.Add($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}"+"\r\n");
}
}
//杩滅▼閫氳
@@ -493,6 +495,8 @@
}
}
+
+ return true;
}
/// <summary>
/// 鍏ㄥ紑鍏ㄥ叧鍔熻兘
@@ -652,6 +656,79 @@
}
/// <summary>
+ /// 鍙戦�佽鍙栧懡浠�
+ /// 鑷姩鍒ゆ柇鏄惁涓篈鍗忚璁惧
+ /// </summary>
+ public void SendReadCommand(List<Function> functions, bool forceRemote = false)
+ {
+ List<string> sids = new List<string>();
+ foreach (Function function in functions)
+ {
+ sids.Add(function.sid);
+ function.refreshTime = DateTime.Now;
+ }
+ if (forceRemote)
+ {
+
+ var pm = new DAL.Server.HttpServerRequest();
+ var pack = pm.RefreshDeviceStatus(sids);
+ }
+ else
+ {
+ if (Ins.GatewayOnline_Local)
+ {
+
+ if (DB_ResidenceData.Instance.GatewayType == 0)
+ {
+ try
+ {
+ var busClient = new Control_Udp();
+ foreach (Function function in functions)
+ {
+ busClient.ReadBusData(function);
+ }
+
+ }
+ catch (Exception ex)
+ {
+ MainPage.Log($"鍙戦�佹暟鎹紓甯�: {ex.Message}");
+ }
+ }
+ else
+ {
+ var objects = new List<Dictionary<string, string>>();
+
+
+ foreach (Function function in functions)
+ {
+ var readKey = new Dictionary<string, string>();
+ readKey.Add("sid", function.sid);
+ objects.Add(readKey);
+ }
+
+
+ var readDataObj = new AlinkReadFunctionStatusObj()
+ {
+ id = Ins.msg_id.ToString(),
+ objects = objects,
+ time_stamp = Utlis.GetTimestamp()
+ };
+ var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj);
+ var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ReadStatus, functionControlDataJson);
+ MainPage.Log($"鏈湴閫氳 鍙戦�丠DL-Link鏁版嵁:{functionControlDataJson}");
+ new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id);
+ }
+ }
+ else
+ {
+ var pm = new DAL.Server.HttpServerRequest();
+ var pack = pm.RefreshDeviceStatus(sids);
+ }
+ }
+ }
+
+
+ /// <summary>
/// 瀹夐槻鎺у埗
/// </summary>
public void ControlSecurity(SecurityAlarm securityAlarm,string state)
@@ -663,7 +740,7 @@
gatewayId = DB_ResidenceData.Instance.HomeGateway.gatewayId,
sid = securityAlarm.sid, status = state, userSecurityId = securityAlarm.userSecurityId
} });
- MainPage.Log($"瀹夐槻鎺у埗缁撴灉:{result.Code}");
+ MainPage.Log($"瀹夐槻鎺у埗缁撴灉:code锛歿result.Code}锛沵sg锛歿result.message}");
}
else
{
@@ -948,6 +1025,7 @@
/// <summary>
/// 鏇存柊璁惧鐘舵��
/// A鍗忚鏁版嵁
+ /// Tag Link鐘舵�佸鐞�
/// </summary>
/// <param name="updateBytes"></param>
public void UpdataFunctionStatus(string revString, byte[] usefulBytes,bool isCloudData = false)
@@ -1062,6 +1140,10 @@
RollingShutterPage.UpdataState(localFunction);
break;
case SPK.CurtainShades:
+ break;
+ case SPK.HvacCac:
+ Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status);
+
break;
case SPK.AcStandard:
case SPK.HvacAC:
@@ -1187,6 +1269,7 @@
case SPK.AirFreshStandard:
case SPK.HvacAirFresh:
case SPK.SensorGas:
+ case SPK.SensorHelp:
//璁惧鐘舵�佹帹閫�
//鐘舵�佹洿鏂�
Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status);
@@ -1194,7 +1277,7 @@
case SPK.AvMusic:
case SPK.MusicStandard:
//UI.Music.MusicMain.mMusicMain.RefreshView(updateTemp);
- Console.WriteLine("闊充箰鎾斁鍣ㄦ樉绀虹姸鎬�======="+ revString);
+ //Console.WriteLine("闊充箰鎾斁鍣ㄦ樉绀虹姸鎬�======="+ revString);
//wjc
break;
}
@@ -1232,13 +1315,88 @@
}
else
{
- Dictionary<string, object> d = new Dictionary<string, object>();
- d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
- d.Add("deviceId", doorlock.deviceId);
- var requestJson = HttpUtil.GetSignRequestJson(d);
- HttpUtil.RequestHttpsPost("/home-wisdom/app/device/door/remoteOpen", requestJson);
+ ConfirmUnlocking(doorlock.deviceId, extStr);
}
}
+ /// <summary>
+ /// 纭寮�閿�
+ /// </summary>
+ /// <param name="functionId"></param>
+ /// <param name="pwd"></param>
+ public void ConfirmUnlocking(string functionId,string pwd)
+ {
+ Loading loading = new Loading();
+ MainPage.BaseView.AddChidren(loading);
+ loading.BackgroundColor = 0x88000000;
+ loading.LodingBackgroundColor = UI.CSS.CSS_Color.BackgroundColor;
+ loading.Start(Language.StringByID(StringId.PleaseWait));
+ new System.Threading.Thread(() =>
+ {
+ try
+ {
+ Dictionary<string, object> d = new Dictionary<string, object>();
+ d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+ d.Add("deviceId", functionId);
+ d.Add("pwd", pwd);
+ var requestJson = HttpUtil.GetSignRequestJson(d);
+ var pack = HttpUtil.RequestHttpsPost("/home-wisdom/app/device/door/pwdConfirm", requestJson);
+ if (pack.Code == StateCode.SUCCESS)
+ {
+ Newtonsoft.Json.Linq.JObject pairs = Newtonsoft.Json.Linq.JObject.Parse(pack.Data.ToString());
+ var scrip = pairs.GetValue("scrip");
+
+ d = new Dictionary<string, object>();
+ d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
+ d.Add("deviceId", functionId);
+ d.Add("scrip", scrip);
+ requestJson = HttpUtil.GetSignRequestJson(d);
+ pack = HttpUtil.RequestHttpsPost("/home-wisdom/app/device/door/remoteOpen", requestJson);
+ //if(pack.Code == StateCode.SUCCESS)
+ //{
+ // return true;
+ //}
+ //else
+ //{
+ // return false;
+ //}
+ if (pack.Code != StateCode.SUCCESS) {
+ Application.RunOnMainThread(() => {
+ new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), pack.message);
+ UserInfo.Current.doorPasswordString = "";//
+ UserInfo.Current.LastTimeOpenDoor = DateTime.MinValue;
+ });
+ }
+ }
+ if (pack.Code != StateCode.SUCCESS)
+ {
+ Application.RunOnMainThread(() => {
+ if(string.IsNullOrEmpty(pack.message))
+ {
+ new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip),
+ Language.StringByID(StringId.OperationFailed));
+ }
+ else
+ {
+ new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), pack.message);
+ }
+ });
+ }
+ }
+ catch (Exception ex)
+ {
+
+ }
+ finally
+ {
+ Application.RunOnMainThread(() =>
+ {
+ loading.Hide();
+ loading.RemoveFromParent();
+ });
+ }
+ })
+ { IsBackground = true }.Start();
+ }
//瀵嗙爜鍐荤粨
//瀵嗙爜楠岃瘉
--
Gitblit v1.8.0