| | |
| | | { |
| | | if (_gatewayOnline != value) |
| | | { |
| | | _gatewayOnline = value; |
| | | //修改主页连接状态 |
| | | UI.HomePage.LoadEvent_CheckLinkStatus(); |
| | | if (value) |
| | | if(value) |
| | | { |
| | | if (IsRemote)//如果是远程 |
| | | { |
| | | 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; |
| | | } |
| | | } |
| | | _gatewayOnline = value; |
| | | //修改主页连接状态 |
| | | HomePage.LoadEvent_CheckLinkStatus(); |
| | | MainPage.Log($"网关在线,刷新设备状态"); |
| | | new System.Threading.Thread(() => |
| | | { |
| | |
| | | FunctionList.List.ReadAllFunctionStatus(); |
| | | }) |
| | | { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start(); |
| | | } |
| | | else |
| | | { |
| | | _gatewayOnline = value; |
| | | //修改主页连接状态 |
| | | HomePage.LoadEvent_CheckLinkStatus(); |
| | | } |
| | | } |
| | | } |
| | |
| | | /// </summary> |
| | | public string GatewayId = ""; |
| | | |
| | | bool _isRemote = false; |
| | | /// <summary> |
| | | /// 是否为远程连接 |
| | | /// </summary> |
| | | public bool IsRemote |
| | | { |
| | | get |
| | | { |
| | | return _isRemote; |
| | | } |
| | | set |
| | | { |
| | | _isRemote = value; |
| | | //修改主页连接状态 |
| | | HomePage.LoadEvent_CheckLinkStatus(); |
| | | } |
| | | } |
| | | public bool IsRemote = false; |
| | | /// <summary> |
| | | /// 通讯地址IP |
| | | /// </summary> |
| | |
| | | /// </summary> |
| | | public void SearchLoaclGateway() |
| | | { |
| | | MainPage.Log($"搜索本地网关列表,网关类型:{DB_ResidenceData.Instance.GatewayType}"); |
| | | var ggg = DB_ResidenceData.Instance.GatewayType == 0 ? "一端口" : "A网关"; |
| | | var ggg1 = MainPage.InternetStatus == 1 ? "4G" : "wifi"; |
| | | MainPage.Log($"搜索网关列表,网关类型:{ggg};网络类型:{ggg1}"); |
| | | if (MainPage.InternetStatus == 0) |
| | | { |
| | | Ins.GatewayOnline = false; |
| | |
| | | { |
| | | if (Ins.IsRemote || DB_ResidenceData.Instance.GatewayType == 1) |
| | | { |
| | | ControlAProtocolScene(scene); |
| | | new System.Threading.Thread(() => |
| | | { |
| | | ControlAProtocolScene(scene); |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | else |
| | | { |
| | |
| | | /// <returns></returns> |
| | | public void SendWriteCommand(Function function, Dictionary<string, string> commandDictionary) |
| | | { |
| | | function.usageCount++; |
| | | function.controlCounter++; |
| | | function.refreshTime = DateTime.Now; |
| | | |
| | | //如果是控制调光的开时,亮度值不能为0 |
| | |
| | | } |
| | | } |
| | | |
| | | MainPage.Log($"发送数据:{Newtonsoft.Json.JsonConvert.SerializeObject(commandDictionary)}"); |
| | | |
| | | //远程通讯 |
| | | if (Ins.IsRemote) |
| | | { |
| | |
| | | var actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | actionObjs.Add(apiControlData); |
| | | var pack = httpServer.ControlDevice(actionObjs); |
| | | //MainPage.Log($"{pack.Code}:{pack.Data}"); |
| | | } |
| | | //本地通讯 |
| | | else |
| | |
| | | MainPage.Log($"发送HDL-Link数据:{functionControlDataJson}"); |
| | | } |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 全开全关功能 |
| | | /// </summary> |
| | | public void SwtichFunctions(bool open,List<Function> functions) |
| | | { |
| | | var count = 0; |
| | | var logString = open ? "打开\r\n" : "关闭\r\n"; |
| | | List<ApiAlinkControlActionObj> actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | Dictionary<string, string> d = new Dictionary<string, string>(); |
| | | d.Add(FunctionAttributeKey.OnOff, open ? "on" : "off"); |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | foreach (var temp in functions) |
| | | { |
| | | logString += temp.spk + ":" + temp.sid + "\r\n"; |
| | | var apiControlData = temp.GetApiControlData(d); |
| | | actionObjs.Add(apiControlData); |
| | | count++; |
| | | if (count > 9) |
| | | { |
| | | var result = pm.ControlDevice(actionObjs); |
| | | actionObjs = new List<ApiAlinkControlActionObj>(); |
| | | count = 0; |
| | | MainPage.Log(logString); |
| | | logString = ""; |
| | | } |
| | | } |
| | | var pack = pm.ControlDevice(actionObjs); |
| | | MainPage.Log(logString); |
| | | } |
| | | |
| | | public void SendApiReadCommand(List<string> functionIds) |
| | |
| | | { |
| | | if (Ins.IsRemote) |
| | | { |
| | | var pm = new HDL_ON.DAL.Server.HttpServerRequest(); |
| | | pm.ExecuteScene(scene.userSceneId); |
| | | var pm = new DAL.Server.HttpServerRequest(); |
| | | var result = pm.ExecuteScene(scene.userSceneId); |
| | | } |
| | | else |
| | | { |
| | |
| | | var device = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceModule>(bodyJObj.objects.ToString()); |
| | | if (device.device_mac == DB_ResidenceData.Instance.residenceGatewayMAC) |
| | | { |
| | | //本地搜索网关成功 |
| | | MainPage.Log("本地搜索网关成功"); |
| | | Control.Ins.IsSearchLocalGatewaySuccessful = true; |
| | | Ins.GatewayOnline = true; |
| | | if (!string.IsNullOrEmpty(device.gatewayId)) |
| | |
| | | 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: |