| | |
| | | } |
| | | } |
| | | |
| | | ///// <summary> |
| | | ///// 改变通讯方式 |
| | | ///// </summary> |
| | | //public void ChangeCommunicationMode(CommunicationMode communicationMode) |
| | | //{ |
| | | // this.communicationMode = communicationMode; |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 搜索本地网关列表 |
| | | /// </summary> |
| | |
| | | //本地搜索不到网关 |
| | | if (!Ins.IsRemote) |
| | | { |
| | | //连接mqtt前,先断开--2020-12-21 |
| | | DAL.Mqtt.MqttClient.DisConnectRemote(); |
| | | Ins.IsRemote = true; |
| | | DAL.Mqtt.MqttClient.InitState(); |
| | | } |
| | |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | function.usageCount++; |
| | | function.refreshTime = DateTime.Now; |
| | | |
| | | //如果是控制调光的开时,亮度值不能为0 |
| | | if (commandDictionary.Count > 2) |
| | | { |
| | | if (commandDictionary.ContainsKey(FunctionAttributeKey.OnOff) && commandDictionary.ContainsKey(FunctionAttributeKey.Brightness)) |
| | | { |
| | | if (commandDictionary[FunctionAttributeKey.OnOff] == "on") |
| | | { |
| | | if (commandDictionary[FunctionAttributeKey.Brightness] == "0") |
| | | { |
| | | commandDictionary[FunctionAttributeKey.Brightness] = "100"; |
| | | } |
| | | } |
| | | if (commandDictionary[FunctionAttributeKey.OnOff] == "off") |
| | | { |
| | | if (commandDictionary[FunctionAttributeKey.Brightness] != "0") |
| | | { |
| | | commandDictionary[FunctionAttributeKey.Brightness] = "0"; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //远程通讯 |
| | | if (Ins.IsRemote) |
| | |
| | | var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(functionControlDataObj); |
| | | var sendBytes = Ins.ConvertSendBodyData(CommunicationTopic.ct.ControlFunctionTopic, functionControlDataJson); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, functionControlDataObj.id); |
| | | MainPage.Log($"发送HDL-Link数据:{functionControlDataJson}"); |
| | | } |
| | | } |
| | | } |
| | |
| | | }; |
| | | 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); |
| | | } |
| | | } |
| | |
| | | |
| | | 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; |
| | | } |
| | |
| | | break; |
| | | } |
| | | } |
| | | |
| | | MainPage.Log($"time 1 :{receiveObj.Topic}"); |
| | | |
| | | |
| | | //验证有效数据长度 |
| | | //if (res[1].Length != receiveObj.Length) |
| | | //{ |
| | |
| | | } |
| | | } |
| | | else if (receiveObj.Topic == CommunicationTopic.ct.ReadStatus + "_reply" || |
| | | receiveObj.Topic == CommunicationTopic.ct.ControlFunctionTopic + "_reply" || |
| | | receiveObj.Topic == CommunicationTopic.ct.GatewayUpStatus) |
| | | { |
| | | //TODO 暂时不传正确的数据上去,如果后面要优化前面这些代码 |
| | |
| | | localAttr.curValue = attr.value; |
| | | } |
| | | } |
| | | MainPage.Log($"{localSwitch.trait_on_off.curValue}: "); |
| | | //rgb.lastState = Language.StringByID(StringId.Brightness) + " : " + rgb.brightness + "%"; |
| | | RelayPage.UpdataState(localSwitch); |
| | | } |
| | | break; |
| | |
| | | } |
| | | } |
| | | lightCCT.lastState = Language.StringByID(StringId.Brightness) + " : " + lightCCT.brightness + "%"; |
| | | DimmerPage.UpdataStates(lightCCT); |
| | | ColorTureLampPage.UpdataStates(lightCCT); |
| | | } |
| | | break; |
| | | case SPK.CurtainSwitch: |