| | |
| | | { |
| | | this.Type = DeviceType.IASZone; |
| | | }
|
| | | /// <summary>
|
| | | /// 光感等级个数(Lux能力)
|
| | | /// <para>有几个等级就显示几个刻度</para>
|
| | | /// </summary>
|
| | | public int LightLevelCount = -1; |
| | | |
| | |
|
| | | #region IAS安防信息上报. |
| | | /// <summary> |
| | | /// IAS安防信息上报 |
| | | /// <para>当安防设备属性状态改变时候(例如一氧化碳传感器检测到一氧化碳气体),设备将上报属性状态变化数据。</para> |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public IASInfoData iASInfo; |
| | | /// <summary> |
| | | /// IAS安防信息上报 |
| | |
| | |
|
| | | 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)
|
| | | {
|
| | |
| | |
|
| | | 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 PirLightAbilitySizeInfo { errorMessageBase = "网关返回的数据为空" };
|
| | | }
|
| | | else
|
| | | {
|
| | | if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null)
|
| | | if (clientDataPassthroughResponseData?.PassData != null)
|
| | | {
|
| | | var data = gatewayTemp.clientDataPassthroughResponseData.PassData;
|
| | | var data = clientDataPassthroughResponseData.PassData;
|
| | | if (data.Length == 12)
|
| | | { |
| | | var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
|
| | |
| | | {
|
| | | var cou = data[10].ToString() + data[11].ToString();
|
| | | int countTemp = Convert.ToInt32(cou, 16);
|
| | | LightLevelCount = countTemp;
|
| | | result = new PirLightAbilitySizeInfo { LightLevelCount = countTemp }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_command:0303_{ topic}");
|
| | | } |
| | |
| | | /// <summary>
|
| | | /// PIR配置参数回复
|
| | | /// </summary>
|
| | | public PirLightAbilitySizeInfo lightLevelSizeInfo;
|
| | | [System.Serializable]
|
| | | public class PirLightAbilitySizeInfo
|
| | | public class PirLightAbilitySizeInfo : ErrorResponCommon
|
| | | {
|
| | | /// <summary>
|
| | | /// 光感等级个数(Lux能力)
|
| | | /// <para>有几个等级就显示几个刻度</para>
|
| | | /// </summary>
|
| | | public int LightLevelCount = -1;
|
| | | }
|
| | |
|
| | | #endregion
|
| | | |
| | | #region PIR传感器参数配置 |
| | | |
| | | /// <summary> |
| | | /// PIR配置参数回复 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class ParamatesInfo : ErrorResponCommon |
| | | { |
| | | /// <summary> |
| | | /// PIR配置参数 |
| | | /// </summary> |
| | | public ConfigureParamates configureParamates; |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// PIR配置参数 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class ConfigureParamates |
| | | { |
| | | /// <summary> |
| | | /// 亮度(光照度)使能 |
| | | /// <para> false(0):不使能</para> |
| | | /// <para>true(1):使能</para> |
| | | /// </summary> |
| | | public bool levelEnable; |
| | | /// <summary> |
| | | /// 光照度等级
|
| | | /// <para>值:0-10</para> |
| | | /// </summary> |
| | | public int levelSize = -1; |
| | | /// <summary> |
| | | ///控制设备使能位 |
| | | ///<para> false(0):不使能</para> |
| | | /// <para>true)1):使能</para> |
| | | /// </summary> |
| | | public bool controlDevEnable; |
| | | /// <summary> |
| | | /// 触发开灯到触发关灯的时间间隔 |
| | | /// <para>0-65535 单位秒</para> |
| | | /// </summary> |
| | | public int transitionTime; |
| | | /// <summary> |
| | | /// IAS上报周期
|
| | | /// <para>10-0xffff 秒</para>
|
| | | /// </summary>
|
| | | public int iasReportPeriod;
|
| | | /// <summary>
|
| | | /// 光照度等级
|
| | | /// <para>0:半自动模式</para>
|
| | | /// <para>1:自动模式</para>
|
| | | /// </summary>
|
| | | public int mode = 0;
|
| | | /// <summary>
|
| | | /// 开灯类型
|
| | | /// <para>值:0:调光</para>
|
| | | ///<para>1:开关 </para>
|
| | | /// </summary>
|
| | | public int type = 0;
|
| | | /// <summary>
|
| | | /// 调光模式,到达开灯亮度的时间
|
| | | /// <para>值:0-10 秒</para>
|
| | | /// </summary>
|
| | | public int dimmerOnTime = 0;
|
| | | /// <summary>
|
| | | /// 调光模式,关灯到达0%所需要的时间
|
| | | /// <para>值:0-10 秒</para>
|
| | | /// </summary>
|
| | | public int dimmerOffTime = 0;
|
| | | /// <summary>
|
| | | /// 调光模式开灯的亮度
|
| | | /// <para>0-0xff (预留)</para>
|
| | | /// </summary>
|
| | | public int dimmerLevel = 0;
|
| | | } |
| | | |
| | | #endregion |
| | |
|
| | | #region 获取PIR lux值(Lux值)
|
| | | ///<summary >
|
| | | ///获取PIR lux值(Lux值)
|
| | | /// <para>reserve:0-ff</para>
|
| | | /// </summary>
|
| | | public async System.Threading.Tasks.Task<PirLuxAbilitySizeInfo> GetPirLuxAbilitySizeAsync(string reserve = "01")
|
| | | {
|
| | | PirLuxAbilitySizeInfo result = null;
|
| | | if (Gateway == null)
|
| | | {
|
| | | result = new PirLuxAbilitySizeInfo { 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 PirLuxAbilitySizeInfo { errorMessageBase = "网关错误回复,且数据是空" };
|
| | | }
|
| | |
|
| | | else
|
| | | {
|
| | | result = new PirLuxAbilitySizeInfo { 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 PirLuxAbilitySizeInfo { 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 == "0306")
|
| | | {
|
| | | var cou = data[10].ToString() + data[11].ToString();
|
| | | int countTemp = Convert.ToInt32(cou, 16);
|
| | | result = new PirLuxAbilitySizeInfo { pirLux = countTemp };
|
| | | System.Console.WriteLine($"UI收到通知后的主题_command:0303_{ topic}");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | | Gateway.Actions += action;
|
| | | System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
| | |
|
| | | try
|
| | | {
|
| | | var passData = SendPIRLuxAbilitySizeData(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 PirLuxAbilitySizeInfo { errorMessageBase = " 回复超时,请重新操作" };
|
| | | }
|
| | | Gateway.Actions -= action;
|
| | | System.Console.WriteLine("ClientDataPassthrough_Actions 退出" + System.DateTime.Now.ToString());
|
| | |
|
| | | return result;
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | ///获取PIR lux值
|
| | | /// </summary>
|
| | | string SendPIRLuxAbilitySizeData(string reserve)
|
| | | {
|
| | | string data = "";
|
| | | string dataLength = "05";
|
| | | string dataComand1 = "05";
|
| | | string dataComand2 = "03";
|
| | | string dataSerialNum = "01";
|
| | | string addDataLength = "01";
|
| | | string reserveData = reserve;
|
| | |
|
| | | try
|
| | | {
|
| | | data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength +
|
| | | reserveData;
|
| | | }
|
| | | catch { };
|
| | |
|
| | | return data;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// PIR配置参数回复
|
| | | /// </summary>
|
| | | [System.Serializable]
|
| | | public class PirLuxAbilitySizeInfo
|
| | | {
|
| | | /// <summary>
|
| | | /// 错误信息
|
| | |
| | | /// </summary>
|
| | | public ErrorResponData errorResponData;
|
| | | /// <summary>
|
| | | /// 光感等级个数(Lux能力)
|
| | | /// <para>有几个等级就显示几个刻度</para>
|
| | | /// 当前Lux值 |
| | | /// <para>0-0xff Lux</para>
|
| | | /// </summary>
|
| | | public int LightLevelCount = -1;
|
| | | public int pirLux = -1;
|
| | | }
|
| | |
|
| | | #endregion
|
| | | |
| | | #region PIR传感器参数配置 |
| | | ///<summary > |
| | | ///PIR传感器参数配置 |
| | | /// </summary> |
| | | public async System.Threading.Tasks.Task<ResponseAllData> SetPIRSensorParamateAsync(ConfigureParamates configureParamates) |
| | | { |
| | | 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:0300_{ topic}");
|
| | | }
|
| | | }
|
| | | } |
| | | } |
| | | } |
| | | };
|
| | |
|
| | | Gateway.Actions += action;
|
| | | System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
| | | |
| | | try |
| | | { |
| | | var passData = SetPIRSensorData(configureParamates); |
| | | 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> |
| | | /// PIR配置参数回复 |
| | | /// </summary> |
| | | public ParamatesInfo paramatesInfo; |
| | | [System.Serializable] |
| | | public class ParamatesInfo |
| | | { |
| | | /// <summary> |
| | | /// 错误信息 |
| | | /// </summary> |
| | | public string errorMessageBase; |
| | | /// <summary> |
| | | /// 网关信息错误反馈 |
| | | /// <para>当网关接收到客户端信息后,出现以下异常情况将反馈错误。</para> |
| | | /// </summary> |
| | | public ErrorResponData errorResponData; |
| | | /// <summary> |
| | | /// PIR配置参数 |
| | | /// </summary> |
| | | public ConfigureParamates configureParamates; |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// PIR配置参数
|
| | | /// </summary>
|
| | | public ConfigureParamates configureParamates;
|
| | | /// <summary>
|
| | | /// PIR配置参数 |
| | | /// </summary> |
| | | [System.Serializable] |
| | | public class ConfigureParamates |
| | | { |
| | | /// <summary> |
| | | ///亮度(光照度)使能 |
| | | ///<para> false:不使能</para> |
| | | /// <para>true:使能</para> |
| | | /// </summary> |
| | | public bool levelEnable; |
| | | /// <summary> |
| | | /// 光照度等级
|
| | | /// <para>值:0-10</para> |
| | | /// </summary> |
| | | public int levelSize = -1; |
| | | /// <summary> |
| | | ///控制设备使能位 |
| | | ///<para> false:不使能</para> |
| | | /// <para>true:使能</para> |
| | | /// </summary> |
| | | public bool controlDevEnable; |
| | | /// <summary> |
| | | /// 触发开灯到触发关灯的时间间隔 |
| | | /// <para>0-65535 单位秒</para> |
| | | /// </summary> |
| | | public int transitionTime; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 配置PIR配置参数 |
| | | /// <para>发配置按键指示灯颜色命令时,此时为发送到网关的透传数据</para> |
| | | /// </summary> |
| | | string SetPIRSensorData(ConfigureParamates configureParamates) |
| | | { |
| | | string data = ""; |
| | | string dataLength = "09"; |
| | | string dataComand1 = "00"; |
| | | string dataComand2 = "03"; |
| | | string dataSerialNum = "01"; |
| | | string addDataLength = "05"; |
| | | string levelEnable = ""; |
| | | string levelSize = ""; |
| | | string controlDevEnable = ""; |
| | | string transitionTime = ""; |
| | | try |
| | | { |
| | | if (configureParamates != null) |
| | | { |
| | | if (configureParamates.levelEnable) |
| | | { |
| | | levelEnable = "01"; |
| | | } |
| | | else |
| | | { |
| | | levelEnable = "00"; |
| | | }
|
| | | //光照等级
|
| | | if (configureParamates.levelSize > 0)
|
| | | {
|
| | | levelSize = configureParamates.levelSize.ToString().PadLeft(2, '0');
|
| | | }
|
| | | else
|
| | | {
|
| | | levelSize = "00";
|
| | | } |
| | | |
| | | if (configureParamates.controlDevEnable) |
| | | { |
| | | controlDevEnable = "01"; |
| | | } |
| | | else |
| | | { |
| | | controlDevEnable = "00"; |
| | | } |
| | |
|
| | | var tempBytes = new byte[2];
|
| | | for (int i = 0; i < 2; i++)
|
| | | {
|
| | | tempBytes[i] = (byte)(configureParamates.transitionTime >> (i * 8) & 0xff);
|
| | | } |
| | | var time1 = Convert.ToString(tempBytes[0], 16);
|
| | | var time2 = Convert.ToString(tempBytes[1], 16);
|
| | | if (time1.Length == 1)
|
| | | {
|
| | | time1 = "0" + time1;
|
| | | }
|
| | | if (time2.Length == 1)
|
| | | {
|
| | | time2 = "0" + time2;
|
| | | }
|
| | | transitionTime = (time1 + time2).ToUpper(); |
| | | } |
| | | |
| | | data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + |
| | | levelEnable + levelSize + controlDevEnable + transitionTime; |
| | | } |
| | | catch { }; |
| | | |
| | | return data; |
| | | } |
| | | #endregion |
| | | |
| | | #region 获取PIR配置数据 |
| | | ///<summary > |
| | | ///PIR传感器参数配置 |
| | | /// <para>reserve:0-ff</para> |
| | | /// </summary> |
| | | public async System.Threading.Tasks.Task<ParamatesInfo> GetPIRSensorParamateAsync(string reserve = "01") |
| | | { |
| | | ParamatesInfo result = null; |
| | | if (Gateway == null) |
| | | { |
| | | result = new ParamatesInfo { 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 ParamatesInfo { errorMessageBase = "网关错误回复,且数据是空" }; |
| | | } |
| | | |
| | | else |
| | | { |
| | | result = new ParamatesInfo { 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 ParamatesInfo { errorMessageBase = "网关返回的数据为空" }; |
| | | } |
| | | else |
| | | { |
| | | if (gatewayTemp.clientDataPassthroughResponseData?.PassData != null) |
| | | { |
| | | var data = gatewayTemp.clientDataPassthroughResponseData.PassData; |
| | | if (data.Length == 20) |
| | | {
|
| | | var command = data[4].ToString() + data[5].ToString() + data[2].ToString() + data[3].ToString();
|
| | | if (command == "0302")
|
| | | {
|
| | | var le = data[10].ToString() + data[11].ToString();
|
| | | var tempD = new ConfigureParamates();
|
| | |
|
| | | if (le == "01")
|
| | | {
|
| | | tempD.levelEnable = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | tempD.levelEnable = false;
|
| | | }
|
| | |
|
| | | var size = data[12].ToString() + data[13].ToString();
|
| | | tempD.levelSize = Convert.ToInt32(size);
|
| | |
|
| | | var cdl = data[14].ToString() + data[15].ToString();
|
| | | if (cdl == "01")
|
| | | {
|
| | | tempD.controlDevEnable = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | tempD.controlDevEnable = false;
|
| | | }
|
| | |
|
| | | tempD.transitionTime = Convert.ToInt32(data[18].ToString() + data[19].ToString() + data[16].ToString() + data[17].ToString(), 16);
|
| | | configureParamates = tempD;
|
| | | result = new ParamatesInfo { configureParamates = tempD }; |
| | | System.Console.WriteLine($"UI收到通知后的主题_command:0301_{ topic}");
|
| | |
|
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | };
|
| | | |
| | | Gateway.Actions += action; |
| | | System.Console.WriteLine("ClientDataPassthrough_Actions 启动" + System.DateTime.Now.ToString());
|
| | | |
| | | try |
| | | {
|
| | | var passData = GetPIRSensorData(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 ParamatesInfo { errorMessageBase = " 回复超时,请重新操作" }; |
| | | } |
| | | Gateway.Actions -= action; |
| | | System.Console.WriteLine("ClientDataPassthrough_Actions 退出" + System.DateTime.Now.ToString()); |
| | | |
| | | return result; |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | ///PIR光照能力值 |
| | | /// <para>发配置按键指示灯颜色命令时,此时为发送到网关的透传数据</para> |
| | | /// </summary> |
| | | string GetPIRSensorData(string reserve) |
| | | { |
| | | string data = ""; |
| | | string dataLength = "05"; |
| | | string dataComand1 = "01"; |
| | | string dataComand2 = "03"; |
| | | string dataSerialNum = "01"; |
| | | string addDataLength = "01"; |
| | | string reserveData = reserve; |
| | | |
| | | try |
| | | { |
| | | data = dataLength + dataComand1 + dataComand2 + dataSerialNum + addDataLength + |
| | | reserveData; |
| | | } |
| | | catch { }; |
| | | |
| | | return data; |
| | | } |
| | | #endregion |
| | |
|
| | | |
| | | } |
| | | } |