From b7591dba0127890e24eb1ae41e150a0ad8ee1a51 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 17 七月 2020 11:49:21 +0800
Subject: [PATCH] 2020-07-17 1.修复在大屏幕手机,部分界面图标会变形问题.
---
Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs | 140 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 119 insertions(+), 21 deletions(-)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs b/Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs
index 3991130..ac206b1 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/CommonPage.cs
@@ -103,7 +103,7 @@
foreach (var bin in usefullBytes) {
pushBytesString += bin + ",";
}
- Console.WriteLine (pushBytesString);
+ Utlis.WriteLine (pushBytesString);
#endif
if (DeviceList.Find ((l) => { return l.SubnetID == subnetID && l.DeviceID == deviceID; }) != null) {
return;
@@ -122,7 +122,7 @@
continue;
}
DeviceType deviceType_wireless = (DeviceType)(usefullBytes [i] * 256 + usefullBytes [i + 1]);
- Console.WriteLine (deviceType_wireless.ToString ());
+ Utlis.WriteLine (deviceType_wireless.ToString ());
if (noRemake || MyEncodingGB2312.GetString (usefullBytes, 2, 20).Trim ('\0') == "") {
byte [] ddd = CommonPage.MyEncodingGB2312.GetBytes (deviceType_wireless.ToString () + "-" + subnetID.ToString () + "-" + deviceID.ToString ());
byte [] newddd = new byte [20];
@@ -256,7 +256,8 @@
}
break;
case Command.SetSingleLightACK:
- Console.WriteLine ("Command.SetSingleLightACK");
+ //Utlis.WriteLine ($"Command.SetSingleLightACK: subnetID:{subnetID} deviceID:{deviceID} 鍥炶矾锛歿usefullBytes [0]}");
+ //Utlis.WriteLine ("Command.SetSingleLightACK");
foreach (var room in Room.Lists) {
var common = room.DeviceList.Find ((obj) => obj.CommonLoopID == subnetID.ToString () + "_" + deviceID.ToString () + "_" + usefullBytes [0].ToString ());
if (common != null) {
@@ -279,7 +280,14 @@
hadBeUpdate = false;
(common as LightDimming).CurrentBrightness = usefullBytes [2];
} else if (common.Type == DeviceType.FanModule) {
+ //if ((common as FanModule).Switch == usefullBytes [2]) {
+ // hadBeUpdate = false;
+ //}
(common as FanModule).Switch = usefullBytes [2];
+ if (usefullBytes [2] != 0)
+ (common as FanModule).WindSpeed = usefullBytes [2];
+
+ //(common as FanModule).Switch = usefullBytes [2];
} else if (common.Type == DeviceType.LightMixSwitch) {
if ((common as LightMixSwitch).CurrentBrightness == usefullBytes [2])
hadBeUpdate = false;
@@ -312,6 +320,7 @@
if (!string.IsNullOrEmpty (room.Name))
UserDeviceToLight.UpdateBrighingCount (updateFlag);
if (hadBeUpdate) {
+
UserRoom.UpdataDeviceStatus (common);
UserLightPage.UpdateStatus (updateFlag, usefullBytes [2]);
UserDeviceToLight.UpdateStatus (updateFlag, usefullBytes [2]);
@@ -326,7 +335,7 @@
}
}
break;
- case Command. ReadAnalogValueACK:
+ case Command.ReadAnalogValueACK:
foreach (var room in Room.Lists) {
foreach (var common in room.DeviceList) {
if (common.SubnetID != subnetID || common.DeviceID != deviceID || common.LoopID != usefullBytes [1]) {
@@ -339,18 +348,20 @@
UserDeviceToLight.UpdataEnergy (usefullBytes [0], updateFlag, usefullBytes [2] * 256 + usefullBytes [3]);
UserRoom.UpdataEnergy (usefullBytes [0], common.Type + "_" + updateFlag, usefullBytes [2] * 256 + usefullBytes [3]);
break;
- } else if (usefullBytes [0] == 11) {
- UserDeviceToSocket.UpdataEnergy (usefullBytes [0], updateFlag, usefullBytes [2] * 256 * 256 * 256 + usefullBytes [3] * 256 * 256 + usefullBytes [4] * 256 + usefullBytes [5]);
- UserDeviceToLight.UpdataEnergy (usefullBytes [0], updateFlag, usefullBytes [2] * 256 * 256 * 256 + usefullBytes [3] * 256 * 256 + usefullBytes [4] * 256 + usefullBytes [5]);
- UserRoom.UpdataEnergy (usefullBytes [0], common.Type + "_" + updateFlag, usefullBytes [2] * 256 * 256 * 256 + usefullBytes [3] * 256 * 256 + usefullBytes [4] * 256 + usefullBytes [5]);
- break;
}
+ //2020-07-01 瀹㈡埛鎻愬嚭闅愯棌kwh
+ //else if (usefullBytes [0] == 11) {
+ // UserDeviceToSocket.UpdataEnergy (usefullBytes [0], updateFlag, usefullBytes [2] * 256 * 256 * 256 + usefullBytes [3] * 256 * 256 + usefullBytes [4] * 256 + usefullBytes [5]);
+ // UserDeviceToLight.UpdataEnergy (usefullBytes [0], updateFlag, usefullBytes [2] * 256 * 256 * 256 + usefullBytes [3] * 256 * 256 + usefullBytes [4] * 256 + usefullBytes [5]);
+ // UserRoom.UpdataEnergy (usefullBytes [0], common.Type + "_" + updateFlag, usefullBytes [2] * 256 * 256 * 256 + usefullBytes [3] * 256 * 256 + usefullBytes [4] * 256 + usefullBytes [5]);
+ // break;
+ //}
}
- int dddd = usefullBytes [0] & 0x3F;
+ int dddd = usefullBytes [0] & 0x3F;
// 0xXX锛氬叕鍙稿唴閮ㄥ崗璁搴旂殑搴忓彿
// common.Type锛氬搴旂殑鏄紪杈戣蒋浠剁殑搴忓彿(娌℃湁涓�涓�瀵瑰簲锛屾槸涓轰簡灏嗙浉杩戠殑璋冩暣鍦ㄤ竴璧凤紝鏂逛究瀹㈡埛浣跨敤)
@@ -704,7 +715,7 @@
case "DISPMODE":
if (7 <= backResult [1].Length) {
music.playMode = int.Parse (backResult [1].Substring (6, 1));
- System.Console.WriteLine ("DISPMODE=====" + music.playMode);
+ Utlis.WriteLine ("DISPMODE=====" + music.playMode);
}
break;
}
@@ -1199,7 +1210,7 @@
continue;
}
deviceType = (DeviceType)(usefullBytes [iReadDeviceModulACK] * 256 + usefullBytes [iReadDeviceModulACK + 1]);
- Console.WriteLine (deviceType.ToString ());
+ Utlis.WriteLine (deviceType.ToString ());
string devcieTempName = MyEncodingGB2312.GetString (usefullBytes, 2, 20).Trim ('\0');
if (notHasRemake || MyEncodingGB2312.GetString (usefullBytes, 2, 20).Trim ('\0') == "") {
devcieTempName = deviceType.ToString ().Replace (DeviceType.Sensor.ToString (), "") + "-" + deviceID.ToString ();
@@ -1265,6 +1276,11 @@
//} else if (deviceType1.ToString ().Contains ("Switch")) {
// devcieLoopName = "Relay SW" + usefullBytes [2].ToString ();
//}
+
+ //2020-07-03 濡傛灉鏄孩澶栨ā鍧楃被鍨嬶紝澶囨敞涓虹┖鐨勮瘽锛岄粯璁や负TV鍚嶅瓧
+ if (deviceType1 == DeviceType.InfraredMode) {
+ devcieLoopName = "TV " + usefullBytes [2].ToString ();
+ }
byte [] ddd = CommonPage.MyEncodingGB2312.GetBytes (devcieLoopName);
byte [] newddd = new byte [20];
Array.Copy (ddd, 0, newddd, 0, 20 < ddd.Length ? 20 : ddd.Length);
@@ -1583,7 +1599,7 @@
wirelessPanelButtonKey.Name = MyEncodingGB2312.GetString (usefullBytes, 3, 20).Trim ('\0');
wirelessPanelButtonKey.Mode = usefullBytes [23];
ButtonBkeyModelList.Add (wirelessPanelButtonKey.Mode);
- System.Console.WriteLine ("璇诲彇闈㈡澘鎸夐敭锛氬洖璺彿锛�" + wirelessPanelButtonKey.LoopID + " 妯″紡锛�" + wirelessPanelButtonKey.Mode);
+ Utlis.WriteLine ("璇诲彇闈㈡澘鎸夐敭锛氬洖璺彿锛�" + wirelessPanelButtonKey.LoopID + " 妯″紡锛�" + wirelessPanelButtonKey.Mode);
IO.FileUtils.SaveEquipmentMessage (wirelessPanelButtonKey, wirelessPanelButtonKey.LoopID.ToString ());
#endregion
break;
@@ -2060,7 +2076,7 @@
//01 01 59(+30) 02 0D 03 64 00 01
break;
case Command.AssignedAddressACK:
- Console.WriteLine (usefullBytes [0].ToString ());
+ Utlis.WriteLine (usefullBytes [0].ToString ());
if (usefullBytes [0] == 3) {
dt = DateTime.Now;
} else if (usefullBytes [0] == 4) {
@@ -2068,24 +2084,24 @@
}
break;
case Command.Remote3thACK:
- Console.WriteLine (usefullBytes [0]);
+ Utlis.WriteLine (usefullBytes [0]);
break;
case Command.DownloadInfraredACK:
string loopID_IM = usefullBytes [0] < 10 ? "0" + usefullBytes [0].ToString () : usefullBytes [0].ToString ();
if ((InfraredType)usefullBytes [2] != InfraredType.AC) {
if ((InfraredType)usefullBytes [2] == InfraredType.NULL) {
- Console.WriteLine ("NULL-------------");
+ Utlis.WriteLine ("NULL-------------");
}
string filePath = "Equipment_InfraredMode_" + subnetID + "_" + deviceID + "_" + loopID_IM;
InfraredMode im = Newtonsoft.Json.JsonConvert.DeserializeObject<InfraredMode> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (filePath)));
im.InfraredType = (InfraredType)usefullBytes [2];
- Console.WriteLine (im.InfraredType.ToString () + "------------------------------------------------------");
+ Utlis.WriteLine (im.InfraredType.ToString () + "------------------------------------------------------");
IO.FileUtils.SaveEquipmentMessage (im, im.LoopID.ToString ());
}
break;
}
} catch (Exception ex) {
- Console.WriteLine ("Packet_ReceiveEvent锛�" + ex.ToString ());
+ Utlis.WriteLine ("Packet_ReceiveEvent锛�" + ex.ToString ());
}
}
@@ -2102,6 +2118,85 @@
}
return s;//
}
+
+ //static void httpListener_EventHandler (System.Collections.Specialized.NameValueCollection nameValueCollection, System.IO.Stream outputStream, System.IO.Stream inputStream)
+ //{
+ // //if (!isHttpListenerStart) {
+ // // return;
+ // //}
+ // try {
+ // //System.Net.WebClient webClient = new System.Net.WebClient ();
+ // //byte []bytes= webClient.DownloadData("http://ip:6001/GetAllFiles");
+ // // System.Text.Encoding.UTF8.GetString (bytes);
+ // //List<string> list = new List<string> ();
+ // //foreach(string s in list) {
+ // // byte [] bytes = webClient.DownloadData ("http://ip:6001/Get"+s);
+ // // FileUtils.WriteFileByBytes (s, bytes);
+ // //}
+
+ // if (nameValueCollection ["Command"] != null && nameValueCollection ["Command"].StartsWith ("Get")) {
+ // string tempFileName = nameValueCollection ["Command"].Replace ("Get", "");
+ // if ("AllFiles" == tempFileName) {
+ // byte [] bytes = System.Text.Encoding.UTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (IO.FileUtils.ReadFiles ()));
+ // outputStream.Write (bytes, 0, bytes.Length);
+ // outputStream.Flush ();
+ // } else {
+ // byte [] bytes;
+ // if (!IO.FileUtils.Exists (tempFileName)) {
+ // bytes = System.Text.Encoding.UTF8.GetBytes ("鏂囦欢鍚嶄笉瀛樺湪锛�");
+ // outputStream.Write (bytes, 0, bytes.Length);
+ // outputStream.Flush ();
+ // return;
+ // }
+ // System.IO.FileStream fs = new System.IO.FileStream (Application.RootPath + tempFileName, System.IO.FileMode.Open);
+ // bytes = new byte [fs.Length];
+ // fs.Read (bytes, 0, bytes.Length);
+ // fs.Close ();
+ // outputStream.Write (bytes, 0, bytes.Length);
+ // outputStream.Flush ();
+ // }
+ // } else if (nameValueCollection ["Command"].StartsWith ("Upload")) {
+ // string path = Application.RootPath + nameValueCollection ["Command"].Replace ("Upload", "");
+ // string dePath = nameValueCollection ["Command"].Replace ("Upload", "");
+ // if (dePath.StartsWith ("Room_")) {
+ // new Room ().Add (dePath);
+ // }
+ // if (dePath.Split ('_').Length == 5) {
+ // if (dePath.Split ('_') [1] == (typeof (OnePortBus).Name) || dePath.Split ('_') [1] == (typeof (OnePortWirelessFR).Name)) {
+ // UserConfig.Instance.RemoteModeFile = dePath;
+ // UserConfig.Instance.SaveUserConfig ();
+ // }
+ // if (dePath.Split ('_') [1] == (typeof (SecurityModul).Name)) {
+ // if (UserConfig.Instance.HideDeviceTypes.Contains ((R.MyInternationalizationString.Security))) {
+ // UserConfig.Instance.HideDeviceTypes.Remove (R.MyInternationalizationString.Security);
+ // UserConfig.Instance.SaveUserConfig ();
+ // }
+ // }
+ // }
+
+ // if (dePath.Split ('_').Length == 2 && dePath.StartsWith ("GlobalScene")) {
+ // var sceneFileList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>> (System.Text.Encoding.UTF8.GetString (IO.FileUtils.ReadFile (Scene.GlobalSceneFilePath)));
+ // if (!sceneFileList.Contains (dePath)) {
+ // sceneFileList.Add (dePath);
+ // IO.FileUtils.WriteFileByBytes (Scene.GlobalSceneFilePath, CommonPage.MyEncodingUTF8.GetBytes (Newtonsoft.Json.JsonConvert.SerializeObject (sceneFileList)));
+ // }
+ // }
+ // //Utlis.WriteLine ("鎺ユ敹"+path);
+ // FileUtils.WriteFileByInputStream (path, inputStream);
+ // Common common = Newtonsoft.Json.JsonConvert.DeserializeObject<Common> (CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (path)));
+ // if (common.DeviceTextID == R.MyInternationalizationString.ElectricalControl) {
+ // UserConfig.Instance.SocketList.Add (common.CommonLoopID);
+ // }
+ // } else {
+ // byte [] bytes = System.Text.Encoding.UTF8.GetBytes ("璇锋眰鍛戒护鏃犳晥锛�");
+ // outputStream.Write (bytes, 0, bytes.Length);
+ // outputStream.Flush ();
+ // }
+ // } catch (Exception ex) {
+ // Utlis.WriteLine ("httpListener_EventHandler" + ex.ToString ());
+ // }
+ //}
+
static void httpListener_EventHandler (System.Collections.Specialized.NameValueCollection nameValueCollection, System.IO.Stream outputStream, System.IO.Stream inputStream)
{
@@ -2142,9 +2237,11 @@
} else if (nameValueCollection ["Command"].StartsWith ("Upload")) {
string path = Application.RootPath + nameValueCollection ["Command"].Replace ("Upload", "");
string dePath = nameValueCollection ["Command"].Replace ("Upload", "");
- if (dePath.StartsWith ("Room_")) {
+ if (dePath.Contains ("Room_")) {
new Room ().Add (dePath);
}
+
+
if (dePath.Split ('_').Length == 5) {
if (dePath.Split ('_') [1] == (typeof (OnePortBus).Name) || dePath.Split ('_') [1] == (typeof (OnePortWirelessFR).Name)) {
UserConfig.Instance.RemoteModeFile = dePath;
@@ -2156,6 +2253,7 @@
UserConfig.Instance.SaveUserConfig ();
}
}
+
}
if (dePath.Split ('_').Length == 2 && dePath.StartsWith ("GlobalScene")) {
@@ -2176,8 +2274,8 @@
outputStream.Flush ();
}
} catch (Exception ex) {
- Console.WriteLine ("httpListener_EventHandler" + ex.ToString ());
- }
+ Utlis.WriteLine ("httpListener_EventHandler" + ex.ToString ());
+ }
}
/// <summary>
--
Gitblit v1.8.0