From bfb3d0d4879dca8c59ff287c92f5113162f3a33a Mon Sep 17 00:00:00 2001
From: wxr <wxr@hdlchina.com.cn>
Date: 星期二, 27 八月 2024 15:22:48 +0800
Subject: [PATCH] 代码备份

---
 OnPro/HDL_ON/DAL/DriverLayer/Packet.cs |  793 ++------------------------------------------------------
 1 files changed, 30 insertions(+), 763 deletions(-)

diff --git a/OnPro/HDL_ON/DAL/DriverLayer/Packet.cs b/OnPro/HDL_ON/DAL/DriverLayer/Packet.cs
index 0e8f8dc..9a2ae4b 100644
--- a/OnPro/HDL_ON/DAL/DriverLayer/Packet.cs
+++ b/OnPro/HDL_ON/DAL/DriverLayer/Packet.cs
@@ -54,712 +54,40 @@
         /// </summary>
         public virtual void Manager()
         {
-#if DEBUG
-#else
-            try
+            //瀵逛簬鎿嶄綔鏁版嵁搴撶殑鏃堕棿姣旇緝闀跨殑锛屽彲浠ュ垱寤哄彟涓�涓嚎绋嬪鐞�
+            if (!"HDLMIRACLE".Equals(Encoding.ASCII.GetString(Bytes, 4, 10)))
             {
-#endif
-                //瀵逛簬鎿嶄綔鏁版嵁搴撶殑鏃堕棿姣旇緝闀跨殑锛屽彲浠ュ垱寤哄彟涓�涓嚎绋嬪鐞�
-                if (!"HDLMIRACLE".Equals(Encoding.ASCII.GetString(Bytes, 4, 10)))
-                {
-                    return;
-                }
-
-                byte subnetID = this.Bytes[17]; //婧愬瓙缃戝彿
-                byte deviceID = this.Bytes[18]; //婧愯澶囧彿
-
-                //婧愯澶囩被鍨�
-                int deviceType = this.Bytes[19] * 256 + this.Bytes[20];
-
-                Command command = (Command)(Bytes[21] * 256 + Bytes[22]); //鎿嶄綔鐮佹帶鍒跺懡浠�
-
-                byte targetSubnetID = this.Bytes[23];
-                byte targetDeviceID = this.Bytes[24];
-
-                //涓嶆槸瑕佹帴鏀剁殑鎸囦护灏辫繑鍥�
-                if (!((targetSubnetID == 0 && targetDeviceID == 252) || (targetSubnetID == 0xff && targetDeviceID == 0xff)))
-                {
-                    return;
-                }
-                byte[] usefulBytes = null;
-                if (this.Bytes[16] == 0xFF)
-                {
-                    usefulBytes = new byte[Bytes.Length - 16 - 11];
-                    Array.Copy(Bytes, 27, usefulBytes, 0, usefulBytes.Length);
-                }
-                else
-                {
-                    //鏈夌敤鐨勯檮鍔犳暟鎹�
-                    usefulBytes = new byte[this.Bytes[16] - 11];
-                    Array.Copy(Bytes, 25, usefulBytes, 0, usefulBytes.Length);
-                }
-                //澶勭悊鎺ユ敹鍒扮殑鏁版嵁
-                UdpPacket_DataProcessing(subnetID, deviceID, command, usefulBytes);
-#if DEBUG
-                string ddd = "";
-                foreach(var bb in usefulBytes)
-                {
-                    ddd += bb + ",";
-                }
-                MainPage.Log($"bus鍛戒护:" + ((int)command).ToString("X").PadLeft(4, '0') + " : 鏁版嵁:" + ddd);
-                //MainPage.Log($"bus鍛戒护:"+ ((int)command) + " : 鏁版嵁:" + ddd);
-#endif
-                //澶勭悊鏄惁瑕侀噸鍙戞暟鎹�
-                ManagerReceive(subnetID, deviceID, command, usefulBytes);
-
-#if DEBUG
-#else
-              }
-            catch (Exception ex)
-            {
-                MainPage.Log($"packet {ex.Message} ");
+                return;
             }
-#endif
+
+            byte subnetID = this.Bytes[17]; //婧愬瓙缃戝彿
+            byte deviceID = this.Bytes[18]; //婧愯澶囧彿
+
+            //婧愯澶囩被鍨�
+            int deviceType = this.Bytes[19] * 256 + this.Bytes[20];
+
+            byte targetSubnetID = this.Bytes[23];
+            byte targetDeviceID = this.Bytes[24];
+
+            //涓嶆槸瑕佹帴鏀剁殑鎸囦护灏辫繑鍥�
+            if (!((targetSubnetID == 0 && targetDeviceID == 252) || (targetSubnetID == 0xff && targetDeviceID == 0xff)))
+            {
+                return;
+            }
+            byte[] usefulBytes = null;
+            if (this.Bytes[16] == 0xFF)
+            {
+                usefulBytes = new byte[Bytes.Length - 16 - 11];
+                Array.Copy(Bytes, 27, usefulBytes, 0, usefulBytes.Length);
+            }
+            else
+            {
+                //鏈夌敤鐨勯檮鍔犳暟鎹�
+                usefulBytes = new byte[this.Bytes[16] - 11];
+                Array.Copy(Bytes, 25, usefulBytes, 0, usefulBytes.Length);
+            }
         }
 
