wxr
2020-03-19 b69d7735274b8d0f741da8a6bb8b8e1347477a5a
HDL_ON/DAL/Net/CommonPage.cs
@@ -109,34 +109,65 @@
                                if (function.functionCategory == FunctionType.Light)
                                {
                                    var light = function as Light;
                                    if (receiveBytes[2] == 0 && light.state == 0)
                                    {
                                        break;
                                    }
                                    if (receiveBytes[2] == 100 && light.state == 1)
                                    if (receiveBytes[2] == 0 && light.on_off == 0)
                                    {
                                        break;
                                    }
                                    if (function.functionType == "Relay")
                                    {
                                        var relay = function as Light;
                                        relay.state = receiveBytes[2] == 0 ? 0 : 1;
                                        relay.on_off = receiveBytes[2] == 0 ? 0 : 1;
                                        HomePage.UpdataLightView(relay);
                                    }
                                    else if (function.functionType == "brightness")
                                    else if (function.functionType == "Dimmer")
                                    {
                                        var dimmer = function as Light;
                                        dimmer.state = receiveBytes[2] == 0 ? 0 : 1;
                                        dimmer.dicPropert["brightness"] = receiveBytes[1];
                                        //dimmer.brightness = receiveBytes[1];
                                        if (receiveBytes[2] > 0)
                                        dimmer.on_off = receiveBytes[2] == 0 ? 0 : 1;
                                        if (dimmer.on_off == 1)
                                        {
                                            dimmer.brightness = receiveBytes[2];
                                            dimmer.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
                                        }
                                        HomePage.UpdataLightView(dimmer);
                                        RoomPage.UpdataStates(dimmer);
                                        FunctionPage.UpdataStates(dimmer);
                                        DimmerPage.UpdataStates(dimmer);
                                    }
                                }
                            }
                        }
                        break;
                    case Command.SetLogicLoopColorACK:
                        foreach (var function in DB_ResidenceData.residenceData.functionList.lights)
                        {
                            if (function.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                            {
                                if (function.functionType == "RGB")
                                {
                                    var light = function as Light;
                                    if (receiveBytes[2] == 0 && light.on_off == 0)
                                    {
                                        break;
                                    }
                                    var rgb = function as Light;
                                    rgb.on_off = receiveBytes[1] == 0 ? 0 : 1;
                                    if (rgb.on_off == 1)
                                    {
                                        rgb.brightness = receiveBytes[1];
                                        rgb.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[1] + "%";
                                    }
                                    rgb.redColor = receiveBytes[6];
                                    rgb.greenColor = receiveBytes[7];
                                    rgb.blueColor = receiveBytes[8];
                                    HomePage.UpdataLightView(rgb);
                                    RoomPage.UpdataStates(rgb);
                                    FunctionPage.UpdataStates(rgb);
                                    RGBPage.UpdataStates(rgb);
                                }
                            }
                        }
                        break;
                }
            }
            catch (Exception ex)