| | |
| | | /// 发送读取命令 |
| | | /// 自动判断是否为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 }); |
| | | } |
| | | } |
| | | |
| | |
| | | case SPK.SensorWater: |
| | | case SPK.ClothesHanger: |
| | | case SPK.AcIr: |
| | | case SPK.SenesorMegahealth: |
| | | //设备状态推送 |
| | | //状态更新 |
| | | Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status); |
| | | break; |
| | | } |