-        /// <summary>
-        /// 鏁版嵁鍖呭鐞�
-        /// </summary>
-        /// <param name="subnetID"></param>
-        /// <param name="deviceID"></param>
-        /// <param name="command"></param>
-        /// <param name="receiveBytes"></param>
-        void UdpPacket_DataProcessing(byte subnetID, byte deviceID, Command command, byte[] receiveBytes)
-        {
-#if DEBUG
-#else
-            try
-            {
-#endif
-                switch (command)
-                {
-                    case Command.SetSingleLightACK:
-                        var queryList = new List<Function>();
-                        queryList.AddRange(FunctionList.List.GetElectricals());
-                        queryList.AddRange(FunctionList.List.GetLightList());
-                        foreach (var updataObj in queryList)
-                        {
-                            if (updataObj.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                if (updataObj.spk != SPK.LightRGB)
-                                {
-                                    updataObj.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[2] > 0 ? "on" : "off");
-                                    if (updataObj.trait_on_off.curValue.ToString() == "on")
-                                    {
-                                        switch (updataObj.spk)
-                                        {
-                                            case SPK.HvacFan:
-                                            case SPK.ElectricFan:
-                                                updataObj.SetAttrState(FunctionAttributeKey.OpenLevel, receiveBytes[2].ToString());
-                                                updataObj.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
-                                                break;
-                                            case SPK.LightDimming:
-                                                updataObj.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[2].ToString());
-                                                updataObj.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
-                                                break;
-                                        }
-                                    }
-                                    HomePage.UpdataFunctionStates(updataObj);
-                                    RoomPage.UpdataStates(updataObj);
-                                    FunctionPage.UpdataStates(updataObj);
-                                    ClassificationPage.UpdataInfo(updataObj);
-                                    switch (updataObj.spk)
-                                    {
-                                        case SPK.LightSwitch:
-                                            RelayPage.UpdataState(updataObj);
-                                            break;
-                                        case SPK.LightDimming:
-                                            DimmerPage.UpdataStates(updataObj);
-                                            break;
-                                        case SPK.HvacFan:
-                                        case SPK.ElectricFan:
-                                            FanPage.UpdataState(updataObj);
-                                            break;
-                                    }
-                                    break;
-                                }
-                            }
-                        }
-                        break;
-                    case Command.ReadLightAllLoopBrightnessACK:
-                        for (int i = 0; i < receiveBytes[0]; i++)
-                        {
-                            var light = FunctionList.List.GetLightList().Find((obj) => obj.bus.SubnetID == subnetID && obj.bus.DeviceID == deviceID && obj.bus.LoopId == (i + 1));
-                            if (light != null)
-                            {
-                                if (light.spk != SPK.LightRGB)
-                                {
-                                    light.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[light.bus.LoopId] == 0 ? "off" : "on");
-                                    if (light.trait_on_off.curValue.ToString() == "on")
-                                    {
-                                        light.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[i+1].ToString());
-                                        light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
-                                    }
-                                    HomePage.UpdataFunctionStates(light);
-                                    RoomPage.UpdataStates(light);
-                                    FunctionPage.UpdataStates(light);
-                                    ClassificationPage.UpdataInfo(light);
-                                    switch (light.spk)
-                                    {
-                                        case SPK.LightSwitch:
-                                            RelayPage.UpdataState(light);
-                                            break;
-                                        case SPK.LightDimming:
-                                            DimmerPage.UpdataStates(light);
-                                            break;
-                                    }
-                                }
-                            }
-                            else
-                            {
-                                var function = FunctionList.List.GetElectricals().Find((obj) => obj.bus.SubnetID == subnetID && obj.bus.DeviceID == deviceID && obj.bus.LoopId == i);
-                                if (function != null)
-                                {
-                                    function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[2] == 0 ? "off" : "on");
-                                    if (function.trait_on_off.curValue.ToString() == "on")
-                                    {
-                                        function.SetAttrState(FunctionAttributeKey.OpenLevel, receiveBytes[2].ToString());
-                                        function.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
-                                    }
-                                    HomePage.UpdataFunctionStates(function);
-                                    RoomPage.UpdataStates(function);
-                                    FunctionPage.UpdataStates(function);
-                                    ClassificationPage.UpdataInfo(function);
-                                    switch (function.spk)
-                                    {
-                                        case SPK.ElectricFan:
-                                        case SPK.HvacFan:
-                                            FanPage.UpdataState(function);
-                                            break;
-                                        case SPK.ElectricSocket:
-                                        case SPK.PanelSocket:
-                                            SocketPage.UpdataState(function);
-                                            break;
-                                    }
-                                }
-                            }
-                        }
-                        break;
-                    case Command.SetLogicLoopColorACK:
-                    case Command.ReadLogicLoopColorACK:
-                        foreach (var lightTeme in FunctionList.List.GetLightList())
-                        {
-                            if (lightTeme.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                if (lightTeme.spk == SPK.LightRGB)
-                                {
-                                    lightTeme.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] > 0 ? "on" : "off");
-                                    if (receiveBytes[1] > 0)
-                                    {
-                                        lightTeme.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[1].ToString());
-                                        lightTeme.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%";
-                                    }
-                                    new Light().SetRGBcolor(new byte[] { receiveBytes[6], receiveBytes[7], receiveBytes[8] }, lightTeme);
-
-                                    HomePage.UpdataFunctionStates(lightTeme);
-                                    RoomPage.UpdataStates(lightTeme);
-                                    FunctionPage.UpdataStates(lightTeme);
-                                    ClassificationPage.UpdataInfo(lightTeme);
-                                    RGBPage.UpdataStates(lightTeme);
-                                }else if(lightTeme.spk == SPK.LightCCT)
-                                {
-                                    lightTeme.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] > 0 ? "on" : "off");
-                                    if (receiveBytes[1] > 0)
-                                    {
-                                        lightTeme.SetAttrState(FunctionAttributeKey.Brightness, receiveBytes[1].ToString());
-                                        lightTeme.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%";
-                                    }
-                                    new Light().SetCCT(new byte[] { receiveBytes[6], receiveBytes[7] }, lightTeme);
-
-                                    HomePage.UpdataFunctionStates(lightTeme);
-                                    RoomPage.UpdataStates(lightTeme);
-                                    FunctionPage.UpdataStates(lightTeme);
-                                    ClassificationPage.UpdataInfo(lightTeme);
-                                    ColorTureLampPage.UpdataStatus(lightTeme);
-                                }
-                            }
-                        }
-                        break;
-                    case Command.SetCurtainModelStutasACK:
-                    case Command.ReadCurtainStutasACK:
-                        foreach (var curtain in FunctionList.List.GetCurtainList())
-                        {
-                            if (curtain.bus.SubnetID == subnetID && curtain.bus.DeviceID == deviceID)
-                            {
-                                if (receiveBytes[0] == 17)
-                                {
-                                    if (receiveBytes[1] > 1)
-                                    {
-                                        curtain.SetAttrState(FunctionAttributeKey.OnOff, "on");
-                                    }
-                                    else
-                                    {
-                                        curtain.SetAttrState(FunctionAttributeKey.OnOff, "off");
-                                    }
-                                    curtain.SetAttrState(FunctionAttributeKey.Percent, receiveBytes[1].ToString());
-                                    curtain.lastState = Language.StringByID(StringId.Open) + curtain.GetAttrState(FunctionAttributeKey.Percent) + "%";
-                                }
-                                else
-                                {
-                                    if (curtain.bus.LoopId != receiveBytes[0])
-                                        continue;
-                                    switch (receiveBytes[1])
-                                    {
-                                        case 0:
-                                            curtain.SetAttrState(FunctionAttributeKey.OnOff, "stop");
-                                            return;
-                                        case 1:
-                                            curtain.SetAttrState(FunctionAttributeKey.OnOff, "on");
-                                            //curtain.
-                                            curtain.lastState = Language.StringByID(StringId.Open);
-                                            break;
-                                        case 2:
-                                            curtain.SetAttrState(FunctionAttributeKey.OnOff, "off");
-                                            curtain.lastState = Language.StringByID(StringId.Close);
-                                            break;
-                                    }
-                                }
-                                RoomPage.UpdataStates(curtain);
-                                FunctionPage.UpdataStates(curtain);
-                                HomePage.UpdataFunctionStates(curtain);
-                                ClassificationPage.UpdataInfo(curtain);
-                                switch (curtain.spk)
-                                {
-                                    case SPK.CurtainSwitch:
-                                        CurtainModulePage.UpdataState(curtain);
-                                        break;
-                                    case SPK.CurtainTrietex:
-                                        MotorCurtainPage.UpdataState(curtain);
-                                        break;
-                                    case SPK.CurtainRoller:
-                                        RollingShutterPage.UpdataState(curtain);
-                                        break;
-                                    case SPK.CurtainShades:
-                                        VenetianBlindsPage.UpdataState(curtain);
-                                        break;
-                                }
-                            }
-                        }
-                        break;
-                    case Command.SetACModeACK:
-                    case Command.ReadACModeACK:
-                        foreach (var function in FunctionList.List.Functions)
-                        {
-                        if (function.bus == null || function.spk != SPK.AcStandard)
-                        {
-                            continue;
-                        }
-                            var acFunction = new AC();
-                            if (function.bus.SubnetID == subnetID &&
-                                function.bus.DeviceID ==  deviceID &&
-                                function.bus.LoopId == receiveBytes[0])
-                            {
-                            Console.WriteLine(function.GetBusId());
-                                function.SetAttrState(FunctionAttributeKey.TempType, receiveBytes[1].ToString());
-                                function.SetAttrState(FunctionAttributeKey.RoomTemp, receiveBytes[2].ToString());
-                                function.SetAttrState(FunctionAttributeKey.OnOff,  receiveBytes[8] == 1 ? "on" : "off");
-                                acFunction.SetMode(receiveBytes[9],function);
-                                acFunction.SetFan(receiveBytes[10],function);
-                                function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[11].ToString());
-                                function.lastState = "";
-                                switch (function.GetAttrState(FunctionAttributeKey.Mode))
-                                {
-                                    case "cool":
-                                        function.lastState = Language.StringByID(StringId.Cool);
-                                        break;
-                                    case "heat":
-                                        function.lastState = Language.StringByID(StringId.Heat);
-                                        break;
-                                    case "dry":
-                                        function.lastState = Language.StringByID(StringId.Dry);
-                                        break;
-                                    case "auto":
-                                        function.lastState = Language.StringByID(StringId.Auto);
-                                        break;
-                                    case "fan":
-                                        function.lastState = Language.StringByID(StringId.AirSupply);
-                                        break;
-                                }
-                                switch (function.GetAttrState(FunctionAttributeKey.FanSpeed))
-                                {
-                                    case "high":
-                                        function.lastState += " " + Language.StringByID(StringId.HighWindSpeed);
-                                        break;
-                                    case "medium":
-                                        function.lastState += " " + Language.StringByID(StringId.MiddleWindSpeed);
-                                        break;
-                                    case "low":
-                                        function.lastState += " " + Language.StringByID(StringId.LowWindSpeed);
-                                        break;
-                                    case "auto":
-                                        function.lastState += " " + Language.StringByID(StringId.Auto);
-                                        break;
-                                }
-                                function.lastState += " " + function.GetAttrState(FunctionAttributeKey.SetTemp) + acFunction.GetTempUnitString(function);
-                                RoomPage.UpdataStates(function);
-                                FunctionPage.UpdataStates(function);
-                                HomePage.UpdataFunctionStates(function);
-                                ClassificationPage.UpdataInfo(function);
-                                Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(function);
-
-                            }
-                        }
-                        break;
-                    case Command.ReadFloorHeatACK:
-                    case Command.SetFloorHeatACK:
-                        foreach (var function in FunctionList.List.GetFloorHeatingList())
-                        {
-                            if (function.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                function.SetAttrState(FunctionAttributeKey.TempType, receiveBytes[2]);
-                                function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] % 2 == 0 ? "off" : "on");
-                                new FloorHeating().SetModeIndex(receiveBytes[3],function);
-
-                                if (function.Fh_Mode_Temp.ContainsKey("normal"))
-                                {
-                                    function.Fh_Mode_Temp["normal"] = receiveBytes[4];
-                                }
-                                else
-                                {
-                                    function.Fh_Mode_Temp.Add("normal", receiveBytes[4]);
-                                }
-                                if (function.Fh_Mode_Temp.ContainsKey("day"))
-                                {
-                                    function.Fh_Mode_Temp["day"] = receiveBytes[5];
-                                }
-                                else
-                                {
-                                    function.Fh_Mode_Temp.Add("day", receiveBytes[5]);
-                                }
-                                if (function.Fh_Mode_Temp.ContainsKey("night"))
-                                {
-                                    function.Fh_Mode_Temp["night"] = receiveBytes[6];
-                                }
-                                else
-                                {
-                                    function.Fh_Mode_Temp.Add("night", receiveBytes[6]);
-                                }
-                                if (function.Fh_Mode_Temp.ContainsKey("away"))
-                                {
-                                    function.Fh_Mode_Temp["away"] = receiveBytes[7];
-                                }
-                                else
-                                {
-                                    function.Fh_Mode_Temp.Add("away", receiveBytes[7]);
-                                }
-                                if (function.GetAttribute(FunctionAttributeKey.Mode) == null)
-                                {
-                                    function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[4].ToString());
-                                }
-                                else
-                                {
-                                    switch (function.GetAttrState(FunctionAttributeKey.Mode))
-                                    {
-                                        case "normal":
-                                            function.lastState = Language.StringByID(StringId.Normal);
-                                            function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[4].ToString());
-                                            break;
-                                        case "day":
-                                            function.lastState = Language.StringByID(StringId.Day);
-                                            function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[5].ToString());
-                                            break;
-                                        case "night":
-                                            function.lastState = Language.StringByID(StringId.Night);
-                                            function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[6].ToString());
-                                            break;
-                                        case "timer":
-                                            function.lastState = Language.StringByID(StringId.Auto);
-                                            if (receiveBytes[8] == 0)
-                                            {
-                                                function.SetAttrState(FunctionAttributeKey.TimeFlag, 0);
-                                                function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[5].ToString());
-                                            }
-                                            else
-                                            {
-                                                function.SetAttrState(FunctionAttributeKey.TimeFlag, 1);
-                                                function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[6].ToString());
-                                            }
-                                            break;
-                                        case "away":
-                                            function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[7].ToString());
-                                            function.lastState = Language.StringByID(StringId.Away);
-                                            break;
-                                    }
-                                }
-                                var indoorTemp = 0;
-                                if (receiveBytes[9] > 128)
-                                {
-                                    indoorTemp = 1 - (receiveBytes[9] - 128);
-                                }else
-                                {
-                                    indoorTemp = receiveBytes[9];
-                                }
-                                function.SetAttrState(FunctionAttributeKey.RoomTemp, indoorTemp);
-
-                                if (function.GetAttribute(FunctionAttributeKey.Mode) == null)
-                                {
-                                    function.lastState = "";
-                                }
-                                else
-                                {
-                                    function.lastState += " " + function.GetAttrState(FunctionAttributeKey.Mode) + new FloorHeating().GetTempUnitString(function);
-                                }
-                                RoomPage.UpdataStates(function);
-                                FunctionPage.UpdataStates(function);
-                                HomePage.UpdataFunctionStates(function);
-                                ClassificationPage.UpdataInfo(function);
-                                FloorHeatingPage.UpdataStates(function);
-                            }
-                        }
-                        break;
-                    case Command.ReadDeviceLoopInfoACK:
-                        string tag = receiveBytes[1] + "_" + subnetID + "_" + deviceID + "_" + receiveBytes[2];
-                        foreach (var sensor in FunctionList.List.GetEnvirSensorsList())
-                        {
-                            byte sensorType = 0;
-                            switch (sensor.spk)
-                            {
-                                case SPK.SensorTemperature:
-                                    sensorType = 2;
-                                    break;
-                                case SPK.SensorHumidity:
-                                    sensorType = 3;
-                                    break;
-                                case SPK.SensorTVOC:
-                                    sensorType = 5;
-                                    break;
-                                case SPK.SensorPm25:
-                                    sensorType = 6;
-                                    break;
-                                case SPK.SensorCO2:
-                                    sensorType = 7;
-                                    break;
-                            }
-                            if (sensor.bus != null)
-                            {
-                                if (sensorType == receiveBytes[1] && sensor.bus.SubnetID == subnetID &&
-                                    sensor.bus.DeviceID == deviceID && sensor.bus.LoopId == receiveBytes[2])
-                                {
-                                    switch (sensor.spk)
-                                    {
-                                        case SPK.SensorTemperature:
-                                            byte[] tempBytes = new byte[] { receiveBytes[24], receiveBytes[25], receiveBytes[26], receiveBytes[27] };
-                                            sensor.SetAttrState(FunctionAttributeKey.Value,Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString());
-                                            sensor.SetAttrState(sensor.spk,Math.Round(BitConverter.ToSingle(tempBytes, 0), 1).ToString());
-                                            break;
-                                        case SPK.SensorHumidity:
-                                            sensor.SetAttrState(FunctionAttributeKey.Value, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 10).ToString());
-                                            sensor.SetAttrState(sensor.spk, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 10).ToString());
-                                            break;
-                                        case SPK.SensorTVOC:
-                                            sensor.SetAttrState(FunctionAttributeKey.Value, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 100).ToString());
-                                            sensor.SetAttrState(sensor.spk, (Convert.ToDouble(receiveBytes[24] * 256 + receiveBytes[25]) / 100).ToString());
-                                            break;
-                                        case SPK.SensorPm25:
-                                            sensor.SetAttrState(FunctionAttributeKey.Value,Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString());
-                                            sensor.SetAttrState(sensor.spk,Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString());
-                                            break;
-                                        case SPK.SensorCO2:
-                                            sensor.SetAttrState(FunctionAttributeKey.Value, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString());
-                                            sensor.SetAttrState(sensor.spk, Convert.ToInt32(receiveBytes[24] * 256 + receiveBytes[25]).ToString());
-                                            break;
-                                    }
-                                    EnvironmentalPage.LoadEvent_UpdataStatus(sensor);
-                                //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor);
-                                }
-                            }
-                        }
-                        break;
-                    case Command.New_Analog_Quantity_BROADCAST:
-                        string tag1 = receiveBytes[1] + "_" + subnetID + "_" + deviceID + "_" + receiveBytes[2];
-                        foreach (var sensor in FunctionList.List.GetEnvirSensorsList())
-                        {
-                            byte sensorType = 0;
-                            switch (sensor.spk)
-                            {
-                                case SPK.SensorTemperature:
-                                    sensorType = 2;
-                                    break;
-                                case SPK.SensorHumidity:
-                                    sensorType = 3;
-                                    break;
-                                case SPK.SensorTVOC:
-                                    sensorType = 5;
-                                    break;
-                                case SPK.SensorPm25:
-                                    sensorType = 6;
-                                    break;
-                                case SPK.SensorCO2:
-                                    sensorType = 7;
-                                    break;
-                            }
-                            if (sensor.bus != null)
-                            {
-                                if (sensorType == receiveBytes[1] && sensor.bus.SubnetID == subnetID &&
-                                    sensor.bus.DeviceID == deviceID && sensor.bus.LoopId == receiveBytes[2])
-                                {
-                                    //0淇濈暀 1鏃犵鍙�4Byte鏁村舰  2鏈夌鍙�4Byte鏁村舰  3Float褰紙浠B憋級
-                                    switch (receiveBytes[3])
-                                    {
-                                        case 1:
-                                            sensor.SetAttrState(FunctionAttributeKey.Value,( (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString());
-                                            sensor.SetAttrState(sensor.spk,( (receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8]).ToString());
-                                            break;
-                                        case 2:
-                                            sensor.SetAttrState(FunctionAttributeKey.Value,( -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString());
-                                            sensor.SetAttrState(sensor.spk,( -1 * ((receiveBytes[5] * 256 * 256 * 256) + (receiveBytes[6] * 256 * 256) + (receiveBytes[7] * 256) + receiveBytes[8])).ToString());
-                                            break;
-                                        case 3:
-                                            byte[] tempBytes = new byte[] { receiveBytes[5], receiveBytes[6], receiveBytes[7], receiveBytes[8] };
-                                            sensor.SetAttrState(FunctionAttributeKey.Value,( Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString());
-                                            sensor.SetAttrState(sensor.spk,( Math.Round(BitConverter.ToSingle(tempBytes, 0), 1)).ToString());
-                                            break;
-                                    }
-                                    switch (receiveBytes[4])
-                                    {
-                                        case 2:
-                                            if (receiveBytes[1] == 5)//TVOC闇�姹傞櫎浠�100000
-                                            {
-                                                var value = Convert.ToInt32(sensor.GetAttrState(FunctionAttributeKey.Value));
-                                                sensor.SetAttrState(FunctionAttributeKey.Value, (value /= 100000).ToString());
-                                                sensor.SetAttrState(sensor.spk, (value /= 100000).ToString());
-                                            }
-                                            break;
-                                    }
-                                    
-                                //A_EnvironmentalDataCenter.LoadEvent_UpdataStatus(sensor);
-                                    EnvironmentalPage.LoadEvent_UpdataStatus(sensor);
-                                }
-                            }
-                        }
-                        break;
-                    case Command.InstructionPanelKeyACK:
-                    case Command.ReadInstructionPanelKeyACK:
-                        byte reACPanel = 0;
-                        if (receiveBytes.Length == 2)
-                        {
-                            reACPanel = 1;
-                        }
-                        else if (receiveBytes.Length == 3)
-                        {
-                            reACPanel = receiveBytes[2];
-                        }
-                        else
-                        {
-                            break;
-                        }
-                        foreach (var function in FunctionList.List.GetAcList())
-                        {
-                            var acFunction = new AC();
-                            if (function.GetBusId() == subnetID + "_" + deviceID + "_" + reACPanel)
-                            {
-                                switch (receiveBytes[0])
-                                {
-                                    case 3://
-                                        function.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[1] == 1 ? "on" : "off");
-                                        break;
-                                    case 4:
-                                    case 7:
-                                    case 8:
-                                    case 19:
-                                        function.SetAttrState(FunctionAttributeKey.SetTemp, receiveBytes[1].ToString());
-                                        break;
-                                    case 5:
-                                        acFunction.SetFan ( receiveBytes[1],function);
-                                        break;
-                                    case 6:
-                                        acFunction.SetMode ( receiveBytes[1],function);
-                                        break;
-
-                                }
-                                function.lastState = "";
-                                function.lastState += acFunction.GetModeAttrText(function.GetAttrState(FunctionAttributeKey.Mode)) +
-                                    acFunction.GetModeAttrText(function.GetAttrState(FunctionAttributeKey.FanSpeed)) +
-                                    " " + function.GetAttrState(FunctionAttributeKey.SetTemp) + acFunction.GetTempUnitString(function);
-                                RoomPage.UpdataStates(function);
-                                FunctionPage.UpdataStates(function);
-                                HomePage.UpdataFunctionStates(function);
-                                ClassificationPage.UpdataInfo(function);
-                                Stan.HdlDeviceStatuPushLogic.Current.UpdateDeviceStatu(function.sid, function.status);
-                            }
-                        }
-                        break;
-                    case Command.ReadPanleTempACK://1944
-                    case Command.PanleBroadcastTemp:
-                        foreach (var ac in FunctionList.List.GetAcList())
-                        {
-                            if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
-                            {
-                                ac.SetAttrState(FunctionAttributeKey.RoomTemp, receiveBytes[1].ToString());
-                                FunctionPage.UpdataStates(ac);
-                            }
-                        }
-                        break;
-                    case Command.ReadGatewayACK:
-                        var mac = ByteToHex16(receiveBytes[5]) + ByteToHex16(receiveBytes[6]) + ByteToHex16(receiveBytes[7]) + ByteToHex16(receiveBytes[8]) + ByteToHex16(receiveBytes[9]) + ByteToHex16(receiveBytes[10]) + ByteToHex16(receiveBytes[11]) + ByteToHex16(receiveBytes[12]);
-                        var Name = Encoding.GetEncoding("gb2312").GetString(receiveBytes, 13, 20).Trim('\0'); ;
-                        MainPage.Log($"name : {Name} ; mac : {mac}");
-                        if (DB_ResidenceData.Instance.residenceGatewayMAC == mac)
-                        {
-                            //鏈湴鎼滅储缃戝叧鎴愬姛
-                            Control.Ins.IsSearchLocalGatewaySuccessful = true;
-                            Control.Ins.GatewayOnline_Local = true;
-                            DAL.Mqtt.MqttClient.DisConnectRemote();//鏂紑mqtt
-                        }
-                        break;
-                    case Command.FreshAirControlACK_JinMao:
-                    case Command.FreshAirReadACK_JinMao:
-                        var airFresh = FunctionList.List.GetAirFreshList().Find((obj) => obj.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0]);
-                        if (airFresh != null)
-                        {
-                            /// 3	寮�鍏�	0-鍏虫満锛�1-寮�鏈�
-                            /// 4	杩愯妯″紡	1-閫氶锛�2-鍔犳箍 humidification/fan
-                            /// 5	鑺傝兘鑸掗�傞�夋嫨	1-鑸掗�傦紝2-鑺傝兘 true/false
-                            /// 6	椋庨�熸。浣�	0-鑷姩锛�1-1妗o紝2-2妗o紝3-3妗�  level_1/level_2/level_3/auto
-                            /// 7	婀垮害璁惧畾	%
-                            /// 8	瀹ゅ唴娓╁害鍊�	鈩�
-                            /// 9	瀹ゅ唴婀垮害鍊�	鈩�
-                            /// 10	杩囨护缃戝墿浣�	%
-                            /// 11	杩囨护缃戜娇鐢ㄨ秴鏃�	1 瓒呮椂 0 鏃� true/false
-                            airFresh.SetAttrState(FunctionAttributeKey.OnOff, receiveBytes[2] == 0 ? "off" : "on");
-                            airFresh.SetAttrState(FunctionAttributeKey.Mode, receiveBytes[3] == 1 ? "fan" : "humidification");
-                            airFresh.SetAttrState(FunctionAttributeKey.Energy, receiveBytes[4] == 1 ? "false" : "true");
-                            switch (receiveBytes[5])
-                            {
-                                case 0:
-                                    airFresh.SetAttrState(FunctionAttributeKey.FanSpeed, "auto");
-                                    break;
-                                case 1:
-                                    airFresh.SetAttrState(FunctionAttributeKey.FanSpeed, "level_1");
-                                    break;
-                                case 2:
-                                    airFresh.SetAttrState(FunctionAttributeKey.FanSpeed, "level_2");
-                                    break;
-                                case 3:
-                                    airFresh.SetAttrState(FunctionAttributeKey.FanSpeed, "level_3");
-                                    break;
-                            }
-                            airFresh.SetAttrState(FunctionAttributeKey.Humidity, receiveBytes[6].ToString());
-                            airFresh.SetAttrState(FunctionAttributeKey.IndoorTemp, receiveBytes[7].ToString());
-                            airFresh.SetAttrState(FunctionAttributeKey.IndoorHumidity, receiveBytes[8].ToString());
-                            airFresh.SetAttrState(FunctionAttributeKey.FilterRemain, receiveBytes[9].ToString());
-                            airFresh.SetAttrState(FunctionAttributeKey.FilterTimeout, receiveBytes[10] == 1 ? "true" : "false");
-                            //璁惧鐘舵�佹帹閫�
-                            Stan.HdlFormLogic.Current.DeviceStatuPush(airFresh, true);
-                        }
-                        break;
-                }
-
-#if DEBUG
-#else
-              }
-            catch (Exception ex)
-            {
-                MainPage.Log($"Bus Rev Erorr : {ex.Message}");
-            }
-#endif
-
-        }
         /// <summary>
         /// byte杞�16杩涘埗瀛楃涓�
         /// </summary>
