| | |
| | | MainPage.BasePageView.AddChidren(page); |
| | | page.Show(); |
| | | MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; |
| | | page.BackAction += () => { |
| | | PirMain.BackAction += () => |
| | | { |
| | | action?.Invoke(); |
| | | }; |
| | | }); |
| | |
| | | var pirDevice = Pir.pirDeviceList[i]; |
| | | try |
| | | { |
| | | var responsePackNew = PirSend.ControlList(pirDevice); |
| | | var responsePackNew = PirSend.ControlList(pirDevice.deviceId); |
| | | if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") |
| | | { |
| | | var jArray = JArray.Parse(responsePackNew.Data.ToString()); |
| | |
| | | /// 获取单个红外宝遥控器列表 |
| | | /// </summary> |
| | | /// <param name="action">回调函数</param> |
| | | public static void GetControlList(FrameLayout frame ,Action action, Pir pirDevice) |
| | | public static void GetControlList(FrameLayout frame, Action action, Pir pirDevice) |
| | | { |
| | | Loading loading = new Loading(); |
| | | frame.AddChidren(loading); |
| | | loading.Start(); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | try |
| | | { |
| | | |
| | | try |
| | | { |
| | | 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]; |
| | | //数据返序列化为Logic对象 |
| | | 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 { } |
| | | |
| | | |
| | | } |
| | | catch { } |
| | | finally |
| | | { |
| | | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | action(); |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | ThreadSend(new Control { deviceId = pirDevice.deviceId }, (responsePackNew) => |
| | | { |
| | | var jArray = JArray.Parse(responsePackNew.Data.ToString()); |
| | | for (int a = 0; a < jArray.Count; a++) |
| | | { |
| | | var jay = jArray[a]; |
| | | //数据返序列化为Logic对象 |
| | | 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.deviceId == pirJosn.deviceId)) |
| | | { |
| | | pirDevice.FunctioList.Add(pirJosn); |
| | | } |
| | | } |
| | | } |
| | | action(); |
| | | }, "获取遥控器列表", "frame", frame, null); |
| | | |
| | | } |
| | | /// <summary> |
| | |
| | | /// <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(() => |
| | | ThreadSend(control, (responsePackNew) => |
| | | { |
| | | 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 { } |
| | | finally |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | loading.Hide(); |
| | | action(function); |
| | | }); |
| | | } |
| | | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | var function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString()); |
| | | action(function); |
| | | }, "获取设备详情", "frame", frame, null); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 发送命令线程 |
| | | /// </summary> |
| | |
| | | |
| | | responsePackNew = PirSend.DeviceRename(control.deviceId, control.name); |
| | | } |
| | | else if (str == "删除按键") { |
| | | // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name); |
| | | else if (str == "删除按键") |
| | | { |
| | | // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name); |
| | | } |
| | | else if (str == "获取设备详情") |
| | | { |
| | | // 获取设备详情通过(spk,sid) |
| | | responsePackNew = PirSend.GetinfoBySid(control); |
| | | } |
| | | else if (str == "获取遥控器列表") |
| | | { |
| | | responsePackNew = PirSend.ControlList(control.deviceId); |
| | | } |
| | | } |
| | | catch { } |
| | |
| | | str = buttondata; |
| | | } |
| | | |
| | | if (!string.IsNullOrEmpty(controldata)) |
| | | if (!string.IsNullOrEmpty(str)) |
| | | { |
| | | try |
| | | { |