| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using HDL_ON.DAL.Mqtt; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.UI; |
| | |
| | | /// <summary> |
| | | /// 判断是否本地加密并且加密key不为空 |
| | | /// </summary> |
| | | public bool IsLocalEncryptAndGetAesKey { |
| | | get { |
| | | public bool IsLocalEncryptAndGetAesKey |
| | | { |
| | | get |
| | | { |
| | | return IsLocalEncrypt && (!string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.localSecret)); |
| | | } |
| | | } |
| | |
| | | HomePage.LoadEvent_CheckLinkStatus(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | MainPage.Log($"状态一致,不更新数据(本地)"); |
| | | } |
| | | } |
| | | } |
| | | bool _GatewayOnline_Cloud = false; |
| | |
| | | } |
| | | 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(); |
| | | int count = 20; |
| | | while (true) |
| | | { |
| | | System.Threading.Thread.Sleep(500); |
| | | if (MqttClient.isSubscribeSuccess || count<1) |
| | | { |
| | | break; |
| | | } |
| | | count--; |
| | | } |
| | | 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(); |
| | | MainPage.Log($"状态一致,不更新数据(云端)"); |
| | | } |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"Set GatewayCloudOnline Error:{ex.Message}"); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | public void OpenTcpClent() |
| | | { |
| | | return; |
| | | if (myTcpClient == null) |
| | | { |
| | | myTcpClient = new Control_TcpClient(reportIp); |
| | |
| | | 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; |
| | | } |
| | |
| | | } |
| | | else if (MainPage.InternetStatus == 2) |
| | | { |
| | | DAL.Mqtt.MqttClient.InitState(); |
| | | OpenUdp(DB_ResidenceData.Instance.GatewayType == 0 ? 6000 : 8585); |
| | | //重置搜索网关标志 |
| | | IsSearchLocalGatewaySuccessful = false; |
| | |
| | | System.Threading.Thread.Sleep(500); |
| | | } |
| | | |
| | | DAL.Mqtt.MqttClient.InitState(); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | |
| | | /// </summary> |
| | | public void LoginGateway() |
| | | { |
| | | if(loginGatewayThread== null) |
| | | return;//tcp控制存在问题,但是先不用tcp控制了,要经过测试先 2023-07-29 10:14:32 |
| | | if (loginGatewayThread == null) |
| | | { |
| | | loginGatewayThread = new System.Threading.Thread(() => { |
| | | loginGatewayThread = new System.Threading.Thread(() => |
| | | { |
| | | while (!Ins.myTcpClient.isConnected) |
| | | { |
| | | if (Ins.GatewayOnline_Local && myTcpClient.isConnected) |
| | |
| | | try |
| | | { |
| | | loginGatewayThread?.Abort(); |
| | | }catch (Exception ex) |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"重启登录网关线程异常:{ex.Message}"); |
| | | } |
| | |
| | | LoginGateway(); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | public void ControlScene(Scene scene) |
| | | { |
| | | //体验模式 |
| | | if(MainPage.NoLoginMode) |
| | | if (MainPage.NoLoginMode) |
| | | { |
| | | foreach(var sceneFunction in scene.functions) |
| | | foreach (var sceneFunction in scene.functions) |
| | | { |
| | | var revString = ""; |
| | | var upDataObj = new AlinkFunctionStatusObj(); |
| | |
| | | /// <param name="function"></param> |
| | | /// <param name="useRemote">是否直接使用远程发送</param> |
| | | /// <returns></returns> |
| | | public bool 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; |
| | |
| | | UpdataFunctionStatus(revString, null, true); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | //MainPage.Log($"发送数据:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}"); |
| | | |
| | |
| | | var functionControlDataObj = function.GetGatewayAlinkControlData(commandDictionary); |
| | | var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj); |
| | | var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id,resend); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, resend); |
| | | MainPage.Log($"本地通讯 发送HDL-Link数据:{functionControlDataJson}"); |
| | | //Ins.myTcpClient.SendMessage(sendBytes); |
| | | } |
| | | } |
| | | //远程通讯 |
| | |
| | | commandDictionary.Add(FunctionAttributeKey.OnOff, commandDictionary[FunctionAttributeKey.Brightness] == "0" ? "off" : "on"); |
| | | } |
| | | } |
| | | if(function.spk == SPK.LightCCT) |
| | | if (function.spk == SPK.LightCCT) |
| | | { |
| | | if (!commandDictionary.ContainsKey(FunctionAttributeKey.CCT)) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 全开全关功能 |
| | | /// </summary> |
| | | public void SwtichFunctions(bool open,List<Function> functions) |
| | | public void SwtichFunctions(bool open, List<Function> functions) |
| | | { |
| | | //dome模式控制 |
| | | if(MainPage.NoLoginMode) |
| | | if (MainPage.NoLoginMode) |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | |
| | | { |
| | | Dictionary<string, string> d1 = new Dictionary<string, string>(); |
| | | d1.Add(FunctionAttributeKey.OnOff, open ? "on" : "off"); |
| | | if (function.spk == SPK.PanelSocket) |
| | | if (function.spk == SPK.PanelSocket) |
| | | { |
| | | if (function.attributes.Find((obj) => obj.key == "on_off_usb") != null) |
| | | { |
| | |
| | | { |
| | | foreach (var temp in functions) |
| | | { |
| | | if((temp.trait_on_off.state.ToString() == "on" && open)|| temp.trait_on_off.state.ToString() == "off"&& !open) |
| | | { |
| | | continue; |
| | | } |
| | | var apiControlData = temp.GetApiControlData(d); |
| | | actionObjs.Add(apiControlData); |
| | | count++; |
| | |
| | | System.Threading.Thread.Sleep(100); |
| | | } |
| | | } |
| | | var pack = pm.ControlDevice(actionObjs); |
| | | if (actionObjs.Count > 0) |
| | | { |
| | | var pack = pm.ControlDevice(actionObjs); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | var pack = pm.GetDeviceInfoList(functionIds); |
| | | if(pack!= null&& pack.Data!=null) |
| | | if (pack != null && pack.Data != null) |
| | | { |
| | | //待测试2021-03-04 |
| | | var ddd = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AlinkStatusData>>(pack.Data.ToString()); |
| | | if(ddd!= null) |
| | | if (ddd != null) |
| | | { |
| | | foreach(var function in ddd) |
| | | foreach (var function in ddd) |
| | | { |
| | | var temp = FunctionList.List.GetDeviceFunctionList().Find((obj) => obj.deviceId == function.deviceId); |
| | | if(temp!= null) |
| | | if (temp != null) |
| | | { |
| | | if (SPK.Get3tySpk(SPK.BrandType.Tuya).Contains(temp.spk)) |
| | | { |
| | |
| | | /// 发送读取命令 |
| | | /// 自动判断是否为A协议设备 |
| | | /// </summary> |
| | | public void SendReadCommand(Function function ,bool forceRemote = false) |
| | | public void SendReadCommand(Function function, bool forceRemote = false) |
| | | { |
| | | function.refreshTime = DateTime.Now; |
| | | if (forceRemote) |
| | |
| | | } |
| | | else |
| | | { |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId }); |
| | | var pm = new HttpServerRequest(); |
| | | try |
| | | { |
| | | pm.RefreshDeviceStatus(new List<string>() { function.deviceId }); |
| | | }catch(Exception ex) |
| | | { |
| | | MainPage.Log($"远程读取设备状态异常:{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | pm = null; |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | busClient.ReadBusData(function); |
| | | } |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 安防控制 |
| | | /// </summary> |
| | | public void ControlSecurity(SecurityAlarm securityAlarm,string state) |
| | | public void ControlSecurity(SecurityAlarm securityAlarm, string state) |
| | | { |
| | | if (!Ins.GatewayOnline_Local)//网关本地不在线 |
| | | { |
| | |
| | | }, |
| | | time_stamp = Utlis.GetTimestamp() |
| | | }; |
| | | var aLinkJson = Newtonsoft.Json.JsonConvert.SerializeObject(aLinkData); |
| | | var aLinkJson = JsonConvert.SerializeObject(aLinkData); |
| | | var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlScene, aLinkJson); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id,0); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id, 0); |
| | | } |
| | | } |
| | | |
| | |
| | | /// 转换接收到的数据 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public void ConvertReceiveData(byte[] receiveBytes,string ip) |
| | | public void ConvertReceiveData(byte[] receiveBytes, string ip) |
| | | { |
| | | if (!UserInfo.Current.IsLogin) |
| | | { |
| | | return; |
| | | } |
| | | var reString = Encoding.UTF8.GetString(receiveBytes); |
| | | AnalysisReceiveData(reString, receiveBytes,ip); |
| | | AnalysisReceiveData(reString, receiveBytes, ip); |
| | | } |
| | | /// <summary> |
| | | /// 转换接收到的数据 |
| | |
| | | /// <param name="receiveString">转String后的数据</param> |
| | | /// <param name="originalReceiveBytes"原始Bytes数据</param> |
| | | /// <returns></returns> |
| | | public LocalCommunicationData AnalysisReceiveData(string receiveString, byte[] originalReceiveBytes , string sIp = null) |
| | | public LocalCommunicationData AnalysisReceiveData(string receiveString, byte[] originalReceiveBytes, string sIp = null) |
| | | { |
| | | |
| | | LocalCommunicationData receiveObj = new LocalCommunicationData(); |
| | | |
| | | |
| | |
| | | |
| | | if (receiveObj.Topic == CommunicationTopic.ct.HeartBeat + "_reply") |
| | | { |
| | | Ins.myTcpClient.ClearHeartBeatLog(); |
| | | //Ins.myTcpClient.ClearHeartBeatLog(); |
| | | MainPage.Log("tcp心跳回复"); |
| | | return null; |
| | | } |
| | |
| | | //2021-09-23 新增获取当前网关是否本地加密 |
| | | Ins.IsLocalEncrypt = device.isLocalEncrypt; |
| | | //MainPage.Log("网关本地加密状态:" + device.local_encrypt.ToString()); |
| | | |
| | | OpenTcpClent(); |
| | | //登录网关Tcp |
| | | //OpenTcpClent(); |
| | | |
| | | |
| | | } |
| | | } |
| | | 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)) |
| | | { |
| | | //TODO 暂时不传正确的数据上去,如果后面要优化前面这些代码 |
| | | //Console.WriteLine($"{receiveObj.Topic}\r\n{receiveObj.BodyDataString}"); |
| | | UpdataFunctionStatus(receiveObj.BodyDataString, null); |
| | | } |
| | | else if (receiveObj.Topic == CommunicationTopic.ct.ControlSeurity + "_reply" |
| | |
| | | MainPage.Log($"安防局域网异常:{ex.Message}"); |
| | | } |
| | | } |
| | | else if (receiveObj.Topic == $"/user/{GatewayId}/custom/gateway/login_reply") { |
| | | else if (receiveObj.Topic == $"/user/{GatewayId}/custom/gateway/login_reply") |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<JObject>(receiveObj.BodyDataString); |
| | | if (temp.GetValue("objects").ToString().Contains("success")) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | if(processedDataList.Count> 50) |
| | | if (processedDataList.Count > 50) |
| | | { |
| | | processedDataList.RemoveAt(0); |
| | | } |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 更新群控设备状态 |
| | | /// A协议数据 |
| | | /// </summary> |
| | | 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> |
| | | /// <param name="updateBytes"></param> |
| | | public void UpdataFunctionStatus(string revString, byte[] usefulBytes,bool isCloudData = false) |
| | | public void UpdataFunctionStatus(string revString, byte[] usefulBytes, bool isCloudData = false) |
| | | { |
| | | ////test 云端连接成功时,不适用本地数据更新 |
| | | //if (Ins.GatewayOnline_Cloud && !isCloudData) |
| | |
| | | // return; |
| | | //} |
| | | |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString); |
| | | var temp = JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString); |
| | | if (temp != null) |
| | | { |
| | | Control_Udp.ReceiveRepeatManager(temp.id, usefulBytes); |
| | |
| | | } |
| | | MainPage.Log(localFunction.name); |
| | | |
| | | if (Ins.GatewayOnline_Local && isCloudData)//本地链接,除了涂鸦设备数据之外的云端数据不处理 |
| | | { |
| | | if (!SPK.Get3tySpk(SPK.BrandType.All3tyBrand).Contains(localFunction.spk) && !SPK.MusicSpkList().Contains( localFunction.spk)) |
| | | { |
| | | //MainPage.Log($"A协议更新状态:本地链接,除了涂鸦设备数据之外的云端数据不处理........"); |
| | | |
| | | return; |
| | | } |
| | | } |
| | | |
| | | //if (SPK.MusicSpkList().Contains(localFunction.spk)) |
| | | //{ |
| | | // if (updateTemp.status.Count < 3) |
| | |
| | | // return; |
| | | // } |
| | | //} |
| | | //MainPage.Log($"A协议更新状态:{revString}"); |
| | | MainPage.Log($"收到数据:{revString}"); |
| | | foreach (var attr in updateTemp.status) |
| | | { |
| | | localFunction.time_stamp = temp.time_stamp; |
| | | localFunction.SetAttrState(attr.key, attr.value); |
| | | //Console.WriteLine("音乐播放器添加缓存数据=======" + revString); |
| | | |
| | | |
| | | } |
| | | if(localFunction.spk == SPK.AirSwitchP3) |
| | | { |
| | | localFunction.online = updateTemp.online; |
| | | } |
| | | if (SPK.LightSpkList().Contains(localFunction.spk)) |
| | | { |
| | | localFunction.updateTime = DateTime.Now; |
| | | } |
| | | |
| | | |
| | | //更新界面状态 |
| | | switch (localFunction.spk) |
| | |
| | | break; |
| | | case SPK.AirSwitch: |
| | | AirSwitchPage.UpdataState(localFunction); |
| | | if(localFunction.GetAttribute(FunctionAttributeKey.Power)!=null)//如果是带电量的空开也要更新能源界面 |
| | | if (localFunction.GetAttribute(FunctionAttributeKey.Power) != null)//如果是带电量的空开也要更新能源界面 |
| | | { |
| | | EnergyMainPage.UpdataStatus(localFunction); |
| | | } |
| | | break; |
| | | case SPK.AirSwitchP3: |
| | | AirSwitchP3Page.UpdataState(localFunction); |
| | | AirSwitchP3SubloopEnergyPage.UpdataStatus(localFunction); |
| | | break; |
| | | case SPK.ElectricEnergy: |
| | | EnergyMainPage.UpdataStatus(localFunction); |
| | |
| | | RGBPage.UpdataStates(localFunction); |
| | | break; |
| | | case SPK.LightRGBW: |
| | | localFunction.lastState = Language.StringByID(StringId.Brightness) + " : " + localFunction.GetAttrState(FunctionAttributeKey.Brightness) + "%"; |
| | | RGBWPage.UpdataStates(localFunction); |
| | | break; |
| | | case SPK.LightCCT: |
| | | localFunction.lastState = Language.StringByID(StringId.Brightness) + " : " + localFunction.GetAttrState(FunctionAttributeKey.Brightness) + "%"; |
| | |
| | | CurtainModulePage.UpdataState(localFunction); |
| | | break; |
| | | case SPK.CurtainDream: |
| | | if(localFunction.GetAttrState(FunctionAttributeKey.Percent) == "0") |
| | | if (localFunction.GetAttrState(FunctionAttributeKey.Percent) == "0") |
| | | { |
| | | localFunction.SetAttrState(FunctionAttributeKey.OnOff, "off"); |
| | | } |
| | |
| | | RollingShutterPage.UpdataState(localFunction); |
| | | break; |
| | | case SPK.CurtainShades: |
| | | localFunction.lastState = Language.StringByID(StringId.Open) + localFunction.GetAttrState(FunctionAttributeKey.Percent) + "%"; |
| | | VenetianBlindsPage.UpdataState(localFunction); |
| | | break; |
| | | case SPK.AcStandard: |
| | | case SPK.HvacAC: |
| | |
| | | FloorHeatingPage.UpdataStates(localFunction); |
| | | break; |
| | | case SPK.SensorPm25: |
| | | case SPK.SensorPm10: |
| | | case SPK.SensorCO2: |
| | | case SPK.SensorTVOC: |
| | | case SPK.SensorTemperature: |
| | | case SPK.SensorHumidity: |
| | | case SPK.SensorHcho: |
| | | if(localFunction.spk == SPK.SensorTemperature) |
| | | case SPK.SensorLight: |
| | | if (localFunction.spk == SPK.SensorTemperature) |
| | | { |
| | | HomePage.LoadEvent_RefreshEnvirIndoorTemp(); |
| | | } |
| | |
| | | EnvironmentalPage.LoadEvent_UpdataStatus(localFunction); |
| | | //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(localFunction); |
| | | break; |
| | | case SPK.SensorEnvironment: |
| | | case SPK.SensorEnvironment:case SPK.SensorEnvironmentHailin: |
| | | case SPK.SensorEnvironment2: |
| | | case SPK.SensorEnvironment3: |
| | | if (localFunction.GetAttributes().Contains(FunctionAttributeKey.Temperature)) |
| | |
| | | case SPK.ElectricTuyaWeepRobot2: |
| | | case SPK.ElectricTuyaWaterValve: |
| | | case SPK.ElectricTuyaWaterValve2: |
| | | case SPK.SensorPir: |
| | | case SPK.SensorDoorWindow: |
| | | case SPK.SensorSmoke: |
| | | case SPK.SensorWater: |
| | |
| | | case SPK.SensorGas: |
| | | case SPK.HvacCac: |
| | | case SPK.SensorHelp: |
| | | case SPK.MechanicalArm: |
| | | //设备状态推送 |
| | | //状态更新 |
| | | Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status); |
| | | break; |
| | | case SPK.SensorPir: |
| | | case SPK.SensorPirHold: |
| | | var tempPirStatus = localFunction.attributes.Find((sta) => sta.key == "people_status"); |
| | | if (tempPirStatus != null) |
| | | { |
| | | if(tempPirStatus.state == "true") |
| | | { |
| | | localFunction.lastState = Language.StringByID(StringId.Someone); |
| | | } |
| | | else |
| | | { |
| | | localFunction.lastState = Language.StringByID(StringId.wuren); |
| | | } |
| | | } |
| | | Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status); |
| | | break; |
| | | case SPK.SenesorMegahealth: |
| | | case SPK.SenesorMegahealth2: |
| | | case SPK.SensorMmvPose: |
| | | |
| | | var tempStatus = localFunction.attributes.Find((sta) => sta.key == FunctionAttributeKey.TargetStatus); |
| | | if (tempStatus != null) |
| | |
| | | switch (tempStatus.state) |
| | | {//0空,1走,2跑,3坐,4跌倒,5站 |
| | | case "0": |
| | | localFunction.lastState = Language.StringByID(StringId.SensorNormalState); |
| | | localFunction.lastState = Language.StringByID(StringId.wuren); |
| | | break; |
| | | case "1": |
| | | localFunction.lastState = Language.StringByID(StringId.SomeoneIn); |
| | |
| | | case SPK.AvMusic: |
| | | case SPK.MusicStandard: |
| | | //UI.Music.MusicMain.mMusicMain.RefreshView(updateTemp); |
| | | //Console.WriteLine("音乐播放器显示状态======="+ revString); |
| | | Console.WriteLine("音乐播放器显示状态=======" + revString); |
| | | foreach (var music in UI.Music.A31MusicModel.A31MusicModelList)//每次收到数据都要更新一下时间 |
| | | { |
| | | if (music.functionMusic.sid == localFunction.sid) |
| | | { |
| | | music.LastDateTime = DateTime.Now; |
| | | } |
| | | } |
| | | if (UI.Music.A31MusicModel.Current != null) |
| | | { |
| | | UI.Music.A31MusicModel.Current.LastDateTime = DateTime.Now; |
| | | } |
| | | //wjc |
| | | break; |
| | | case SPK.Inverter: |
| | | MainPage.Log("逆变器数据更新"); |
| | | case SPK.InverterRst: |
| | | var status = new Dictionary<string, object> { ["method"] = "status", ["data"] = temp.objects }; |
| | | MainPage.Log("逆变器数据更新1"); |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | Inverter.Ins.H5Page.CallJS($"nativeToJs(\'{Newtonsoft.Json.JsonConvert.SerializeObject(status)}\')"); |
| | | }); |
| | | MainPage.Log("逆变器数据更新2"); |
| | | break; |
| | | } |
| | | |
| | | |
| | | HomePage.UpdataFunctionStates(localFunction); |
| | | RoomPage.UpdataStates(localFunction); |
| | | FunctionPage.UpdataStates(localFunction); |
| | |
| | | /// <summary> |
| | | /// //一键(远程)开锁 |
| | | /// </summary> |
| | | public void OneKeyUnlocking(Function doorlock,string extStr) |
| | | public void OneKeyUnlocking(Function doorlock, string extStr) |
| | | { |
| | | if (Ins.GatewayOnline_Local) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | var functionControlDataObj = doorlock.GetGatewayAlinkDoorlockData(UserInfo.Current.ID,extStr); |
| | | var functionControlDataObj = doorlock.GetGatewayAlinkDoorlockData(UserInfo.Current.ID, extStr); |
| | | var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj); |
| | | var sendBytes = Ins.ConvertSendBodyData($"/base/{Control.Ins.GatewayId}/thing/service/doorRemoteOpen/down", functionControlDataJson); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id, 0); |
| | |
| | | /// </summary> |
| | | /// <param name="functionId"></param> |
| | | /// <param name="pwd"></param> |
| | | public void ConfirmUnlocking(string functionId,string pwd) |
| | | public void ConfirmUnlocking(string functionId, string pwd) |
| | | { |
| | | Loading loading = new Loading(); |
| | | MainPage.BaseView.AddChidren(loading); |
| | |
| | | //{ |
| | | // return false; |
| | | //} |
| | | if (pack.Code != StateCode.SUCCESS) { |
| | | Application.RunOnMainThread(() => { |
| | | 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)) |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | if (string.IsNullOrEmpty(pack.message)) |
| | | { |
| | | new PublicAssmebly().TipMsg(Language.StringByID(StringId.Tip), |
| | | Language.StringByID(StringId.OperationFailed)); |