wei
2020-11-27 e53a1951d6aa07ad22aad9816da4703496fcbccd
HDL_ON/DAL/DriverLayer/Packet.cs
@@ -73,7 +73,7 @@
                byte targetDeviceID = this.Bytes[24];
                //不是要接收的指令就返回
                if (!((targetSubnetID == 252 && targetDeviceID == 252) || (targetSubnetID == 0xff && targetDeviceID == 0xff)))
                if (!((targetSubnetID == 0 && targetDeviceID == 252) || (targetSubnetID == 0xff && targetDeviceID == 0xff)))
                {
                    return;
                }
@@ -124,7 +124,7 @@
                            {
                                if (updataObj.functionType != FunctionType.RGB)
                                {
                                    if (updataObj.trait_on_off.value.ToString() == "on")
                                    if (updataObj.trait_on_off.curValue.ToString() == "on")
                                    {
                                        switch (updataObj.functionType)
                                        {
@@ -169,8 +169,8 @@
                            {
                                if (light.functionType != FunctionType.RGB)
                                {
                                    light.trait_on_off.value = receiveBytes[light.bus_Data.LoopID] == 0 ? "off" : "on";
                                    if (light.trait_on_off.value.ToString() == "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];
                                        light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
@@ -196,8 +196,8 @@
                                if (e != null)
                                {
                                    var fan = e as Fan;
                                    fan.trait_on_off.value = receiveBytes[2] == 0 ? "off" : "on";
                                    if (fan.trait_on_off.value.ToString() == "on")
                                    fan.trait_on_off.curValue = receiveBytes[2] == 0 ? "off" : "on";
                                    if (fan.trait_on_off.curValue.ToString() == "on")
                                    {
                                        fan.openLevel = receiveBytes[2];
                                        fan.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
@@ -227,7 +227,7 @@
                            {
                                if (rgb.functionType == FunctionType.RGB)
                                {
                                    rgb.trait_on_off.value = receiveBytes[1] > 0 ? "on" : "off";
                                    rgb.trait_on_off.curValue = receiveBytes[1] > 0 ? "on" : "off";
                                    if (receiveBytes[1] > 0)
                                    {
                                        rgb.brightness = receiveBytes[1];
@@ -256,11 +256,11 @@
                                {
                                    if (receiveBytes[1] > 1)
                                    {
                                        curtain.trait_on_off.value = "on";
                                        curtain.trait_on_off.curValue = "on";
                                    }
                                    else
                                    {
                                        curtain.trait_on_off.value = "off";
                                        curtain.trait_on_off.curValue = "off";
                                    }
                                    curtain.percent = receiveBytes[1];
                                    curtain.lastState = Language.StringByID(StringId.Open) + curtain.percent + "%";
@@ -272,14 +272,14 @@
                                    switch (receiveBytes[1])
                                    {
                                        case 0:
                                            curtain.trait_on_off.value = "stop";
                                            curtain.trait_on_off.curValue = "stop";
                                            break;
                                        case 1:
                                            curtain.trait_on_off.value = "on";
                                            curtain.trait_on_off.curValue = "on";
                                            curtain.lastState = Language.StringByID(StringId.Open);
                                            break;
                                        case 2:
                                            curtain.trait_on_off.value = "off";
                                            curtain.trait_on_off.curValue = "off";
                                            curtain.lastState = Language.StringByID(StringId.Close);
                                            break;
                                    }
@@ -311,12 +311,12 @@
                            {
                                ac.curTempType = receiveBytes[1];
                                ac.indoorTemp = receiveBytes[2];
                                ac.trait_on_off.value = receiveBytes[8] == 1 ? "on" : "off";
                                ac.trait_on_off.curValue = receiveBytes[8] == 1 ? "on" : "off";
                                ac.curModeIndex = receiveBytes[9];
                                ac.curFanIndex = receiveBytes[10];
                                ac.trait_temp.value = receiveBytes[11];
                                ac.trait_temp.curValue = receiveBytes[11];
                                ac.lastState = "";
                                switch (ac.trait_mode.value.ToString())
                                switch (ac.trait_mode.curValue.ToString())
                                {
                                    case "cool":
                                        ac.lastState = Language.StringByID(StringId.Cool);
@@ -334,7 +334,7 @@
                                        ac.lastState = Language.StringByID(StringId.AirSupply);
                                        break;
                                }
                                switch (ac.trait_fan.value.ToString())
                                switch (ac.trait_fan.curValue.ToString())
                                {
                                    case "high":
                                        ac.lastState += " " + Language.StringByID(StringId.HighWindSpeed);
@@ -349,7 +349,7 @@
                                        ac.lastState += " " + Language.StringByID(StringId.Auto);
                                        break;
                                }
                                ac.lastState += " " + ac.trait_temp.value + ac.tempUnitString;
                                ac.lastState += " " + ac.trait_temp.curValue + ac.tempUnitString;
                                RoomPage.UpdataStates(ac);
                                FunctionPage.UpdataStates(ac);
                                HomePage.UpdataFunctionStates(ac);
@@ -365,7 +365,7 @@
                            if (fh.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                            {
                                fh.curTempType = receiveBytes[2];
                                fh.trait_on_off.value = receiveBytes[1] % 2 == 0 ? "off" : "on";
                                fh.trait_on_off.curValue = receiveBytes[1] % 2 == 0 ? "off" : "on";
                                fh.curModeIndex = receiveBytes[3];
                                if (fh.modeTemp.ContainsKey("normal"))
                                {
@@ -400,39 +400,39 @@
                                    fh.modeTemp.Add("away", receiveBytes[7]);
                                }
                                switch (fh.trait_mode.value)
                                switch (fh.trait_mode.curValue)
                                {
                                    case "normal":
                                        fh.lastState = Language.StringByID(StringId.Normal);
                                        fh.trait_temp.value = receiveBytes[4];
                                        fh.trait_temp.curValue = receiveBytes[4];
                                        break;
                                    case "day":
                                        fh.lastState = Language.StringByID(StringId.Day);
                                        fh.trait_temp.value = receiveBytes[5];
                                        fh.trait_temp.curValue = receiveBytes[5];
                                        break;
                                    case "night":
                                        fh.lastState = Language.StringByID(StringId.Night);
                                        fh.trait_temp.value = receiveBytes[6];
                                        fh.trait_temp.curValue = receiveBytes[6];
                                        break;
                                    case "timer":
                                        fh.lastState = Language.StringByID(StringId.Auto);
                                        if (receiveBytes[8] == 0)
                                        {
                                            fh.timeFlag = 0;
                                            fh.trait_temp.value = receiveBytes[5];
                                            fh.trait_temp.curValue = receiveBytes[5];
                                        }
                                        else
                                        {
                                            fh.timeFlag = 1;
                                            fh.trait_temp.value = receiveBytes[6];
                                            fh.trait_temp.curValue = receiveBytes[6];
                                        }
                                        break;
                                    case "away":
                                        fh.trait_temp.value = receiveBytes[7];
                                        fh.trait_temp.curValue = receiveBytes[7];
                                        fh.lastState = Language.StringByID(StringId.Away);
                                        break;
                                }
                                fh.lastState += " " + fh.trait_temp.value + fh.tempUnitString;
                                fh.lastState += " " + fh.trait_temp.curValue + fh.tempUnitString;
                                RoomPage.UpdataStates(fh);
                                FunctionPage.UpdataStates(fh);
                                HomePage.UpdataFunctionStates(fh);
@@ -532,13 +532,13 @@
                                switch (receiveBytes[0])
                                {
                                    case 3://
                                        ac.trait_on_off.value = receiveBytes[1] == 1 ? "on" : "off";
                                        ac.trait_on_off.curValue = receiveBytes[1] == 1 ? "on" : "off";
                                        break;
                                    case 4:
                                    case 7:
                                    case 8:
                                    case 19:
                                        ac.trait_temp.value = receiveBytes[1];
                                        ac.trait_temp.curValue = receiveBytes[1];
                                        break;
                                    case 5:
                                        ac.curFanIndex = receiveBytes[1];
@@ -549,7 +549,7 @@
                                }
                                ac.lastState = "";
                                ac.lastState += " " + ac.trait_temp.value + ac.tempUnitString;
                                ac.lastState += " " + ac.trait_temp.curValue + ac.tempUnitString;
                                RoomPage.UpdataStates(ac);
                                FunctionPage.UpdataStates(ac);
                                HomePage.UpdataFunctionStates(ac);
@@ -573,9 +573,6 @@
                        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 DEBUG
                        DB_ResidenceData.residenceData.residenceGatewayMAC = "4E47323347591243";
#endif
                        if (DB_ResidenceData.residenceData.residenceGatewayMAC == mac)
                        {
                            DriverLayer.Control.Ins.GatewayOnline = true;