From f4c86f68b900bd506ef7214b2ae9bd23a9d2ffa8 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期六, 19 十二月 2020 17:48:11 +0800
Subject: [PATCH] 完成筛选房间的功能
---
HDL_ON/Entity/Function/Function.cs | 428 ++++++++++++-----------------------------------------
1 files changed, 99 insertions(+), 329 deletions(-)
diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index 29ec0d6..73b521e 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 闊充箰
@@ -120,11 +119,15 @@
/// bus鍗忚鏁版嵁鏍煎紡
/// 浣跨敤A鍗忚鎺у埗鏃讹紝鏀瑰睘鎬т负绌�
/// </summary>
- public BusData bus_Data;
+ public BusData bus;
/// <summary>
/// 鏄惁鏀惰棌
/// </summary>
public bool collect = false;
+ /// <summary>
+ /// 鏄惁鍦ㄧ嚎
+ /// </summary>
+ public bool online = true;
/// <summary>
/// 浜戠鏁版嵁鍒涘缓鐨勬椂闂�
/// </summary>
@@ -145,37 +148,6 @@
/// 寤舵椂
/// </summary>
public int delay = 0;
- /// <summary>
- /// 寤舵椂鏄剧ず鐨勬枃鏈�
- /// </summary>
- [Newtonsoft.Json.JsonIgnore]
- public string delayText
- {
- get
- {
- string text = "";
- switch (delay)
- {
- case 0:
- text = Language.StringByID(StringId.NoDelay);
- break;
- case 30:
- text = "30s";
- break;
- case 60:
- text = "1min";
- break;
- case 120:
- text = "2min";
- break;
- case 300:
- text = "5min";
- break;
- }
- return text;
- }
- }
-
/// <summary>
/// 鏈�鍚庢帶鍒剁殑涓�娆$姸鎬�
/// </summary>
@@ -201,8 +173,8 @@
max = 1,
min = 0,
};
+ _trait_on_off.curValue = "on";
}
- _trait_on_off.curValue = "on";
}
return _trait_on_off;
}
@@ -219,7 +191,8 @@
/// <summary>
/// 浣跨敤棰戠巼
/// </summary>
- public double usageFrequency {
+ public double usageFrequency
+ {
get
{
return usageCount / 7;
@@ -230,12 +203,12 @@
/// </summary>
public int fixedSerialNumber = int.MaxValue;
- public string GetBusId ()
+ public string GetBusId()
{
string busId = "";
- if (bus_Data != null)
+ if (bus != null)
{
- busId = bus_Data.SubnetID + "_" + bus_Data.DeviceID + "_" + bus_Data.loopId;
+ busId = bus.SubnetID + "_" + bus.DeviceID + "_" + bus.LoopId;
}
return busId;
}
@@ -247,9 +220,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 +253,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>
/// 杞崲鎴愬満鏅姛鑳藉璞�
@@ -296,8 +286,22 @@
var sFunc = new SceneFunction();
foreach (var attr in attributes)
{
- sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() });
+ if (attr.curValue.ToString() == "{}")
+ {
+ attr.curValue = "0";
+ }
+ if (attr.key == FunctionAttributeKey.SetTemp)
+ {
+ double vv = 16;
+ Double.TryParse(attr.curValue.ToString(),out vv);
+ sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = Convert.ToInt32(vv).ToString() });
+ }
+ else
+ {
+ sFunc.status.Add(new SceneFunctionStatus() { key = attr.key, value = attr.curValue.ToString() });
+ }
}
+ sFunc.sid = this.sid;
return sFunc;
}
@@ -309,18 +313,18 @@
/// <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;
- var aca = new AlinkControlAttributes();
- foreach(var dic in commandDictionary)
+ foreach (var dic in commandDictionary)
{
+ var aca = new AlinkControlAttributes();
aca.key = dic.Key;
aca.value = dic.Value;
acd.status.Add(aca);
@@ -334,7 +338,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 +372,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鍗忚鎺у埗鏁版嵁
@@ -410,6 +425,7 @@
/// 鍔熻兘灞炴��
/// 灞炴�у瓧娈佃В鏋愶細attri :灞炴�у唴瀹癸紝value 灞炴�х殑鍊硷紝max 鏈�澶у�� min 鏈�灏忓��
/// </summary>
+ [System.Serializable]
public class FunctionAttributes
{
/// <summary>
@@ -423,11 +439,11 @@
/// <summary>
/// 鏈�澶у��
/// </summary>
- public int max;
+ public int max = 100;
/// <summary>
/// 鏈�灏忓��
/// </summary>
- public int min;
+ public int min = 0;
/// <summary>
/// 鏁版嵁绫诲瀷
/// </summary>
@@ -437,270 +453,6 @@
/// </summary>
public object curValue = new object();
- //----app鑷畾涔�
- /// <summary>
- /// 灞炴�у�煎崟浣�
- /// </summary>
- string _uintString;
- [Newtonsoft.Json.JsonIgnore]
- public string uintString
- {
- get
- {
- if (!string.IsNullOrEmpty(_uintString))
- {
- return _uintString;
- }
- var us = "";
- switch (key)
- {
- case "temperature":
- case "set_temperature":
- us = "掳C";
- break;
- case "percent":
- case "brightness":
- us = "%";
- break;
- }
- return us;
- }
- }
-
- /// <summary>
- /// 灞炴�у悕绉版樉绀烘枃鏈�
- /// 涓嫳鏂囨樉绀�
- /// </summary>
- [Newtonsoft.Json.JsonIgnore]
- public string name_text
- {
- get
- {
- string text = "";
- switch (key)
- {
- case "on_off":
- text = Language.StringByID(StringId.OnOff);
- break;
- case "brightness":
- text = Language.StringByID(StringId.Brightness);
- break;
- case "color":
- text = Language.StringByID(StringId.ColorValue);
- break;
- case "mode":
- text = Language.StringByID(StringId.Mode);
- break;
- case "fan":
- text = Language.StringByID(StringId.FanSpeed);
- break;
- case "temperature":
- case "set_temperature":
- text = Language.StringByID(StringId.Temp);
- break;
- case "delay":
- text = Language.StringByID(StringId.Delay);
- break;
- case "cct":
- text = "CCT";
- break;
- //case "fade_time":
- case "percent":
- text = Language.StringByID(StringId.PercentAdjustment);
- break;
- //case "lock":
- //case "ico":
- //case "swing":
- //case "set_point":
- //case "pm25":
- //case "volume":
- //case "vol_step":
- //case "source":
- //case "treble":
- //case "bass":
- //case "playlist":
- //case "song_name":
- //case "current_status":
- //case "enable":
- //case "lux":
- //case "adjust_value":
- //case "range":
- //case "humidity":
- //case "type":
- //case "state":
- //case "sensitivity":
- //case "pm25value":
- }
- return text;
- }
- }
-
- /// <summary>
- /// 鑾峰彇褰撳墠灞炴�х殑鏄剧ず鏂囨湰
- /// 涓嫳鏂囨樉绀�
- /// </summary>
- public string GetCurValueText()
- {
- return GetValueText(curValue.ToString());
- }
-
- /// <summary>
- /// 鑾峰彇鎸囧畾灞炴�х殑鏄剧ず鏂囨湰
- /// 涓嫳鏂囨樉绀�
- /// </summary>
- public string GetValueText(string value)
- {
- string text = "";
- value = value.Replace("{}", "");
- switch (key)
- {
- case "on_off":
- text = value == "on" ? Language.StringByID(StringId.On) : Language.StringByID(StringId.OFF);
- break;
- case "temperature":
- case "set_temperature":
- case "brightness":
- case "percent":
- if (value == "")
- {
- this.curValue = this.min;
- text = this.min.ToString();
- }
- else
- {
- text = value;
- }
- break;
- //case "color":
- case "mode":
- switch (value)
- {
- //----绌鸿皟
- case "auto":
- text = Language.StringByID(StringId.Auto);
- break;
- case "cool":
- text = Language.StringByID(StringId.Cool);
- break;
- case "heat":
- text = Language.StringByID(StringId.Heat);
- break;
- case "dry":
- text = Language.StringByID(StringId.Dry);
- break;
- case "fan":
- text = Language.StringByID(StringId.AirSupply);
- break;
- //-----鍦扮儹
- case "day":
- text = Language.StringByID(StringId.Day);
- break;
- case "night":
- text = Language.StringByID(StringId.Night);
- break;
- case "away":
- text = Language.StringByID(StringId.Away);
- break;
- case "normal":
- text = Language.StringByID(StringId.Normal);
- break;
- case "timer":
- text = Language.StringByID(StringId.Timer);
- break;
- default:
- if (this.value.Contains("cool"))
- {
- this.curValue = "cool";
- text = Language.StringByID(StringId.Cool);
- }
- else if (this.value.Contains("day"))
- {
- this.curValue = "day";
- text = Language.StringByID(StringId.Day);
- }
- else
- {
- foreach (var v in this.value)
- {
- this.curValue = v;
- text = GetCurValueText();
- }
- }
- break;
- }
- break;
- case "fan":
- switch (value)
- {
- case "high":
- text = Language.StringByID(StringId.HighWindSpeed);
- break;
- case "medium":
- text = Language.StringByID(StringId.MiddleWindSpeed);
- break;
- case "low":
- text = Language.StringByID(StringId.LowWindSpeed);
- break;
- case "auto":
- text = Language.StringByID(StringId.Auto);
- break;
- default:
- if (this.value.Contains("low"))
- {
- this.curValue = "low";
- text = Language.StringByID(StringId.LowWindSpeed);
- }
- else
- {
- foreach (var v in this.value)
- {
- this.curValue = v;
- text = GetCurValueText();
- }
- }
- break;
- }
- break;
- //case "delay":
- //case "cct":
- //case "fade_time":
- //case "lock":
- //case "ico":
- //case "swing":
- //case "set_point":
- //case "pm25":
- //case "volume":
- //case "vol_step":
- //case "source":
- //case "treble":
- //case "bass":
- //case "playlist":
- //case "song_name":
- //case "current_status":
- //case "enable":
- //case "lux":
- //case "adjust_value":
- //case "range":
- //case "humidity":
- //case "type":
- //case "state":
- //case "sensitivity":
- //case "pm25value":
- case "high":
- text = Language.StringByID(StringId.HighWindSpeed);
- break;
- case "medium":
- text = Language.StringByID(StringId.MiddleWindSpeed);
- break;
- case "low":
- text = Language.StringByID(StringId.LowWindSpeed);
- break;
- case "auto":
- text = Language.StringByID(StringId.Auto);
- break;
- }
- return text;
- }
}
/// <summary>
/// 鍔熻兘灞炴�ч敭鍚嶅垪琛�
@@ -718,7 +470,11 @@
/// <summary>
/// 棰滆壊
/// </summary>
- public const string Color = "color";
+ public const string RGB = "rgb";
+ /// <summary>
+ /// 娓愬彉鏃堕棿
+ /// </summary>
+ public const string FadeTime = "fade_time";
/// <summary>
/// 妯″紡
/// </summary>
@@ -728,9 +484,9 @@
/// </summary>
public const string FanSpeed = "fan";
/// <summary>
- /// 娓╁害
+ /// 璁剧疆娓╁害
/// </summary>
- public const string Temp = "temperature";
+ public const string SetTemp = "set_temp";
/// <summary>
/// 寤舵椂
/// </summary>
@@ -743,6 +499,10 @@
/// 鐧惧垎姣�
/// </summary>
public const string Percent = "percent";
+ /// <summary>
+ /// 瀹ゅ唴娓╁害
+ /// </summary>
+ public const string IndoorTemp = "room_temp";
}
/// <summary>
/// 璁惧鍔熻兘oid
@@ -763,6 +523,7 @@
public class BusData
{
public string addresses = "FFFF";
+ [Newtonsoft.Json.JsonIgnore]
public byte SubnetID
{
get
@@ -770,6 +531,7 @@
return Convert.ToByte(addresses.Substring(0, 2), 16);
}
}
+ [Newtonsoft.Json.JsonIgnore]
public byte DeviceID
{
get
@@ -777,7 +539,15 @@
return Convert.ToByte(addresses.Substring(2, 2), 16);
}
}
- public byte loopId;
+ public byte LoopId
+ {
+ get
+ {
+ return Convert.ToByte(loopId, 16);
+ }
+ }
+
+ public string loopId;
}
public static class SPK
@@ -873,15 +643,15 @@
/// <summary>
/// 瀹剁數銆佹彃搴�
/// </summary>
- public const string ElectricSocket = "electric.socket ";
+ public const string ElectricSocket = "electrical.socket";
/// <summary>
/// 瀹剁數銆佺數瑙�
/// </summary>
- public const string ElectricTV = "electric.tv";
+ public const string ElectricTV = "electrical.tv";
/// <summary>
/// 瀹剁數銆侀鎵�
/// </summary>
- public const string ElectricFan = "electric.fan";
+ public const string ElectricFan = "electrical.fan";
}
-}
+}
\ No newline at end of file
--
Gitblit v1.8.0