| | |
| | | public int currentCoolingSetpoint = 0; |
| | | |
| | | /// <summary> |
| | | /// 当前自动温度 |
| | | /// </summary> |
| | | public int currentAutoSetpoint; |
| | | |
| | | /// <summary> |
| | | ///恒温设备类型 |
| | | /// <para>恒温设备具备功能,Attribute Values如下</para> |
| | | /// <para>0:(Cooling Only) 无Heat和Emergency功能</para> |
| | |
| | | public int currentFanMode = 0; |
| | | |
| | | /// <summary> |
| | | /// 风扇zz扫风当前模式 |
| | | /// <para>0:1挡 </para> |
| | | /// <para>1:2</para> |
| | | /// <para>2:3</para> |
| | | /// <para>3:4 </para> |
| | | /// <para>4:5 </para> |
| | | /// <para>7:Auto </para> |
| | | /// </summary> |
| | | public int currentFanSwingMode = 0; |
| | | |
| | | /// <summary> |
| | | /// 支持的控制模式 |
| | | /// </summary> |
| | | public List<AcMode> acModes = new List<AcMode> { }; |
| | |
| | | /// 支持的风速模式 |
| | | /// </summary> |
| | | public List<FanMode> fanModes = new List<FanMode> { }; |
| | | /// <summary>
|
| | | /// <para>自定义空调支持的模式(默认全关)</para>
|
| | | /// <para>数组索引 -> 0:制冷 1:制热 2:送风 3:除湿 4:自动</para>
|
| | | /// <para>值 -> 1:代表使用 0:代表不使用</para>
|
| | | /// </summary> |
| | | public int[] listSupportMode = new int[5] { 0, 0, 0, 0, 0 }; |
| | | |
| | | /// <summary> |
| | | /// 过滤网清洗状态 |
| | | /// </summary> |
| | | public bool CleanStatu = false; |
| | | |
| | | /// <summary> |
| | | /// 获取当前室内温度. |
| | |
| | | public void ReadHeatingSetpoint() |
| | | { |
| | | ReadAttri(Device.Cluster_ID.Thermostat, AttriButeId.HeatingSetpoint); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取当前自动度数. |
| | | /// <para>AttriButeId=18 (先调用发现属性接口,查看设备是否支持该接口的属性)</para> |
| | | /// </summary> |
| | | public void ReadAutoSetpoint() |
| | | { |
| | | ReadAttri(Device.Cluster_ID.Thermostat, AttriButeId.AutoSetpoint); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | ReadAttri(Device.Cluster_ID.FanControl, AttriButeId.FanModeSequence); |
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 获取空调自定义设置的支持模式
|
| | | /// </summary> |
| | | public void ReadModeSupport()
|
| | | {
|
| | | ReadAttri(Device.Cluster_ID.Thermostat, AttriButeId.AcModeSupport);
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// 过滤网清洗状态 |
| | | /// </summary> |
| | | public void ReadCleanStatu() |
| | | { |
| | | ReadAttri(Device.Cluster_ID.Thermostat, AttriButeId.CleanStatu); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 扫风模式 |
| | | /// </summary> |
| | | public enum FanSwingMode |
| | | { |
| | | /// <summary> |
| | | /// 一档 |
| | | /// </summary> |
| | | First = 0, |
| | | /// <summary> |
| | | /// 二挡 |
| | | /// </summary> |
| | | Second = 1, |
| | | /// <summary> |
| | | /// 三挡 |
| | | /// </summary> |
| | | Thrid = 2, |
| | | /// <summary> |
| | | /// 四挡 |
| | | /// </summary> |
| | | Fourth = 3, |
| | | /// <summary> |
| | | /// 五档 |
| | | /// </summary> |
| | | Fifth = 4, |
| | | /// <summary> |
| | | /// 自动 |
| | | /// </summary> |
| | | Auto = 7 |
| | | } |
| | | /// <summary> |
| | | /// 获取扫风模式 |
| | | /// </summary> |
| | | public void ReadSystemFansSwingMode() |
| | | { |
| | | ReadAttri(Device.Cluster_ID.FanSwing, AttriButeId.FanSwing); |
| | | } |
| | | /// <summary> |
| | | /// 设置扫风模式 |
| | | /// </summary> |
| | | /// <param name="fanSwing"></param> |
| | | /// <returns></returns> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetFanSwingAsyncMode(FanSwingMode fanSwing) |
| | | { |
| | | 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 }; |
| | | DebugPrintLog($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | Gateway.Actions += action; |
| | | DebugPrintLog("SetWritableValue_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | try |
| | | { |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 514 }, { "Command", 120 } }; |
| | | var data = new JObject { { "Undivided", 0 }, { "AttributeId", 4096 }, { "AttributeDataType", 48 }, { "AttributeData", (int)fanSwing } }; |
| | | 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; |
| | | DebugPrintLog("SetWritableValue_Actions 退出" + System.DateTime.Now.ToString()); |
| | | return d; |
| | | }); |
| | | } |
| | | |
| | | |
| | | ///<summary > |
| | | ///设置制冷度数. |
| | |
| | | } |
| | | |
| | | ///<summary > |
| | | ///设置自动度数. |
| | | /// </summary> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetAutoTemperatureAsync(int temperature) |
| | | { |
| | | 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 }; |
| | | DebugPrintLog($"UI收到通知后的主题_{ topic}"); |
| | | } |
| | | } |
| | | }; |
| | | Gateway.Actions += action; |
| | | DebugPrintLog("SetWritableValue_Actions 启动" + "_" + System.DateTime.Now.ToString()); |
| | | try |
| | | { |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 513 }, { "Command", 120 } }; |
| | | var data = new JObject { { "Undivided", 0 }, { "AttributeId", 4096 }, { "AttributeDataType", 41 }, { "AttributeData", (int)temperature } }; |
| | | 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; |
| | | DebugPrintLog("SetWritableValue_Actions 退出" + System.DateTime.Now.ToString()); |
| | | return d; |
| | | }); |
| | | } |
| | | |
| | | ///<summary > |
| | | ///设置恒温器设备当前工作模式. |
| | | /// </summary> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetSystemModeAsync(AcMode acMode) |