| | |
| | | } |
| | | set |
| | | { |
| | | if (_GatewayOnline_Cloud != value) |
| | | try |
| | | { |
| | | _GatewayOnline_Cloud = value; |
| | | if (GatewayOnline_Local) |
| | | if (_GatewayOnline_Cloud != value) |
| | | { |
| | | return; |
| | | } |
| | | if (value) |
| | | { |
| | | if (DB_ResidenceData.Instance.HomeGateway == null) |
| | | _GatewayOnline_Cloud = value; |
| | | if (GatewayOnline_Local) |
| | | { |
| | | return; |
| | | } |
| | | if (!DB_ResidenceData.Instance.HomeGateway.gatewayStatus)//远程情况下,网关未链接服务器不能修改主页网关状态 |
| | | if (value) |
| | | { |
| | | if (DB_ResidenceData.Instance.HomeGateway == null) |
| | | { |
| | | return; |
| | | } |
| | | if (!DB_ResidenceData.Instance.HomeGateway.gatewayStatus)//远程情况下,网关未链接服务器不能修改主页网关状态 |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | System.Threading.Thread.Sleep(3000); |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | pm.GetGatewayInfo(); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | return; |
| | | } |
| | | //修改主页连接状态 |
| | | HomePage.LoadEvent_CheckLinkStatus(); |
| | | MainPage.Log($"网关云端在线,刷新设备状态"); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | System.Threading.Thread.Sleep(3000); |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | pm.GetGatewayInfo(); |
| | | System.Threading.Thread.Sleep(1000); |
| | | FunctionList.List.ReadAllFunctionStatus(); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | return; |
| | | { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start(); |
| | | } |
| | | //修改主页连接状态 |
| | | HomePage.LoadEvent_CheckLinkStatus(); |
| | | MainPage.Log($"网关云端在线,刷新设备状态"); |
| | | new System.Threading.Thread(() => |
| | | else |
| | | { |
| | | System.Threading.Thread.Sleep(1000); |
| | | FunctionList.List.ReadAllFunctionStatus(); |
| | | }) |
| | | { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start(); |
| | | //修改主页连接状态 |
| | | HomePage.LoadEvent_CheckLinkStatus(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //修改主页连接状态 |
| | | HomePage.LoadEvent_CheckLinkStatus(); |
| | | } |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"Set GatewayCloudOnline Error:{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void SearchLoaclGateway() |
| | | { |
| | | //2021-01-15 : 住宅没有绑定网关的时候不用搜索,并且不能链接mqtt |
| | | if (DB_ResidenceData.Instance.HomeGateway == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.HomeGateway.gatewayId)) |
| | | if (DB_ResidenceData.Instance.HomeGateway == null || string.IsNullOrEmpty(DB_ResidenceData.Instance.HomeGateway.gatewayId) || |
| | | !UserInfo.Current.IsLogin) |
| | | { |
| | | return; |
| | | } |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | //MainPage.Log($"发送数据:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}"); |
| | | |
| | | ///第三方涂鸦设备统一使用远程控制 |
| | |
| | | var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, resend); |
| | | MainPage.Log($"本地通讯 发送HDL-Link数据:{functionControlDataJson}"); |
| | | Ins.myTcpClient.SendMessage(sendBytes); |
| | | } |
| | | } |
| | | //远程通讯 |
| | |
| | | } |
| | | } |
| | | else if (receiveObj.Topic == CommunicationTopic.ct.ReadStatus + "_reply" || |
| | | receiveObj.Topic == CommunicationTopic.ct.ControlFunctionTopic + "_reply" || |
| | | receiveObj.Topic == CommunicationTopic.ct.ControlFunctionTopic + "_reply" || |
| | | receiveObj.Topic == CommunicationTopic.ct.ControlGroupControlTopic + "_reply" || |
| | | receiveObj.Topic == CommunicationTopic.ct.GatewayUpStatus || |
| | | receiveObj.Topic.Contains(CommunicationTopic.ct.GatewayUpSortTopic)) |
| | | { |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 更新设备状态 |
| | | /// A协议数据 |
| | | /// </summary> |
| | | /// <param name="updateBytes"></param> |
| | | public void UpdataGroupControlStatus(string revString, byte[] usefulBytes, bool isCloudData = false) |
| | | { |
| | | var temp = JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString); |
| | | if (temp != null) |
| | | { |
| | | Control_Udp.ReceiveRepeatManager(temp.id, usefulBytes); |
| | | var allLocalFuntion = FunctionList.List.groupControls; |
| | | foreach (var updateTemp in temp.objects) |
| | | { |
| | | try |
| | | { |
| | | var localFunction = allLocalFuntion.Find((obj) => obj.sid == updateTemp.sid); |
| | | if (localFunction == null) |
| | | { |
| | | continue; |
| | | } |
| | | MainPage.Log($"收到数据:{revString}"); |
| | | foreach (var attr in updateTemp.status) |
| | | { |
| | | localFunction.time_stamp = temp.time_stamp; |
| | | localFunction.SetAttrState(attr.key, attr.value); |
| | | |
| | | } |
| | | |
| | | //更新界面状态 |
| | | switch (localFunction.spk) |
| | | { |
| | | case SPK.ElectricEnergy: |
| | | EnergyMainPage.UpdataStatus(localFunction); |
| | | break; |
| | | } |
| | | |
| | | HomePage.UpdataFunctionStates(localFunction); |
| | | RoomPage.UpdataStates(localFunction); |
| | | FunctionPage.UpdataStates(localFunction); |
| | | ClassificationPage.UpdataInfo(localFunction); |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"A协议更新状态异常:{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 更新设备状态 |
| | | /// A协议数据 |
| | | /// </summary> |
| | | public void UpdataFunctionStatus(string revString, byte[] usefulBytes, bool isCloudData = false) |
| | | { |
| | | ////test 云端连接成功时,不适用本地数据更新 |