wei
2020-12-22 d07d62be7111d78b2aaa44c9cdee23a7d22b4dda
HDL_ON/DAL/DriverLayer/Packet.cs
@@ -163,12 +163,12 @@
                    case Command.ReadLightAllLoopBrightnessACK:
                        for (int i = 0; i < receiveBytes[0]; i++)
                        {
                            var light = FunctionList.List.lights.Find((obj) => obj.bus.SubnetID == subnetID && obj.bus.DeviceID == deviceID && obj.bus.loopId == (i + 1));
                            var light = FunctionList.List.lights.Find((obj) => obj.bus.SubnetID == subnetID && obj.bus.DeviceID == deviceID && obj.bus.LoopId == (i + 1));
                            if (light != null)
                            {
                                if (light.functionType != FunctionType.RGB)
                                {
                                    light.trait_on_off.curValue = receiveBytes[light.bus.loopId] == 0 ? "off" : "on";
                                    light.trait_on_off.curValue = receiveBytes[light.bus.LoopId] == 0 ? "off" : "on";
                                    if (light.trait_on_off.curValue.ToString() == "on")
                                    {
                                        light.brightness = receiveBytes[2];
@@ -191,7 +191,7 @@
                            }
                            else
                            {
                                var e = FunctionList.List.electricals.Find((obj) => obj.bus.SubnetID == subnetID && obj.bus.DeviceID == deviceID && obj.bus.loopId == i);
                                var e = FunctionList.List.electricals.Find((obj) => obj.bus.SubnetID == subnetID && obj.bus.DeviceID == deviceID && obj.bus.LoopId == i);
                                if (e != null)
                                {
                                    var fan = e as Fan;
@@ -264,7 +264,7 @@
                                }
                                else
                                {
                                    if (curtain.bus.loopId != receiveBytes[0])
                                    if (curtain.bus.LoopId != receiveBytes[0])
                                        continue;
                                    switch (receiveBytes[1])
                                    {
@@ -307,11 +307,11 @@
                            if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                            {
                                ac.curTempType = receiveBytes[1];
                                ac.trait_IndoorTemp.curValue = receiveBytes[2];
                                ac.trait_IndoorTemp.curValue = receiveBytes[2].ToString();
                                ac.trait_on_off.curValue = receiveBytes[8] == 1 ? "on" : "off";
                                ac.curModeIndex = receiveBytes[9];
                                ac.curFanIndex = receiveBytes[10];
                                ac.trait_temp.curValue = receiveBytes[11];
                                ac.trait_temp.curValue = receiveBytes[11].ToString();
                                ac.lastState = "";
                                switch (ac.trait_mode.curValue.ToString())
                                {
@@ -401,31 +401,31 @@
                                {
                                    case "normal":
                                        fh.lastState = Language.StringByID(StringId.Normal);
                                        fh.trait_temp.curValue = receiveBytes[4];
                                        fh.trait_temp.curValue = receiveBytes[4].ToString();
                                        break;
                                    case "day":
                                        fh.lastState = Language.StringByID(StringId.Day);
                                        fh.trait_temp.curValue = receiveBytes[5];
                                        fh.trait_temp.curValue = receiveBytes[5].ToString();
                                        break;
                                    case "night":
                                        fh.lastState = Language.StringByID(StringId.Night);
                                        fh.trait_temp.curValue = receiveBytes[6];
                                        fh.trait_temp.curValue = receiveBytes[6].ToString();
                                        break;
                                    case "timer":
                                        fh.lastState = Language.StringByID(StringId.Auto);
                                        if (receiveBytes[8] == 0)
                                        {
                                            fh.timeFlag = 0;
                                            fh.trait_temp.curValue = receiveBytes[5];
                                            fh.trait_temp.curValue = receiveBytes[5].ToString();
                                        }
                                        else
                                        {
                                            fh.timeFlag = 1;
                                            fh.trait_temp.curValue = receiveBytes[6];
                                            fh.trait_temp.curValue = receiveBytes[6].ToString();
                                        }
                                        break;
                                    case "away":
                                        fh.trait_temp.curValue = receiveBytes[7];
                                        fh.trait_temp.curValue = receiveBytes[7].ToString();
                                        fh.lastState = Language.StringByID(StringId.Away);
                                        break;
                                }
@@ -446,7 +446,7 @@
                            if (sensor.bus != null)
                            {
                                if ((int)sensor.functionType % 256 == receiveBytes[1] && sensor.bus.SubnetID == subnetID &&
                                    sensor.bus.DeviceID == deviceID && sensor.bus.loopId == receiveBytes[2])
                                    sensor.bus.DeviceID == deviceID && sensor.bus.LoopId == receiveBytes[2])
                                {
                                    switch (dt)
                                    {
@@ -479,7 +479,7 @@
                            if (sensor.bus != null)
                            {
                                if ((int)sensor.functionType % 256 == receiveBytes[1] && sensor.bus.SubnetID == subnetID &&
                                    sensor.bus.DeviceID == deviceID && sensor.bus.loopId == receiveBytes[2])
                                    sensor.bus.DeviceID == deviceID && sensor.bus.LoopId == receiveBytes[2])
                                {
                                    //0保留 1无符号4Byte整形  2有符号4Byte整形  3Float形(代±)
                                    switch (receiveBytes[3])
@@ -535,7 +535,7 @@
                                    case 7:
                                    case 8:
                                    case 19:
                                        ac.trait_temp.curValue = receiveBytes[1];
                                        ac.trait_temp.curValue = receiveBytes[1].ToString();
                                        break;
                                    case 5:
                                        ac.curFanIndex = receiveBytes[1];
@@ -561,7 +561,7 @@
                        {
                            if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                            {
                                ac.trait_IndoorTemp.curValue = receiveBytes[1];
                                ac.trait_IndoorTemp.curValue = receiveBytes[1].ToString();
                                FunctionPage.UpdataStates(ac);
                            }
                        }
@@ -572,6 +572,8 @@
                        MainPage.Log($"name : {Name} ; mac : {mac}");
                        if (DB_ResidenceData.Instance.residenceGatewayMAC == mac)
                        {
                            //本地搜索网关成功
                            Control.Ins.IsSearchLocalGatewaySuccessful = true;
                            Control.Ins.GatewayOnline = true;
                            Control.Ins.IsRemote = false;
                            DAL.Mqtt.MqttClient.DisConnectRemote();//断开mqtt
@@ -642,12 +644,12 @@
                        receiveFlag += string.Format("{0},{1}", usefulBytes[0], usefulBytes[1]);
                        break;
                    case Command.ReadRemark:
                        DriverLayer.Control.Ins.myUdp.ReceiveReadRemark(usefulBytes);
                        new Control_Udp().ReceiveReadRemark(usefulBytes);
                        break;
                    default:
                        break;
                }
                DriverLayer.Control.Ins.myUdp.ReceiveRepeatManager(receiveFlag);
                Control_Udp.ReceiveRepeatManager(receiveFlag,usefulBytes);
            }
            catch (Exception ex)
            {