@@ -774,67 +102,6 @@
             }
             return s;
         }
-
-        /// <summary>
-        /// 澶勭悊鎺ユ敹鍥炴潵鐨勬暟鎹�
-        /// </summary>
-        void ManagerReceive(byte subnetID, byte deviceID, Command command, byte[] usefulBytes)
-        {
-            try
-            {
-                string receiveFlag = string.Format("{0},{1},{2},", subnetID, deviceID, (int)command);
-
-                switch (command)
-                {
-                    case Command.SetSingleLightACK:
-                    case Command.FreshAirReadACK:
-                    case Command.FreshAirControlACK:
-                    case Command.FreshAirReadACK_JinMao:
-                    case Command.FreshAirControlACK_JinMao:
-                        receiveFlag += string.Format("{0}", usefulBytes[0]);
-                        break;
-                    case Command.SetLogicLoopColorACK:
-                        receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]);
-                        break;
-                    case Command.ReadLogicLoopColorACK:
-                    case Command.ReadACModeACK:
-                    case Command.SetACModeACK:
-                    case Command.ReadFloorHeatACK:
-                    case Command.SetFloorHeatACK:
-                        receiveFlag += string.Format("{0}", usefulBytes[0]);
-                        break;
-                    case Command.ReadLightAllLoopBrightnessACK:
-                        receiveFlag += "";
-                        break;
-                    case Command.ReadGatewayACK:
-                        receiveFlag = string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]);
-                        break;
-                    case Command.ReadDeviceLoopInfoACK:
-                        if (usefulBytes[0] == 1)
-                        {
-                            receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[2]); ;
-                        }
-                        else
-                            receiveFlag += string.Format("{0},{1},{2}", usefulBytes[0], usefulBytes[1], usefulBytes[2]);
-                        break;
-                    case Command.InstructionPanelKeyACK:
-                    case Command.ReadInstructionPanelKeyACK:
-                        receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]);
-                        break;
-                    case Command.ReadRemark:
-                        new Control_Udp().ReceiveReadRemark(usefulBytes);
-                        break;
-                    default:
-                        break;
-                }
-                Control_Udp.ReceiveRepeatManager(receiveFlag,usefulBytes);
-            }
-            catch (Exception ex)
-            {
-                MainPage.Log("ManagerReceive鎶涘嚭寮傚父锛�" + ex.ToString());
-            }
-        }
-
 
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0