| | |
| | | /// </summary> |
| | | public void ControlScene(Scene scene) |
| | | { |
| | | //远程或者控制link网关场景 |
| | | if (!Ins.GatewayOnline_Local || DB_ResidenceData.Instance.GatewayType == 1) |
| | | { |
| | | new System.Threading.Thread(() => |
| | |
| | | /// 发送读取命令 |
| | | /// 自动判断是否为A协议设备 |
| | | /// </summary> |
| | | public void SendReadCommand(Function function) |
| | | public void SendReadCommand(Function function ,bool forceRemote = false) |
| | | { |
| | | function.refreshTime = DateTime.Now; |
| | | if (Ins.GatewayOnline_Local) |
| | | if (forceRemote) |
| | | { |
| | | |
| | | if (DB_ResidenceData.Instance.GatewayType == 0) |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId }); |
| | | } |
| | | else |
| | | { |
| | | if (Ins.GatewayOnline_Local) |
| | | { |
| | | try |
| | | |
| | | if (DB_ResidenceData.Instance.GatewayType == 0) |
| | | { |
| | | new Control_Udp().ReadBusData(function); |
| | | try |
| | | { |
| | | new Control_Udp().ReadBusData(function); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"发送数据异常: {ex.Message}"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | else |
| | | { |
| | | MainPage.Log($"发送数据异常: {ex.Message}"); |
| | | var readKey = new Dictionary<string, string>(); |
| | | readKey.Add("sid", function.sid); |
| | | |
| | | var readDataObj = new AlinkReadFunctionStatusObj() |
| | | { |
| | | id = Ins.msg_id.ToString(), |
| | | objects = new List<Dictionary<string, string>>() |
| | | { |
| | | readKey |
| | | }, |
| | | time_stamp = Utlis.GetTimestamp() |
| | | }; |
| | | var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj); |
| | | var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ReadStatus, functionControlDataJson); |
| | | MainPage.Log($"本地通讯 发送HDL-Link数据:{functionControlDataJson}"); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var readKey = new Dictionary<string, string>(); |
| | | readKey.Add("sid", function.sid); |
| | | |
| | | var readDataObj = new AlinkReadFunctionStatusObj() |
| | | { |
| | | id = Ins.msg_id.ToString(), |
| | | objects = new List<Dictionary<string, string>>() |
| | | { |
| | | readKey |
| | | }, |
| | | time_stamp = Utlis.GetTimestamp() |
| | | }; |
| | | var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj); |
| | | var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ReadStatus, functionControlDataJson); |
| | | MainPage.Log($"本地通讯 发送HDL-Link数据:{functionControlDataJson}"); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id); |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId }); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId }); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | string sendDataString = topicString + lengthString + bodyDataString; |
| | | byte[] sendDataBytes = Encoding.ASCII.GetBytes(sendDataString); |
| | | //MainPage.Log($"转换HDL-Link数据\r\n{sendDataString}\r\n"); |
| | | MainPage.Log($"转换HDL-Link数据\r\n{sendDataString}\r\n"); |
| | | |
| | | return sendDataBytes; |
| | | } |
| | |
| | | { |
| | | Ins.GatewayId = device.device_mac; |
| | | } |
| | | reportIp = "239.0.168.188";// device.ip_address; |
| | | reportIp = "239.0.168.188";// device.ip_address;//主播地址也能控制设备 |
| | | } |
| | | } |
| | | else if (receiveObj.Topic == CommunicationTopic.ct.ReadStatus + "_reply" || |
| | |
| | | /// <param name="updateBytes"></param> |
| | | public void UpdataFunctionStatus(string revString, byte[] usefulBytes,bool isCloudData = false) |
| | | { |
| | | |
| | | if (Ins.GatewayOnline_Local && isCloudData)//本地链接,除了涂鸦设备数据之外的云端数据不处理 |
| | | { |
| | | if (FunctionList.List.GetDeviceFunctionList(SPK.BrandType.Tuya).Count == 0) |
| | | { |
| | | //MainPage.Log($"A协议更新状态:本地链接,除了涂鸦设备数据之外的云端数据不处理..."); |
| | | return; |
| | | } |
| | | } |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString); |
| | | if (temp != null) |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | if (Ins.GatewayOnline_Local && isCloudData)//本地链接,除了涂鸦设备数据之外的云端数据不处理 |
| | | { |
| | | if (FunctionList.List.OtherBrandFunction.Count != 0) |
| | | { |
| | | if (FunctionList.List.OtherBrandFunction.Find((obj) => obj.sid == updateTemp.sid) == null) |
| | | { |
| | | //MainPage.Log($"A协议更新状态:本地链接,除了涂鸦设备数据之外的云端数据不处理..."); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | var localFunction = allLocalFuntion.Find((obj) => obj.sid == updateTemp.sid); |
| | | if (localFunction == null) |
| | | { |
| | |
| | | Function localObj = null; |
| | | switch (localFunction.spk) |
| | | { |
| | | case SPK.ElectricEnergy: |
| | | EnergyMainPage.UpdataStatus(localFunction); |
| | | break; |
| | | case SPK.LightSwitch: |
| | | RelayPage.UpdataState(localFunction); |
| | | break; |
| | |
| | | case SPK.SensorTVOC: |
| | | case SPK.SensorTemperature: |
| | | case SPK.SensorHumidity: |
| | | if(localFunction.spk == SPK.SensorTemperature) |
| | | { |
| | | HomePage.LoadEvent_RefreshEnvirIndoorTemp(); |
| | | } |
| | | else if (localFunction.spk == SPK.SensorHumidity) |
| | | { |
| | | HomePage.LoadEvent_RefreshEnvirIndoorHumi(); |
| | | } |
| | | EnvironmentalPage.LoadEvent_UpdataStatus(localFunction); |
| | | break; |
| | | case SPK.ElectricSocket: |
| | |
| | | case SPK.SensorWater: |
| | | case SPK.ClothesHanger: |
| | | case SPK.AcIr: |
| | | case SPK.SenesorMegahealth: |
| | | //设备状态推送 |
| | | //状态更新 |
| | | Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status); |
| | | break; |
| | | } |