tzy
2021-06-09 f5b46f80546aac860ade6e4c53821e43df833b39
HDL_ON/DAL/DriverLayer/Control.cs
@@ -283,7 +283,6 @@
        /// </summary>
        public void ControlScene(Scene scene)
        {
            //远程或者控制link网关场景
            if (!Ins.GatewayOnline_Local || DB_ResidenceData.Instance.GatewayType == 1)
            {
                new System.Threading.Thread(() =>
@@ -478,16 +477,9 @@
        /// 发送读取命令
        /// 自动判断是否为A协议设备
        /// </summary>
        public void SendReadCommand(Function function ,bool forceRemote = false)
        public void SendReadCommand(Function function)
        {
            function.refreshTime = DateTime.Now;
            if (forceRemote)
            {
                var pm = new DAL.Server.HttpServerRequest();
                var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId });
            }
            else
            {
                if (Ins.GatewayOnline_Local)
                {
@@ -526,7 +518,6 @@
                {
                    var pm = new DAL.Server.HttpServerRequest();
                    var pack = pm.RefreshDeviceStatus(new List<string>() { function.deviceId });
                }
            }
        }
@@ -570,7 +561,7 @@
            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;
        }
@@ -644,7 +635,7 @@
                        {
                            Ins.GatewayId = device.device_mac;
                        }
                        reportIp = "239.0.168.188";// device.ip_address;//主播地址也能控制设备
                        reportIp = "239.0.168.188";// device.ip_address;
                    }
                }
                else if (receiveObj.Topic == CommunicationTopic.ct.ReadStatus + "_reply" ||
@@ -670,6 +661,15 @@
        /// <param name="updateBytes"></param>
        public void UpdataFunctionStatus(string revString, byte[] usefulBytes,bool isCloudData = false)
        {
            if (Ins.GatewayOnline_Local && isCloudData)//本地链接,除了涂鸦设备数据之外的云端数据不处理
            {
                if (FunctionList.List.GetDeviceFunctionList(SPK.BrandType.Tuya).Count == 0)
                {
                    //MainPage.Log($"A协议更新状态:本地链接,除了涂鸦设备数据之外的云端数据不处理...");
                    return;
                }
            }
            var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<AlinkFunctionStatusObj>(revString);
            if (temp != null)
            {
@@ -679,22 +679,6 @@
                {
                    try
                    {
                        if (Ins.GatewayOnline_Local && isCloudData)//本地链接,除了涂鸦设备数据之外的云端数据不处理
                        {
                            if (FunctionList.List.OtherBrandFunction.Count != 0)
                            {
                                if (FunctionList.List.OtherBrandFunction.Find((obj) => obj.sid == updateTemp.sid) == null)
                                {
                                    //MainPage.Log($"A协议更新状态:本地链接,除了涂鸦设备数据之外的云端数据不处理...");
                                    return;
                                }
                            }
                        }
                        var localFunction = allLocalFuntion.Find((obj) => obj.sid == updateTemp.sid);
                        if (localFunction == null)
                        {
@@ -719,9 +703,6 @@
                        Function localObj = null;
                        switch (localFunction.spk)
                        {
                            case SPK.ElectricEnergy:
                                EnergyMainPage.UpdataStatus(localFunction);
                                break;
                            case SPK.LightSwitch:
                                RelayPage.UpdataState(localFunction);
                                break;
@@ -828,14 +809,6 @@
                            case SPK.SensorTVOC:
                            case SPK.SensorTemperature:
                            case SPK.SensorHumidity:
                                if(localFunction.spk == SPK.SensorTemperature)
                                {
                                    HomePage.LoadEvent_RefreshEnvirIndoorTemp();
                                }
                                else if (localFunction.spk == SPK.SensorHumidity)
                                {
                                    HomePage.LoadEvent_RefreshEnvirIndoorHumi();
                                }
                                EnvironmentalPage.LoadEvent_UpdataStatus(localFunction);
                                break;
                            case SPK.ElectricSocket:
@@ -853,9 +826,7 @@
                            case SPK.SensorWater:
                            case SPK.ClothesHanger:
                            case SPK.AcIr:
                            case SPK.SenesorMegahealth:
                                //设备状态推送
                                //状态更新
                                Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(updateTemp.sid, updateTemp.status);
                                break;
                        }