From 3d7673c7b4aa0dc886d4816fe2d0ab400702e6e1 Mon Sep 17 00:00:00 2001
From: lss <lsc@hdlchina.com.cn>
Date: 星期四, 25 三月 2021 19:11:13 +0800
Subject: [PATCH] 2021-03-25 集成丰林可视对讲
---
HDL_ON/Entity/Function/Function.cs | 209 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 146 insertions(+), 63 deletions(-)
diff --git a/HDL_ON/Entity/Function/Function.cs b/HDL_ON/Entity/Function/Function.cs
index 848dc4a..0997ffa 100644
--- a/HDL_ON/Entity/Function/Function.cs
+++ b/HDL_ON/Entity/Function/Function.cs
@@ -65,6 +65,22 @@
#region 浼樺寲鍖哄煙 2021-02-25
/// <summary>
+ /// 鏇存柊鐨勬渶鍚庢椂闂�
+ /// </summary>
+ public string time_stamp = "1615261019796";
+
+ public string GeteTime()
+ {
+ try
+ {
+ DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 褰撳湴鏃跺尯
+ return startTime.AddMilliseconds(Convert.ToDouble(time_stamp)).ToString("s");
+ }
+ catch {
+ return DateTime.MinValue.ToString("s");
+ }
+ }
+ /// <summary>
/// 鑾峰彇灞炴�у垪琛�
/// </summary>
/// <returns></returns>
@@ -79,7 +95,7 @@
return attrs;
}
/// <summary>
- /// 鑾峰彇鍒跺畾灞炴��
+ /// 鑾峰彇鎸囧畾灞炴��
/// </summary>
/// <returns></returns>
public FunctionAttributes GetAttribute(string key)
@@ -89,18 +105,18 @@
}
/// <summary>
- /// 鑾峰彇灞炴�х姸鎬�
+ /// 鑾峰彇灞炴�у綋鍓嶇姸鎬�
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public string GetAttrState(string key)
{
- var attrState = status.Find((s) => s.key == key.ToString());
- if(attrState == null)
+ var attrState = attributes.Find((s) => s.key == key.ToString());
+ if (attrState == null || string.IsNullOrEmpty(attrState.state))
{
- return "";
+ return "0";
}
- return attrState.value;
+ return attrState.state;
}
/// <summary>
/// 璁剧疆灞炴�х姸鎬�
@@ -108,46 +124,50 @@
/// <param name="key"></param>
/// <param name="value"></param>
/// <returns>淇敼缁撴灉</returns>
- public bool SetAttrState(string key, string value)
+ public bool SetAttrState(string key, object value)
{
- var attrState = status.Find((s) => s.key == key.ToString());
- if (attrState == null)
+ //var attrState = status.Find((s) => s.key == key.ToString());
+ var attr = attributes.Find((s) => s.key == key);
+ if (attr == null)
{
return false;
}
else
{
- attrState.value = value;
+ attr.state = value.ToString();
+ attr.curValue = value.ToString();
}
return true;
}
+ /// <summary>
+ /// icon鏂囦欢鍚嶇О
+ /// </summary>
+ public string IconName
+ {
+ get
+ {
+ return spk.Replace(".","");
+ }
+ }
+
+ /// <summary>
+ /// 涓婁竴娆℃墦寮�鐨勪寒搴�
+ /// 鐏厜绉佹湁灞炴��
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public int lastBrightness = 100;
+
+ /// <summary>
+ /// 宸ヤ綔妯″紡瀵瑰簲鐨勫伐浣滄俯搴�
+ /// 鍦扮儹绉佹湁灞炴��
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public Dictionary<string, byte> Fh_Mode_Temp = new Dictionary<string, byte>();
#endregion
#region base info
- /// <summary>
- /// HDL缁熶竴鍗忚鏍煎紡锛�14bytes
- /// 涓句緥锛� 鏉ユ簮 鍘傚晢浠g爜 閫氳鏂瑰紡 浜у搧鏃堕棿鎴� 浜у搧绫诲埆 鐗╂ā鍨嬬被 閫氶亾鍙� 澶у皬绫诲埆
- /// 1byte 1byte 1byte 4byte 1byte 2byte 2byte 2byte
- /// 鏉ユ簮锛�00 榛樿鍘熺敓鎬佺郴缁熸暟鎹� 銆�01 缃戝叧鎴栬�呭叾浠朅璁惧銆�02 璋冭瘯杞欢銆�03 APP搴旂敤绋嬪簭銆�04 绗笁鏂圭綉鍏虫垨鑰呭钩鍙�
- /// 鍘傚晢浠g爜锛�01 HDL
- /// 閫氳鏂瑰紡锛�01 HDL Bus銆�02 Zigbee銆�03 KNX銆�04 Z-Wave
- /// 浜у搧鏃堕棿鎴筹細4bytes 浠�2020骞�1鏈�1鏃ョ畻鍑虹殑鏃堕棿鎴�0.1s涓哄崟浣�
- /// 浜у搧绫诲埆锛�01 璋冨厜鍣ㄣ��02 缁х數鍣ㄣ��03 骞叉帴鐐规ā鍧椼��04 浼犳劅鍣ㄣ��05 闈㈡澘
- /// 鐗╂ā鍨嬬被鍨嬶細
- /// 01 寮�鍏崇被锛�01 寮�鍏炽��02 鎻掑骇銆�03
- /// 02 鐓ф槑锛� 01 寮�鍏炽��02 璋冨厜銆�03 鑹叉俯銆�04 LED
- /// 03 閬槼锛� 01 绐楀笜鐢垫満銆�02 鐧惧彾绐椼��03 寮�鍚堝笜銆�04 鍗峰笜
- /// 04 鎭掓俯鍣細01 绌鸿皟銆�02 鍦版殩銆�03 姣涚粏绌鸿皟
- /// 05 鏂伴
- /// 06 褰遍煶
- /// 07 闊充箰
- /// 08 鑳芥簮
- /// 09 瀹夐槻
- /// 澶х被鍒� 1bytes 锛堥鐣欙級
- /// 灏忕被鍒� 1byte 锛堥鐣欙級
- /// </summary> 鈥�0001021599F98A04050300010000鈥�
public string sid = "0301011234567801012301230123";
/// <summary>
/// 澶囨敞
@@ -187,23 +207,6 @@
/// attri
/// </summary>
public List<FunctionAttributes> attributes = new List<FunctionAttributes>();
- /// <summary>
- /// 鍔熻兘鐘舵�佸垪琛�
- /// </summary>
- public List<AttributesStatus> status = new List<AttributesStatus>();
- /// <summary>
- /// 鑾峰彇鐘舵�佸��
- /// </summary>
- /// <returns></returns>
- public string GetStatusValus(string key)
- {
- var d = status.Find((obj) => obj.key == key);
- if(d==null)
- {
- return null;
- }
- return d.value;
- }
/// <summary>
/// 鎴块棿ID鍒楄〃
@@ -299,7 +302,6 @@
public void CollectFunction()
{
var result = "";
- //var waitPage = new Loading();
new System.Threading.Thread(() =>
{
@@ -318,6 +320,12 @@
{
collect = !collect;
IMessageCommon.Current.ShowErrorInfoAlter(result);
+ });
+ }else
+ {
+ Application.RunOnMainThread(() =>
+ {
+ UI.HomePage.RefreshFunctionView();
});
}
})
@@ -528,10 +536,8 @@
{
var sendDataObj = new AlinkFunctionStatusObj();
sendDataObj.id = Control.Ins.msg_id.ToString();
- sendDataObj.time_stamp = Control.Ins.Get_TimeStamp();
-
-
- var acd = new AlinkControlData();
+ sendDataObj.time_stamp = Utlis.GetTimestamp();
+ var acd = new AlinkStatusData();
acd.sid = sid;
foreach (var dic in commandDictionary)
{
@@ -540,9 +546,7 @@
aca.value = dic.Value;
acd.status.Add(aca);
}
-
sendDataObj.objects.Add(acd);
-
return sendDataObj;
}
/// <summary>
@@ -593,7 +597,7 @@
/// </summary>
public class AlinkFunctionStatusObj
{
- public List<AlinkControlData> objects = new List<AlinkControlData>();
+ public List<AlinkStatusData> objects = new List<AlinkStatusData>();
public string time_stamp = "";
public string id = "";
@@ -609,11 +613,23 @@
public string time_stamp = "";
}
/// <summary>
- /// A鍗忚鎺у埗鏁版嵁
+ /// A鍗忚鐘舵�佹暟鎹�
/// </summary>
- public class AlinkControlData
+ public class AlinkStatusData
{
+ /*
+ mqtt鎺ユ敹鐨勭姸鎬佹暟鎹病鏈塪eviceId
+ 鎺ュ彛鍙嶉鐨勬暟鎹湁
+ */
+ /// <summary>
+ ///
+ /// </summary>
public string sid = "";
+ /// <summary>
+ /// 璁惧ID
+ /// 浜戠璐熻矗鐢熸垚
+ /// </summary>
+ public string deviceId = "0";
public List<AttributesStatus> status = new List<AttributesStatus>();
}
/// <summary>
@@ -661,6 +677,10 @@
/// </summary>
public string data_type = "";
/// <summary>
+ /// 褰撳墠鐘舵��
+ /// </summary>
+ public string state = "";
+ /// <summary>
/// 褰撳墠鍊�
/// </summary>
public object curValue = new object();
@@ -692,13 +712,41 @@
/// </summary>
public const string Mode = "mode";
/// <summary>
+ /// 宸ヤ綔妯″紡
+ /// 鍦扮儹/鍦板喎/鍔熺巼鍦扮儹/鍔熺巼鍦板喎
+ /// </summary>
+ public const string WorkMode = "mode_work";
+ /// <summary>
/// 椋庨��
/// </summary>
public const string FanSpeed = "fan";
/// <summary>
+ /// 鎵嬪姩椋庡悜
+ /// </summary>
+ public const string FanManual = "fan_manual";
+ /// <summary>
+ /// 鑷姩椋庡悜
+ /// </summary>
+ public const string FanAuto = "fan_auto";
+
+ /// <summary>
/// 璁剧疆娓╁害
/// </summary>
public const string SetTemp = "set_temp";
+ /// <summary>
+ /// 娓╁害鍔犲噺
+ /// </summary>
+ public const string SetTempStep = "set_temp_step";
+ /// <summary>
+ /// 娓╁害妯″紡
+ /// 绌鸿皟銆佸湴鐑�//app鑷姞
+ /// </summary>
+ public const string TempType = "temperature_type";
+ /// <summary>
+ /// 鏃堕棿鏍囪
+ /// 鍦扮儹//app鑷姞
+ /// </summary>
+ public const string TimeFlag = "time_flag";
/// <summary>
/// 寤舵椂
/// </summary>
@@ -771,7 +819,26 @@
/// 娑堟瘨鍓╀綑鏃堕棿
/// </summary>
public const string DisinfectTimeLeft = "disinfect_time_surplus";
-
+ /// <summary>
+ /// 璐熺瀛�
+ /// </summary>
+ public const string Anion = "anion";
+ /// <summary>
+ /// 璐熺瀛愭椂闂�
+ /// </summary>
+ public const string AnionTime = "anion_time";
+ /// <summary>
+ /// 璐熺瀛愬墿浣欐椂闂�
+ /// </summary>
+ public const string AnionTimeLeft = "anion_time_surplus";
+ /// <summary>
+ /// 鎵撳紑鐧昏(椋庢墖)
+ /// </summary>
+ public const string OpenLevel = "openLevel";
+ /// <summary>
+ /// 绾㈠鎸夐敭
+ /// </summary>
+ public const string Key = "key";
#region tuya
@@ -958,9 +1025,13 @@
/// </summary>
public const string ElectricTV = "electrical.tv";
/// <summary>
+ /// 绾㈠銆佺數瑙�
+ /// </summary>
+ public const string TvIr = "ir.tv";
+ /// <summary>
/// 瀹剁數銆侀鎵�
/// </summary>
- public const string ElectricFan = "electrical.fan";
+ public const string ElectricFan = "electrical.fan";
/// <summary>
/// 瀹剁數銆佹秱楦︾┖姘斿噣鍖栧櫒
/// </summary>
@@ -968,7 +1039,7 @@
/// <summary>
/// 瀹剁數銆佹秱楦︾數椋庢墖
/// </summary>
- public const string ElectricTuyaFan = "electrical.tyqborgovyzytytz";
+ public const string ElectricTuyaFan = "electrical.tyqborgovyzytytz";
/// <summary>
/// 瀹剁數銆佹秱楦︽壂鍦版満鍣ㄤ汉
/// </summary>
@@ -981,6 +1052,14 @@
/// 鍑夐湼
/// </summary>
public const string ClothesHanger = "electrical.racks";
+ /// <summary>
+ /// 绾㈠瀹�
+ /// </summary>
+ public const string IrModule = "ir.module";
+ /// <summary>
+ /// 绾㈠閬ユ帶鍣�
+ /// </summary>
+ public const string IrLearn = "ir.learn";
/// <summary>
@@ -1062,8 +1141,12 @@
/// 瀹剁數
/// </summary>
public const string Electric = "electrical";
+ /// <summary>
+ /// 绾㈠璁惧
+ /// </summary>
+ public const string IR = "ir";
- //Music = 0x09,
+
}
--
Gitblit v1.8.0