using System;
|
using System.Collections.Generic;
|
using System.Threading.Tasks;
|
using MQTTnet;
|
using Newtonsoft.Json.Linq;
|
using Shared.Common;
|
|
namespace ZigBee.Device
|
{
|
[System.Serializable]
|
public class Panel : BindObj
|
{
|
public Panel()
|
{
|
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>
|
[Newtonsoft.Json.JsonIgnore]
|
public int currentMutilfunctionBindType = 0;
|
/// <summary>
|
/// 当前选择模式
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public string currentKeySelectModeText = "";
|
/// <summary>
|
/// 当前选择的楼层ID
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public string currentSelectFloorId = string.Empty;
|
/// <summary>
|
/// 当前选择的房间ID【新风面板】
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public string currentSelectRoomId = string.Empty;
|
|
/// <summary>
|
/// 绑定的楼层房间信息
|
/// </summary>
|
[System.Serializable]
|
public class FloorRoomBindObj
|
{
|
/// <summary>
|
/// 楼层ID
|
/// </summary>
|
public string floodID;
|
/// <summary>
|
/// 楼层名称
|
/// </summary>
|
public string floodName;
|
/// <summary>
|
/// 房间ID
|
/// </summary>
|
public string roomID;
|
/// <summary>
|
/// 房间名称
|
/// </summary>
|
public string roomName;
|
/// <summary>
|
/// 绑定目标ID
|
/// </summary>
|
public string BindID;
|
/// <summary>
|
/// 绑定目标名称
|
/// </summary>
|
public string BindName;
|
/// <summary>
|
/// 图片路径
|
/// </summary>
|
public string IconPath = "";
|
|
}
|
|
// <summary>
|
/// 按键中被绑定的目标列表
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public List<BindListResponseObj> bindList = new List<BindListResponseObj>();
|
|
/// <summary>
|
/// 私有功能类
|
/// <para>256:Key,按键类类 </para>
|
/// <para>768:PIR,PIR类</para>
|
/// <para>1024:Light,灯类</para>
|
/// </summary>
|
public List<int> privateFuncFirstLevelList = new List<int>();
|
|
/// <summary>
|
/// 第二级信息
|
/// <para>1:特殊功能</para>
|
/// <para>100:Switch,开关(按键类)</para>
|
/// <para>200:Dimmer,调光(按键类)</para>
|
/// <para>300:Curtain,窗帘(按键类)</para>
|
/// <para>0:EnergySavingMode,节能模式(灯类)</para>
|
/// <para>1:SleepMode,睡眠模式(灯类)</para>
|
/// <para>100:WhiteBalance,白平衡(灯类)</para>
|
/// <para>101:RGBColor,RGB指示灯颜色(灯类)</para>
|
/// <para>102:RGBLevel,RGB指示灯亮度(灯类)</para>
|
/// </summary>
|
public List<int> privateFuncSecondLevelList = new List<int>();
|
|
/// <summary>
|
/// 第三级信息
|
/// <para>1:场景触发(特殊功能)</para>
|
/// <para>65535:禁止发送功能(特殊功能)</para>
|
/// <para>100:SwitchOpen,开关开(按键类)</para>
|
/// <para>101:SwitchClose,开关关(按键类)</para>
|
/// <para>102:SwitchChange,开关切换(按键类)</para>
|
/// <para>200:DimmerStepUp,增大调光(按键类)</para>
|
/// <para>201:DimmerStepDown,降低调光(按键类)</para>
|
/// <para>202:DimmerStepChange,调光切换(按键类)</para>
|
/// <para>300:CurtainOpen,窗帘开(按键类)</para>
|
/// <para>301:CurtainClose,窗帘关(按键类)</para>
|
/// <para>302:CurtainStop,窗帘停</para>
|
/// <para>303:CurtainUpStop,窗帘上升停</para>
|
/// <para>304:CurtainDownstop,窗帘下降停</para>
|
/// </summary>
|
public List<int> privateFuncThirdLevelList = new List<int>();
|
|
#region 获取面板的私有信息.
|
/// <summary>
|
///获取面板的私有信息
|
/// <para>注意params传入参数如下:</para>
|
/// <para>方法1:当int[]传空,返回值是“面板具有的功能大类,即返回“第一级别。1024:灯类,256:按键类,768:PIR类</para>
|
/// <para>方法2:、当int[]值为第一级别PrivateFuncTypeFir中选择一个。</para>
|
/// <para>返回值是“面按键发送功能类”,即返回“第二级别。</para>
|
/// <para>1:特殊功能;100:Switch,开关(按键类);200:Dimmer,调光(按键类);300:Curtain,窗帘(按键类)</para>
|
/// <para>0:EnergySavingMode,节能模式(灯类);1:SleepMode,睡眠模式(灯类);100:WhiteBalance,白平衡(灯类);101:RGBColor,RGB指示灯颜色(灯类);102:RGBLevel,RGB指示灯亮度(灯类)</para>
|
/// <para>方法3:当int[]值为第一级别PrivateFuncTypeFir中选择一个,接着再选第二级别PrivateFunTypeSec中选择一个 </para>
|
/// <para>返回值是“面按键具体功能配置”,即返回“第二级别。</para>
|
/// <para>1:场景触发;65535:禁止发送功能
|
/// <para>100:SwitchOpen,开关开(按键类);101:SwitchClose,开关关(按键类);102:SwitchChange,开关切换(按键类)</para>
|
/// <para>200:DimmerStepUp,增大调光(按键类);201:DimmerStepDown,降低调光(按键类);202:DimmerStepChange,调光切换(按键类)</para>
|
/// <para>300:CurtainOpen,窗帘开(按键类);301:CurtainClose,窗帘关(按键类);302:CurtainStop,窗帘停;303:CurtainUpStop,窗帘上升停;304:CurtainDownstop,窗帘下降停</para>
|
/// </summary>
|
public async System.Threading.Tasks.Task<PanelPrivateFunctionsResponseAllInfo> GetPanelPrivateFunctionsAsync(params int[] args)
|
{
|
PanelPrivateFunctionsResponseAllInfo result = null;
|
if (Gateway == null)
|
{
|
result = new PanelPrivateFunctionsResponseAllInfo { 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 PanelPrivateFunctionsResponseAllInfo { errorMessageBase = "网关错误回复,且数据是空" };
|
}
|
|
else
|
{
|
result = new PanelPrivateFunctionsResponseAllInfo { 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 PanelPrivateFunctionsResponseAllInfo { errorMessageBase = "网关返回的数据为空" };
|
}
|
else
|
{
|
if (clientDataPassthroughResponseData?.PassData != null)
|
{
|
var data = clientDataPassthroughResponseData.PassData;
|
|
if (data.Length > 12)
|
{
|
var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
|
if (command == "0004")
|
{
|
var tempD = new PanelPrivateFunctionsResponseInfo();
|
int len = 2 + 2 * Convert.ToInt32(data[0].ToString() + data[1].ToString(), 16);
|
int usefulLength = (len - 12);
|
tempD.funLevel = Convert.ToInt32(data[10].ToString() + data[11].ToString(), 16);
|
int tempCount = 0;
|
var listData = new List<string>();
|
|
switch (tempD.funLevel)
|
{
|
case 1:
|
while (tempCount < usefulLength)
|
{
|
listData.Add(data[12 + tempCount].ToString());
|
tempCount++;
|
}
|
for (int j = 0; j < listData.Count / 4; j++)
|
{
|
int curIndex = 4 * j;
|
tempD.privateFuncTypeLevelFirstList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//if (privateFuncFirstLevelList.Contains(256) == false)
|
//{
|
// privateFuncFirstLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
|
//}
|
}
|
break;
|
case 2:
|
while (tempCount < usefulLength)
|
{
|
listData.Add(data[12 + tempCount].ToString());
|
tempCount++;
|
}
|
for (int j = 0; j < listData.Count / 4; j++)
|
{
|
int curIndex = 4 * j;
|
if (j == 0)
|
{
|
tempD.privateFuncTypeLevelFirstList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//if (privateFuncFirstLevelList.Contains(256) == false)
|
//{
|
// privateFuncFirstLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//}
|
}
|
else
|
{
|
tempD.privateFuncTypeLevelSecondList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//if (privateFuncSecondLevelList.Contains(1) == false || privateFuncSecondLevelList.Contains(100) == false || privateFuncSecondLevelList.Contains(200) == false || privateFuncSecondLevelList.Contains(300) == false)
|
//{
|
// privateFuncSecondLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//}
|
}
|
}
|
break;
|
case 3:
|
while (tempCount < usefulLength)
|
{
|
listData.Add(data[12 + tempCount].ToString());
|
tempCount++;
|
}
|
for (int j = 0; j < listData.Count / 4; j++)
|
{
|
int curIndex = 4 * j;
|
if (j == 0)
|
{
|
tempD.privateFuncTypeLevelFirstList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//if (privateFuncFirstLevelList.Contains(256) == false)
|
//{
|
// privateFuncFirstLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//}
|
}
|
else if (j == 1)
|
{
|
tempD.privateFuncTypeLevelSecondList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//if (privateFuncSecondLevelList.Contains(1) == false || privateFuncSecondLevelList.Contains(100) == false || privateFuncSecondLevelList.Contains(200) == false || privateFuncSecondLevelList.Contains(300) == false)
|
//{
|
// privateFuncSecondLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//}
|
}
|
else
|
{
|
tempD.privateFuncTypeLevelThirdList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16));
|
//if (privateFuncThirdLevelList.Contains(1) == false || privateFuncThirdLevelList.Contains(65535) == false || privateFuncThirdLevelList.Contains(100) == false || privateFuncThirdLevelList.Contains(101) == false || privateFuncThirdLevelList.Contains(102) == false || privateFuncThirdLevelList.Contains(200) == false || privateFuncThirdLevelList.Contains(201) == false || privateFuncThirdLevelList.Contains(202) == false || privateFuncThirdLevelList.Contains(300) == false || privateFuncThirdLevelList.Contains(301) == false || privateFuncThirdLevelList.Contains(302) == false || privateFuncThirdLevelList.Contains(303) == false || privateFuncThirdLevelList.Contains(304) == false)
|
//{
|
// privateFuncThirdLevelList.Add(Convert.ToInt32(listData[curIndex + 2] + listData[curIndex + 3].ToString() + listData[curIndex].ToString() + listData[curIndex + 1].ToString(), 16)); ;
|
//}
|
}
|
}
|
break;
|
}
|
result = new PanelPrivateFunctionsResponseAllInfo { panelPrivateFunctionsResponseInfo = tempD };
|
System.Console.WriteLine($"UI收到通知后的主题_command:0003_{topic}");
|
}
|
}
|
}
|
}
|
}
|
};
|
|
Gateway.Actions += action;
|
System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
|
try
|
{
|
var passData = SendPanelPrivateFunctions(args);
|
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 PanelPrivateFunctionsResponseAllInfo { errorMessageBase = " 回复超时,请重新操作" };
|
}
|
Gateway.Actions -= action;
|
System.Console.WriteLine("ClientDataPassthrough_Actions 退出" + System.DateTime.Now.ToString());
|
|
return result;
|
});
|
}
|
|
/// <summary>
|
/// PIR配置参数回复
|
/// </summary>
|
[System.Serializable]
|
public class PanelPrivateFunctionsResponseAllInfo : ErrorResponCommon
|
{
|
/// <summary>
|
/// 光感等级个数(Lux能力)
|
/// <para>有几个等级就显示几个刻度</para>
|
/// </summary>
|
public PanelPrivateFunctionsResponseInfo panelPrivateFunctionsResponseInfo;
|
}
|
|
/// <summary>
|
/// 配置参数回复
|
/// </summary>
|
[System.Serializable]
|
public class PanelPrivateFunctionsResponseInfo
|
{
|
/// <summary>
|
/// 功能类级别梯度
|
/// <para>1:第一级别</para>
|
/// <para>2:第二级别</para>
|
/// <para>3:第三级别</para>
|
/// </summary>
|
public int funLevel = -1;
|
|
/// <summary>
|
/// 私有功能类
|
/// <para>256:Key,按键类类 </para>
|
/// <para>768:PIR,PIR类</para>
|
/// <para>1024:Light,灯类</para>
|
/// </summary>
|
public List<int> privateFuncTypeLevelFirstList = new List<int>();
|
|
/// <summary>
|
/// 第二级信息
|
/// <para>1:特殊功能</para>
|
/// <para>100:Switch,开关(按键类)</para>
|
/// <para>200:Dimmer,调光(按键类)</para>
|
/// <para>300:Curtain,窗帘(按键类)</para>
|
/// <para>0:EnergySavingMode,节能模式(灯类)</para>
|
/// <para>1:SleepMode,睡眠模式(灯类)</para>
|
/// <para>100:WhiteBalance,白平衡(灯类)</para>
|
/// <para>101:RGBColor,RGB指示灯颜色(灯类)</para>
|
/// <para>102:RGBLevel,RGB指示灯亮度(灯类)</para>
|
/// </summary>
|
public List<int> privateFuncTypeLevelSecondList = new List<int>();
|
|
/// <summary>
|
/// 第三级信息
|
/// <para>1:场景触发(特殊功能)</para>
|
/// <para>65535:禁止发送功能(特殊功能)</para>
|
/// <para>100:SwitchOpen,开关开(按键类)</para>
|
/// <para>101:SwitchClose,开关关(按键类)</para>
|
/// <para>102:SwitchChange,开关切换(按键类)</para>
|
/// <para>200:DimmerStepUp,增大调光(按键类)</para>
|
/// <para>201:DimmerStepDown,降低调光(按键类)</para>
|
/// <para>202:DimmerStepChange,调光切换(按键类)</para>
|
/// <para>300:CurtainOpen,窗帘开(按键类)</para>
|
/// <para>301:CurtainClose,窗帘关(按键类)</para>
|
/// <para>302:CurtainStop,窗帘停</para>
|
/// <para>303:CurtainUpStop,窗帘上升停</para>
|
/// <para>304:CurtainDownstop,窗帘下降停</para>
|
/// </summary>
|
public List<int> privateFuncTypeLevelThirdList = new List<int>();
|
|
}
|
|
/// <summary>
|
///读取面板的私有信息
|
/// <para>注意params取值如下:</para>
|
/// <para>1、当int[]传空,返回值是“面板具有的功能大类”:1024:灯类,256:按键类,768:PIR类</para>
|
/// <para>2、当int[]值为第一级别PrivateFuncTypeFir中选择一个。返回值是“面按键发送功能类”</para>
|
/// <para>3、当int[]值为第一级别PrivateFuncTypeFir中选择一个,接着再选第二级别PrivateFunTypeSec中选择一个,返回值是“面按键具体功能配置”</para>
|
/// </summary>
|
string SendPanelPrivateFunctions(params int[] args)
|
{
|
string data = "";
|
string dataLength = "";
|
string dataComand1 = "03";
|
string dataComand2 = "00";
|
string dataSerialNum = "01";
|
string addDataLength = "";
|
string value0 = "";
|
string value1 = "";
|
string value2 = "";
|
try
|
{
|
|
if (args.Length != 0)
|
{
|
if (Convert.ToString(2 * args.Length + 5, 16).Length == 1)
|
{
|
dataLength = string.Concat(0, 2 * args.Length + 5);
|
}
|
else
|
{
|
dataLength = Convert.ToString(2 * args.Length + 5, 16);
|
}
|
|
|
if (Convert.ToString(2 * args.Length, 16).Length == 1)
|
{
|
addDataLength = string.Concat(0, 2 * args.Length + 1);
|
}
|
else
|
{
|
addDataLength = Convert.ToString(2 * args.Length + 1, 16);
|
}
|
|
for (int i = 0; i < args.Length; i++)
|
{
|
switch (args.Length)
|
{
|
case 1:
|
value0 = "02";
|
switch (args[0])
|
{
|
case 1024:
|
value1 = "0004";
|
break;
|
case 256:
|
value1 = "0001";
|
break;
|
case 768:
|
value1 = "0003";
|
break;
|
}
|
break;
|
case 2:
|
value0 = "03";
|
switch (args[0])
|
{
|
case 1024:
|
value1 = "0004";
|
switch (args[1])
|
{
|
case 0:
|
value2 = "0000";
|
break;
|
case 1:
|
value2 = "0100";
|
break;
|
case 100:
|
value2 = "6400";
|
break;
|
case 101:
|
value2 = "6500";
|
break;
|
case 102:
|
value2 = "6600";
|
break;
|
}
|
break;
|
case 256:
|
value1 = "0001";
|
switch (args[1])
|
{
|
case 1:
|
value2 = "0100";
|
break;
|
case 100:
|
value2 = "6400";
|
break;
|
case 200:
|
value2 = "C800";
|
break;
|
case 300:
|
value2 = "2C01";
|
break;
|
}
|
break;
|
case 768:
|
value1 = "0003";
|
break;
|
}
|
|
break;
|
}
|
}
|
|
}
|
else
|
{
|
dataLength = "05";
|
addDataLength = "01";
|
value0 = "01";
|
}
|
data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
|
value0 + value1 + value2;
|
}
|
catch { };
|
|
return data;
|
}
|
|
/// <summary>
|
/// 私有功能类(第一级别)信息
|
/// </summary>
|
public class PrivateFuncTypeFir
|
{
|
/// <summary>
|
/// 私有功能类
|
/// <para>256:Key,按键类类 </para>
|
/// <para>768:PIR,PIR类</para>
|
/// <para>1024:Light,灯类</para>
|
/// </summary>
|
public int privateFuncTypeOne;
|
}
|
|
/// <summary>
|
/// 私有功能类(第二级别)信息
|
/// </summary>
|
public class PrivateFunTypeSec
|
{
|
/// <summary>
|
/// 第二级信息
|
/// <para>100:Switch,开关(按键类)</para>
|
/// <para>200:Dimmer,调光(按键类)</para>
|
/// <para>300:Curtain,窗帘(按键类)</para>
|
/// <para>0:EnergySavingMode,节能模式(灯类)</para>
|
/// <para>1:SleepMode,睡眠模式(灯类)</para>
|
/// <para>100:WhiteBalance,白平衡(灯类)</para>
|
/// <para>101:RGBColor,RGB指示灯颜色(灯类)</para>
|
/// <para>102:RGBLevel,RGB指示灯亮度(灯类)</para>
|
/// </summary>
|
public int privateFuncTypeTwo;
|
}
|
|
/// <summary>
|
/// 私有功能类(第三级别)信息
|
/// </summary>
|
public class PrivateFunTypeThird
|
{
|
/// <summary>
|
/// 第三级信息
|
/// <para>0:EnergySavingModeOpenLevel,节能模式开亮度(灯类 )</para>
|
/// <para>1:EnergySavingModeCloseLevel,节能模式关亮度(灯类)</para>
|
/// <para>1:场景触发;(特殊功能)</para>
|
/// <para>65535:禁止发送功能(特殊功能)</para>
|
/// <para>100:SwitchOpen,开关开(按键类)</para>
|
/// <para>101:SwitchClose,开关关(按键类)</para>
|
/// <para>102:SwitchChange,开关切换(按键类)</para>
|
/// <para>200:DimmerStepUp,增大调光(按键类)</para>
|
/// <para>201:DimmerStepDown,降低调光(按键类)</para>
|
/// <para>202:DimmerStepChange,调光切换(按键类)</para>
|
/// <para>300:CurtainOpen,窗帘开(按键类)</para>
|
/// <para>301:CurtainClose,窗帘关(按键类)</para>
|
/// <para>302:CurtainStop,窗帘停</para>
|
/// <para>303:CurtainUpStop,窗帘上升停</para>
|
/// <para>304:CurtainDownstop,窗帘下降停</para>
|
/// </summary>
|
public int privateFuncTypeThird;
|
}
|
|
/// <summary>
|
/// 获取按键面板的第一级别功能功能系(1024:灯类,256:按键类,768:PIR类)
|
/// </summary>
|
/// <param name="panel">按键面板的某一个回路</param>
|
/// <returns></returns>
|
public async Task<List<int>> GetPanelDeviceFunctionLevel1()
|
{
|
var result = await GetPanelPrivateFunctionsAsync();
|
if (result == null || result.panelPrivateFunctionsResponseInfo == null)
|
{
|
return null;
|
}
|
|
return result.panelPrivateFunctionsResponseInfo.privateFuncTypeLevelFirstList;
|
}
|
|
/// <summary>
|
/// <para>获取按键面板的第二级别功能功能系(以下为返回值)</para>
|
/// <para>100:Switch,开关(按键类)</para>
|
/// <para>200:Dimmer,调光(按键类)</para>
|
/// <para>300:Curtain,窗帘(按键类)</para>
|
/// <para>0:EnergySavingMode,节能模式(灯类)</para>
|
/// <para>1:SleepMode,睡眠模式(灯类)</para>
|
/// <para>100:WhiteBalance,白平衡(灯类)</para>
|
/// <para>101:RGBColor,RGB指示灯颜色(灯类)</para>
|
/// <para>102:RGBLevel,RGB指示灯亮度(灯类)</para>
|
/// </summary>
|
/// <param name="panel">按键面板的某一个回路</param>
|
/// <param name="level1">第一级别的ID(1024:灯类,256:按键类,768:PIR类)</param>
|
/// <returns></returns>
|
public async Task<List<int>> GetPanelDeviceFunctionLevel2(int level1)
|
{
|
var result = await GetPanelPrivateFunctionsAsync(new int[] { level1 });
|
if (result == null || result.panelPrivateFunctionsResponseInfo == null)
|
{
|
return null;
|
}
|
return result.panelPrivateFunctionsResponseInfo.privateFuncTypeLevelSecondList;
|
}
|
|
/// <summary>
|
/// 按键类第三级别如下:
|
/// <para>1:场景触发;(特殊功能)</para>
|
/// <para>65535:禁止发送功能(特殊功能)</para>
|
/// <para>100:SwitchOpen,开关开(按键类)</para>
|
/// <para>101:SwitchClose,开关关(按键类)</para>
|
/// <para>102:SwitchChange,开关切换(按键类)</para>
|
/// <para>200:DimmerStepUp,增大调光(按键类)</para>
|
/// <para>201:DimmerStepDown,降低调光(按键类)</para>
|
/// <para>202:DimmerStepChange,调光切换(按键类)</para>
|
/// <para>300:CurtainOpen,窗帘开(按键类)</para>
|
/// <para>301:CurtainClose,窗帘关(按键类)</para>
|
/// <para>302:CurtainStop,窗帘停</para>
|
/// <para>303:CurtainUpStop,窗帘上升停</para>
|
/// <para>304:CurtainDownstop,窗帘下降停</para>
|
/// </summary>
|
/// <param name="panel">按键面板的某一个回路</param>
|
/// <param name="level1">第一级别的ID(1024:灯类,256:按键类,768:PIR类)</param>
|
/// <param name="level2">第二级别的ID(当第一级别是按键类,1:特殊功能,100:按键开关,200:按键调光;300:按键窗帘)</param>
|
/// <returns></returns>
|
public async Task<List<int>> GetPanelDeviceFunctionLevel3(int level1, int level2)
|
{
|
var result = await GetPanelPrivateFunctionsAsync(new int[] { level1, level2 });
|
if (result == null || result.panelPrivateFunctionsResponseInfo == null)
|
{
|
return null;
|
}
|
return result.panelPrivateFunctionsResponseInfo.privateFuncTypeLevelThirdList;
|
}
|
#endregion
|
|
#region 控制按键指示灯.
|
///<summary >
|
///控制按键指示灯
|
/// </summary>
|
public async System.Threading.Tasks.Task<ResponseAllData> ControlKeyAsync(KeyNumStatus keyNum, KeyStatus keyStatus)
|
{
|
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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.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 clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
|
|
if (clientDataPassthroughResponseData == null)
|
{
|
result = new ResponseAllData { errorMessageBase = "网关返回的数据为空" };
|
}
|
else
|
{
|
if (clientDataPassthroughResponseData?.PassData != null)
|
{
|
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 = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
|
tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
|
if (tempD.command == "0400")
|
{
|
result = new ResponseAllData { responseData = tempD };
|
System.Console.WriteLine($"UI收到通知后的主题_command:0400_{ topic}");
|
}
|
|
}
|
}
|
}
|
}
|
}
|
};
|
|
Gateway.Actions += action;
|
System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
|
try
|
{
|
var passData = ControlKeyData(keyNum, keyStatus);
|
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>
|
/// 按键指示灯状态
|
/// </summary>
|
public enum KeyStatus
|
{
|
/// <summary>
|
/// 关
|
/// </summary>
|
close = 0x00,
|
/// <summary>
|
/// 开
|
/// </summary>
|
open = 0x64,
|
/// <summary>
|
/// 无效
|
/// </summary>
|
inValid = 0xff,
|
}
|
|
/// <summary>
|
/// 控制按键指示灯
|
/// </summary>
|
string ControlKeyData(KeyNumStatus keyNumStatus, KeyStatus keyStatus)
|
{
|
string data = "";
|
string dataLength = "07";
|
string dataComand1 = "00";
|
string dataComand2 = "04";
|
string dataSerialNum = "01";
|
string addDataLength = "03";
|
string kStatus = "";
|
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());
|
|
switch (keyStatus)
|
{
|
case KeyStatus.close:
|
kStatus = "00";
|
break;
|
case KeyStatus.open:
|
kStatus = "64";
|
break;
|
case KeyStatus.inValid:
|
kStatus = "ff";
|
break;
|
}
|
|
|
data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
|
tempAttributeData + kStatus;
|
}
|
catch { };
|
|
return data;
|
}
|
#endregion
|
|
#region 配置按键指示灯颜色.
|
|
/// <summary>
|
/// 绑定设备信息,网关反馈信息
|
/// </summary>
|
[System.Serializable]
|
public class KeyColorDataResponseAllData
|
{
|
/// <summary>
|
/// 错误信息
|
/// </summary>
|
public string errorMessageBase;
|
/// <summary>
|
/// 网关信息错误反馈
|
/// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para>
|
/// </summary>
|
public ErrorResponData errorResponData;
|
/// <summary>
|
/// 按键指示灯颜色信息
|
/// </summary>
|
public KeyColorData keyColorData;
|
}
|
|
// <summary>
|
/// 按键指示灯颜色信息
|
/// </summary>
|
[System.Serializable]
|
public class KeyColorData
|
{
|
/// <summary>
|
/// 指示灯对应顺序号
|
/// </summary>
|
public KeyNum keyNum;
|
/// <summary>
|
/// 开状态颜色R(0-ff)
|
/// </summary>
|
public string OpenColorR;
|
/// <summary>
|
/// 开状态颜色G(0-ff)
|
/// </summary>
|
public string OpenColorG;
|
/// <summary>
|
/// 开状态颜色B(0-ff)
|
/// </summary>
|
public string OpenColorB;
|
/// <summary>
|
/// 关状态颜色R(0-ff)
|
/// </summary>
|
public string CloseColorR;
|
/// <summary>
|
/// 关状态颜色G(0-ff)
|
/// </summary>
|
public string CloseColorG;
|
/// <summary>
|
/// 关状态颜色B(0-ff)
|
/// </summary>
|
public string CloseColorB;
|
}
|
|
/// <summary>
|
/// 按键指示灯颜色信息对应顺序号
|
/// </summary>
|
public class KeyNumStatus
|
{
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key1;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key2;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key3;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key4;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key5;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key6;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key7;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key8;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key9;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key10;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key11;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key12;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key13;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key14;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key15;
|
/// <summary>
|
/// false:关
|
/// true:开
|
/// </summary>
|
public bool Key16;
|
}
|
#endregion
|
|
#region 配置接近传感
|
///<summary >
|
/// 配置接近传感
|
/// <para>sensorEnable:传感器使能</para>
|
/// </summary>
|
public async System.Threading.Tasks.Task<ResponseAllData> SetProximitySensor(bool sensorEnable)
|
{
|
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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.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 clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
|
|
if (clientDataPassthroughResponseData == null)
|
{
|
result = new ResponseAllData { errorMessageBase = "网关返回的数据为空" };
|
}
|
else
|
{
|
if (clientDataPassthroughResponseData?.PassData != null)
|
{
|
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 = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
|
tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
|
if (tempD.command == "0500")
|
{
|
result = new ResponseAllData { responseData = tempD };
|
DebugPrintLog($"UI收到通知后的主题_command:0500_{ topic}");
|
}
|
}
|
}
|
}
|
}
|
}
|
};
|
|
Gateway.Actions += action;
|
System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
|
try
|
{
|
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);
|
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>
|
/// 配置接近传感
|
/// [该条协议另外2个参数UI和设备都不需要,设备都同事要求传感器距离和传感器触发延迟时间都默认是FFFF]
|
/// </summary>
|
/// <param name="sensorEnable">传感器使能 0-disable 1-enable</param>
|
/// <returns></returns>
|
string SetProximitySensorData(bool sensorEnable)
|
{
|
string data = "";
|
string dataLength = "09";
|
string dataComand1 = "00";
|
string dataComand2 = "05";
|
string dataSerialNum = "01";
|
string addDataLength = "05";
|
string sEnable = "";
|
try
|
{
|
if (sensorEnable)
|
{
|
sEnable = "01";
|
}
|
else
|
{
|
sEnable = "00";
|
}
|
|
data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
|
sEnable + "FFFFFFFF";
|
}
|
catch { };
|
|
return data;
|
}
|
#endregion
|
|
#region 校正温度
|
///<summary >
|
/// 校正温度
|
/// </summary>
|
public async System.Threading.Tasks.Task<ResponseAllData> CorrectTemperature(double correctValue, int direction = 0, int type = 0)
|
{
|
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 temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.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 clientDataPassthroughResponseData = Newtonsoft.Json.JsonConvert.DeserializeObject<ClientDataPassthroughResponseData>(jobject["Data"].ToString());
|
|
if (clientDataPassthroughResponseData == null)
|
{
|
result = new ResponseAllData { errorMessageBase = "网关返回的数据为空" };
|
}
|
else
|
{
|
if (clientDataPassthroughResponseData?.PassData != null)
|
{
|
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 = data[12].ToString() + data[13].ToString() + data[10].ToString() + data[11].ToString();
|
tempD.status = Convert.ToInt32(data[14].ToString() + data[15].ToString(), 16);
|
if (tempD.command == "0503")
|
{
|
result = new ResponseAllData { responseData = tempD };
|
DebugPrintLog($"UI收到通知后的主题_command:0500_{ topic}");
|
}
|
}
|
}
|
}
|
}
|
}
|
};
|
|
Gateway.Actions += action;
|
System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
|
try
|
{
|
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);
|
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>
|
/// 校正温度
|
/// [该条协议另外2个参数UI和设备都不需要,设备都同事要求传感器距离和传感器触发延迟时间都默认是FFFF]
|
/// </summary>
|
/// <param name="correctValue">校正温度值</param>
|
/// <returns></returns>
|
string CorrectTemperatureData(double correctValue,int direction=0, int type = 0)
|
{
|
string data = "";
|
string dataLength = "09";
|
string dataComand1 = "03";
|
string dataComand2 = "05";
|
string dataSerialNum = "01";
|
string addDataLength = "05";
|
string typeString = "";
|
string directString = "";
|
string correctValueString = "";
|
try
|
{
|
if (type == 1)
|
{
|
typeString = "0100";
|
}
|
else
|
{
|
typeString = "0000";
|
}
|
|
if (direction == 1)
|
{
|
directString = "01";
|
}
|
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 +
|
typeString + directString + correctValueString;
|
}
|
catch { };
|
|
return data;
|
}
|
#endregion
|
|
#region 获取按键指示灯开关颜色.
|
|
/// <summary>
|
/// 按键指示灯颜色信息对应顺序号(睡眠组号)
|
/// </summary>
|
public enum KeyNum
|
{
|
Key1 = 1,
|
Key2 = 2,
|
Key3 = 3,
|
Key4 = 4,
|
Key5 = 5,
|
Key6 = 6,
|
Key7 = 7,
|
Key8 = 8,
|
Key9 = 9,
|
Key10 = 10,
|
Key11 = 11,
|
Key12 = 12,
|
Key13 = 13,
|
Key14 = 14,
|
Key15 = 15,
|
Key16 = 16,
|
}
|
#endregion
|
|
#region 获取按键指示灯面板开关亮度配置.
|
|
/// <summary>
|
/// 按键指示灯面板开关亮度配置回复
|
/// </summary>
|
[System.Serializable]
|
public class PanelSwitchLevelInfo
|
{
|
/// <summary>
|
/// 错误信息
|
/// </summary>
|
public string errorMessageBase;
|
/// <summary>
|
/// 网关信息错误反馈
|
/// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para>
|
/// </summary>
|
public ErrorResponData errorResponData;
|
/// <summary>
|
///按键开状态(指示)亮度(这个是点击后的值,或者 1-6干接点的背光灯)
|
/// </summary>
|
public int panelDirectionsLevel = -1;
|
|
/// <summary>
|
/// 按键关状态(背光)亮度(这个是点击前的值,或者 第七干接点的背光灯)
|
/// </summary>
|
public int panelBacklightLevel = -1;
|
}
|
#endregion
|
|
#region 获取按键节能模式配置状态.
|
|
/// <summary>
|
/// 获取按键节能模式配置状态数据回复
|
/// </summary>
|
[System.Serializable]
|
public class PanelSwitchLevelResponInfo
|
{
|
/// <summary>
|
/// 错误信息
|
/// </summary>
|
public string errorMessageBase;
|
/// <summary>
|
/// 网关信息错误反馈
|
/// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para>
|
/// </summary>
|
public ErrorResponData errorResponData;
|
/// <summary>
|
/// 网关信息错误反馈
|
/// <para>获取按键节能模式配置状态数据</para>
|
/// </summary>
|
public PanelSaveEnergyModeInfo panelSaveEnergyModeInfo;
|
}
|
|
/// <summary>
|
/// 获取按键节能模式配置状态数据
|
/// </summary>
|
[System.Serializable]
|
public class PanelSaveEnergyModeInfo
|
{
|
/// <summary>
|
///false-disable true-enable
|
/// </summary>
|
public bool enable;
|
/// <summary>
|
///无操作进入节能模式时间(0-255 单位秒)
|
/// </summary>
|
public int time = -1;
|
|
/// <summary>
|
/// 节能模式亮度(0-100)
|
/// </summary>
|
public int level = -1;
|
}
|
#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 >
|
///获取按键指示灯睡眠组
|
///<para>sleepGroup:睡眠组号</para>
|
/// </summary>
|
//public async System.Threading.Tasks.Task<PanelSleepGroupResponseAllData> GetPanelSleepGroupAsync(SleepGroup sleepGroup)
|
//{
|
// PanelSleepGroupResponseAllData result = null;
|
// if (Gateway == null)
|
// {
|
// result = new PanelSleepGroupResponseAllData { 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 PanelSleepGroupResponseAllData { errorMessageBase = "网关错误回复,且数据是空" };
|
// }
|
|
// else
|
// {
|
// result = new PanelSleepGroupResponseAllData { 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 PanelSleepGroupResponseAllData { errorMessageBase = "网关返回的数据为空" };
|
// }
|
// else
|
// {
|
// if (clientDataPassthroughResponseData?.PassData != null)
|
// {
|
// var data = clientDataPassthroughResponseData.PassData;
|
// if (data.Length == 14)
|
// {
|
// var tempR = new PanelSleepGroupResponseData();
|
// tempR.status = int.Parse(data[12].ToString() + data[13].ToString());
|
// switch (data[10].ToString() + data[11].ToString())
|
// {
|
// case "01":
|
// tempR.sleepGroupNum = SleepGroupNum.Group1;
|
// break;
|
// case "02":
|
// tempR.sleepGroupNum = SleepGroupNum.Group2;
|
// break;
|
// case "03":
|
// tempR.sleepGroupNum = SleepGroupNum.Group3;
|
// break;
|
// case "04":
|
// tempR.sleepGroupNum = SleepGroupNum.Group4;
|
// break;
|
// case "05":
|
// tempR.sleepGroupNum = SleepGroupNum.Group5;
|
// break;
|
// case "06":
|
// tempR.sleepGroupNum = SleepGroupNum.Group6;
|
// break;
|
// case "07":
|
// tempR.sleepGroupNum = SleepGroupNum.Group7;
|
// break;
|
// case "08":
|
// tempR.sleepGroupNum = SleepGroupNum.Group8;
|
// break;
|
// case "09":
|
// tempR.sleepGroupNum = SleepGroupNum.Group9;
|
// break;
|
// case "0a":
|
// tempR.sleepGroupNum = SleepGroupNum.Group10;
|
// break;
|
// case "0b":
|
// tempR.sleepGroupNum = SleepGroupNum.Group11;
|
// break;
|
// case "0c":
|
// tempR.sleepGroupNum = SleepGroupNum.Group12;
|
// break;
|
// case "0d":
|
// tempR.sleepGroupNum = SleepGroupNum.Group13;
|
// break;
|
// case "0e":
|
// tempR.sleepGroupNum = SleepGroupNum.Group14;
|
// break;
|
// case "0f":
|
// tempR.sleepGroupNum = SleepGroupNum.Group15;
|
// break;
|
// }
|
// result = new PanelSleepGroupResponseAllData { panelSleepGroupResponseData = tempR };
|
// }
|
// }
|
// System.Console.WriteLine($"UI收到通知后的主题_{ topic}");
|
// }
|
// }
|
// };
|
|
// Gateway.Actions += action;
|
// System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
|
// try
|
// {
|
// OpenPassthroughControl(Gateway);
|
// var passData = SetPanelSleepGroupData(sleepGroup);
|
// var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", 200 }, { "Cluster_ID", 64513 }, { "Command", 0 } };
|
// var data = new JObject { { "PassData", passData } };
|
// jObject.Add("Data", data);
|
// CurrentGateWayId = Gateway.getGatewayBaseInfo?.gwID;
|
// 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 > WaitReceiveDataTime)
|
// {
|
// result = new PanelSleepGroupResponseAllData { errorMessageBase = " 回复超时,请重新操作" };
|
// }
|
// Gateway.Actions -= action;
|
// System.Console.WriteLine("ClientDataPassthrough_Actions 退出" + System.DateTime.Now.ToString());
|
|
// return result;
|
// });
|
//}
|
|
///// <summary>
|
///// 绑定设备信息,网关反馈信息
|
///// </summary>
|
//public PanelSleepGroupResponseAllData panelSleepGroupResponseAllData;
|
//[System.Serializable]
|
//public class PanelSleepGroupResponseAllData
|
//{
|
// /// <summary>
|
// /// 错误信息
|
// /// </summary>
|
// public string errorMessageBase;
|
// /// <summary>
|
// /// 网关信息错误反馈
|
// /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para>
|
// /// </summary>
|
// public ErrorResponData errorResponData;
|
// /// <summary>
|
// /// 绑定设备信息
|
// /// </summary>
|
// public PanelSleepGroupResponseData panelSleepGroupResponseData;
|
//}
|
|
///// <summary>
|
///// 绑定设备信息,网关反馈信息
|
///// </summary>
|
//public PanelSleepGroupResponseData panelSleepGroupResponseData;
|
//[System.Serializable]
|
//public class PanelSleepGroupResponseData
|
//{
|
// /// <summary>
|
// /// 睡眠组号
|
// /// </summary>
|
// public SleepGroupNum sleepGroupNum;
|
// /// <summary>
|
// /// 状态
|
// /// <para>0--执行 1—唤醒</para>
|
// /// </summary>
|
// public int status;
|
//}
|
|
///// <summary>
|
///// 配置按键指示灯睡眠组分区
|
///// </summary>
|
//string SetPanelSleepGroupData(SleepGroup sleepGroup)
|
//{
|
// string data = "";
|
// string dataLength = "06";
|
// string dataComand1 = "0a";
|
// string dataComand2 = "04";
|
// string dataSerialNum = "01";
|
// string addDataLength = "02";
|
// int attributeData = 0;
|
|
// try
|
// {
|
// int bit0 = 0, bit1 = 0, bit2 = 0, bit3 = 0, bit4 = 0, bit5 = 0, bit6 = 0, bit7 = 0, bit8 = 0, bit9 = 0, bit10 = 0, bit11 = 0, bit12 = 0, bit13 = 0, bit14 = 0, bit15 = 0;
|
// if (sleepGroup != null)
|
// {
|
// if (sleepGroup.bit0)
|
// {
|
// bit0 = 1;
|
// }
|
// if (sleepGroup.bit1)
|
// {
|
// bit1 = 1;
|
// }
|
// if (sleepGroup.bit2)
|
// {
|
// bit2 = 1;
|
// }
|
// if (sleepGroup.bit3)
|
// {
|
// bit3 = 1;
|
// }
|
// if (sleepGroup.bit4)
|
// {
|
// bit4 = 1;
|
// }
|
// if (sleepGroup.bit5)
|
// {
|
// bit5 = 1;
|
// }
|
// if (sleepGroup.bit6)
|
// {
|
// bit6 = 1;
|
// }
|
// if (sleepGroup.bit7)
|
// {
|
// bit7 = 1;
|
// }
|
// if (sleepGroup.bit8)
|
// {
|
// bit8 = 1;
|
// }
|
// if (sleepGroup.bit9)
|
// {
|
// bit9 = 1;
|
// }
|
// if (sleepGroup.bit10)
|
// {
|
// bit10 = 1;
|
// }
|
// if (sleepGroup.bit11)
|
// {
|
// bit11 = 1;
|
// }
|
// if (sleepGroup.bit12)
|
// {
|
// bit12 = 1;
|
// }
|
// if (sleepGroup.bit13)
|
// {
|
// bit13 = 1;
|
// }
|
// if (sleepGroup.bit14)
|
// {
|
// bit14 = 1;
|
// }
|
// if (sleepGroup.bit15)
|
// {
|
// bit15 = 1;
|
// }
|
// attributeData = bit0 * 1 + bit1 * 2 + bit2 * 4 + bit3 * 8 + bit4 * 16 + bit5 * 32 + bit6 * 64 + bit7 * 128 + bit8 * 256 + bit9 * 512 + bit10 * 1024 + bit11 * 2048 + bit12 * 4096 + bit13 * 8192 + bit14 * 16384 + bit15 * 32768;
|
// }
|
// string tempAttributeData = attributeData.ToString("X4");
|
|
// if (sleepGroup != null)
|
// {
|
// data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
|
// tempAttributeData;
|
// }
|
// }
|
// catch { };
|
|
// return data;
|
//}
|
|
///// <summary>
|
///// 睡眠组号(可位或)
|
///// </summary>
|
//public class SleepGroup
|
//{
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit0;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit1;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit2;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit3;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit4;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit5;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit6;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit7;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit8;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit9;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit10;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit11;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit12;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit13;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit14;
|
// /// <summary>
|
// /// false:关
|
// /// true:开
|
// /// </summary>
|
// public bool bit15;
|
//}
|
|
///// <summary>
|
///// 执行按键指示灯睡眠组
|
///// </summary>
|
//public enum SleepGroupNum
|
//{
|
// Group1 = 1,
|
// Group2 = 2,
|
// Group3 = 3,
|
// Group4 = 4,
|
// Group5 = 5,
|
// Group6 = 6,
|
// Group7 = 7,
|
// Group8 = 8,
|
// Group9 = 9,
|
// Group10 = 10,
|
// Group11 = 11,
|
// Group12 = 12,
|
// Group13 = 13,
|
// Group14 = 14,
|
// Group15 = 15,
|
// Group16 = 16,
|
//}
|
#endregion
|
|
#region 配置面板功能
|
|
/// <summary>
|
/// 配置面板的功能模式
|
/// </summary>
|
public enum KeyMode
|
{
|
/// <summary>
|
/// 开关类型——开.
|
/// </summary>
|
Scene_Trigger = 1,
|
/// <summary>
|
/// 开关类型——开.
|
/// </summary>
|
OnOff_On = 100,
|
/// <summary>
|
/// 开关类型——关.
|
/// </summary>
|
OnOff_oFF = 101,
|
/// <summary>
|
/// 开关类型——取反.
|
/// </summary>
|
OnOff_OnOff = 102,
|
/// <summary>
|
/// 亮度类型——按等级调大.
|
/// </summary>
|
Level_Step_Up = 200,
|
/// <summary>
|
/// 亮度类型——按等级调小.
|
/// </summary>
|
Level_Step_Down = 201,
|
/// <summary>
|
/// 亮度类型——按等级取反.
|
/// </summary>
|
Level_Step_Up_Down = 202,
|
/// <summary>
|
/// 亮度类型——取反.
|
/// </summary>
|
Level_Up = 203,
|
/// <summary>
|
/// 亮度类型——取反.
|
/// </summary>
|
Level_Down = 204,
|
/// <summary>
|
/// 亮度类型——取反.
|
/// </summary>
|
Level_Up_Down = 205,
|
/// <summary>
|
/// 窗帘类型——开.
|
/// </summary>
|
Wcd_Up = 300,
|
/// <summary>
|
/// 窗帘类型——关.
|
/// </summary>
|
Wcd_Down = 301,
|
/// <summary>
|
/// 窗帘类型——停.
|
/// </summary>
|
Wcd_Stop = 302,
|
/// <summary>
|
/// 窗帘类型——上升停止.
|
/// </summary>
|
Wcd_Up_Stop = 303,
|
/// <summary>
|
/// 窗帘类型——下降停止.
|
/// </summary>
|
Wcd_Down_Stop = 304,
|
/// <summary>
|
/// 窗帘类型——下降停止.
|
/// </summary>
|
Default = 65535,
|
}
|
#endregion
|
|
/// <summary>
|
///读取面板的配置信息
|
/// </summary>
|
public void ReadPanelSupportAttribute()
|
{
|
ReadAttri(Device.Cluster_ID.HdlKey, AttriButeId.HdlKey);
|
}
|
|
#region 读取面板的配置信息
|
|
/// <summary>
|
/// 网关恢复出厂设置返回数据
|
/// </summary>
|
[System.Serializable]
|
public class PanelConfigureInfoResponAllData
|
{
|
/// <summary>
|
/// 错误信息
|
/// </summary>
|
public string errorMessageBase;
|
/// <summary>
|
/// 网关信息错误反馈
|
/// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para>
|
/// </summary>
|
public ErrorResponData errorResponData;
|
///<summary >
|
///设备数据
|
/// </summary>
|
public DeviceStatusReportData deviceStatusReportData;
|
}
|
#endregion
|
|
#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 (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()));
|
|
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>
|
[System.Serializable]
|
public class GetSceneInfo
|
{
|
/// <summary>
|
///场景总数
|
/// </summary>
|
public int ScenesSum;
|
|
/// <summary>
|
/// 场景列表
|
/// </summary>
|
public List<ScenesListInfo> ScenesList = new List<ScenesListInfo>();
|
}
|
|
/// <summary>
|
/// 场景列表中的具体信息
|
/// </summary>
|
[System.Serializable]
|
public class ScenesListInfo
|
{
|
/// <summary>
|
/// 场景ID
|
/// </summary>
|
public int ScenesId;
|
|
/// <summary>
|
/// 名称
|
/// </summary>
|
public string ScenesName;
|
|
/// <summary>
|
/// 是否处于开启状态
|
///0:场景没有被开启
|
///1:场景处于开启状态
|
/// </summary>
|
public int IsOpen;
|
}
|
#endregion
|
}
|
}
|