From a35617eb62b317bf3ed92b1462018cf67c920411 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 15 十二月 2020 15:17:35 +0800
Subject: [PATCH] 2020-12-15-2
---
HDL_ON/Entity/Function/Function.cs | 82 ++++++++++++++++++++++++++++++-----------
1 files changed, 60 insertions(+), 22 deletions(-)
diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index 29ec0d6..578e86f 100644
--- a/HDL_ON/Entity/Function/Function.cs
+++ b/HDL_ON/Entity/Function/Function.cs
@@ -30,7 +30,6 @@
public Function()
{
}
-
#region base info
/// <summary>
@@ -43,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 闊充箰
@@ -125,6 +124,10 @@
/// 鏄惁鏀惰棌
/// </summary>
public bool collect = false;
+ /// <summary>
+ /// 鏄惁鍦ㄧ嚎
+ /// </summary>
+ public bool online = true;
/// <summary>
/// 浜戠鏁版嵁鍒涘缓鐨勬椂闂�
/// </summary>
@@ -230,7 +233,7 @@
/// </summary>
public int fixedSerialNumber = int.MaxValue;
- public string GetBusId ()
+ public string GetBusId()
{
string busId = "";
if (bus_Data != null)
@@ -247,9 +250,9 @@
public string GetRoomListName()
{
string roomNameList = "";
- foreach(var roomId in roomIds)
+ foreach (var roomId in roomIds)
{
- var findRoom = DB_ResidenceData.residenceData.Rooms.Find(obj => obj.uid == roomId);
+ var findRoom = SpatialInfo.CurrentSpatial.RoomList.Find(obj => obj.roomId == roomId);
if (findRoom == null)
{
continue;
@@ -280,12 +283,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, 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));
+ Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd);
+ }
+ else
+ {
+ Utlis.ShowTip(Language.StringByID(StringId.EditFunctionInfoFail) + "\r\nCode:" + pack.Code);
+ }
+ }
+ else
+ {
+ var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
+ Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd);
+ }
}
+
/// <summary>
/// 杞崲鎴愬満鏅姛鑳藉璞�
@@ -297,6 +317,7 @@
foreach (var attr in attributes)
{
sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() });
+ sFunc.sid = this.sid;
}
return sFunc;
}
@@ -309,9 +330,9 @@
/// <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();
@@ -319,7 +340,7 @@
var acd = new AlinkControlData();
acd.sid = sid;
var aca = new AlinkControlAttributes();
- foreach(var dic in commandDictionary)
+ foreach (var dic in commandDictionary)
{
aca.key = dic.Key;
aca.value = dic.Value;
@@ -334,7 +355,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;
@@ -368,18 +389,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鍗忚鎺у埗鏁版嵁
@@ -423,11 +455,11 @@
/// <summary>
/// 鏈�澶у��
/// </summary>
- public int max;
+ public int max=100;
/// <summary>
/// 鏈�灏忓��
/// </summary>
- public int min;
+ public int min=0;
/// <summary>
/// 鏁版嵁绫诲瀷
/// </summary>
@@ -455,7 +487,7 @@
switch (key)
{
case "temperature":
- case "set_temperature":
+ case "set_temp":
us = "掳C";
break;
case "percent":
@@ -495,7 +527,7 @@
text = Language.StringByID(StringId.FanSpeed);
break;
case "temperature":
- case "set_temperature":
+ case "set_temp":
text = Language.StringByID(StringId.Temp);
break;
case "delay":
@@ -558,7 +590,7 @@
text = value == "on" ? Language.StringByID(StringId.On) : Language.StringByID(StringId.OFF);
break;
case "temperature":
- case "set_temperature":
+ case "set_temp":
case "brightness":
case "percent":
if (value == "")
@@ -743,6 +775,10 @@
/// 鐧惧垎姣�
/// </summary>
public const string Percent = "percent";
+ /// <summary>
+ /// 瀹ゅ唴娓╁害
+ /// </summary>
+ public const string IndoorTemp = "room_temp";
}
/// <summary>
/// 璁惧鍔熻兘oid
@@ -763,6 +799,7 @@
public class BusData
{
public string addresses = "FFFF";
+ [Newtonsoft.Json.JsonIgnore]
public byte SubnetID
{
get
@@ -770,6 +807,7 @@
return Convert.ToByte(addresses.Substring(0, 2), 16);
}
}
+ [Newtonsoft.Json.JsonIgnore]
public byte DeviceID
{
get
--
Gitblit v1.8.0