From 4f0ab0ad21ce450b7856d50f98322a7899361386 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 22 九月 2020 10:30:01 +0800
Subject: [PATCH] 不要下载这个备份
---
ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs | 2498 ++++++++++-------------------------------------------------
1 files changed, 433 insertions(+), 2,065 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs
index ea8b188..aed8f7a 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/Panel.cs
@@ -1,6 +1,7 @@
锘縰sing System;
using System.Collections.Generic;
using System.Threading.Tasks;
+using MQTTnet;
using Newtonsoft.Json.Linq;
using Shared.Common;
@@ -14,60 +15,36 @@
this.Type = DeviceType.OnOffSwitch;
}
/// <summary>
+ /// 澶氬姛鑳介潰鏉夸腑琚粦瀹氱殑鐩爣
+ /// </summary>
+ [Newtonsoft.Json.JsonIgnore]
+ public System.Collections.Generic.Dictionary<string, List<BindListAllInfo>> bindTargetsFromMutilfunctionPanelList = new System.Collections.Generic.Dictionary<string, List<BindListAllInfo>>();
+ /// <summary>
/// 鎸夐敭妯″紡锛堢鏈夊姛鑳斤級
/// </summary>
public int panelMode = 65535;
/// <summary>
- ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�
+ ///褰撳墠閫夋嫨鐨勭畝绾﹀鍔熻兘闈㈡澘鐨勭被鍨嬨�愮畝绾﹀鍔熻兘闈㈡澘銆�
+ /// 0:鍦烘櫙 1:寮�鍏� 2:鎻掑骇 3:鐏厜 4:閬槼 5:绌鸿皟 6:鏂伴
/// </summary>
- public int panelDirectionsLevel = -1;
-
- /// <summary>
- /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�
- /// </summary>
- public int panelBacklightLevel = -1;
-
+ [Newtonsoft.Json.JsonIgnore]
+ public int currentMutilfunctionBindType = 0;
/// <summary>
/// 褰撳墠閫夋嫨妯″紡
/// </summary>
+ [Newtonsoft.Json.JsonIgnore]
public string currentKeySelectModeText = "";
/// <summary>
/// 褰撳墠閫夋嫨鐨勬ゼ灞侷D
/// </summary>
+ [Newtonsoft.Json.JsonIgnore]
public string currentSelectFloorId = string.Empty;
/// <summary>
- /// 褰撳墠寮�鍏虫ā寮�
+ /// 褰撳墠閫夋嫨鐨勬埧闂碔D銆愭柊椋庨潰鏉裤��
/// </summary>
- public string CurrentSwitchMode = "";
- /// <summary>
- /// 褰撳墠灞炴�фā寮�
- /// </summary>
- public int currentClusterID;
+ [Newtonsoft.Json.JsonIgnore]
+ public string currentSelectRoomId = string.Empty;
- /// <summary>
- /// 褰撳墠璋冨厜妯″紡
- /// </summary>
- public string CurrentDimmerMode = "";
-
- /// <summary>
- /// 褰撳墠閬槼妯″紡
- /// </summary>
- public string CurrentCurtainMode = "";
-
- /// <summary>
- /// 褰撳墠鎴块棿ID
- /// </summary>
- public string RoomId = "";
-
- /// <summary>
- /// 褰撳墠鎴块棿ID
- /// </summary>
- public string curSelectSceneID = "";
-
- /// <summary>
- /// 鏈湴妤煎眰鎴块棿缁戝畾鍒楄〃
- /// </summary>
- public Dictionary<int, FloorRoomBindObj> FloorRoomBindObjList = new Dictionary<int, FloorRoomBindObj> { };
/// <summary>
/// 缁戝畾鐨勬ゼ灞傛埧闂翠俊鎭�
/// </summary>
@@ -108,12 +85,8 @@
// <summary>
/// 鎸夐敭涓缁戝畾鐨勭洰鏍囧垪琛�
/// </summary>
- public System.Collections.Generic.List<BindListResponseObj> bindList = new System.Collections.Generic.List<BindListResponseObj> { };
-
- /// <summary>
- /// 鎸夐敭鏀寔鐨勭鏈夋ā寮忓垪琛�
- /// </summary>
- public System.Collections.Generic.Dictionary<int, string> priDeviceModeFunList = new System.Collections.Generic.Dictionary<int, string> { };
+ [Newtonsoft.Json.JsonIgnore]
+ public List<BindListResponseObj> bindList = new List<BindListResponseObj>();
/// <summary>
/// 绉佹湁鍔熻兘绫�
@@ -154,6 +127,7 @@
/// <para>304:CurtainDownstop,绐楀笜涓嬮檷鍋�</para>
/// </summary>
public List<int> privateFuncThirdLevelList = new List<int>();
+
#region 鑾峰彇闈㈡澘鐨勭鏈変俊鎭�.
/// <summary>
///鑾峰彇闈㈡澘鐨勭鏈変俊鎭�
@@ -187,8 +161,7 @@
if (topic == gatewayID + "/" + "Error_Respon")
{
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
if (temp == null)
{
@@ -203,18 +176,17 @@
if (topic == gatewayID + "/" + "ZbDataPassthrough")
{
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
- if (gatewayTemp.clientDataPassthroughResponseData == null)
+ if (clientDataPassthroughResponseData == null)
{
result = new PanelPrivateFunctionsResponseAllInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
}
else
{
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+ if (clientDataPassthroughResponseData?.PassData != null)
{
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
+ var data = clientDataPassthroughResponseData.PassData;
if (data.Length > 12)
{
@@ -310,7 +282,6 @@
}
break;
}
- panelPrivateFunctionsResponseInfo = tempD;
result = new PanelPrivateFunctionsResponseAllInfo { panelPrivateFunctionsResponseInfo = tempD };
System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0003_{topic}");
}
@@ -357,17 +328,8 @@
/// PIR閰嶇疆鍙傛暟鍥炲
/// </summary>
[System.Serializable]
- public class PanelPrivateFunctionsResponseAllInfo
+ public class PanelPrivateFunctionsResponseAllInfo : ErrorResponCommon
{
- /// <summary>
- /// 閿欒淇℃伅
- /// </summary>
- public string errorMessageBase;
- /// <summary>
- /// 缃戝叧淇℃伅閿欒鍙嶉
- /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- /// </summary>
- public ErrorResponData errorResponData;
/// <summary>
/// 鍏夋劅绛夌骇涓暟锛圠ux鑳藉姏锛�
/// <para>鏈夊嚑涓瓑绾у氨鏄剧ず鍑犱釜鍒诲害</para>
@@ -378,7 +340,6 @@
/// <summary>
/// 閰嶇疆鍙傛暟鍥炲
/// </summary>
- public PanelPrivateFunctionsResponseInfo panelPrivateFunctionsResponseInfo;
[System.Serializable]
public class PanelPrivateFunctionsResponseInfo
{
@@ -711,8 +672,7 @@
if (topic == gatewayID + "/" + "Error_Respon")
{
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
if (temp == null)
{
@@ -727,28 +687,31 @@
if (topic == gatewayID + "/" + "ZbDataPassthrough")
{
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
- if (gatewayTemp.clientDataPassthroughResponseData == null)
+ if (clientDataPassthroughResponseData == null)
{
result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
}
else
{
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+ if (clientDataPassthroughResponseData?.PassData != null)
{
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
+ var data = clientDataPassthroughResponseData.PassData;
if (data.Length == 16)
{
var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
if (command == "0002")
{
var tempD = new ResponseData();
- tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
+ tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
- result = new ResponseAllData { responseData = tempD };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0400_{ topic}");
+ if (tempD.command == "0400")
+ {
+ result = new ResponseAllData { responseData = tempD };
+ System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0400_{ topic}");
+ }
+
}
}
}
@@ -820,7 +783,6 @@
string dataSerialNum = "01";
string addDataLength = "03";
string kStatus = "";
- string kNum = "";
int attributeData = 0;
try
@@ -866,102 +828,6 @@
#endregion
#region 閰嶇疆鎸夐敭鎸囩ず鐏鑹�.
- ///<summary >
- ///閰嶇疆鎸夐敭鎸囩ず鐏鑹�
- /// </summary>
- public async System.Threading.Tasks.Task<ResponseAllData> SetPanelColorInfoAsync(KeyColorData keyColorData, KeyNumStatus keyNumStatus)
- {
- ResponseAllData result = null;
- if (Gateway == null)
- {
- result = new ResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
- return result;
- }
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- Action<string, string> action = (topic, message) =>
- {
- var gatewayID = topic.Split('/')[0];
- var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- if (topic == gatewayID + "/" + "Error_Respon")
- {
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- result = new ResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
-
- else
- {
- result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
- if (topic == gatewayID + "/" + "ZbDataPassthrough")
- {
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
-
- if (gatewayTemp.clientDataPassthroughResponseData == null)
- {
- result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
- {
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
- if (data.Length == 16)
- {
- var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
- if (command == "0002")
- {
- var tempD = new ResponseData();
- tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
- tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
- result = new ResponseAllData { responseData = tempD };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0401_{ topic}");
- }
- }
- }
- }
- }
- };
-
- Gateway.Actions += action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
-
- try
- {
- var passData = SetPanelColorData(keyColorData, keyNumStatus);
- var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
- var data = new JObject { { "PassData", passData } };
- jObject.Add("Data", data);
- Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
- }
- catch { }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (result != null)
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- result = new ResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- Gateway.Actions -= action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return result;
- });
- }
/// <summary>
/// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅
@@ -984,136 +850,6 @@
public KeyColorData keyColorData;
}
- /// <summary>
- /// 閰嶇疆鎸夐敭鎸囩ず鐏鑹叉暟鎹�
- /// <para>鍙戦厤缃寜閿寚绀虹伅棰滆壊鍛戒护鏃讹紝姝ゆ椂涓哄彂閫佸埌缃戝叧鐨勯�忎紶鏁版嵁</para>
- /// </summary>
- /// <returns>The passthorugh data.</returns>
- /// <param name="keyColorData">Key color data.</param>
- /// <param name="keyNum">Key number.</param>
- string SetPanelColorData(KeyColorData keyColorData, KeyNumStatus keyNumStatus)
- {
- string data = "";
- string dataLength = "0c";
- string dataComand1 = "01";
- string dataComand2 = "04";
- string dataSerialNum = "01";
- string addDataLength = "08";
- int attributeData = 0;
-
- try
- {
- for (int i = 1; i <= 16; i++)
- {
- Type type = keyNumStatus.GetType();
- var obj = type.InvokeMember("Key" + i, System.Reflection.BindingFlags.GetField, null, keyNumStatus, null);
- int value0 = 0;
- if (Convert.ToBoolean(obj) == true)
- {
- value0 = 1;
- }
- int v = (int)Math.Pow(2, i - 1);
- attributeData += value0 * v;
- }
-
- string td = attributeData.ToString("X4");
- char[] td1 = td.ToCharArray();
- string tempAttributeData = string.Concat(td1[2].ToString(), td1[3].ToString(), td1[0].ToString(), td1[1].ToString());
- string temp = "";
- var tempColor1 = keyColorData.OpenColorR.ToString();
- var sbString1 = new System.Text.StringBuilder();
- switch (tempColor1.Length)
- {
- case 1:
- temp = "0" + tempColor1;
- break;
- case 2:
- temp = tempColor1;
- break;
- }
- sbString1.Append(temp.ToUpper());
-
- var tempColor2 = keyColorData.OpenColorG.ToString();
- var sbString2 = new System.Text.StringBuilder();
- switch (tempColor2.Length)
- {
- case 1:
- temp = "0" + tempColor2;
- break;
- case 2:
- temp = tempColor2;
- break;
- }
- sbString2.Append(temp.ToUpper());
-
- var tempColor3 = keyColorData.OpenColorB.ToString();
- var sbString3 = new System.Text.StringBuilder();
- switch (tempColor3.Length)
- {
- case 1:
- temp = "0" + tempColor3;
- break;
- case 2:
- temp = tempColor3;
- break;
- }
- sbString3.Append(temp.ToUpper());
-
- var tempColor4 = keyColorData.CloseColorR.ToString();
- var sbString4 = new System.Text.StringBuilder();
- switch (tempColor3.Length)
- {
- case 1:
- temp = "0" + tempColor4;
- break;
- case 2:
- temp = tempColor4;
- break;
- }
- sbString4.Append(temp.ToUpper());
-
- var tempColor5 = keyColorData.CloseColorG.ToString();
- var sbString5 = new System.Text.StringBuilder();
- switch (tempColor5.Length)
- {
- case 1:
- temp = "0" + tempColor5;
- break;
- case 2:
- temp = tempColor5;
- break;
- }
- sbString5.Append(temp.ToUpper());
-
- var tempColor6 = keyColorData.CloseColorB.ToString();
- var sbString6 = new System.Text.StringBuilder();
- switch (tempColor6.Length)
- {
- case 1:
- temp = "0" + tempColor6;
- break;
- case 2:
- temp = tempColor6;
- break;
- }
- sbString6.Append(temp.ToUpper());
-
- if (keyColorData != null)
- {
- data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
- tempAttributeData + sbString1 + sbString2 + sbString3 +
- sbString4 + sbString5 + sbString6;
- }
- }
- catch { };
-
- return data;
- }
-
- /// <summary>
- /// 鎸夐敭鎸囩ず鐏鑹蹭俊鎭�
- /// </summary>
- public KeyColorData keyColorData;
// <summary>
/// 鎸夐敭鎸囩ず鐏鑹蹭俊鎭�
/// </summary>
@@ -1238,13 +974,12 @@
}
#endregion
- #region 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉夸寒搴﹀睘鎬�.
+ #region 閰嶇疆鎺ヨ繎浼犳劅
///<summary >
- ///閰嶇疆鎸夐敭鎸囩ず鐏潰鏉夸寒搴﹀睘鎬�
- /// <para>directionsLevel:鎸囩ず鐏寒搴� 0-100(杩欎釜鏄偣鍑诲悗鐨勫��)</para>
- /// <para>backlightLevel:鑳屽厜鐏寒搴� 0-100(杩欎釜鏄偣鍑诲墠鐨勫��)</para>
+ /// 閰嶇疆鎺ヨ繎浼犳劅
+ /// <para>sensorEnable:浼犳劅鍣ㄤ娇鑳�</para>
/// </summary>
- public async System.Threading.Tasks.Task<ResponseAllData> SetKeyLevelAsync(int directionsLevel, int backlightLevel)
+ public async System.Threading.Tasks.Task<ResponseAllData> SetProximitySensor(bool sensorEnable)
{
ResponseAllData result = null;
if (Gateway == null)
@@ -1261,8 +996,7 @@
if (topic == gatewayID + "/" + "Error_Respon")
{
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
if (temp == null)
{
@@ -1274,30 +1008,33 @@
result = new ResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
}
}
+
if (topic == gatewayID + "/" + "ZbDataPassthrough")
{
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
- if (gatewayTemp.clientDataPassthroughResponseData == null)
+ if (clientDataPassthroughResponseData == null)
{
result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
}
else
- {
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
{
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
+ var data = clientDataPassthroughResponseData.PassData;
if (data.Length == 16)
{
var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
if (command == "0002")
{
var tempD = new ResponseData();
- tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
+ tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
- result = new ResponseAllData { responseData = tempD };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0402_{ topic}");
+ if (tempD.command == "0500")
+ {
+ result = new ResponseAllData { responseData = tempD };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0500_{ topic}");
+ }
}
}
}
@@ -1310,10 +1047,10 @@
try
{
- var passData = SetPanelLevelData(directionsLevel, backlightLevel);
+ var passData = SetProximitySensorData(sensorEnable);
var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
var data = new JObject { { "PassData", passData } };
- jObject.Add("Data", data);
+ jObject.Add("Data", data);
Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
}
catch { }
@@ -1339,47 +1076,33 @@
}
/// <summary>
- /// 鎺у埗鎸夐敭鎸囩ず鐏�
+ /// 閰嶇疆鎺ヨ繎浼犳劅
+ /// [璇ユ潯鍗忚鍙﹀2涓弬鏁癠I鍜岃澶囬兘涓嶉渶瑕侊紝璁惧閮藉悓浜嬭姹備紶鎰熷櫒璺濈鍜屼紶鎰熷櫒瑙﹀彂寤惰繜鏃堕棿閮介粯璁ゆ槸FFFF]
/// </summary>
- string SetPanelLevelData(int level1, int level2)
+ /// <param name="sensorEnable">浼犳劅鍣ㄤ娇鑳� 0-disable 1-enable</param>
+ /// <returns></returns>
+ string SetProximitySensorData(bool sensorEnable)
{
string data = "";
- string dataLength = "06";
- string dataComand1 = "02";
- string dataComand2 = "04";
+ string dataLength = "09";
+ string dataComand1 = "00";
+ string dataComand2 = "05";
string dataSerialNum = "01";
- string addDataLength = "02";
- string l1 = "";
- string l2 = "";
+ string addDataLength = "05";
+ string sEnable = "";
try
{
- var sbString1 = new System.Text.StringBuilder();
- var sbString2 = new System.Text.StringBuilder();
- string temp1 = Convert.ToString(level1, 16);
- string temp2 = Convert.ToString(level2, 16);
+ if (sensorEnable)
+ {
+ sEnable = "01";
+ }
+ else
+ {
+ sEnable = "00";
+ }
- switch (temp1.Length)
- {
- case 1:
- l1 = "0" + temp1;
- break;
- case 2:
- l1 = temp1;
- break;
- }
- switch (temp2.Length)
- {
- case 1:
- l2 = "0" + temp2;
- break;
- case 2:
- l2 = temp2;
- break;
- }
- sbString1.Append(l1.ToString().ToUpper());
- sbString2.Append(l2.ToString().ToUpper());
data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
- sbString1 + sbString2;
+ sEnable + "FFFFFFFF";
}
catch { };
@@ -1387,14 +1110,11 @@
}
#endregion
- #region 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉胯妭鑳芥ā寮�.
+ #region 鏍℃娓╁害
///<summary >
- /// 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉胯妭鑳芥ā寮�
- /// <para>modeEnable:鑺傝兘妯″紡浣胯兘</para>
- /// <para>modeTime:鏃犳搷浣滆繘鍏ヨ妭鑳芥ā寮忔椂闂� 0-ff</para>
- /// <para>鑺傝兘妯″紡浜害:0-100</para>
+ /// 鏍℃娓╁害
/// </summary>
- public async System.Threading.Tasks.Task<ResponseAllData> SetKeyModeAsync(bool modeEnable, int modeTime, int level)
+ public async System.Threading.Tasks.Task<ResponseAllData> CorrectTemperature(double correctValue, int direction = 0, int type = 0)
{
ResponseAllData result = null;
if (Gateway == null)
@@ -1411,8 +1131,7 @@
if (topic == gatewayID + "/" + "Error_Respon")
{
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
if (temp == null)
{
@@ -1427,28 +1146,30 @@
if (topic == gatewayID + "/" + "ZbDataPassthrough")
{
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
- if (gatewayTemp.clientDataPassthroughResponseData == null)
+ if (clientDataPassthroughResponseData == null)
{
result = new ResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
}
else
- {
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
{
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
+ var data = clientDataPassthroughResponseData.PassData;
if (data.Length == 16)
{
var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
if (command == "0002")
{
var tempD = new ResponseData();
- tempD.command = Convert.ToInt32(data[10].ToString() + data[11].ToString() + data[12].ToString() + data[13].ToString(), 16);
+ tempD.command = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
- result = new ResponseAllData { responseData = tempD };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0403_{ topic}");
+ if (tempD.command == "0503")
+ {
+ result = new ResponseAllData { responseData = tempD };
+ DebugPrintLog($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0500_{ topic}");
+ }
}
}
}
@@ -1461,10 +1182,10 @@
try
{
- var passData = SetPanelModeModeData(modeEnable, modeTime, level);
+ var passData = CorrectTemperatureData(correctValue,direction, type);
var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
var data = new JObject { { "PassData", passData } };
- jObject.Add("Data", data);
+ jObject.Add("Data", data);
Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
}
catch { }
@@ -1490,57 +1211,66 @@
}
/// <summary>
- /// 閰嶇疆鎸夐敭鎸囩ず鐏潰鏉胯妭鑳芥ā寮�
+ /// 鏍℃娓╁害
+ /// [璇ユ潯鍗忚鍙﹀2涓弬鏁癠I鍜岃澶囬兘涓嶉渶瑕侊紝璁惧閮藉悓浜嬭姹備紶鎰熷櫒璺濈鍜屼紶鎰熷櫒瑙﹀彂寤惰繜鏃堕棿閮介粯璁ゆ槸FFFF]
/// </summary>
- string SetPanelModeModeData(bool modeEnable, int modeTime, int modelevel)
+ /// <param name="correctValue">鏍℃娓╁害鍊�</param>
+ /// <returns></returns>
+ string CorrectTemperatureData(double correctValue,int direction=0, int type = 0)
{
string data = "";
- string dataLength = "07";
+ string dataLength = "09";
string dataComand1 = "03";
- string dataComand2 = "04";
+ string dataComand2 = "05";
string dataSerialNum = "01";
- string addDataLength = "03";
- string mode = "";
- string time = "";
- string level = "";
+ string addDataLength = "05";
+ string typeString = "";
+ string directString = "";
+ string correctValueString = "";
try
{
- if (modeEnable)
+ if (type == 1)
{
- mode = "01";
+ typeString = "0100";
}
else
{
- mode = "00";
- }
- var sbString1 = new System.Text.StringBuilder();
- string temp = Convert.ToString(modeTime, 16);
- switch (temp.Length)
- {
- case 1:
- time = "0" + temp;
- break;
- case 2:
- time = temp;
- break;
+ typeString = "0000";
}
- var sbString2 = new System.Text.StringBuilder();
- string temp2 = Convert.ToString(modelevel, 16);
- switch (temp2.Length)
+ if (direction == 1)
{
- case 1:
- level = "0" + temp2;
- break;
- case 2:
- level = temp2;
- break;
+ directString = "01";
}
-
- sbString1.Append(time.ToUpper());
- sbString2.Append(level.ToUpper());
+ else if (direction == 2)
+ {
+ directString = "02";
+ }
+ else
+ {
+ directString = "00";
+ }
+
+ int curV = (int)(correctValue * 100);
+ var tempBytes = new byte[2];
+ for (int i = 0; i < 2; i++)
+ {
+ tempBytes[i] = (byte)(curV >> (i * 8) & 0xff);
+ }
+ var curV1 = Convert.ToString(tempBytes[0], 16);
+ var curV2 = Convert.ToString(tempBytes[1], 16);
+ if (curV1.Length == 1)
+ {
+ curV1 = "0" + curV1;
+ }
+ if (curV2.Length == 1)
+ {
+ curV2 = "0" + curV2;
+ }
+
+ correctValueString = (curV1 + curV2).ToUpper();
data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
- mode + sbString1 + sbString2;
+ typeString + directString + correctValueString;
}
catch { };
@@ -1549,233 +1279,6 @@
#endregion
#region 鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�.
- ///<summary >
- ///鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�.
- /// </summary>
- public async System.Threading.Tasks.Task<KeyColorDataResponseAllData> GetPanelColorInfoAsync(KeyNum keyNum)
- {
- KeyColorDataResponseAllData result = null;
- if (Gateway == null)
- {
- result = new KeyColorDataResponseAllData { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
- return result;
- }
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- Action<string, string> action = (topic, message) =>
- {
- var gatewayID = topic.Split('/')[0];
- var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- if (topic == gatewayID + "/" + "Error_Respon")
- {
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- result = new KeyColorDataResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
-
- else
- {
- result = new KeyColorDataResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
- if (topic == gatewayID + "/" + "ZbDataPassthrough")
- {
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
-
- if (gatewayTemp.clientDataPassthroughResponseData == null)
- {
- result = new KeyColorDataResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
- {
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
- if (data.Length == 24)
- {
- var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
- if (command == "0405")
- {
- var key1 = data[10] + data[11];
- var key = data[10].ToString() + data[11].ToString();
- var tempR = new KeyColorData();
- tempR.OpenColorR = data[12].ToString() + data[13].ToString(); ;
- tempR.OpenColorG = data[14].ToString() + data[15].ToString(); ;
- tempR.OpenColorB = data[16].ToString() + data[17].ToString(); ;
- tempR.CloseColorR = data[18].ToString() + data[19].ToString(); ;
- tempR.CloseColorG = data[20].ToString() + data[21].ToString(); ;
- tempR.CloseColorB = data[22].ToString() + data[23].ToString(); ;
-
- switch (key)
- {
- case "01":
- tempR.keyNum = KeyNum.Key1;
- break;
- case "02":
- tempR.keyNum = KeyNum.Key2;
- break;
- case "03":
- tempR.keyNum = KeyNum.Key3;
- break;
- case "04":
- tempR.keyNum = KeyNum.Key4;
- break;
- case "05":
- tempR.keyNum = KeyNum.Key5;
- break;
- case "06":
- tempR.keyNum = KeyNum.Key6;
- break;
- case "07":
- tempR.keyNum = KeyNum.Key7;
- break;
- case "08":
- tempR.keyNum = KeyNum.Key8;
- break;
- case "09":
- tempR.keyNum = KeyNum.Key9;
- break;
- case "0a":
- tempR.keyNum = KeyNum.Key10;
- break;
- case "0b":
- tempR.keyNum = KeyNum.Key11;
- break;
- case "0c":
- tempR.keyNum = KeyNum.Key12;
- break;
- case "0d":
- tempR.keyNum = KeyNum.Key13;
- break;
- case "0e":
- tempR.keyNum = KeyNum.Key14;
- break;
- case "0f":
- tempR.keyNum = KeyNum.Key15;
- break;
- }
- keyColorData = tempR;
- result = new KeyColorDataResponseAllData { keyColorData = tempR };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0404_{ topic}");
- }
- }
- }
- }
- }
- };
-
- Gateway.Actions += action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
-
- try
- {
- var passData = GetkeyColorData(keyNum);
- var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
- var data = new JObject { { "PassData", passData } };
- jObject.Add("Data", data);
- Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
- }
- catch { }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)// WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (result != null)
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- result = new KeyColorDataResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- Gateway.Actions -= action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return result;
- });
- }
-
- /// <summary>
- /// 鑾峰彇鎸夐敭鎸囩ず鐏紑鍏抽鑹�
- /// </summary>
- string GetkeyColorData(KeyNum keyNum)
- {
- string data = "";
- string dataLength = "05";
- string dataComand1 = "04";
- string dataComand2 = "04";
- string dataSerialNum = "01";
- string addDataLength = "01";
- string kNum = "";
-
- try
- {
- switch (keyNum)
- {
- case KeyNum.Key1:
- kNum = "01";
- break;
- case KeyNum.Key2:
- kNum = "02";
- break;
- case KeyNum.Key3:
- kNum = "03";
- break;
- case KeyNum.Key4:
- kNum = "04";
- break;
- case KeyNum.Key5:
- kNum = "05";
- break;
- case KeyNum.Key6:
- kNum = "06";
- break;
- case KeyNum.Key7:
- kNum = "07";
- break;
- case KeyNum.Key8:
- kNum = "08";
- break;
- case KeyNum.Key9:
- kNum = "09";
- break;
- case KeyNum.Key10:
- kNum = "0A";
- break;
- case KeyNum.Key11:
- kNum = "0B";
- break;
- case KeyNum.Key12:
- kNum = "0C";
- break;
- case KeyNum.Key13:
- kNum = "0D";
- break;
- case KeyNum.Key14:
- kNum = "0E";
- break;
- case KeyNum.Key15:
- kNum = "0F";
- break;
- case KeyNum.Key16:
- kNum = "10";
- break;
- }
-
- data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + kNum;
- }
- catch { };
-
- return data;
- }
/// <summary>
/// 鎸夐敭鎸囩ず鐏鑹蹭俊鎭搴旈『搴忓彿(鐫$湢缁勫彿)
@@ -1802,128 +1305,6 @@
#endregion
#region 鑾峰彇鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃�.
- ///<summary >
- ///鑾峰彇鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃�
- /// </summary>
- public async System.Threading.Tasks.Task<PanelSwitchLevelInfo> GetPanelSwitchLevelAsync(string reserve = "01")
- {
- PanelSwitchLevelInfo result = null;
- if (Gateway == null)
- {
- result = new PanelSwitchLevelInfo { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
- return result;
- }
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- Action<string, string> action = (topic, message) =>
- {
- var gatewayID = topic.Split('/')[0];
- var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- if (topic == gatewayID + "/" + "Error_Respon")
- {
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- result = new PanelSwitchLevelInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
-
- else
- {
- result = new PanelSwitchLevelInfo { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
- if (topic == gatewayID + "/" + "ZbDataPassthrough")
- {
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
-
- if (gatewayTemp.clientDataPassthroughResponseData == null)
- {
- result = new PanelSwitchLevelInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
- {
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
- if (data.Length == 14)
- {
- var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
- if (command == "0407")
- {
- var level1 = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16);
- var level2 = Convert.ToInt32(data[12].ToString() + data[13].ToString(), 16);
- panelDirectionsLevel = level1;
- panelBacklightLevel = level2;
- result = new PanelSwitchLevelInfo { panelDirectionsLevel = level1, panelBacklightLevel = level2 };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0406_{ topic}");
- }
- }
- }
- }
- }
- };
-
- Gateway.Actions += action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
-
- try
- {
- var passData = SendPanelSwitchLevelData(reserve);
- var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
- var data = new JObject { { "PassData", passData } };
- jObject.Add("Data", data);
- Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
- }
- catch { }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < 9000)//WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (result != null)
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- result = new PanelSwitchLevelInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- Gateway.Actions -= action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return result;
- });
- }
-
- /// <summary>
- /// 鑾峰彇鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃暟鎹�
- /// <para>鍙戦厤缃寜閿寚绀虹伅棰滆壊鍛戒护鏃讹紝姝ゆ椂涓哄彂閫佸埌缃戝叧鐨勯�忎紶鏁版嵁</para>
- /// </summary>
- string SendPanelSwitchLevelData(string reserve)
- {
- string data = "";
- string dataLength = "05";
- string dataComand1 = "06";
- string dataComand2 = "04";
- string dataSerialNum = "01";
- string addDataLength = "01";
- string reserveData = reserve;
-
- try
- {
- data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
- reserveData;
- }
- catch { };
-
- return data;
- }
/// <summary>
/// 鎸夐敭鎸囩ず鐏潰鏉垮紑鍏充寒搴﹂厤缃洖澶�
@@ -1941,147 +1322,18 @@
/// </summary>
public ErrorResponData errorResponData;
/// <summary>
- ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�(杩欎釜鏄偣鍑诲悗鐨勫��)
+ ///鎸夐敭寮�鐘舵�侊紙鎸囩ず锛変寒搴�(杩欎釜鏄偣鍑诲悗鐨勫��,鎴栬�� 1-6骞叉帴鐐圭殑鑳屽厜鐏�)
/// </summary>
public int panelDirectionsLevel = -1;
/// <summary>
- /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�(杩欎釜鏄偣鍑诲墠鐨勫��)
+ /// 鎸夐敭鍏崇姸鎬侊紙鑳屽厜锛変寒搴�(杩欎釜鏄偣鍑诲墠鐨勫��,鎴栬�� 绗竷骞叉帴鐐圭殑鑳屽厜鐏�)
/// </summary>
public int panelBacklightLevel = -1;
}
#endregion
#region 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵��.
- ///<summary >
- ///鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵��
- /// </summary>
- public async System.Threading.Tasks.Task<PanelSwitchLevelResponInfo> GetPanelSaveEnergyModeAsync(string reserve = "01")
- {
- PanelSwitchLevelResponInfo result = null;
- if (Gateway == null)
- {
- result = new PanelSwitchLevelResponInfo { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
- return result;
- }
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- Action<string, string> action = (topic, message) =>
- {
- var gatewayID = topic.Split('/')[0];
- var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- if (topic == gatewayID + "/" + "Error_Respon")
- {
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- result = new PanelSwitchLevelResponInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
-
- else
- {
- result = new PanelSwitchLevelResponInfo { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
- if (topic == gatewayID + "/" + "ZbDataPassthrough")
- {
- var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
-
- if (gatewayTemp.clientDataPassthroughResponseData == null)
- {
- result = new PanelSwitchLevelResponInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
- {
- var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
- if (data.Length == 16)
- {
- var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
- if (command == "0409")
- {
- var tempR = new PanelSaveEnergyModeInfo();
- if (data[10].ToString() + data[11].ToString() == "01")
- {
- tempR.enable = true;
- }
- else
- {
- tempR.enable = false;
- }
- tempR.time = Convert.ToInt32(data[12].ToString() + data[13].ToString(), 16);
- tempR.level = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
- panelSaveEnergyModeInfo = tempR;
- result = new PanelSwitchLevelResponInfo { panelSaveEnergyModeInfo = tempR };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0408_{ topic}");
- }
- }
- }
- }
- }
- };
-
- Gateway.Actions += action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
-
- try
- {
- var passData = SendPanelSaveEnergyModeData(reserve);
- var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
- var data = new JObject { { "PassData", passData } };
- jObject.Add("Data", data);
- Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
- }
- catch { }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (result != null)
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)// WaitReceiveDataTime)
- {
- result = new PanelSwitchLevelResponInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- Gateway.Actions -= action;
- System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return result;
- });
- }
-
- /// <summary>
- /// 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵�佹暟鎹�
- /// </summary>
- string SendPanelSaveEnergyModeData(string reserve)
- {
- string data = "";
- string dataLength = "05";
- string dataComand1 = "08";
- string dataComand2 = "04";
- string dataSerialNum = "01";
- string addDataLength = "01";
- string reserveData = reserve;
-
- try
- {
- data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
- reserveData;
- }
- catch { };
-
- return data;
- }
/// <summary>
/// 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵�佹暟鎹洖澶�
@@ -2106,10 +1358,6 @@
}
/// <summary>
- /// 鎸夐敭鑺傝兘妯″紡淇℃伅
- /// </summary>
- public PanelSaveEnergyModeInfo panelSaveEnergyModeInfo;
- /// <summary>
/// 鑾峰彇鎸夐敭鑺傝兘妯″紡閰嶇疆鐘舵�佹暟鎹�
/// </summary>
[System.Serializable]
@@ -2131,6 +1379,179 @@
}
#endregion
+ #region 鑾峰彇鎺ヨ繎浼犳劅閰嶇疆
+ ///<summary >
+ ///鑾峰彇鎺ヨ繎浼犳劅閰嶇疆
+ /// </summary>
+ public async System.Threading.Tasks.Task<PanelProximitySensorResponInfo> GetProximitySensorAsync(string reserve = "01")
+ {
+ PanelProximitySensorResponInfo result = null;
+ if (Gateway == null)
+ {
+ result = new PanelProximitySensorResponInfo { errorMessageBase = "褰撳墠娌℃湁缃戝叧" };
+ return result;
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+
+ if (topic == gatewayID + "/" + "Error_Respon")
+ {
+ var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
+
+ if (temp == null)
+ {
+ result = new PanelProximitySensorResponInfo { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+
+ else
+ {
+ result = new PanelProximitySensorResponInfo { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
+ }
+ }
+
+ if (topic == gatewayID + "/" + "ZbDataPassthrough")
+ {
+ var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+
+ if (clientDataPassthroughResponseData == null)
+ {
+ result = new PanelProximitySensorResponInfo { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
+ }
+ else
+ {
+ if (clientDataPassthroughResponseData?.PassData != null)
+ {
+ var data = clientDataPassthroughResponseData.PassData;
+ if (data.Length == 20)
+ {
+ var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
+ if (command == "0502")
+ {
+ var tempR = new PanelProximitySensorInfo();
+ if (data[10].ToString() + data[11].ToString() == "01")
+ {
+ tempR.enable = true;
+ }
+ else
+ {
+ tempR.enable = false;
+ }
+ tempR.sensorDistance = Convert.ToInt32(data[14].ToString() + data[15].ToString() + data[12].ToString() + data[13].ToString(), 16);
+ tempR.sensorDelayTime = Convert.ToInt32(data[18].ToString() + data[19].ToString() + data[16].ToString() + data[17].ToString(), 16);
+ result = new PanelProximitySensorResponInfo { panelProximitySensorInfo = tempR };
+ System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_command:0408_{ topic}");
+ }
+ }
+ }
+ }
+ }
+ };
+
+ Gateway.Actions += action;
+ System.Console.WriteLine("ClientDataPassthrough_Actions 鍚姩" + System.DateTime.Now.ToString());
+
+ try
+ {
+ var passData = SendProiximitySensorData(reserve);
+ var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
+ var data = new JObject { { "PassData", passData } };
+ jObject.Add("Data", data);
+ Gateway.Send(("ClientDataPassthrough"), jObject.ToString());
+ }
+ catch { }
+
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result != null)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > 9000)// WaitReceiveDataTime)
+ {
+ result = new PanelProximitySensorResponInfo { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ Gateway.Actions -= action;
+ System.Console.WriteLine("ClientDataPassthrough_Actions 閫�鍑�" + System.DateTime.Now.ToString());
+
+ return result;
+ });
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎺ヨ繎浼犳劅閰嶇疆鏁版嵁
+ /// </summary>
+ string SendProiximitySensorData(string reserve)
+ {
+ string data = "";
+ string dataLength = "05";
+ string dataComand1 = "01";
+ string dataComand2 = "05";
+ string dataSerialNum = "01";
+ string addDataLength = "01";
+ string reserveData = reserve;
+
+ try
+ {
+ data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
+ reserveData;
+ }
+ catch { };
+
+ return data;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎺ヨ繎浼犳劅閰嶇疆鏁版嵁鍥炲
+ /// </summary>
+ [System.Serializable]
+ public class PanelProximitySensorResponInfo
+ {
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public string errorMessageBase;
+ /// <summary>
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+ /// </summary>
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// <para>鑾峰彇鎺ヨ繎浼犳劅閰嶇疆鏁版嵁</para>
+ /// </summary>
+ public PanelProximitySensorInfo panelProximitySensorInfo;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎺ヨ繎浼犳劅閰嶇疆鏁版嵁
+ /// </summary>
+ [System.Serializable]
+ public class PanelProximitySensorInfo
+ {
+ /// <summary>
+ /// 浼犳劅鍣ㄤ娇鑳�
+ ///false-disable true-enable
+ /// </summary>
+ public bool enable= false;
+
+ /// <summary>
+ ///浼犳劅鍣ㄨ窛绂�
+ /// </summary>
+ public int sensorDistance = -1;
+
+ /// <summary>
+ /// 浼犳劅鍣ㄨЕ鍙戝欢杩熸椂闂�
+ /// </summary>
+ public int sensorDelayTime = -1;
+ }
+ #endregion
+
#region 閰嶇疆鎸夐敭鎸囩ず鐏潯鐪犵粍鍒嗭紙鏆傛椂涓嶅仛锛�
///<summary >
///鑾峰彇鎸夐敭鎸囩ず鐏潯鐪犵粍
@@ -2153,8 +1574,7 @@
// if (topic == gatewayID + "/" + "Error_Respon")
// {
- // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString());
// if (temp == null)
// {
@@ -2168,18 +1588,17 @@
// }
// if (topic == gatewayID + "/" + "ZbDataPassthrough")
// {
- // var gatewayTemp = new ZbGateway() { DataID = jobject.Value<int>("Data_ID") };
- // gatewayTemp.clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
+ // var clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
- // if (gatewayTemp.clientDataPassthroughResponseData == null)
+ // if (clientDataPassthroughResponseData == null)
// {
// result = new PanelSleepGroupResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
// }
// else
// {
- // if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
+ // if (clientDataPassthroughResponseData?.PassData != null)
// {
- // var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
+ // var data = clientDataPassthroughResponseData.PassData;
// if (data.Length == 14)
// {
// var tempR = new PanelSleepGroupResponseData();
@@ -2524,84 +1943,6 @@
#endregion
#region 閰嶇疆闈㈡澘鍔熻兘
- ///<summary >
- ///閰嶇疆闈㈡澘鍔熻兘
- ///<para>value:缁欓潰鏉块厤缃殑妯″紡</para>
- /// </summary>
- public async System.Threading.Tasks.Task<SetWritableValueResponAllData> ConfigureHdlKeyValueAsync(KeyMode value, int clusterID = 6)
- {
- if (Gateway == null)
- {
- return null;
- }
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- SetWritableValueResponAllData d = null;
- Action<string, string> action = (topic, message) =>
- {
- var gatewayID = topic.Split('/')[0];
- var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- if (topic == gatewayID + "/" + "Error_Respon")
- {
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
- else
- {
- d = new SetWritableValueResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
-
- if (topic == gatewayID + "/" + "SetWritableValue_Respon")
- {
- var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<SetWritableValueResponData>(jobject["Data"].ToString());
-
- if (tempData == null)
- {
- d = new SetWritableValueResponAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- }
- else
- {
- d = new SetWritableValueResponAllData { setWritableValueResponData = tempData };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- }
- }
- };
- Gateway.Actions += action;
- System.Console.WriteLine("SetWritableValue_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
- try
- {
- var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterID }, { "Command", 120 } };
- var data = new JObject { { "Undivided", 0 }, { "AttributeId", 6533 }, { "AttributeDataType", 33 }, { "AttributeData", (int)value } };
- jObject.Add("Data", data);
- Gateway.Send("SetWritableValue", jObject.ToString());
- }
- catch { }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (d != null)
- {
- break;
- }
- }
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- d = new SetWritableValueResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- Gateway.Actions -= action;
- System.Console.WriteLine("SetWritableValue_Actions 閫�鍑�" + System.DateTime.Now.ToString());
- return d;
- });
- }
/// <summary>
/// 閰嶇疆闈㈡澘鐨勫姛鑳芥ā寮�
@@ -2684,118 +2025,6 @@
}
#region 璇诲彇闈㈡澘鐨勯厤缃俊鎭�
- /// <summary>
- /// 璇诲彇闈㈡澘鐨勯厤缃俊鎭�
- /// </summary>
- public async System.Threading.Tasks.Task<PanelConfigureInfoResponAllData> ReadPanelConfigureInfoAsync(params int[] args)
- {
- if (Gateway == null)
- {
- return null;
- }
- return await System.Threading.Tasks.Task.Run(async () =>
- {
- PanelConfigureInfoResponAllData d = null;
- Action<string, string> action = (topic, message) =>
- {
- var gatewayID = topic.Split('/')[0];//缃戝叧杩斿洖鐨勭綉鍏矷D
- var reportStatus = topic.Split('/')[1];//涓婚涓鸿澶囦笂鎶ョ殑涓婚
- string addr = "";//涓婃姤鐨勮澶嘺ddr
- string epoint = "";//涓婃姤鐨勮澶噀point
- string cluID = "";//涓婃姤鐨勮澶嘽luID
- string attrId = "";//涓婃姤鐨勮澶嘺ttrId
- if (reportStatus == "DeviceStatusReport")
- {
- addr = topic.Split('/')[2];
- epoint = topic.Split('/')[3];
- cluID = topic.Split('/')[4];
- attrId = topic.Split('/')[5];
- }
- var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- if (topic == gatewayID + "/" + "Error_Respon")
- {
- var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- if (temp == null)
- {
- d = new PanelConfigureInfoResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
- else
- {
- d = new PanelConfigureInfoResponAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- }
- }
- else if (topic == gatewayID + "/" + "DeviceStatusReport" + "/" + addr + "/" + epoint + "/" + cluID + "/" + attrId)
- {
- var deviceID = jobject.Value<int>("Device_ID");
- var deviceAddr = jobject.Value<string>("DeviceAddr");
- var tempEpoint = jobject.Value<int>("Epoint");
- var dataId = jobject.Value<int>("Data_ID");
-
- var lightSwitch = new Panel { DeviceID = deviceID, DeviceAddr = deviceAddr, DeviceEpoint = tempEpoint, DataID = dataId };
- lightSwitch.DeviceStatusReport = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString());
- if ((DeviceType)(deviceID) == DeviceType.OnOffSwitch)
- {
- var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(jobject["Data"].ToString());
- if (tempData == null)
- {
- d = new PanelConfigureInfoResponAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- }
- else
- {
- d = new PanelConfigureInfoResponAllData { deviceStatusReportData = tempData };
- System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- }
- }
- }
- };
-
- Gateway.Actions += action;
- System.Console.WriteLine("GetDeviceStatus_Actions 鍚姩" + System.DateTime.Now.ToString());
-
- try
- {
- var JObject = new JObject {
- { "DeviceAddr",DeviceAddr },
- { "Epoint", DeviceEpoint },
- { "Cluster_ID", (int)Device.Cluster_ID.HdlKey },
- { "Command", 108 }
- };
- var attriBute = new JArray{
- new JObject {
- { "AttriButeId", (int)AttriButeId.HdlKey}
- }
- };
- var data = new JObject { { "AttriBute", attriBute } };
- JObject.Add("Data", data);
- Gateway?.Send(("GetDeviceStatus"), JObject.ToString());
- }
- catch
- {
- }
-
- var dateTime = DateTime.Now;
- while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- {
- await System.Threading.Tasks.Task.Delay(10);
- if (d != null)
- {
- break;
- }
- }
-
- if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- {
- d = new PanelConfigureInfoResponAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- }
- Gateway.Actions -= action;
- System.Console.WriteLine("GetDeviceStatus_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- return d;
- });
- }
/// <summary>
/// 缃戝叧鎭㈠鍑哄巶璁剧疆杩斿洖鏁版嵁
@@ -2819,993 +2048,132 @@
}
#endregion
- //#region 璁惧缁戝畾
- ///// <summary>
- /////璁惧缁戝畾
- ///// </summary>
- //public async System.Threading.Tasks.Task<AddedDeviceBindResponseAllData> AddDeviceBindAsync(AddBindData addBindData)
- //{
- // return await System.Threading.Tasks.Task.Run(async () =>
- // {
- // var result = new AddedDeviceBindResponseAllData();
- // var mainGateway = ZbGateway.MainGateWay;
- // if (mainGateway == null)
- // {
- // result.errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�";
- // return result;
- // }
- // Action<string, string> action = (topic, message) =>
- // {
- // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- // var gatewayID = topic.Split('/')[0];
- // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
- // if (topic == gatewayID + "/" + "Error_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID };
- // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ #region 鑾峰彇缃戝叧涓殑鍦烘櫙
+ /// <summary>
+ /// 鍙兘鑾峰彇鍦烘櫙淇℃伅锛屾病鏈夊満鏅腑鐨勮澶囦俊鎭�
+ /// </summary>
+ /// <returns></rxeturns>
+ public async System.Threading.Tasks.Task<GetOnlySceneAllData> GetSceneInfoAsync()
+ {
+ GetOnlySceneAllData result = null;
+ if (ZbGateway.MainGateWay == null)
+ {
+ result = new GetOnlySceneAllData { errorMessageBase = "娌℃湁涓荤綉鍏�" };
+ }
+ return await System.Threading.Tasks.Task.Run(async () =>
+ {
+ Action<string, string> action = (topic, message) =>
+ {
+ var gatewayID = topic.Split('/')[0];
+ var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+ if (topic == gatewayID + "/" + "Error_Respon")
+ {
+ var tempResult = Newtonsoft.Json.JsonConvert.DeserializeObject<ErrorResponData>(jobject["Data"].ToString());
+ if (tempResult == null)
+ {
+ result = new GetOnlySceneAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+ else
+ {
+ result = new GetOnlySceneAllData { errorResponData = tempResult };
+ }
+ }
- // if (temp == null)
- // {
- // result.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
- // }
- // else
- // {
- // result.errorResponData = temp;
- // result.errorMessageBase = ErrorMess(temp.Error);
- // }
- // }
- // else if (topic == gatewayID + "/" + "Bind/SetBind_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID };
- // //var tempBindName = Newtonsoft.Json.JsonConvert.DeserializeObject<string>(jobject["Data"]["BindName"].ToString());
- // var tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString());
- // if (tempBindList == null)
- // {
- // result.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�";
- // }
- // else
- // {
- // var dataBindRes = new AddedDeviceBindResponseData();
- // for (int m = 0; tempBindList != null && m < tempBindList.Count; m++)
- // {
- // var tempBind = tempBindList[m];
- // dataBindRes.BindList.Add(Newtonsoft.Json.JsonConvert.DeserializeObject<AddBindListResponseObj>(tempBind.ToString()));
- // }
- // if (dataBindRes != null)
- // {
- // result.addedDeviceBindResponseData = dataBindRes;
- // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{topic}");
- // }
- // }
- // }
- // else if (topic == gatewayID + "/" + "Bind/BindResult")
- // {
- // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID };
- // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<AddBindResultResponseData>(jobject["Data"].ToString());
+ if (topic == gatewayID + "/" + "Scene/GetInfo_Respon")
+ {
+ var getSceneInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<GetSceneInfo>(jobject["Data"].ToString());
+ if (getSceneInfo == null)
+ {
+ result = new GetOnlySceneAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
+ }
+ else
+ {
+ result = new GetOnlySceneAllData { getSceneInfo = getSceneInfo };
+ }
+ }
+ };
+ ZbGateway.MainGateWay.Actions += action;
+ System.Console.WriteLine("Scene/GetInfo_Actions 鍚姩" + System.DateTime.Now.ToString());
+ var jobjectData = new JObject { { "Cluster_ID", 0 }, { "Command", 805 } };
+ await ZbGateway.MainGateWay.Send(("Scene/GetInfo"), System.Text.Encoding.UTF8.GetBytes(jobjectData.ToString()));
- // if (tempData != null)
- // {
- // result.addBindResultResponseData = tempData;
- // }
- // }
- // };
- // mainGateway.Actions += action;
- // System.Console.WriteLine("Bind/SetBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
- // try
- // {
- // if (addBindData != null)
- // {
- // var jObject = new JObject { { "DeviceAddr", addBindData.DeviceAddr }, { "Epoint", addBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5001 } };
- // var bindList = new JArray { };
- // foreach (var bindInfo in addBindData.BindList)
- // {
- // if (bindInfo.BindType == 0)
- // {
- // var dInfo = new JObject{
- // { "BindMacAddr",bindInfo.BindMacAddr},
- // { "BindEpoint", bindInfo.BindEpoint} ,
- // { "BindCluster", bindInfo.BindCluster} ,
- // { "BindType",bindInfo.BindType}
- // };
- // bindList.Add(dInfo);
- // }
- // else if (bindInfo.BindType == 1)
- // {
- // var dInfo = new JObject{
- // { "BindCluster", bindInfo.BindCluster} ,
- // { "BindType",bindInfo.BindType},
- // { "BindScenesId", bindInfo.BindScenesId}
- // };
- // bindList.Add(dInfo);
- // }
- // }
- // var data = new JObject{
- // {"BindName",addBindData.BindName},
- // { "BindList", bindList }
- // };
- // jObject.Add("Data", data);
- // mainGateway.Send("Bind/SetBind", jObject.ToString());
- // }
- // }
- // catch
- // {
- // }
-
- // var dateTime = DateTime.Now;
- // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- // {
- // await System.Threading.Tasks.Task.Delay(100);
- // if (result == null || result.addedDeviceBindResponseData == null)
- // {
- // continue;
- // }
- // if (0 < result.addedDeviceBindResponseData.BindList.FindAll((obj) => obj.BindType == 0).Count)
- // {
- // if (result.addBindResultResponseData != null)
- // {
- // break;
- // }
- // }
- // else
- // {
- // break;
- // }
- // }
- // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- // {
- // result.errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔";
- // }
- // mainGateway.Actions -= action;
- // System.Console.WriteLine($"Bind/SetBind_Actions 閫�鍑� {System.DateTime.Now}");
- // return result;
- // });
- //}
-
- ///// <summary>
- ///// 缁戝畾璁惧淇℃伅,缃戝叧鍙嶉淇℃伅
- ///// </summary>
- //public AddedDeviceBindResponseAllData addedDeviceBindResponseAllData;
- //[System.Serializable]
- //public class AddedDeviceBindResponseAllData
- //{
- // /// <summary>
- // /// 閿欒淇℃伅
- // /// </summary>
- // public string errorMessageBase;
- // /// <summary>
- // /// 缃戝叧淇℃伅閿欒鍙嶉
- // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- // /// </summary>
- // public ErrorResponData errorResponData;
- // /// <summary>
- // /// 缃戝叧鐩存帴鍙嶉缁戝畾璁惧淇℃伅
- // /// </summary>
- // public AddedDeviceBindResponseData addedDeviceBindResponseData;
- // /// <summary>
- // /// 鎸夐敭璁惧鐨勭‘璁ゅ弽棣堢粦瀹氳澶囦俊鎭�
- // /// </summary>
- // public AddBindResultResponseData addBindResultResponseData;
- //}
-
- ///// <summary>
- ///// 缁戝畾璁惧淇℃伅
- ///// </summary>
- //public AddedDeviceBindResponseData addedDeviceBindResponseData;
- //[System.Serializable]
- //public class AddedDeviceBindResponseData
- //{
- // /// <summary>
- // ///缁戝畾鍚嶇О
- // /// </summary>
- // public string BindName;
- // /// <summary>
- // ///缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦�
- // /// </summary>
- // public List<AddBindListResponseObj> BindList = new List<AddBindListResponseObj>();
- //}
-
- ///// <summary>
- ///// 缁戝畾鍒楄〃鐨勪俊鎭�
- ///// </summary>
- //[System.Serializable]
- //public class AddBindListResponseObj : BindListResponseObj
- //{
- // /// <summary>
- // /// 0锛氬姞鍏ユ垚鍔燂紙璇ョ姸鎬佸彧閫傜敤鐢ㄤ簬璺ㄧ綉鍏崇粦瀹氬拰缁戝畾鍦烘櫙銆傚悓缃戝叧璁惧闂寸殑缁戝畾闇�瑕佽妭鐐硅澶囩殑纭鎴愬姛淇℃伅锛屼笉浼氱洿鎺ュ弽棣堟垚鍔熴�傦級
- // ///<para>1锛氬け璐ワ紝鑺傜偣璁惧鎴栧満鏅笉瀛樺湪銆�</para>
- // ///<para>2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/BindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para>
- // ///<para>3锛氱粦瀹氬凡缁忓瓨鍦ㄣ��</para>
- // /// </summary>
- // public int Result;
- //}
-
- ///// <summary>
- ///// 鎸夐敭璁惧鐨勭‘璁ょ殑淇℃伅
- ///// </summary>
- //[System.Serializable]
- //public class AddBindResultResponseData
- //{
- // /// <summary>
- // ///缁戝畾缁撴灉
- // ///<para>0锛氭垚鍔�</para>
- // ///<para>140锛氬け璐ワ紝鎺у埗璁惧鐨勭粦瀹氬垪琛ㄥ凡婊�</para>
- // ///<para>鍏朵粬锛氬け璐�</para>
- // /// </summary>
- // public int Result;
- // /// <summary>
- // /// 缁戝畾鐨刢luster
- // /// </summary>
- // public int BindCluster;
- // /// <summary>
- // /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦�
- // /// </summary>
- // public string BindMacAddr;
- // /// <summary>
- // /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦�
- // /// </summary>
- // public int BindEpoint;
- // /// <summary>
- // /// 缁戝畾鍦烘櫙锛屽綋BindType=2鏃跺瓨鍦�
- // /// </summary>
- // public int BindScenesId;
- // /// <summary>
- // /// 缁戝畾璁惧鐨勫悕绉�
- // /// </summary>
- // public string DeviceName;
- //}
-
- ///// <summary>
- ///// 缁戝畾璁惧鐨勬暟鎹�
- ///// </summary>
- //public AddBindData addBindData;
- //[System.Serializable]
- //public class AddBindData
- //{
- // /// <summary>
- // /// 鎺у埗璁惧鑺傜偣鐨刴ac鍦板潃
- // /// </summary>
- // public string DeviceAddr;
- // /// <summary>
- // /// 閿欒淇℃伅
- // /// </summary>
- // public int Epoint;
- // /// <summary>
- // ///缁戝畾鍚嶇О锛屼笉淇敼鍚嶇О鏃跺拷鐣ヨ閫夐」
- // /// </summary>
- // public string BindName;
- // /// <summary>
- // ///缁戝畾鍒楄〃锛屼笉淇敼缁戝畾鍒楄〃鏃跺拷鐣ヨ閫夐」銆�
- // /// </summary>
- // public List<AddBindListObj> BindList = new List<AddBindListObj>();
- //}
-
- ///// <summary>
- ///// 鎺у埗璁惧缁戝畾鐨勪俊鎭�
- ///// </summary>
- //[System.Serializable]
- //public class AddBindListObj
- //{
- // /// <summary>
- // /// 缁戝畾绫诲瀷
- // ///<para>0锛氱粦瀹氳澶� </para>
- // ///<para>1锛氱粦瀹氬満鏅�</para>
- // /// </summary>
- // public int BindType;
- // /// <summary>
- // /// 缁戝畾鐨刢luster,闇�瑕佹帶鍒惰澶囩殑OutCluster鍒楄〃涓瓨鍦ㄨcluster銆�
- // ///濡傜粦瀹氭煇涓澶囩殑on/off锛屼负6銆�
- // /// </summary>
- // public int BindCluster;
- // /// <summary>
- // /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦�
- // /// </summary>
- // public string BindMacAddr;
- // /// <summary>
- // /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦�
- // /// </summary>
- // public int BindEpoint;
- // /// <summary>
- // /// 缁戝畾鍦烘櫙锛屽綋BindType=1鏃跺瓨鍦�
- // /// </summary>
- // public int BindScenesId;
- //}
- //#endregion
-
- //#region 瑙i櫎缁戝畾
- ///// <summary>
- ///// 瑙i櫎缁戝畾
- ///// </summary>
- //public async System.Threading.Tasks.Task<DelDeviceBindResponseAllData> DelDeviceBindAsync(DelDeviceBindData delDeviceBindData)
- //{
- // return await System.Threading.Tasks.Task.Run(async () =>
- // {
- // var responseData = new DelDeviceBindResponseAllData();
- // var mainGateway = ZbGateway.MainGateWay;
- // if (mainGateway == null)
- // {
- // responseData.errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�";
- // return responseData;
- // }
-
- // Action<string, string> action = (topic, message) =>
- // {
- // var gatewayID = topic.Split('/')[0];
- // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- // if (topic == gatewayID + "/" + "Error_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID };
- // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- // if (temp == null)
- // {
- // responseData.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
- // }
- // else
- // {
- // responseData.errorResponData = temp;
- // responseData.errorMessageBase = ErrorMess(temp.Error);
- // }
- // }
-
- // if (topic == gatewayID + "/" + "Bind/RemoveBind_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<DelDeviceBindResponseData>(jobject["Data"].ToString());
-
- // if (tempData == null)
- // {
- // responseData.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�";
-
- // }
- // else
- // {
- // responseData.delDeviceBindResponseData = tempData;
- // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- // }
- // }
-
- // if (topic == gatewayID + "/" + "Bind/RemoveBindResult")
- // {
- // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID };
- // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<RemoveBindResultResponseData>(jobject["Data"].ToString());
-
- // if (tempData != null)
- // {
- // responseData.removeBindResultResponseData = tempData;
- // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- // }
- // }
- // };
- // mainGateway.Actions += action;
- // System.Console.WriteLine("DeviceBind/DelBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
- // try
- // {
- // if (delDeviceBindData != null)
- // {
- // var jObject = new JObject { { "DeviceAddr", delDeviceBindData.DeviceAddr }, { "Epoint", delDeviceBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5003 } };
- // var removeBindList = new JArray { };
- // foreach (var removeBindInfo in delDeviceBindData.RemoveBindList)
- // {
- // if (removeBindInfo.BindType == 0)
- // {
- // var dInfo = new JObject{
- // { "BindMacAddr",removeBindInfo.BindMacAddr},
- // { "BindEpoint", removeBindInfo.BindEpoint} ,
- // { "BindCluster", removeBindInfo.BindCluster} ,
- // { "BindType",removeBindInfo.BindType}
- // };
- // removeBindList.Add(dInfo);
- // }
- // else if (removeBindInfo.BindType == 1)
- // {
- // var dInfo = new JObject{
- // { "BindCluster", removeBindInfo.BindCluster} ,
- // { "BindType",removeBindInfo.BindType},
- // { "BindScenesId", removeBindInfo.BindScenesId}
- // };
- // removeBindList.Add(dInfo);
- // }
- // }
- // var data = new JObject {
- // {"RemoveBindList",removeBindList}
- // };
- // jObject.Add("Data", data);
- // mainGateway.Send("Bind/RemoveBind", jObject.ToString());
- // }
- // }
- // catch { }
-
-
- // var dateTime = DateTime.Now;
- // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- // {
- // await System.Threading.Tasks.Task.Delay(100);
- // if (responseData == null || responseData.delDeviceBindResponseData == null)
- // {
- // continue;
- // }
- // if (0 < responseData.delDeviceBindResponseData.RemoveBindList.FindAll((obj) => obj.BindType == 0).Count)
- // {
- // if (responseData.removeBindResultResponseData != null)
- // {
- // break;
- // }
- // }
- // else
- // {
- // break;
- // }
- // }
-
- // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- // {
- // responseData.errorMessageBase = "鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔";
- // }
- // mainGateway.Actions -= action;
- // System.Console.WriteLine("DeviceBind/DelBind_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- // return responseData;
- // });
- //}
-
- ///// <summary>
- /////瑙i櫎缁戝畾鏁版嵁,缃戝叧鍙嶉淇℃伅
- ///// </summary>
- //public DelDeviceBindResponseAllData delDeviceBindResponseAllData;
- ///// <summary>
- /////瑙i櫎缁戝畾鏁版嵁,缃戝叧鍙嶉淇℃伅
- ///// </summary>
- //[System.Serializable]
- //public class DelDeviceBindResponseAllData
- //{
- // /// <summary>
- // /// 閿欒淇℃伅
- // /// </summary>
- // public string errorMessageBase;
- // /// <summary>
- // /// 缃戝叧淇℃伅閿欒鍙嶉
- // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- // /// </summary>
- // public ErrorResponData errorResponData;
- // /// <summary>
- // /// 瑙i櫎缁戝畾鏁版嵁淇℃伅
- // /// </summary>
- // public DelDeviceBindResponseData delDeviceBindResponseData;
-
- // /// <summary>
- // /// 瑙i櫎缁戝畾鎸夐敭纭鏁版嵁淇℃伅
- // /// </summary>
- // public RemoveBindResultResponseData removeBindResultResponseData;
- //}
-
- ///// <summary>
- ///// 瑙i櫎缁戝畾鏁版嵁
- ///// </summary>
- //public DelDeviceBindResponseData delDeviceBindResponseData;
- ///// <summary>
- ///// 瑙i櫎缁戝畾鏁版嵁
- ///// </summary>
- //[System.Serializable]
- //public class DelDeviceBindResponseData
- //{
- // /// <summary>
- // ///缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦�
- // /// </summary>
- // public List<RemoveBindListResponseObj> RemoveBindList = new List<RemoveBindListResponseObj>();
- //}
-
- ///// <summary>
- ///// 绉婚櫎璁惧缁戝畾鐨勪俊鎭�
- ///// </summary>
- //[System.Serializable]
- //public class RemoveBindListResponseObj : BindListResponseObj
- //{
- // /// <summary>
- // /// 0锛氱Щ闄ゆ垚鍔燂紙璇ョ姸鎬佸彧閫傜敤鐢ㄤ簬璺ㄧ綉鍏崇粦瀹氥�佺粦瀹氬満鏅�佸け鏁堣澶囷紙璁惧宸茬粡浠庣綉鍏崇殑璁惧鍒楄〃涓垹闄わ級銆傚悓缃戝叧璁惧闂寸殑瑙i櫎缁戝畾闇�瑕佽妭鐐硅澶囩殑纭鎴愬姛淇℃伅锛屼笉浼氱洿鎺ュ弽棣堟垚鍔熴�傦級
- // ///<para>1锛氬け璐ワ紝璁惧涓嶅湪缁戝畾鍒楄〃涓�</para>
- // ///<para>3锛氬け璐ワ紝鍦ㄧ瓑寰呰妭鐐硅澶囩‘璁ゆ槸鍚﹁В闄ょ粦瀹氭垚鍔燂紙褰撶綉鍏宠繕鍦ㄧ瓑寰呮煇鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛鐨勫弽棣堜俊鎭椂锛屽鎴风鍐嶆鍙戦�佽В闄ょ粦瀹氳鑺傜偣璁惧鐨勬寚浠わ紝灏嗗弽棣堣鐘舵�併�傦級</para>
- // ///<para>4锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/RemoveBindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔熴��</para>
- // /// </summary>
- // public int Result;
-
- //}
-
- ///// <summary>
- ///// 绉婚櫎璁惧缁戝畾鎸夐敭纭鐨勪俊鎭�
- ///// </summary>
- //[System.Serializable]
- //public class RemoveBindResultResponseData
- //{
- // /// <summary>
- // ///缁戝畾缁撴灉
- // ///<para>0锛氭垚鍔�</para>
- // ///<para>136锛氭帶鍒惰澶囨湰鍦扮粦瀹氬垪琛ㄤ腑鏃犳缁戝畾</para>
- // ///<para>鍏朵粬锛氬け璐�</para>
- // /// </summary>
- // public int Result;
-
- // /// <summary>
- // /// 缁戝畾璁惧Mac鍦板潃
- // /// </summary>
- // public string BindMacAddr;
- // /// <summary>
- // /// 缁戝畾璁惧鐨勭鍙e彿
- // /// </summary>
- // public int BindEpoint;
- // /// <summary>
- // /// 缁戝畾鐨刢luster
- // /// </summary>
- // public int BindCluster;
- // /// <summary>
- // /// 缁戝畾璁惧鍚嶇О
- // /// </summary>
- // public string DeviceName;
- //}
-
- ///// <summary>
- ///// 瑙i櫎缁戝畾鏁版嵁
- ///// </summary>
- //public DelDeviceBindData delDeviceBindData;
- ///// <summary>
- ///// 瑙i櫎缁戝畾鏁版嵁
- ///// </summary>
- //[System.Serializable]
- //public class DelDeviceBindData
- //{
- // /// <summary>
- // /// 鎺у埗璁惧鑺傜偣鐨刴ac鍦板潃
- // /// </summary>
- // public string DeviceAddr;
- // /// <summary>
- // /// 閿欒淇℃伅
- // /// </summary>
- // public int Epoint;
- // /// <summary>
- // ///缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦�
- // /// </summary>
- // public List<RemoveBindListObj> RemoveBindList = new List<RemoveBindListObj>();
- //}
-
- ///// <summary>
- ///// 绉婚櫎璁惧缁戝畾鐨勪俊鎭�
- ///// </summary>
- //[System.Serializable]
- //public class RemoveBindListObj
- //{
-
- // /// <summary>
- // /// 缁戝畾绫诲瀷
- // ///<para>0锛氱Щ闄よ澶� </para>
- // ///<para>1锛氱Щ闄ゅ満鏅�</para>
- // /// </summary>
- // public int BindType;
- // /// <summary>
- // /// 缁戝畾鐨刢luster
- // /// </summary>
- // public int BindCluster;
- // /// <summary>
- // /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦�
- // /// </summary>
- // public string BindMacAddr;
- // /// <summary>
- // /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦�
- // /// </summary>
- // public int BindEpoint;
- // /// <summary>
- // /// 缁戝畾鍦烘櫙锛屽綋BindType=1鏃跺瓨鍦�
- // /// </summary>
- // public int BindScenesId;
- //}
- //#endregion
-
- //#region 鑾峰彇鎵�鏈夌粦瀹�
- ///// <summary>
- /////鑾峰彇鎵�鏈夌粦瀹�
- ///// </summary>
- //public async System.Threading.Tasks.Task<GetDeviceBindResponseAllData> GetDeviceBindAsyncAsync()
- //{
- // return await System.Threading.Tasks.Task.Run(async () =>
- // {
- // GetDeviceBindResponseAllData d = null;
- // var mainGateway = ZbGateway.MainGateWay;
- // if (mainGateway == null)
- // {
- // d = new GetDeviceBindResponseAllData { errorMessageBase = "褰撳墠娌℃湁涓荤綉鍏�" };
- // return d;
- // }
-
- // Action<string, string> action = (topic, message) =>
- // {
- // var gatewayID = topic.Split('/')[0];
- // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- // if (topic == gatewayID + "/" + "Error_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID };
- // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- // if (temp == null)
- // {
- // d = new GetDeviceBindResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- // }
- // else
- // {
- // d = new GetDeviceBindResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- // }
- // }
-
- // if (topic == gatewayID + "/" + "Bind/GetDeviceBind_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = mainGateway.getGatewayBaseInfo.gwID };
- // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetDeviceBindResponseData>(jobject["Data"].ToString());
- // //var tempBindList = Newtonsoft.Json.Linq.JArray.Parse(jobject["Data"]["BindList"].ToString());
- // if (tempData == null)
- // {
- // d = new GetDeviceBindResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- // }
- // else
- // {
- // d = new GetDeviceBindResponseAllData { getAllBindResponseData = tempData };
- // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- // }
- // }
- // };
- // mainGateway.Actions += action;
-
- // try
- // {
- // System.Console.WriteLine("Bind/GetDeviceBind_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
- // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } };
- // mainGateway.Send("Bind/GetDeviceBind", jObject.ToString());
- // }
- // catch { }
-
- // var dateTime = DateTime.Now;
- // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- // {
- // await System.Threading.Tasks.Task.Delay(10);
- // if (d != null)
- // {
- // break;
- // }
- // }
- // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- // {
- // d = new GetDeviceBindResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- // }
- // mainGateway.Actions -= action;
- // System.Console.WriteLine("Bind/GetDeviceBind_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- // return d;
- // });
- //}
-
- ///// <summary>
- /////鑾峰彇鎵�鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅
- ///// </summary>
- //public GetDeviceBindResponseAllData getAllBindResponseAllData;
- //[System.Serializable]
- //public class GetDeviceBindResponseAllData
- //{
- // /// <summary>
- // /// 閿欒淇℃伅
- // /// </summary>
- // public string errorMessageBase;
- // /// <summary>
- // /// 缃戝叧淇℃伅閿欒鍙嶉
- // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- // /// </summary>
- // public ErrorResponData errorResponData;
- // /// <summary>
- // /// 鎺у埗璁惧缁戝畾鐨勮澶囧垪琛ㄥ洖澶嶆暟鎹�
- // /// </summary>
- // public GetDeviceBindResponseData getAllBindResponseData;
- //}
-
- ///// <summary>
- ///// 鑾峰彇鎵�鏈夌粦瀹氬洖澶嶇殑鏁版嵁
- ///// </summary>
- //public GetDeviceBindResponseData getAllBindResponseData;
- //[System.Serializable]
- //public class GetDeviceBindResponseData
- //{
- // /// <summary>
- // /// 0锛氭垚鍔�
- // ///<para>1锛氱粦瀹氫笉瀛樺湪</para>
- // /// </summary>
- // public int Result;
- // /// <summary>
- // /// 缁戝畾鍒楄〃 锛屽綋Status=0鏃跺瓨鍦ㄣ��
- // /// </summary>
- // public List<BindListResponseObj> BindList = new List<BindListResponseObj>();
- //}
-
- ///// <summary>
- ///// 鑾峰彇鎵�鏈夌粦瀹氱殑淇℃伅
- ///// </summary>
- //public class BindListResponseObj
- //{
- // /// <summary>
- // /// 缁戝畾绫诲瀷
- // ///<para>0锛氱Щ闄よ澶囷紝鍚岀綉鍏宠澶囬棿鐨勭Щ闄�</para>
- // ///<para>1锛氱Щ闄よ澶囷紝璺ㄧ綉鍏宠澶囬棿鐨勭Щ闄�</para>
- // ///<para>2锛氱Щ闄ょ粦瀹氬満鏅�</para>
- // /// </summary>
- // public int BindType;
- // /// <summary>
- // /// 缁戝畾鐨刢luster
- // /// </summary>
- // public int BindCluster;
- // /// <summary>
- // /// 缁戝畾璁惧Mac鍦板潃锛� 褰揃indType=0鏃跺瓨鍦�
- // /// </summary>
- // public string BindMacAddr;
- // /// <summary>
- // /// 缁戝畾璁惧鐨勭鍙e彿锛屽綋BindType=0鏃跺瓨鍦�
- // /// </summary>
- // public int BindEpoint;
- // /// <summary>
- // /// 缁戝畾鍦烘櫙锛屽綋BindType=1鏃跺瓨鍦�
- // /// </summary>
- // public int BindScenesId;
- // /// <summary>
- // /// 缁戝畾鐨勮澶囨垨鍦烘櫙鍚嶇О
- // /// </summary>
- // public string ESName;
- //}
- //#endregion
-
- //#region 鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭�
- ///// <summary>
- /////鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭�
- ///// </summary>
- //public async System.Threading.Tasks.Task<ClearBindInfoResponseAllData> ClearBindInfoAsync()
- //{
- // if (Gateway == null)
- // {
- // return null;
- // }
- // return await System.Threading.Tasks.Task.Run(async () =>
- // {
- // ClearBindInfoResponseAllData d = null;
- // Action<string, string> action = (topic, message) =>
- // {
- // var gatewayID = topic.Split('/')[0];
- // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
-
- // if (topic == gatewayID + "/" + "Error_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
-
- // if (temp == null)
- // {
- // d = new ClearBindInfoResponseAllData { errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖" };
- // }
- // else
- // {
- // d = new ClearBindInfoResponseAllData { errorResponData = temp, errorMessageBase = ErrorMess(temp.Error) };
- // }
- // }
-
- // if (topic == gatewayID + "/" + "Bind/ClearBindInfo_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClearBindInfoResponseData>(jobject["Data"].ToString());
- // if (tempData == null)
- // {
- // d = new ClearBindInfoResponseAllData { errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�" };
- // }
- // else
- // {
- // d = new ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData };
- // System.Console.WriteLine($"UI鏀跺埌閫氱煡鍚庣殑涓婚_{ topic}");
- // }
- // }
- // };
- // Gateway.Actions += action;
- // System.Console.WriteLine("Bind/ClearBindInfo_Actions 鍚姩" + "_" + System.DateTime.Now.ToString());
-
- // try
- // {
- // var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } };
- // Gateway.Send("Bind/ClearBindInfo", jObject.ToString());
- // }
- // catch { }
-
- // var dateTime = DateTime.Now;
- // while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
- // {
- // await System.Threading.Tasks.Task.Delay(10);
- // if (d != null)
- // {
- // break;
- // }
- // }
- // if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
- // {
- // d = new ClearBindInfoResponseAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
- // }
- // Gateway.Actions -= action;
- // System.Console.WriteLine("Bind/ClearBindInfo_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- // return d;
- // });
- //}
-
- ///// <summary>
- /////鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氭暟鎹�,缃戝叧鍙嶉淇℃伅
- ///// </summary>
- //public ClearBindInfoResponseAllData clearBindInfoResponseAllData;
- //[System.Serializable]
- //public class ClearBindInfoResponseAllData
- //{
- // /// <summary>
- // /// 閿欒淇℃伅
- // /// </summary>
- // public string errorMessageBase;
- // /// <summary>
- // /// 缃戝叧淇℃伅閿欒鍙嶉
- // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- // /// </summary>
- // public ErrorResponData errorResponData;
- // /// <summary>
- // /// 鎺у埗璁惧缁戝畾鐨勮澶囧垪琛ㄥ洖澶嶆暟鎹�
- // /// </summary>
- // public ClearBindInfoResponseData clearBindInfoResponseData;
- //}
-
- ///// <summary>
- ///// 鍒犻櫎涓�涓帶鍒惰澶囨墍鏈夌粦瀹氫俊鎭洖澶嶇殑鏁版嵁
- ///// </summary>
- //public ClearBindInfoResponseData clearBindInfoResponseData;
- //[System.Serializable]
- //public class ClearBindInfoResponseData
- //{
- // /// <summary>
- // /// 0锛氭垚鍔�
- // ///<para>1锛氱粦瀹氫俊鎭笉瀛樺湪</para>
- // /// </summary>
- // public int Result;
- //}
-
- //#endregion
+ var dateTime = DateTime.Now;
+ while ((DateTime.Now - dateTime).TotalMilliseconds < WaitReceiveDataTime)
+ {
+ await System.Threading.Tasks.Task.Delay(10);
+ if (result != null)
+ {
+ break;
+ }
+ }
+ if ((DateTime.Now - dateTime).TotalMilliseconds > WaitReceiveDataTime)
+ {
+ result = new GetOnlySceneAllData { errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔" };
+ }
+ return result;
+ });
+ }
+ /// <summary>
+ ///鑾峰彇鍦烘櫙淇℃伅,缃戝叧鍙嶉淇℃伅
+ /// </summary>
+ [System.Serializable]
+ public class GetOnlySceneAllData
+ {
+ /// <summary>
+ /// 閿欒淇℃伅
+ /// </summary>
+ public string errorMessageBase;
+ /// <summary>
+ /// 缃戝叧淇℃伅閿欒鍙嶉
+ /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
+ /// </summary>
+ public ErrorResponData errorResponData;
+ /// <summary>
+ /// 鑾峰彇鍦烘櫙淇℃伅
+ /// </summary>
+ public GetSceneInfo getSceneInfo;
+ }
/// <summary>
- /// 璇诲彇闈㈡澘鐨勯厤缃俊鎭�(淇℃伅瀛樺埌褰撳墠鐨勫璞″叿浣撳�间腑锛�
+ /// 鑾峰彇鍦烘櫙淇℃伅
/// </summary>
- //public void ReadPanelConfigureInfo()
- //{
- // ReadAttri(Device.Cluster_ID.HdlKey, AttriButeId.HdlKey);
- //}
+ [System.Serializable]
+ public class GetSceneInfo
+ {
+ /// <summary>
+ ///鍦烘櫙鎬绘暟
+ /// </summary>
+ public int ScenesSum;
- //#region 鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧
- ///// <summary>
- /////鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧
- ///// </summary>
- //public async System.Threading.Tasks.Task<GetControlDeviceBindResponseAllData> GetControlDeviceAsync()
- //{
- // if (Gateway == null)
- // {
- // return null;
- // }
- // return await System.Threading.Tasks.Task.Run(async () =>
- // {
- // var d = new GetControlDeviceBindResponseAllData { };
- // Action<string, string> action = (topic, message) =>
- // {
- // var gatewayID = topic.Split('/')[0];
- // var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
+ /// <summary>
+ /// 鍦烘櫙鍒楄〃
+ /// </summary>
+ public List<ScenesListInfo> ScenesList = new List<ScenesListInfo>();
+ }
- // if (topic == gatewayID + "/" + "Error_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { Time = jobject.Value<int>("Time"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- // var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<ZbGateway.ErrorResponData>(jobject["Data"].ToString());
+ /// <summary>
+ /// 鍦烘櫙鍒楄〃涓殑鍏蜂綋淇℃伅
+ /// </summary>
+ [System.Serializable]
+ public class ScenesListInfo
+ {
+ /// <summary>
+ /// 鍦烘櫙ID
+ /// </summary>
+ public int ScenesId;
- // if (temp == null)
- // {
- // d.errorMessageBase = "缃戝叧閿欒鍥炲锛屼笖鏁版嵁鏄┖";
- // }
- // else
- // {
- // d.errorResponData = temp;
- // d.errorMessageBase = ErrorMess(temp.Error);
- // }
- // }
+ /// <summary>
+ /// 鍚嶇О
+ /// </summary>
+ public string ScenesName;
- // if (topic == gatewayID + "/" + "DeviceBind_AddBind_Respon")
- // {
- // var gatewayTemp = new ZbGateway() { DeviceID = jobject.Value<int>("Device_ID"), DeviceAddr = jobject.Value<string>("DeviceAddr"), DeviceEpoint = jobject.Value<int>("Epoint"), DataID = jobject.Value<int>("Data_ID"), CurrentGateWayId = Gateway.getGatewayBaseInfo.gwID };
- // var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<GetControlDeviceBindResponseData>(jobject["Data"].ToString());
-
- // if (tempData == null)
- // {
- // d.errorMessageBase = "缃戝叧杩斿洖鐨勬暟鎹负绌�";
- // }
- // else
- // {
- // d.getControlDeviceBindResponseData = tempData;
- // }
- // }
- // };
- // Gateway.Actions += action;
- // System.Console.WriteLine("GetControlDevice_Actions 鍚姩" + "_" + Gateway.getGatewayBaseInfo.gwID + System.DateTime.Now.ToString());
-
- // var jObject = new JObject {{ "Cluster_ID", 0 }, { "Command", 154 } };
- // Gateway.Send("DeviceBind/GetControlDevice", jObject.ToString());
-
- // var dateTime = DateTime.Now;
- // while ((DateTime.Now - dateTime).TotalMilliseconds < 1000)
- // {
- // await System.Threading.Tasks.Task.Delay(10);
- // if (d.getControlDeviceBindResponseData != null)
- // {
- // break;
- // }
- // }
- // if ((DateTime.Now - dateTime).TotalMilliseconds > 10000)
- // {
- // d.errorMessageBase = " 鍥炲瓒呮椂锛岃閲嶆柊鎿嶄綔";
- // }
- // Gateway.Actions -= action;
- // System.Console.WriteLine("GetControlDevice_Actions 閫�鍑�" + System.DateTime.Now.ToString());
-
- // return d;
- // });
- //}
-
- ///// <summary>
- ///// 鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧鏁版嵁,缃戝叧鍙嶉淇℃伅
- ///// </summary>
- //public GetControlDeviceBindResponseAllData getControlDeviceBindResponseAllData;
- //[System.Serializable]
- //public class GetControlDeviceBindResponseAllData
- //{
- // /// <summary>
- // /// 閿欒淇℃伅
- // /// </summary>
- // public string errorMessageBase;
- // /// <summary>
- // /// 缃戝叧淇℃伅閿欒鍙嶉
- // /// <para>褰撶綉鍏虫帴鏀跺埌瀹㈡埛绔俊鎭悗锛屽嚭鐜颁互涓嬪紓甯告儏鍐靛皢鍙嶉閿欒銆�</para>
- // /// </summary>
- // public ErrorResponData errorResponData;
- // /// <summary>
- // /// 鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧鏁版嵁
- // /// </summary>
- // public GetControlDeviceBindResponseData getControlDeviceBindResponseData;
- //}
-
-
- ///// <summary>
- ///// 鑾峰彇鎵�鏈夊仛浜嗙粦瀹氱殑鎺у埗璁惧鏁版嵁
- ///// </summary>
- //public GetControlDeviceBindResponseData getControlDeviceBindResponseData;
- //[System.Serializable]
- //public class GetControlDeviceBindResponseData
- //{
- // /// <summary>
- // /// 璁惧灞炴�у垪琛�
- // /// </summary>
- // public List<DeviceObj> DeviceObj = new List<DeviceObj>();
- //}
-
- ///// <summary>
- ///// Command鏁扮粍
- ///// </summary>
- //public class DeviceObj
- //{
- // /// <summary>
- // /// 鎺у埗璁惧鐨刴ac鍦板潃
- // /// </summary>
- // public string DeviceAddr;
-
- // /// <summary>
- // /// 鎺у埗璁惧鐨勭鍙e彿
- // /// </summary>
- // public int Epoint;
- //}
- //#endregion
+ /// <summary>
+ /// 鏄惁澶勪簬寮�鍚姸鎬�
+ ///0锛氬満鏅病鏈夎寮�鍚�
+ ///1锛氬満鏅浜庡紑鍚姸鎬�
+ /// </summary>
+ public int IsOpen;
+ }
+ #endregion
}
}
--
Gitblit v1.8.0