From 17c8d94258154ab2e9f6d2cf821202c873b9f118 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期三, 16 十二月 2020 15:39:15 +0800
Subject: [PATCH] 22222
---
HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs | 104 ++++++++++++++++++++++++++++++++++------------------
1 files changed, 68 insertions(+), 36 deletions(-)
diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
index 81b0ae6..f93ff6c 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs
@@ -4,7 +4,7 @@
namespace HDL_ON.UI.UI2.Intelligence.Automation
{
-
+
public class LogicMethod
{
/// <summary>
@@ -22,6 +22,47 @@
{
MainPage.BasePageView.RemoveViewByTag("Logic");
}
+
+ /// <summary> Converts an array of bytes into a formatted string of hex digits (ex: E4 CA B2)</summary>
+ /// <param name="data"> The array of bytes to be translated into a string of hex digits. </param>
+ /// <returns> Returns a well formatted string of hex digits with spacing. </returns>
+ static string byteArrayToHexString(byte[] data)
+ {
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ foreach (byte b in data)
+ {
+ sb.Append(Convert.ToString(b, 16).PadLeft(2, '0'));
+ }
+
+ return sb.ToString().ToUpper();
+ }
+
+ /**
+ * int杞琤yte[]
+ * 璇ユ柟娉曞皢涓�涓猧nt绫诲瀷鐨勬暟鎹浆鎹负byte[]褰㈠紡锛屽洜涓篿nt涓�32bit锛岃�宐yte涓�8bit鎵�浠ュ湪杩涜绫诲瀷杞崲鏃讹紝鐭ヤ細鑾峰彇浣�8浣嶏紝
+ * 涓㈠純楂�24浣嶃�傞�氳繃浣嶇Щ鐨勬柟寮忥紝灏�32bit鐨勬暟鎹浆鎹㈡垚4涓�8bit鐨勬暟鎹�傛敞鎰� &0xff锛屽湪杩欏綋涓紝&0xff绠�鍗曠悊瑙d负涓�鎶婂壀鍒�锛�
+ * 灏嗘兂瑕佽幏鍙栫殑8浣嶆暟鎹埅鍙栧嚭鏉ャ��
+ * @param i 涓�涓猧nt鏁板瓧
+ * @return byte[]
+ */
+ public static byte[] int2ByteArray(int i)
+ {
+ byte[] result = new byte[4];
+ result[0] = (byte)((i >> 24) & 0xFF);
+ result[1] = (byte)((i >> 16) & 0xFF);
+ result[2] = (byte)((i >> 8) & 0xFF);
+ result[3] = (byte)(i & 0xFF);
+ return result;
+ }
+ /// <summary>
+ /// 鑾峰彇鏃堕棿鎴�
+ /// </summary>
+ /// <returns></returns>
+ static int getTimeStamp()
+ {
+ TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+ return (int)ts.TotalSeconds;
+ }
/// <summary>
/// 鐢熸垚閫昏緫sid鏂规硶
/// </summary>
@@ -34,24 +75,9 @@
DateTime dt = DateTime.Now;
DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2020, 1, 1));
long m = (long)((dt - startTime).TotalMilliseconds / 10);
- string sTimeSpan = "00000000";
-
- byte[] arry = new byte[4];
- arry[0] = (byte)(m & 0xFF);
- arry[1] = (byte)((m & 0xFF00) >> 8);
- arry[2] = (byte)((m & 0xFF0000) >> 16);
- arry[3] = (byte)((m >> 24) & 0xFF);
- sTimeSpan = arry[0].ToString("X2") + arry[1].ToString("X2") + arry[2].ToString("X2") + arry[3].ToString("X2");
+ string sTimeSpan = byteArrayToHexString(int2ByteArray(getTimeStamp()));
- if (sTimeSpan.Length > 8)
- {
- sTimeSpan = sTimeSpan.Substring(0, 8);
- }
- else
- {
- sTimeSpan = "00000000";
- }
logicId = sOidBeginsWith + sTimeSpan;
@@ -66,10 +92,10 @@
string s = Logic.LogicList[i].sid.Substring(20, 4);
int iThisSceneId = Convert.ToInt16(s, 16);
if (iThisSceneId > maxId)
- maxId = iThisSceneId ;
+ maxId = iThisSceneId;
}
- logicId += (maxId+1).ToString("X4");//閫昏緫鍙� 涓や釜byte
+ logicId += (maxId + 1).ToString("X4");//閫昏緫鍙� 涓や釜byte
logicId += "0000";
}
catch
@@ -99,17 +125,16 @@
/// 鑾峰彇缃戝叧鎴块棿鍒楄〃
/// </summary>
/// <returns></returns>
- public static List<HDL_ON.Entity.Room> GetGatewayRoomList()
+ public static List<HDL_ON.Entity.Room> GetGatewayRoomList()
{
- return HDL_ON.Entity.DB_ResidenceData.residenceData.Rooms;
+ return HDL_ON.Entity.SpatialInfo.CurrentSpatial.RoomList;
}
/// <summary>
/// 鑾峰彇缃戝叧鎴块棿鍒楄〃
/// </summary>
/// <returns></returns>
- public static List<HDL_ON.Entity.Room> GetGatewayRoomList(string name)
+ public static List<HDL_ON.Entity.Room> GetGatewayRoomList(string name)
{
-
List<Entity.Room> roomList = new List<Entity.Room>();
Entity.Room room1 = new Entity.Room();
room1.roomName = name;//榛樿涓�涓埧闂村悕涓�:鍏ㄩ儴鍖哄煙
@@ -118,9 +143,14 @@
var roomLists = GetGatewayRoomList();
foreach (var room in roomLists)
{
+ var devlist = GetRoomDevice(room);
+ if (devlist.Count == 0)
+ {
+ //杩囨护鎺夋病鏈夎澶囩殑鎴块棿;
+ continue;
+ }
roomList.Add(room);
}
-
return roomList;
}
/// <summary>
@@ -129,7 +159,7 @@
/// <returns></returns>
public static List<HDL_ON.Entity.Function> GetGatewayDeviceList()
{
- return HDL_ON.Entity.DB_ResidenceData.functionList.GetAllFunction();
+ return Entity.FunctionList.List.GetDeviceFunctionList();
}
/// <summary>
/// 鑾峰彇缃戝叧鍦烘櫙鍒楄〃
@@ -137,7 +167,7 @@
/// <returns></returns>
public static List<HDL_ON.Entity.Scene> GetSceneList()
{
- return HDL_ON.Entity.DB_ResidenceData.functionList.scenes;
+ return HDL_ON.Entity.FunctionList.List.scenes;
}
/// <summary>
/// 鑾峰彇鎴块棿鐨勮澶囧垪琛�
@@ -170,7 +200,7 @@
/// <returns></returns>
public static HDL_ON.Entity.Function GetDevice(string sid)
{
- HDL_ON.Entity.Function device = new Entity.Function() { name= "Unknown",sid="璁惧涓嶅瓨鍦�"};
+ HDL_ON.Entity.Function device = new Entity.Function() { name = "Unknown" };
List<HDL_ON.Entity.Function> deviceLists = GetGatewayDeviceList();
foreach (var dev in deviceLists)
{
@@ -190,7 +220,7 @@
/// <returns></returns>
public static HDL_ON.Entity.Scene GetSecne(string sid)
{
- HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown", sid = "鍦烘櫙涓嶅瓨鍦�" };
+ HDL_ON.Entity.Scene scene = new Entity.Scene() { name = "Unknown" };
List<HDL_ON.Entity.Scene> sceneLists = GetSceneList();
foreach (var sce in sceneLists)
{
@@ -268,17 +298,17 @@
/// </summary>
/// <param name="deviceList">璁惧鍒楄〃</param>
/// <returns></returns>
- public static List<string> GetDeviceTypeList(List<HDL_ON.Entity.Function> deviceList)
+ public static List<string> GetDeviceTypeList(List<HDL_ON.Entity.Function> deviceList)
{
- List<string> deviceStrTypeList = new List<string>();
+ List<string> deviceStrTypeList = new List<string>();
deviceStrTypeList.Clear();
- var lightjosn = deviceList.Find((device) => device.functionType == FunctionType.Relay || device.functionType == FunctionType.Dimmer|| device.functionType == FunctionType.ColorTemperature || device.functionType == FunctionType.RGB|| device.functionType == FunctionType.RGBW);
+ var lightjosn = deviceList.Find((device) => device.functionType == FunctionType.Relay || device.functionType == FunctionType.Dimmer || device.functionType == FunctionType.ColorTemperature || device.functionType == FunctionType.RGB || device.functionType == FunctionType.RGBW);
if (lightjosn != null)
{
deviceStrTypeList.Add(Language.StringByID(StringId.Lights));
}
- var curtainjosn = deviceList.Find((device) => device.functionType ==FunctionType.Curtain|| device.functionType == FunctionType.MotorCurtain|| device.functionType == FunctionType.RollingShutter);
+ var curtainjosn = deviceList.Find((device) => device.functionType == FunctionType.Curtain || device.functionType == FunctionType.MotorCurtain || device.functionType == FunctionType.RollingShutter);
if (curtainjosn != null)
{
deviceStrTypeList.Add(Language.StringByID(StringId.Curtain));
@@ -290,7 +320,7 @@
deviceStrTypeList.Add(Language.StringByID(StringId.AC));
}
var floorHeating = deviceList.Find((device) => device.functionType == FunctionType.FloorHeating);
- if (ac != null)
+ if (floorHeating != null)
{
deviceStrTypeList.Add(Language.StringByID(StringId.FloorHeating));
}
@@ -334,11 +364,13 @@
/// 鏉′欢/鐩爣鏀寔璁惧
/// </summary>
/// <returns></returns>
- public static List<FunctionType> GetSupportEquipment(string if_type)
+ public static List<FunctionType> GetSupportEquipment(string if_type)
{
List<FunctionType> deviceTypeList = new List<FunctionType>();
- switch (if_type) {
- case condition_if: {
+ switch (if_type)
+ {
+ case condition_if:
+ {
deviceTypeList.Add(FunctionType.Relay);
deviceTypeList.Add(FunctionType.RGB);
deviceTypeList.Add(FunctionType.RGBW);
--
Gitblit v1.8.0