| | |
| | | /// 记录接收到的消息,方便zb的工程师调试他们的设备 |
| | | /// </summary> |
| | | public List<string> MsgInfoList = new List<string>(); |
| | | private bool _LocalTcpClientLogin = false; |
| | | /// <summary> |
| | | /// 本地tcp客户端连接是否成功 |
| | | /// 是否登录网关成功 |
| | | /// </summary> |
| | | public bool LocalTcpClientLogin = false; |
| | | public bool LocalTcpClientLogin |
| | | { |
| | | get |
| | | { |
| | | return _LocalTcpClientLogin; |
| | | } |
| | | set |
| | | { |
| | | _LocalTcpClientLogin = value; |
| | | if (!value) |
| | | { |
| | | loginGatewayThread?.Abort(); |
| | | loginGatewayThread = null; |
| | | } |
| | | } |
| | | } |
| | | |
| | | int _msg_id = 1; |
| | | /// <summary> |
| | |
| | | if (myTcpClient == null) |
| | | { |
| | | myTcpClient = new Control_TcpClient(reportIp); |
| | | myTcpClient.Connect(); |
| | | } |
| | | myTcpClient.Connect(); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | if(loginGatewayThread== null) |
| | | { |
| | | loginGatewayThread = new System.Threading.Thread(() => { |
| | | while (true) |
| | | while (!Ins.myTcpClient.isConnected) |
| | | { |
| | | if (Ins.GatewayOnline_Local && myTcpClient.isConnected && LocalTcpClientLogin) |
| | | if (Ins.GatewayOnline_Local && myTcpClient.isConnected) |
| | | { |
| | | var sendData = new { clientType = "app", version = "1.0" }; |
| | | var sendJob = new { id = Control.Ins.msg_id.ToString(), time_stamp = Utlis.GetTimestamp(), objects = sendData }; |
| | |
| | | } |
| | | System.Threading.Thread.Sleep(2000); |
| | | } |
| | | //loginGatewayThread?.Abort(); |
| | | //loginGatewayThread = null; |
| | | |
| | | }); |
| | | loginGatewayThread.Start(); |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | loginGatewayThread?.Abort(); |
| | | }catch (Exception ex) |
| | | { |
| | | MainPage.Log($"重启登录网关线程异常:{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | loginGatewayThread = null; |
| | | LoginGateway(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, aLinkData.id,0); |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取音乐目录 |
| | | /// </summary> |
| | | public void GetMusicDirectory(Function function) |
| | | { |
| | | if (Ins.GatewayOnline_Local) |
| | | { |
| | | var objects = new List<Dictionary<string, string>>(); |
| | | var readKey = new Dictionary<string, string>(); |
| | | readKey.Add("sid", function.sid); |
| | | objects.Add(readKey); |
| | | var readDataObj = new AlinkReadFunctionStatusObj() |
| | | { |
| | | id = Ins.msg_id.ToString(), |
| | | objects = objects, |
| | | time_stamp = Utlis.GetTimestamp() |
| | | }; |
| | | var functionControlDataJson = Newtonsoft.Json.JsonConvert.SerializeObject(readDataObj); |
| | | var sendBytes = Ins.ConvertSendBodyData($"/base/{DB_ResidenceData.Instance.HomeGateway.gatewayId}/thing/service/MusicPlayGroupListGet/down", functionControlDataJson); |
| | | MainPage.Log($"本地通讯 发送HDL-Link数据:{functionControlDataJson}"); |
| | | new Control_Udp().SendLocalHdlLinkData(sendBytes, readDataObj.id); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 网关进入配网模式 |
| | | /// </summary> |
| | |
| | | { |
| | | LocalCommunicationData receiveObj = new LocalCommunicationData(); |
| | | |
| | | MainPage.Log($"局域网信息: \r\n{receiveString}"); |
| | | |
| | | var res = receiveString.Split("\r\n\r\n"); |
| | | |
| | |
| | | //} |
| | | receiveObj.BodyDataString = res[1]; |
| | | |
| | | if(receiveObj.Topic == CommunicationTopic.ct.HeartBeat) |
| | | if (receiveObj.Topic == CommunicationTopic.ct.HeartBeat + "_reply") |
| | | { |
| | | |
| | | Ins.myTcpClient.ClearHeartBeatLog(); |
| | | MainPage.Log("tcp心跳回复"); |
| | | return null; |
| | | } |
| | | |
| | |
| | | //判断当前网关是否开启了本地加密 |
| | | if (IsLocalEncryptAndGetAesKey) |
| | | { |
| | | MainPage.Log($"局域网信息 开始解密"); |
| | | if (originalReceiveBytes != null) |
| | | { |
| | | //拿到原始Bytes数据去解密 |
| | |
| | | //MainPage.Log($"局域网信息: 解密后:" + receiveObj.BodyDataString); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | MainPage.Log($"局域网信息: 明文:" + receiveObj.BodyDataString); |
| | | } |
| | | } |
| | | |
| | |
| | | //2021-09-23 新增获取当前网关是否本地加密 |
| | | Ins.IsLocalEncrypt = device.isLocalEncrypt; |
| | | //MainPage.Log("网关本地加密状态:" + device.local_encrypt.ToString()); |
| | | |
| | | //登录网关Tcp |
| | | OpenTcpClent(); |
| | | |
| | | LoginGateway(); |
| | | |
| | | } |
| | | } |
| | |
| | | if (temp.GetValue("objects").ToString().Contains("success")) |
| | | { |
| | | LocalTcpClientLogin = true; |
| | | try |
| | | { |
| | | loginGatewayThread?.Abort(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"终止登录网关tcp异常:{ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | loginGatewayThread = null; |
| | | } |
| | | MainPage.Log("局域网tcp连接登录网关成功"); |
| | | } |
| | | } |
| | | else |
| | |
| | | // 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); |
| | | Console.WriteLine("音乐播放器添加缓存数据=======" + revString); |
| | | |
| | | } |
| | | |
| | | //更新界面状态 |
| | | switch (localFunction.spk) |
| | | { |
| | | case SPK.AcstParent: |
| | | AcstParentPage.UpdateAcstParentInfo(localFunction); |
| | | break; |
| | | case SPK.AcstSub: |
| | | AcstParentPage.UpdateAcstSubInfo(localFunction); |
| | | AcstSubPage.UpdateStatus(localFunction); |
| | | break; |
| | | case SPK.AirSwitch: |
| | | AirSwitchPage.UpdataState(localFunction); |
| | | if(localFunction.GetAttribute(FunctionAttributeKey.Power)!=null)//如果是带电量的空开也要更新能源界面 |
| | |
| | | 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) + "%"; |
| | |
| | | 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: |
| | |
| | | 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.SensorGas: |
| | | case SPK.HvacCac: |
| | | case SPK.SensorHelp: |
| | | case SPK.MechanicalArm: |
| | | //设备状态推送 |
| | | //状态更新 |
| | | 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) |
| | |
| | | case SPK.AvMusic: |
| | | case SPK.MusicStandard: |
| | | //UI.Music.MusicMain.mMusicMain.RefreshView(updateTemp); |
| | | //Console.WriteLine("音乐播放器显示状态======="+ revString); |
| | | Console.WriteLine("音乐播放器显示状态======="+ revString); |
| | | //wjc |
| | | break; |
| | | case SPK.Inverter: |
| | | case SPK.InverterRst: |
| | | var status = new Dictionary<string, object> { ["method"] = "status", ["data"] = temp.objects }; |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | Inverter.Ins.H5Page.CallJS($"nativeToJs(\'{Newtonsoft.Json.JsonConvert.SerializeObject(status)}\')"); |
| | | }); |
| | | break; |
| | | } |
| | | |
| | | HomePage.UpdataFunctionStates(localFunction); |