From af1cb3ecd0f4b0589e00b28f7f9edccf39e6e12b Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 10 九月 2020 16:15:11 +0800
Subject: [PATCH] 202009101
---
HDL_ON/DriverLayer/CommonPage.cs | 232 ++++++++++++++++++++++++++++++++-------------------------
1 files changed, 131 insertions(+), 101 deletions(-)
diff --git a/HDL_ON/DriverLayer/CommonPage.cs b/HDL_ON/DriverLayer/CommonPage.cs
index d12e95e..da2744c 100644
--- a/HDL_ON/DriverLayer/CommonPage.cs
+++ b/HDL_ON/DriverLayer/CommonPage.cs
@@ -12,8 +12,6 @@
{
public static class CommonPage
{
-
- public static bool IsRemote;
public static Action RefreshAir;
public static string FindGatewayChilrenIPAddress = new NetWiFi().BroadcastIpAddress.ToString();
private static string ip = "0.0.0.0";
@@ -67,31 +65,30 @@
}
}
}
- public static bool isHttpListenerStart;
- public static DateTime dt;
-
+ //public static bool isHttpListenerStart;
+ //public static DateTime dt;
//public static byte currentSubnetID = 0;
- public static void InitHttpListener()
- {
- if (isHttpListenerStart)
- {
- return;
- }
- Console.WriteLine("Init Http Listener !");
- HttpListener.Start(new NetWiFi().IpAddress, 6002);
- HttpListener.EventHandler -= httpListener_EventHandler;
- HttpListener.EventHandler += httpListener_EventHandler;
- isHttpListenerStart = true;
- }
- public static void CloseHttpListener()
- {
- //isHttpListenerStart = false;
- //return;
- if (!isHttpListenerStart)
- return;
- HttpListener.Close();
- isHttpListenerStart = false;
- }
+ //public static void InitHttpListener()
+ //{
+ // if (isHttpListenerStart)
+ // {
+ // return;
+ // }
+ // Console.WriteLine("Init Http Listener !");
+ // HttpListener.Start(new NetWiFi().IpAddress, 6002);
+ // HttpListener.EventHandler -= httpListener_EventHandler;
+ // HttpListener.EventHandler += httpListener_EventHandler;
+ // isHttpListenerStart = true;
+ //}
+ //public static void CloseHttpListener()
+ //{
+ // //isHttpListenerStart = false;
+ // //return;
+ // if (!isHttpListenerStart)
+ // return;
+ // HttpListener.Close();
+ // isHttpListenerStart = false;
+ //}
/// <summary>
/// 鍒濆鍖栧鐞唖ocket鎺ユ敹鐨勬暟鎹�
/// </summary>
@@ -119,16 +116,15 @@
switch (command)
{
- case Command.ReadLightSingleLoopBrightnessACK:
case Command.SetSingleLightACK:
- foreach (var light in DB_ResidenceData.residenceData.functionList.lights)
+ foreach (var light in DB_ResidenceData.functionList.lights)
{
if (light.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
{
if (light.functionType != FunctionType.RGB)
{
- light.on_off = receiveBytes[2] == 0 ? "off" : "on";
- if (light.on_off == "on")
+ light.trait_on_off.value = receiveBytes[2] == 0 ? "off" : "on";
+ if (light.trait_on_off.value.ToString() == "on")
{
light.brightness = receiveBytes[2];
light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
@@ -150,15 +146,15 @@
}
}
- foreach (var e in DB_ResidenceData.residenceData.functionList.electricals)
+ foreach (var e in DB_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.trait_on_off.value = receiveBytes[2] == 0 ? "off" : "on";
+ if (fan.trait_on_off.value == "on")
{
fan.openLevel = receiveBytes[2];
fan.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
@@ -181,15 +177,73 @@
}
break;
+ 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));
+ if (light != null)
+ {
+ 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.brightness = receiveBytes[2];
+ light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
+ }
+ HomePage.UpdataFunctionStates(light);
+ RoomPage.UpdataStates(light);
+ FunctionPage.UpdataStates(light);
+ ClassificationPage.UpdataInfo(light);
+ switch (light.functionType)
+ {
+ case FunctionType.Relay:
+ RelayPage.UpdataState(light);
+ break;
+ case FunctionType.Dimmer:
+ DimmerPage.UpdataStates(light);
+ break;
+ }
+ }
+ }
+ else
+ {
+ 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;
+ fan.trait_on_off.value = receiveBytes[2] == 0 ? "off" : "on";
+ if (fan.trait_on_off.value.ToString() == "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:
- foreach (var rgb in DB_ResidenceData.residenceData.functionList.lights)
+ foreach (var rgb in DB_ResidenceData.functionList.lights)
{
if (rgb.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
{
if (rgb.functionType == FunctionType.RGB)
{
- rgb.on_off = receiveBytes[1] > 0 ? "on" : "off";
+ rgb.trait_on_off.value = receiveBytes[1] > 0 ? "on" : "off";
if (receiveBytes[1] > 0)
{
rgb.brightness = receiveBytes[1];
@@ -210,7 +264,7 @@
break;
case Command.SetCurtainModelStutasACK:
case Command.ReadCurtainStutasACK:
- foreach (var curtain in DB_ResidenceData.residenceData.functionList.curtains)
+ foreach (var curtain in DB_ResidenceData.functionList.curtains)
{
if (curtain.bus_Data.SubnetID == subnetID && curtain.bus_Data.DeviceID == deviceID)
{
@@ -218,14 +272,14 @@
{
if (receiveBytes[1] > 1)
{
- curtain.on_off = "on";
+ curtain.trait_on_off.value = "on";
}
else
{
- curtain.on_off = "off";
+ curtain.trait_on_off.value = "off";
}
- curtain.openLevel = receiveBytes[1];
- curtain.lastState = Language.StringByID(StringId.Open) + curtain.openLevel + "%";
+ curtain.percent = receiveBytes[1];
+ curtain.lastState = Language.StringByID(StringId.Open) + curtain.percent + "%";
}
else
{
@@ -234,14 +288,14 @@
switch (receiveBytes[1])
{
case 0:
- curtain.on_off = "stop";
+ curtain.trait_on_off.value = "stop";
break;
case 1:
- curtain.on_off = "on";
+ curtain.trait_on_off.value = "on";
curtain.lastState = Language.StringByID(StringId.Open);
break;
case 2:
- curtain.on_off = "off";
+ curtain.trait_on_off.value = "off";
curtain.lastState = Language.StringByID(StringId.Close);
break;
}
@@ -262,18 +316,18 @@
break;
case Command.SetACModeACK:
case Command.ReadACModeACK:
- foreach (var ac in DB_ResidenceData.residenceData.functionList.aCs)
+ foreach (var ac in DB_ResidenceData.functionList.aCs)
{
if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
{
ac.curTempType = receiveBytes[1];
ac.indoorTemp = receiveBytes[2];
- ac.on_off = receiveBytes[8] == 1 ? "on" : "off";
+ ac.trait_on_off.value = receiveBytes[8] == 1 ? "on" : "off";
ac.curModeIndex = receiveBytes[9];
ac.curFanIndex = receiveBytes[10];
- ac.curTemp = receiveBytes[11];
+ ac.trait_temp.value = receiveBytes[11];
ac.lastState = "";
- switch (ac.trait_mode.curValues.ToString())
+ switch (ac.trait_mode.value.ToString())
{
case "cool":
ac.lastState = Language.StringByID(StringId.Cool);
@@ -291,7 +345,7 @@
ac.lastState = Language.StringByID(StringId.AirSupply);
break;
}
- switch (ac.trait_fan.curValues.ToString())
+ switch (ac.trait_fan.value.ToString())
{
case "high":
ac.lastState += " " + Language.StringByID(StringId.HighWindSpeed);
@@ -306,7 +360,7 @@
ac.lastState += " " + Language.StringByID(StringId.Auto);
break;
}
- ac.lastState += " " + ac.curTemp + ac.curTempTypeString;
+ ac.lastState += " " + ac.trait_temp.value + ac.tempUnitString;
RoomPage.UpdataStates(ac);
FunctionPage.UpdataStates(ac);
HomePage.UpdataFunctionStates(ac);
@@ -317,20 +371,20 @@
break;
case Command.ReadFloorHeatACK:
case Command.SetFloorHeatACK:
- foreach (var fh in DB_ResidenceData.residenceData.functionList.floorHeatings)
+ foreach (var fh in DB_ResidenceData.functionList.floorHeatings)
{
if (fh.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
{
fh.curTempType = receiveBytes[2];
- fh.on_off = receiveBytes[1] % 2 == 0 ? "off" : "on";
+ fh.trait_on_off.value = receiveBytes[1] % 2 == 0 ? "off" : "on";
fh.curModeIndex = receiveBytes[3];
- if (fh.modeTemp.ContainsKey("ordinary"))
+ if (fh.modeTemp.ContainsKey("normal"))
{
- fh.modeTemp["ordinary"] = receiveBytes[4];
+ fh.modeTemp["normal"] = receiveBytes[4];
}
else
{
- fh.modeTemp.Add("ordinary", receiveBytes[4]);
+ fh.modeTemp.Add("normal", receiveBytes[4]);
}
if (fh.modeTemp.ContainsKey("day"))
{
@@ -340,7 +394,6 @@
{
fh.modeTemp.Add("day", receiveBytes[5]);
}
-
if (fh.modeTemp.ContainsKey("night"))
{
fh.modeTemp["night"] = receiveBytes[6];
@@ -349,7 +402,6 @@
{
fh.modeTemp.Add("night", receiveBytes[6]);
}
-
if (fh.modeTemp.ContainsKey("away"))
{
fh.modeTemp["away"] = receiveBytes[7];
@@ -358,24 +410,32 @@
{
fh.modeTemp.Add("away", receiveBytes[7]);
}
- switch (fh.curMode)
+
+ switch (fh.trait_mode.value)
{
- case "ordinary":
- fh.lastState = Language.StringByID(StringId.Ordinary);
+ case "normal":
+ fh.lastState = Language.StringByID(StringId.Normal);
+ fh.curTemp = receiveBytes[4];
break;
case "day":
fh.lastState = Language.StringByID(StringId.Day);
+ fh.curTemp = receiveBytes[5];
break;
case "night":
fh.lastState = Language.StringByID(StringId.Night);
+ fh.curTemp = receiveBytes[6];
break;
case "timer":
fh.lastState = Language.StringByID(StringId.Auto);
if (receiveBytes[8] == 0)
{
+ fh.timeFlag = 0;
+ fh.curTemp = receiveBytes[5];
}
else
{
+ fh.timeFlag = 1;
+ fh.curTemp = receiveBytes[6];
}
break;
case "away":
@@ -383,7 +443,7 @@
fh.lastState = Language.StringByID(StringId.Away);
break;
}
- fh.lastState += " " + fh.curTemp + fh.curTempTypeString;
+ fh.lastState += " " + fh.curTemp + fh.tempUnitString;
RoomPage.UpdataStates(fh);
FunctionPage.UpdataStates(fh);
HomePage.UpdataFunctionStates(fh);
@@ -396,7 +456,7 @@
FunctionType dt = (FunctionType)(11 * 256 + receiveBytes[1]);
string tag = receiveBytes[1] + "_" + subnetID + "_" + deviceID + "_" + receiveBytes[2];
- foreach (var sensor in DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience)
+ foreach (var sensor in DB_ResidenceData.functionList.sensorsEnvironmentalScience)
{
if (sensor.bus_Data != null)
{
@@ -429,7 +489,7 @@
break;
case Command.New_Analog_Quantity_BROADCAST:
string tag1 = receiveBytes[1] + "_" + subnetID + "_" + deviceID + "_" + receiveBytes[2];
- foreach (var sensor in DB_ResidenceData.residenceData.functionList.sensorsEnvironmentalScience)
+ foreach (var sensor in DB_ResidenceData.functionList.sensorsEnvironmentalScience)
{
if (sensor.bus_Data != null)
{
@@ -477,20 +537,20 @@
{
break;
}
- foreach (var ac in DB_ResidenceData.residenceData.functionList.aCs)
+ foreach (var ac in DB_ResidenceData.functionList.aCs)
{
if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + reACPanel)
{
switch (receiveBytes[0])
{
case 3://
- ac.on_off = receiveBytes[1] == 1 ? "on" : "off";
+ ac.trait_on_off.value = receiveBytes[1] == 1 ? "on" : "off";
break;
case 4:
case 7:
case 8:
case 19:
- ac.curTemp = receiveBytes[1];
+ ac.trait_temp.value = receiveBytes[1];
break;
case 5:
ac.curFanIndex = receiveBytes[1];
@@ -501,7 +561,7 @@
}
ac.lastState = "";
- ac.lastState += " " + ac.curTemp + ac.curTempTypeString;
+ ac.lastState += " " + ac.trait_temp.value + ac.tempUnitString;
RoomPage.UpdataStates(ac);
FunctionPage.UpdataStates(ac);
HomePage.UpdataFunctionStates(ac);
@@ -545,7 +605,7 @@
break;
case Command.ReadPanleTempACK://1944
case Command.PanleBroadcastTemp:
- foreach (var ac in DB_ResidenceData.residenceData.functionList.aCs)
+ foreach (var ac in DB_ResidenceData.functionList.aCs)
{
if (ac.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
{
@@ -581,7 +641,7 @@
}
return s;//
}
-
+ /* 2020-09-01寮冪敤锛屼娇鐢╰cp鎺ユ敹鏁版嵁
static void httpListener_EventHandler(System.Collections.Specialized.NameValueCollection nameValueCollection, System.IO.Stream outputStream, System.IO.Stream inputStream)
{
try
@@ -625,9 +685,9 @@
{
foreach(var obj in common.objects)
{
- DB_ResidenceData.residenceData.functionList.AddFunction(obj);
+ DB_ResidenceData.functionList.AddFunction(obj);
}
- DB_ResidenceData.residenceData.functionList.GetAllFunction();
+ DB_ResidenceData.functionList.GetAllFunction();
}
}
else
@@ -642,36 +702,6 @@
MainPage.Log("httpListener_EventHandler" + ex.ToString());
}
}
-
- /// <summary>
- /// 鐩戝惉璇锋眰鐨凥ttp绔彛
- /// </summary>
- public static int Port = 5555;
- static void httpListener_EventHandler(string rawUrl, System.IO.Stream outputStream, System.IO.Stream inputStream)
- {
- foreach (var musicInfo in MusicInfo.MusicInfoList)
- {
- if ("audio-item-" + musicInfo.ID == rawUrl.TrimStart('/'))
- {
- var file = new System.IO.FileStream(musicInfo.Data, System.IO.FileMode.Open, System.IO.FileAccess.Read);
- byte[] bytes = new byte[1024];
- try
- {
- while (file.CanRead)
- {
- int len = file.Read(bytes, 0, bytes.Length);
- if (len == 0)
- {
- break;
- }
- outputStream.Write(bytes, 0, len);
- }
- }
- catch { }
- file.Close();
- break;
- }
- }
- }
+ */
}
}
\ No newline at end of file
--
Gitblit v1.8.0