From 62d77d3bb8e7215d9da9ecf6f5aeda0b69f805f8 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期二, 08 十二月 2020 18:57:15 +0800
Subject: [PATCH] 20201208
---
HDL_ON/Entity/Function/Function.cs | 209 ++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 185 insertions(+), 24 deletions(-)
diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index 1a642f7..9376caf 100644
--- a/HDL_ON/Entity/Function/Function.cs
+++ b/HDL_ON/Entity/Function/Function.cs
@@ -42,10 +42,10 @@
/// 浜у搧鏃堕棿鎴筹細4bytes 浠�2020骞�1鏈�1鏃ョ畻鍑虹殑鏃堕棿鎴�0.1s涓哄崟浣�
/// 浜у搧绫诲埆锛�01 璋冨厜鍣ㄣ��02 缁х數鍣ㄣ��03 骞叉帴鐐规ā鍧椼��04 浼犳劅鍣ㄣ��05 闈㈡澘
/// 鐗╂ā鍨嬬被鍨嬶細
- /// 01 寮�鍏崇被锛�01 寮�鍏炽��02 鎻掑骇銆�03
- /// 02 鐓ф槑锛� 01 寮�鍏炽��02 璋冨厜銆�03 鑹叉俯銆�04 LED
+ /// 01 寮�鍏崇被锛�01 寮�鍏炽��02 鎻掑骇銆�03
+ /// 02 鐓ф槑锛� 01 寮�鍏炽��02 璋冨厜銆�03 鑹叉俯銆�04 LED
/// 03 閬槼锛� 01 绐楀笜鐢垫満銆�02 鐧惧彾绐椼��03 寮�鍚堝笜銆�04 鍗峰笜
- /// 04 鎭掓俯鍣細01 绌鸿皟銆�02 鍦版殩銆�03 姣涚粏绌鸿皟
+ /// 04 鎭掓俯鍣細01 绌鸿皟銆�02 鍦版殩銆�03 姣涚粏绌鸿皟
/// 05 鏂伴
/// 06 褰遍煶
/// 07 闊充箰
@@ -89,15 +89,16 @@
}
}
}
- /// <summary>
- /// 鍔熻兘绫诲瀷
- /// </summary>
+ ///// <summary>
+ ///// 鍔熻兘绫诲瀷
+ ///// </summary>
public FunctionType functionType
{
get
{
var _functionTypeString = sid.Substring(16, 4);
return (FunctionType)Enum.ToObject(typeof(FunctionType), Convert.ToInt32(_functionTypeString, 16));
+
}
}
@@ -113,6 +114,15 @@
/// 璇ュ姛鑳芥坊鍔犲埌鍒版埧闂村垪琛�
/// </summary>
public List<string> roomIds = new List<string>();
+ /// <summary>
+ /// 缁戝畾鎴块棿
+ /// </summary>
+ public void BindRoom(string roomId)
+ {
+ roomIds.Add(roomId);
+ var pm = new DAL.Server.HttpServerRequest();
+ pm.BindDeviceToRoom(deviceId, roomId);
+ }
/// <summary>
/// bus鍗忚鏁版嵁鏍煎紡
@@ -123,6 +133,25 @@
/// 鏄惁鏀惰棌
/// </summary>
public bool collect = false;
+ /// <summary>
+ /// 鏄惁鍦ㄧ嚎
+ /// </summary>
+ public bool online = true;
+ /// <summary>
+ /// 浜戠鏁版嵁鍒涘缓鐨勬椂闂�
+ /// </summary>
+ public string createTime = "";
+ /// <summary>
+ /// 浜戠鏁版嵁淇敼鐨勬渶鍚庢椂闂�
+ /// </summary>
+ public string modifyTime = "";
+ /// <summary>
+ /// 鍒犻櫎鏍囪
+ /// 闇�瑕佸垹闄ゆ暟鎹椂锛屾爣璁颁负锛歵rue
+ /// 鐢变簯绔垹闄ゆ垚鍔熶箣鍚庯紝杩斿洖鏁版嵁鍐嶆竻闄ゆ湰鍦版暟鎹�
+ /// </summary>
+ public bool DeleteSign = false;
+
#endregion
/// <summary>
/// 寤舵椂
@@ -213,7 +242,7 @@
/// </summary>
public int fixedSerialNumber = int.MaxValue;
- public string GetBusId ()
+ public string GetBusId()
{
string busId = "";
if (bus_Data != null)
@@ -230,9 +259,9 @@
public string GetRoomListName()
{
string roomNameList = "";
- foreach(var roomId in roomIds)
+ foreach (var roomId in roomIds)
{
- var findRoom = DB_ResidenceData.Rooms.Find(obj => obj.uid == roomId);
+ var findRoom = DB_ResidenceData.residenceData.Rooms.Find(obj => obj.uid == roomId);
if (findRoom == null)
{
continue;
@@ -263,11 +292,29 @@
/// <summary>
/// 淇濆瓨鍔熻兘鏁版嵁
/// </summary>
- public void SaveFunctionData()
+ public void SaveFunctionData(bool upSevser)
{
- var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
- FileUtils.WriteFileByBytes( savePath + this.sid, ssd);
- MainPage.Log($"Save FunctionData {this.functionType} : {this.sid}");
+ if (upSevser)
+ {
+ var pm = new DAL.Server.HttpServerRequest();
+ var pack = pm.UpdataDevcieInfo(this);
+ if (pack.Code == DAL.Server.StateCode.SUCCESS)
+ {
+ var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
+ FileUtils.WriteFileByBytes(savePath, ssd);
+ MainPage.Log($"Save FunctionData {this.functionType} : {this.sid}");
+ }
+ else
+ {
+ Utlis.ShowTip(Language.StringByID(StringId.EditFunctionInfoFail) + "Code:" + pack.Code);
+ }
+ }
+ else
+ {
+ var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
+ FileUtils.WriteFileByBytes(savePath, ssd);
+ MainPage.Log($"Save FunctionData {this.functionType} : {this.sid}");
+ }
}
/// <summary>
@@ -292,20 +339,17 @@
/// <summary>
/// 鑾峰彇鏈湴鎺у埗鏁版嵁
/// </summary>
- public GatewayAlinkControlObj GetGatewayAlinkControlData(Dictionary<string, string> commandDictionary)
+ public AlinkFunctionStatusObj GetGatewayAlinkControlData(Dictionary<string, string> commandDictionary)
{
- var sendDataObj = new GatewayAlinkControlObj();
+ var sendDataObj = new AlinkFunctionStatusObj();
sendDataObj.id = Control.Ins.msg_id.ToString();
sendDataObj.time_stamp = Control.Ins.Get_TimeStamp();
var acd = new AlinkControlData();
acd.sid = sid;
-#if DEBUG
- acd.sid = "0001016FB925AB02020100010101";
-#endif
var aca = new AlinkControlAttributes();
- foreach(var dic in commandDictionary)
+ foreach (var dic in commandDictionary)
{
aca.key = dic.Key;
aca.value = dic.Value;
@@ -320,7 +364,7 @@
/// 鑾峰彇Api鎺у埗鏁版嵁
/// </summary>
/// <returns></returns>
- public ApiAlinkControlActionObj GetApiControlData(Dictionary<string,string> keyValues)
+ public ApiAlinkControlActionObj GetApiControlData(Dictionary<string, string> keyValues)
{
ApiAlinkControlActionObj aaao = new ApiAlinkControlActionObj();
aaao.deviceId = this.deviceId;
@@ -354,18 +398,29 @@
public string spk = "";
public List<AlinkControlAttributes> attributes = new List<AlinkControlAttributes>();
+ //[Newtonsoft.Json.JsonIgnore]
+ public BusData bus = new BusData();
}
/// <summary>
- /// 鏈湴鎺у埗
/// A鍗忚鎺у埗鏁版嵁鐨勫璞�
/// </summary>
- public class GatewayAlinkControlObj
+ public class AlinkFunctionStatusObj
{
public List<AlinkControlData> objects = new List<AlinkControlData>();
public string time_stamp = "";
public string id = "";
+ }
+ /// <summary>
+ /// 鏈湴鐘舵�佽鍙�
+ /// A鍗忚鐘舵�佽鍙栨牸寮忓璞�
+ /// </summary>
+ public class AlinkReadFunctionStatusObj
+ {
+ public string id = "0";
+ public List<Dictionary<string, string>> objects = new List<Dictionary<string, string>>();
+ public string time_stamp = "";
}
/// <summary>
/// A鍗忚鎺у埗鏁版嵁
@@ -409,11 +464,11 @@
/// <summary>
/// 鏈�澶у��
/// </summary>
- public int max;
+ public int max=100;
/// <summary>
/// 鏈�灏忓��
/// </summary>
- public int min;
+ public int min=0;
/// <summary>
/// 鏁版嵁绫诲瀷
/// </summary>
@@ -749,6 +804,7 @@
public class BusData
{
public string addresses = "FFFF";
+ [Newtonsoft.Json.JsonIgnore]
public byte SubnetID
{
get
@@ -756,6 +812,7 @@
return Convert.ToByte(addresses.Substring(0, 2), 16);
}
}
+ [Newtonsoft.Json.JsonIgnore]
public byte DeviceID
{
get
@@ -766,4 +823,108 @@
public byte loopId;
}
+ public static class SPK
+ {
+ /// <summary>
+ /// 锛堝紑鍏崇伅锛�
+ /// </summary>
+ public const string LightSwitch = "light.switch";
+ /// <summary>
+ /// 锛堣皟鍏夌伅锛�
+ /// </summary>
+ public const string LightDimming = "light.dimming";
+ /// <summary>
+ /// 锛圧GB鐏級
+ /// </summary>
+ public const string LightRGB = "light.rgb";
+ /// <summary>
+ /// 锛圧GBW鐏級
+ /// </summary>
+ public const string LightRGBW = "light.rgbw";
+ /// <summary>
+ /// 锛圕CT鐏級
+ /// </summary>
+ public const string LightCCT = "light.cct";
+ /// <summary>
+ /// 锛堝紑鍏崇獥甯橈級
+ /// </summary>
+ public const string CurtainSwitch = "curtain.switch";
+ /// <summary>
+ /// 锛堝紑鍚堝笜锛�
+ /// </summary>
+ public const string CurtainTrietex = "curtain.trietex";
+ /// <summary>
+ /// 锛堢櫨鍙跺笜锛�
+ /// </summary>
+ public const string CurtainShades = "curtain.shades";
+ /// <summary>
+ /// 锛堝嵎甯橈級
+ /// </summary>
+ public const string CurtainRoller = "curtain.roller";
+ /// <summary>
+ /// 锛堢┖璋冿級
+ /// </summary>
+ public const string AcStandard = "ac.standard";
+ /// <summary>
+ /// 锛堝湴鐑級
+ /// </summary>
+ public const string FloorHeatStandard = "floorHeat.standard";
+ /// <summary>
+ /// 锛堟柊椋庯級
+ /// </summary>
+ public const string AirFreshStandard = "airFresh.standard";
+ /// <summary>
+ /// 锛堥煶涔愶級
+ /// </summary>
+ public const string MusicStandard = "music.standard";
+ /// <summary>
+ /// 锛堜寒搴︿紶鎰熷櫒锛�
+ /// </summary>
+ public const string SensorLight = "sensor.light";
+ /// <summary>
+ /// 锛堟俯搴︿紶鎰熷櫒锛�
+ /// </summary>
+ public const string SensorTemperature = "sensor.temperature";
+ /// <summary>
+ /// (绾㈠绉诲姩浼犳劅鍣�)
+ /// </summary>
+ public const string SensorPir = "sensor.pir";
+ /// <summary>
+ /// 锛堥棬绐椾紶鎰熷櫒锛�
+ /// </summary>
+ public const string SensorDoorWindow = "sensor.doorwindow";
+ /// <summary>
+ /// 锛圥M2.5浼犳劅鍣級
+ /// </summary>
+ public const string SensorPm25 = "sensor.pm25";
+ /// <summary>
+ /// co2浼犳劅鍣�
+ /// </summary>
+ public const string SensorCO2 = "sensor.co2";
+ /// <summary>
+ /// tvoc浼犳劅鍣�
+ /// </summary>
+ public const string SensorTVOC = "sensor.tvoc";
+ /// <summary>
+ /// 婀垮害浼犳劅鍣�
+ /// </summary>
+ public const string SensorHumidity = "sensor.humidity";
+ /// <summary>
+ /// 锛堝共鎺ョ偣锛�
+ /// </summary>
+ public const string DryContact = "dryContact.standard";
+ /// <summary>
+ /// 瀹剁數銆佹彃搴�
+ /// </summary>
+ public const string ElectricSocket = "electric.socket ";
+ /// <summary>
+ /// 瀹剁數銆佺數瑙�
+ /// </summary>
+ public const string ElectricTV = "electric.tv";
+ /// <summary>
+ /// 瀹剁數銆侀鎵�
+ /// </summary>
+ public const string ElectricFan = "electric.fan";
+ }
+
}
--
Gitblit v1.8.0