wxr
2023-04-18 e89eff06b335a16eaaa043b18f35f5463e1bc203
HDL_ON/DAL/DriverLayer/Control.cs
@@ -138,45 +138,51 @@
            }
            set
            {
                if (_GatewayOnline_Cloud != value)
                try
                {
                    _GatewayOnline_Cloud = value;
                    if (GatewayOnline_Local)
                    if (_GatewayOnline_Cloud != value)
                    {
                        return;
                    }
                    if (value)
                    {
                        if (DB_ResidenceData.Instance.HomeGateway == null)
                        _GatewayOnline_Cloud = value;
                        if (GatewayOnline_Local)
                        {
                            return;
                        }
                        if (!DB_ResidenceData.Instance.HomeGateway.gatewayStatus)//远程情况下,网关未链接服务器不能修改主页网关状态
                        if (value)
                        {
                            if (DB_ResidenceData.Instance.HomeGateway == null)
                            {
                                return;
                            }
                            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;
                            }
                            //修改主页连接状态
                            HomePage.LoadEvent_CheckLinkStatus();
                            MainPage.Log($"网关云端在线,刷新设备状态");
                            new System.Threading.Thread(() =>
                            {
                                System.Threading.Thread.Sleep(3000);
                                var pm = new DAL.Server.HttpServerRequest();
                                pm.GetGatewayInfo();
                                System.Threading.Thread.Sleep(1000);
                                FunctionList.List.ReadAllFunctionStatus();
                            })
                            { IsBackground = true }.Start();
                            return;
                            { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start();
                        }
                        //修改主页连接状态
                        HomePage.LoadEvent_CheckLinkStatus();
                        MainPage.Log($"网关云端在线,刷新设备状态");
                        new System.Threading.Thread(() =>
                        else
                        {
                            System.Threading.Thread.Sleep(1000);
                            FunctionList.List.ReadAllFunctionStatus();
                        })
                        { IsBackground = true, Priority = System.Threading.ThreadPriority.AboveNormal }.Start();
                            //修改主页连接状态
                            HomePage.LoadEvent_CheckLinkStatus();
                        }
                    }
                    else
                    {
                        //修改主页连接状态
                        HomePage.LoadEvent_CheckLinkStatus();
                    }
                }catch(Exception ex)
                {
                    MainPage.Log($"Set GatewayCloudOnline Error:{ex.Message}");
                }
            }
        }
@@ -1175,11 +1181,62 @@
        }
        /// <summary>
        /// 更新设备状态
        /// A协议数据
        /// </summary>
        /// <param name="updateBytes"></param>
        public void UpdataGroupControlStatus(string revString, byte[] usefulBytes, bool isCloudData = false)
        {
            var temp = JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString);
            if (temp != null)
            {
                Control_Udp.ReceiveRepeatManager(temp.id, usefulBytes);
                var allLocalFuntion = FunctionList.List.groupControls;
                foreach (var updateTemp in temp.objects)
                {
                    try
                    {
                        var localFunction = allLocalFuntion.Find((obj) => obj.sid == updateTemp.sid);
                        if (localFunction == null)
                        {
                            continue;
                        }
                        MainPage.Log($"收到数据:{revString}");
                        foreach (var attr in updateTemp.status)
                        {
                            localFunction.time_stamp = temp.time_stamp;
                            localFunction.SetAttrState(attr.key, attr.value);
                        }
                        //更新界面状态
                        switch (localFunction.spk)
                        {
                            case SPK.ElectricEnergy:
                                EnergyMainPage.UpdataStatus(localFunction);
                                break;
                        }
                        HomePage.UpdataFunctionStates(localFunction);
                        RoomPage.UpdataStates(localFunction);
                        FunctionPage.UpdataStates(localFunction);
                        ClassificationPage.UpdataInfo(localFunction);
                    }
                    catch (Exception ex)
                    {
                        MainPage.Log($"A协议更新状态异常:{ex.Message}");
                    }
                }
            }
        }
        /// <summary>
        /// 更新设备状态
        /// A协议数据
        /// </summary>
        public void UpdataFunctionStatus(string revString, byte[] usefulBytes, bool isCloudData = false)
        {
            ////test 云端连接成功时,不适用本地数据更新
@@ -1231,21 +1288,20 @@
                            }
                        }
                        if (SPK.MusicSpkList().Contains(localFunction.spk))
                        {
                            MainPage.Log($"音乐收到数据:{revString}");
                        }
                        //if (SPK.MusicSpkList().Contains(localFunction.spk))
                        //{
                        //    if (updateTemp.status.Count < 3)
                        //    {
                        //        ///是音乐功能的
                        //        ///上报属性少3条不做处理
                        //        return;
                        //    }
                        //}
                        MainPage.Log($"收到数据:{revString}");
                        foreach (var attr in updateTemp.status)
                        {
                            localFunction.time_stamp = temp.time_stamp;
                            localFunction.SetAttrState(attr.key, attr.value);
                            if (SPK.MusicSpkList().Contains(localFunction.spk))
                            {
                                Console.WriteLine("音乐播放器添加缓存数据=======" + revString);
                            }
                        }