From fab43407e01474cc4f7b1d0f4b5e43ce1a038ce4 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 16 三月 2021 16:51:14 +0800
Subject: [PATCH] Merge branch 'dev-tzy' into temp-wxr
---
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs | 418 ++++++++++++++++++++++++++++++++++-------------------------
1 files changed, 242 insertions(+), 176 deletions(-)
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
index a4a0393..d0745a8 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
@@ -8,9 +8,39 @@
{
public class Method
{
+
+ /// <summary>
+ /// 绠$悊浣嶇疆
+ /// </summary>
+ /// <param name="control">褰撳墠璁惧</param>
+ /// <param name="action">鍥炶皟鍑芥暟</param>
+ public void ManagementPosition(Entity.Function control, Action action)
+ {
+ var view = new ChooseRoomPage(control, action);
+ MainPage.BasePageView.AddChidren(view);
+ view.LoadPage();
+ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+ }
+ /// <summary>
+ /// 淇敼鍚嶇О
+ /// </summary>
+ /// <param name="tipText">鎻愮ず鏍囬鏂囨湰</param>
+ /// <param name="list">褰撳墠瀛樺湪鍚嶇О鍒楄〃</param>
+ /// <param name="currName">褰撳墠鍚嶇О</param>
+ /// <param name="action">鍥炶皟鍑芥暟</param>
+ public void EditControlName(int tipText, List<string> list, string currName, Action<string, Dialog> action, Action actionCancel, bool tag = false)
+ {
+ new View.TipView().InputBox(tipText, currName, StringId.nameNull, StringId.NameAlreadyExists, list, (text, view
+ ) =>
+ {
+ action(text, view);
+ }, () => { actionCancel(); }, tag);
+ }
/// <summary>
/// 娣诲姞閬ユ帶鍣ㄧ殑鏂规硶
/// </summary>
+ /// <param name="frameLayout">log鍥炬爣鍔犺浇鐣岄潰</param>
+ /// <param name="action">鍥炶皟鍑芥暟</param>
public void AddControl(FrameLayout frameLayout, Action<Control> action)
{
View.TipView tipView = new View.TipView();
@@ -36,11 +66,12 @@
/// <summary>
/// 鍙戦�侀仴鎺у櫒鍛戒护鏂规硶
/// </summary>
- /// <param name="control"></param>
- /// <param name="frame"></param>
+ /// <param name="control">鍙戦�佸弬鏁板璞�</param>
+ /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param>
+ /// <param name="action">鍥炶皟鍑芥暟</param>
public void ThreadAddControl(Control control, FrameLayout frame, Action<Control> action)
{
- DAL.Server.ResponsePackNew responsePackNew = null;
+ Cloud mqttdate = null;
Loading loading = new Loading();
frame.AddChidren(loading);
loading.Start();
@@ -48,7 +79,18 @@
{
try
{
- responsePackNew = PirSend.Add(control);
+ //鍙戦�佹坊鍔犲懡浠�
+ var responsePackNew = PirSend.Add(control);
+ if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+ {
+ string sid = responsePackNew.Data.ToString();
+ mqttdate = MqttDate(sid);
+ if (mqttdate != null)
+ {
+ control.sid = sid;
+ }
+ }
+
}
catch { }
finally
@@ -56,52 +98,58 @@
Application.RunOnMainThread(() =>
{
loading.Hide();
- if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+ ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰�;
+ if (mqttdate != null)
{
- string sid = responsePackNew.Data.ToString();
- var mqttdate = MqttDate(sid);
- if (mqttdate != null)
+ //浼戠湢500姣锛屼负绛夊緟浜戠鍒涘缓deviceid锛�
+ System.Threading.Thread.Sleep(500);
+ //璇诲彇娣诲姞閬ユ帶鍣╠eviceID锛屾墠鐭ラ亾鏄惁娣诲姞鎴愬姛锛�
+ GetControl(frame, control, (device) =>
{
- ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰橈紝鎵嶇煡閬撴槸鍚︽坊鍔犳垚鍔�
- control.sid = sid;
- //浼戠湢500姣锛屼负绛夊緟浜戠鍒涘缓deviceid锛�
- System.Threading.Thread.Sleep(500);
- GetControl(frame, control,(device)=> {
- if (device != null)
- {
- control.deviceId = device.deviceId;
- frame.RemoveFromParent();//娣诲姞鎴愬姛鍏抽棴寮圭獥
- action(control);
- }
- });
- }
- else
- {
- //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀�
- View.FailView failView = new View.FailView();
- failView.ShouError((view) =>
+ if (device != null)
{
- view.Close();
- ThreadAddControl(control, frame, action);
- });
- }
+ control.deviceId = device.deviceId;
+ frame.RemoveFromParent();//娣诲姞鎴愬姛鍏抽棴寮圭獥
+ action(control);
+ }
+ else
+ {
+ //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀�
+ View.FailView failView = new View.FailView();
+ failView.ShouError((view) =>
+ {
+ view.Close();
+ ThreadAddControl(control, frame, action);
+ });
+ }
+ });
}
else
{
- ErrorShow(responsePackNew);
+ //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀�
+ View.FailView failView = new View.FailView();
+ failView.ShouError((view) =>
+ {
+ view.Close();
+ ThreadAddControl(control, frame, action);
+ });
}
+
+
});
+
}
})
{ IsBackground = true }.Start();
}
-
/// <summary>
/// 鑾峰彇绾㈠璁惧鍒楄〃
/// </summary>
+ /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param>
+ /// <param name="action">鍥炶皟鍑芥暟</param>
public static void GetPirDeviceList(FrameLayout frame, Action action)
{
//娓呴櫎涔嬪墠鍒楄〃;
@@ -109,56 +157,63 @@
//鍔犺浇log
Loading loading = new Loading();
frame.AddChidren(loading);
- HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
loading.Start();
new System.Threading.Thread(() =>
{
try
{
- responsePackNew = PirSend.GetDeviceList("ir.module");
+ var responsePackNew = PirSend.GetDeviceList("ir.module");
+ if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+ {
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(responsePackNew.Data.ToString());
+ string list = jobject["list"].ToString();
+
+ var jArray = Newtonsoft.Json.Linq.JArray.Parse(list);
+ for (int a = 0; a < jArray.Count; a++)
+ {
+ var jay = jArray[a];
+ string spk = jay["spk"].ToString();
+ if (spk == "ir.module")
+ {
+ //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄
+ var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
+ var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str);
+ if (pirJosn != null)
+ {
+ if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId))
+ {
+
+ Pir.pirDeviceList.Add(pirJosn);
+
+ }
+ }
+ }
+
+ }
+
+ }
}
catch { }
finally
{
Application.RunOnMainThread(() =>
{
- loading.Hide();
try
{
- if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+ if (Pir.pirDeviceList.Count != 0)
{
- var jobject = Newtonsoft.Json.Linq.JObject.Parse(responsePackNew.Data.ToString());
- string list = jobject["list"].ToString();
-
- var jArray = Newtonsoft.Json.Linq.JArray.Parse(list);
- for (int a = 0; a < jArray.Count; a++)
+ GetControlList(() =>
{
- var jay = jArray[a];
- string spk = jay["spk"].ToString();
- if (spk == "ir.module")
- {
- //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄
- var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
- var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str);
- if (pirJosn != null)
- {
- if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId))
- {
+ loading.Hide();
+ action();
- Pir.pirDeviceList.Add(pirJosn);
-
- }
- }
- }
-
- }
- GetControlList(frame, action);
-
+ });
}
else
{
+ loading.Hide();
Method method = new Method();
- method.ErrorShow(responsePackNew);
+ method.ErrorShow(null,"璇诲彇绾㈠瀹濆垪琛ㄥけ璐�");
}
}
catch { }
@@ -173,13 +228,10 @@
/// <summary>
/// 鑾峰彇閬ユ帶鍣ㄥ垪琛�
/// </summary>
- public static void GetControlList(FrameLayout frame, Action action)
+ /// <param name="action">鍥炶皟鍑芥暟</param>
+ public static void GetControlList(Action action)
{
- //鍔犺浇log
- Loading loading = new Loading();
- frame.AddChidren(loading);
- HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
- loading.Start();
+
new System.Threading.Thread(() =>
{
try
@@ -189,45 +241,69 @@
var pirDevice = Pir.pirDeviceList[i];
try
{
- responsePackNew = PirSend.ControlList(pirDevice);
+ var responsePackNew = PirSend.ControlList(pirDevice);
+ if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+ {
+ var jArray = JArray.Parse(responsePackNew.Data.ToString());
+ for (int a = 0; a < jArray.Count; a++)
+ {
+ var jay = jArray[a];
+ //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄
+ var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
+ var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str);
+ if (pirJosn != null)
+ {
+ if (null == pirDevice.FunctioList.Find((c) => c.sid == pirJosn.sid))
+ {
+ pirDevice.FunctioList.Add(pirJosn);
+ }
+ }
+
+ }
+ }
}
catch { }
- finally
- {
- Application.RunOnMainThread(() =>
- {
- try
- {
- if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
- {
- var jArray = Newtonsoft.Json.Linq.JArray.Parse(responsePackNew.Data.ToString());
- for (int a = 0; a < jArray.Count; a++)
- {
- var jay = jArray[a];
- //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄
- var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
- var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str);
- if (pirJosn != null)
- {
- if (null == pirDevice.FunctioList.Find((c) => c.sid == pirJosn.sid))
- {
- pirDevice.FunctioList.Add(pirJosn);
- }
- }
- }
- }
- else
- {
- //Method method = new Method();
- //method.ErrorShow(responsePackNew);
- }
- }
- catch { }
+ }
+ }
+ catch { }
+ finally
+ {
- });
- }
+ Application.RunOnMainThread(() =>
+ {
+ action();
+ });
+ }
+
+ })
+ { IsBackground = true }.Start();
+
+ }
+ /// <summary>
+ /// 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid)
+ /// </summary>
+ /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param>
+ /// <param name="control">鍙戦�佸弬鏁板璞�</param>
+ /// <param name="action">鍥炶皟鍑芥暟</param>
+ public void GetControl(FrameLayout frame, Control control, Action<Entity.Function> action)
+ {
+ Entity.Function function = null;
+ //鍔犺浇log
+ Loading loading = new Loading();
+ frame.AddChidren(loading);
+ loading.Start();
+ new System.Threading.Thread(() =>
+ {
+ try
+ {
+ // 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid)
+ var responsePackNew = PirSend.GetinfoBySid(control);
+ if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+ {
+ //var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString());
+ function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString());
}
}
catch { }
@@ -236,119 +312,112 @@
Application.RunOnMainThread(() =>
{
loading.Hide();
- action();
+ action(function);
});
}
+
})
{ IsBackground = true }.Start();
-
}
-
/// <summary>
- /// 鑾峰彇閬ユ帶鍣ㄨ缁�
+ /// 鍙戦�佸懡浠ょ嚎绋�
/// </summary>
- public void GetControl(FrameLayout frame, Control control, Action<Entity.Function> action)
+ /// <param name="control">鍙戦�佹暟鎹璞�</param>
+ /// <param name="action">鍥炶皟鍑芥暟</param>
+ /// <param name="str">鍒ゆ柇瀛楃</param>
+ /// <param name="frame">log鐖舵帶浠�</param>
+ /// <param name="dialog">log鐖舵帶浠�</param>
+ public void ThreadSend(Control control, Action<HDL_ON.DAL.Server.ResponsePackNew> action, string str, FrameLayout frame, Dialog dialog)
{
- Entity.Function function = null;
- //鍔犺浇log
- Loading loading = new Loading();
- frame.AddChidren(loading);
- HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
- loading.Start();
- new System.Threading.Thread(() =>
- {
- try
- {
- responsePackNew = PirSend.GetinfoBySid(control);
- }
- catch { }
- finally
- {
- Application.RunOnMainThread(() =>
- {
- try
- {
- if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
- {
- var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString());
- function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str);
- }
- else
- {
- Method method = new Method();
- method.ErrorShow(responsePackNew);
- }
- }
- catch { }
- finally
- {
- Application.RunOnMainThread(() =>
- {
- loading.Hide();
- action(function);
- });
- }
- });
- }
- })
- { IsBackground = true }.Start();
+
}
- /// <summary>
- /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁(閬ユ帶鍣ㄦ坊鍔�)
- /// </summary>
- public static string addcontrondata = "";
- /// <summary>
- /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁(瀛︿範鎸夐敭)
- /// </summary>
- public static string studybtndata = "";
+ /// <summary>
+ /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁
+ /// </summary>
+ public static string mqttdata = "";
/// <summary>
/// 鍒ゆ柇杩欎釜涓婚鏄惁鏄坊鍔犻仴鎺у櫒涓婚
/// </summary>
+ /// <param name="sid">鍞竴鏍囪瘑</param>
+ /// <param name="timeValue">绛夊緟鏃堕棿鍊�</param>
/// <returns></returns>
- public Cloud MqttDate(string sid,int timeValue=10)
+ public Cloud MqttDate(string sid, int timeValue = 10)
{
- Cloud cloud=null;
+ Cloud cloud = null;
var dateTime = DateTime.Now;
while ((DateTime.Now - dateTime).TotalMilliseconds < timeValue * 1000)
{
- if (!string.IsNullOrEmpty(addcontrondata))
+ if (!string.IsNullOrEmpty(mqttdata))
{
- var cloudjson = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(addcontrondata);
- for (int i = 0; i < cloudjson.objects.Count; i++)
+ try
{
- var objects = cloudjson.objects[i];
- if (sid == objects.sid)
+ var cloudjson = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(mqttdata);
+ for (int i = 0; i < cloudjson.objects.Count; i++)
{
- cloud = cloudjson;
+ var objects = cloudjson.objects[i];
+ if (sid == objects.sid)
+ {
+ cloud = cloudjson;
+ mqttdata = "";
+ break;
+ }
+ }
+ if (cloud!=null)
+ {
break;
}
}
- break;
+ catch { }
}
}
return cloud;
}
-
/// <summary>
/// 閿欒鐮佹彁绀�
/// </summary>
/// <param name="responsePackNew"></param>
- public void ErrorShow(ResponsePackNew responsePackNew)
+ /// <param name="str"></param>
+ public void ErrorShow(ResponsePackNew responsePackNew=null, string str = "")
{
-
- if (responsePackNew != null && responsePackNew.Code == "14005")
+ if (str == "鍒犻櫎閬ユ帶鍣�")
{
- new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
+ new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.delFail));
+ } else if (str == "璇诲彇绾㈠瀹濆垪琛ㄥけ璐�") {
+ new Intelligence.Automation.LogicView.TipPopView().FlashingBox("璇诲彇绾㈠瀹濆垪琛ㄥけ璐�");
}
else
{
- new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
+
+ if (responsePackNew != null)
+ {
+ switch (responsePackNew.Code)
+ {
+
+ case "14005":
+ {
+ new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
+ }
+ break;
+ case "10807":
+ {
+ //绾㈠瀹濅笅閬ユ帶鍣ㄨ秴杩囨渶澶�(10涓�)鏁伴噺闄愬埗
+ new Intelligence.Automation.LogicView.TipPopView().FlashingBox("绾㈠瀹濅笅閬ユ帶鍣ㄨ秴杩囨渶澶�(10涓�)鏁伴噺闄愬埗");
+ }
+ break;
+ default:
+ {
+ new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
+ }
+ break;
+
+ }
+ }
}
}
@@ -357,9 +426,6 @@
[Serializable]
public class Cloud
{
- /// <summary>
- /// 璁惧id
- /// </summary>
public string id = "";
public List<Objects> objects = new List<Objects>();
public string time_stamp = string.Empty;
--
Gitblit v1.8.0