wei
2020-12-08 62d77d3bb8e7215d9da9ecf6f5aeda0b69f805f8
HDL_ON/DAL/DriverLayer/Packet.cs
@@ -124,6 +124,7 @@
                            {
                                if (updataObj.functionType != FunctionType.RGB)
                                {
                                    updataObj.trait_on_off.curValue = receiveBytes[2] > 0 ? "on" : "off";
                                    if (updataObj.trait_on_off.curValue.ToString() == "on")
                                    {
                                        switch (updataObj.functionType)
@@ -132,12 +133,10 @@
                                                (updataObj as Fan).openLevel = receiveBytes[2];
                                                updataObj.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
                                                break;
                                            case FunctionType.Relay:
                                            case FunctionType.Dimmer:
                                                (updataObj as Light).brightness = receiveBytes[2];
                                                updataObj.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
                                                break;
                                            //case FunctionType.Socket:
                                            //    (updataObj as SwitchSocket).
                                        }
                                    }
                                    HomePage.UpdataFunctionStates(updataObj);
@@ -164,12 +163,12 @@
                    case Command.ReadLightAllLoopBrightnessACK:
                        for (int i = 0; i < receiveBytes[0]; i++)
                        {
                            var light = DB_ResidenceData.functionList.lights.Find((obj) => obj.bus_Data.SubnetID == subnetID && obj.bus_Data.DeviceID == deviceID && obj.bus_Data.LoopID == (i + 1));
                            var light = DB_ResidenceData.functionList.lights.Find((obj) => obj.bus_Data.SubnetID == subnetID && obj.bus_Data.DeviceID == deviceID && obj.bus_Data.loopId == (i + 1));
                            if (light != null)
                            {
                                if (light.functionType != FunctionType.RGB)
                                {
                                    light.trait_on_off.curValue = receiveBytes[light.bus_Data.LoopID] == 0 ? "off" : "on";
                                    light.trait_on_off.curValue = receiveBytes[light.bus_Data.loopId] == 0 ? "off" : "on";
                                    if (light.trait_on_off.curValue.ToString() == "on")
                                    {
                                        light.brightness = receiveBytes[2];
@@ -192,7 +191,7 @@
                            }
                            else
                            {
                                var e = DB_ResidenceData.functionList.electricals.Find((obj) => obj.bus_Data.SubnetID == subnetID && obj.bus_Data.DeviceID == deviceID && obj.bus_Data.LoopID == i);
                                var e = DB_ResidenceData.functionList.electricals.Find((obj) => obj.bus_Data.SubnetID == subnetID && obj.bus_Data.DeviceID == deviceID && obj.bus_Data.loopId == i);
                                if (e != null)
                                {
                                    var fan = e as Fan;
@@ -267,7 +266,7 @@
                                }
                                else
                                {
                                    if (curtain.bus_Data.LoopID != receiveBytes[0])
                                    if (curtain.bus_Data.loopId != receiveBytes[0])
                                        continue;
                                    switch (receiveBytes[1])
                                    {
@@ -449,7 +448,7 @@
                            if (sensor.bus_Data != null)
                            {
                                if ((int)sensor.functionType % 256 == receiveBytes[1] && sensor.bus_Data.SubnetID == subnetID &&
                                    sensor.bus_Data.DeviceID == deviceID && sensor.bus_Data.LoopID == receiveBytes[2])
                                    sensor.bus_Data.DeviceID == deviceID && sensor.bus_Data.loopId == receiveBytes[2])
                                {
                                    switch (dt)
                                    {
@@ -482,7 +481,7 @@
                            if (sensor.bus_Data != null)
                            {
                                if ((int)sensor.functionType % 256 == receiveBytes[1] && sensor.bus_Data.SubnetID == subnetID &&
                                    sensor.bus_Data.DeviceID == deviceID && sensor.bus_Data.LoopID == receiveBytes[2])
                                    sensor.bus_Data.DeviceID == deviceID && sensor.bus_Data.loopId == receiveBytes[2])
                                {
                                    //0保留 1无符号4Byte整形  2有符号4Byte整形  3Float形(代±)
                                    switch (receiveBytes[3])
@@ -576,6 +575,8 @@
                        if (DB_ResidenceData.residenceData.residenceGatewayMAC == mac)
                        {
                            DriverLayer.Control.Ins.GatewayOnline = true;
                            DriverLayer.Control.Ins.IsRemote = false;
                            DAL.Mqtt.MqttClient.DisConnectRemote();//断开mqtt
                        }
                        break;
                }