From 7f233a10afa6882b4d9531185af60e8843bc1af2 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 11 五月 2020 09:21:36 +0800
Subject: [PATCH] 20200511

---
 HDL_ON/DriverLayer/CommonPage.cs |  136 ++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 114 insertions(+), 22 deletions(-)

diff --git a/HDL_ON/DAL/Net/CommonPage.cs b/HDL_ON/DriverLayer/CommonPage.cs
similarity index 72%
rename from HDL_ON/DAL/Net/CommonPage.cs
rename to HDL_ON/DriverLayer/CommonPage.cs
index c8d3b65..f684d0b 100644
--- a/HDL_ON/DAL/Net/CommonPage.cs
+++ b/HDL_ON/DriverLayer/CommonPage.cs
@@ -65,7 +65,7 @@
             {
                 return;
             }
-            HttpListener.Start(new NetWiFi().IpAddress, 6001);
+            HttpListener.Start(new NetWiFi().IpAddress, 6002);
             HttpListener.EventHandler -= httpListener_EventHandler;
             HttpListener.EventHandler += httpListener_EventHandler;
             isHttpListenerStart = true;
@@ -102,26 +102,12 @@
                 {
                     case Command.ReadLightSingleLoopBrightnessACK:
                     case Command.SetSingleLightACK:
-                        foreach (var function in DB_ResidenceData.residenceData.functionList.lights)
+                        foreach (var light in DB_ResidenceData.residenceData.functionList.lights)
                         {
-                            if (function.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
+                            if (light.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                             {
-                                if (function.functionCategory == FunctionCategory.Light&& function.functionType != FunctionType.RGB)
+                                if ( light.functionType != FunctionType.RGB)
                                 {
-                                    var light = function as Light;
-                                    //if (receiveBytes[2] == 0 && light.on_off == "off")
-                                    //{
-                                    //    break;
-                                    //}
-                                    //if (function.functionType == "Relay")
-                                    //{
-                                    //    var relay = function as Light;
-                                    //    relay.on_off = receiveBytes[2] == 0 ? "off" : "on";
-                                    //    HomePage.UpdataLightView(relay);
-                                    //}
-                                    //else if (function.functionType == "Dimmer")
-                                    //{
-                                    //var light = function as Light;
                                     light.on_off = receiveBytes[2] == 0 ? "off" : "on";
                                     if (light.on_off == "on")
                                     {
@@ -141,10 +127,40 @@
                                             DimmerPage.UpdataStates(light);
                                             break;
                                     }
-                                    //}
                                 }
                             }
                         }
+
+                        foreach (var e in DB_ResidenceData.residenceData.functionList.electricals)
+                        {
+                            if (e.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
+                            {
+                                if (e.functionType == FunctionType.Fan)
+                                {
+                                    var fan = e as Fan;
+                                    fan.on_off = receiveBytes[2] == 0 ? "off" : "on";
+                                    if (fan.on_off == "on")
+                                    {
+                                        fan.openLevel = receiveBytes[2];
+                                        fan.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
+                                    }
+                                    HomePage.UpdataFunctionStates(fan);
+                                    RoomPage.UpdataStates(fan);
+                                    FunctionPage.UpdataStates(fan);
+                                    ClassificationPage.UpdataInfo(fan);
+                                    switch (fan.functionType)
+                                    {
+                                        case FunctionType.Fan:
+                                            FanPage.UpdataState(fan);
+                                            break;
+                                        case FunctionType.Socket:
+
+                                            break;
+                                    }
+                                }
+                            }
+                        }
+
                         break;
                     case Command.SetLogicLoopColorACK:
                     case Command.ReadLogicLoopColorACK:
@@ -231,7 +247,7 @@
                                 ac.curFanIndex = receiveBytes[10];
                                 ac.curTemp = receiveBytes[11];
                                 ac.lastState = "";
-                                switch (ac.curMode)
+                                switch (ac.trait_mode.curValues.ToString())
                                 {
                                     case "cool":
                                         ac.lastState = Language.StringByID(StringId.Cool);
@@ -249,7 +265,7 @@
                                         ac.lastState = Language.StringByID(StringId.AirSupply);
                                         break;
                                 }
-                                switch (ac.curFan)
+                                switch (ac.trait_fan.curValues.ToString())
                                 {
                                     case "high":
                                         ac.lastState += " " + Language.StringByID(StringId.HighWindSpeed);
@@ -264,7 +280,7 @@
                                         ac.lastState += " " + Language.StringByID(StringId.Auto);
                                         break;
                                 }
-                                ac.lastState += " " + ac.curTemp + "掳C";
+                                ac.lastState += " " + ac.curTemp + ac.curTempTypeString;
                                 RoomPage.UpdataStates(ac);
                                 FunctionPage.UpdataStates(ac);
                                 HomePage.UpdataFunctionStates(ac);
@@ -273,6 +289,82 @@
                             }
                         }
                         break;
+                    case Command.ReadFloorHeatACK:
+                    case Command.SetFloorHeatACK:
+                        foreach (var fh in DB_ResidenceData.residenceData.functionList.floorHeatings)
+                        {
+                            if (fh.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
+                            {
+                                fh.curTempType = receiveBytes[2];
+                                fh.on_off = receiveBytes[1] % 2 ==0?"off":"on";
+                                fh.curModeIndex = receiveBytes[3];
+                                if (fh.modeTemp.ContainsKey("ordinary"))
+                                {
+                                    fh.modeTemp["ordinary"]= receiveBytes[4];
+                                }
+                                else
+                                {
+                                    fh.modeTemp.Add("ordinary", receiveBytes[4]);
+                                }
+                                if (fh.modeTemp.ContainsKey("day"))
+                                {
+                                    fh.modeTemp["day"] = receiveBytes[5];
+                                }
+                                else
+                                {
+                                    fh.modeTemp.Add("day", receiveBytes[5]);
+                                }
+
+                                if (fh.modeTemp.ContainsKey("night"))
+                                {
+                                    fh.modeTemp["night"] = receiveBytes[6];
+                                }
+                                else
+                                {
+                                    fh.modeTemp.Add("night", receiveBytes[6]);
+                                }
+
+                                if (fh.modeTemp.ContainsKey("away"))
+                                {
+                                    fh.modeTemp["away"] = receiveBytes[7];
+                                }
+                                else
+                                {
+                                    fh.modeTemp.Add("away", receiveBytes[7]);
+                                }
+                                switch (fh.curMode)
+                                {
+                                    case "ordinary":
+                                        fh.lastState = Language.StringByID(StringId.Ordinary);
+                                        break;
+                                    case "day":
+                                        fh.lastState = Language.StringByID(StringId.Day);
+                                        break;
+                                    case "night":
+                                        fh.lastState = Language.StringByID(StringId.Night);
+                                        break;
+                                    case "timer":
+                                        fh.lastState = Language.StringByID(StringId.Auto);
+                                        if(receiveBytes[8]==0)
+                                        {
+                                        }else
+                                        {
+                                        }
+                                        break;
+                                    case "away":
+                                        fh.curTemp = receiveBytes[7];
+                                        fh.lastState = Language.StringByID(StringId.Away);
+                                        break;
+                                }
+                                fh.lastState += " " + fh.curTemp + fh.curTempTypeString;
+                                RoomPage.UpdataStates(fh);
+                                FunctionPage.UpdataStates(fh);
+                                HomePage.UpdataFunctionStates(fh);
+                                ClassificationPage.UpdataInfo(fh);
+                                FloorHeatingPage.UpdataStates(fh);
+                            }
+                        }
+                        break;
                 }
             }
             catch (Exception ex)

--
Gitblit v1.8.0