| | |
| | | [System.Serializable] |
| | | public class FreshAir : CommonDevice |
| | | { |
| | | /// <summary> |
| | | /// 该类(新风对象)包含新风设备和新风面板 |
| | | /// </summary> |
| | | public FreshAir() |
| | | { |
| | | this.Type = DeviceType.FreshAir; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 恒温设备当前模式 |
| | | /// <para>恒温设备具备功能,SystemMode Attribute Values如下</para> |
| | | /// <para>0:Off </para> |
| | | /// <para>1:Auto </para> |
| | | /// <para>3:Cool </para> |
| | | /// <para>4:Heat </para> |
| | | /// <para>5:Emergency heating </para> |
| | | /// <para>6:Precooling</para> |
| | | /// <para>7:Fan only </para> |
| | | /// <para>8:Dry </para> |
| | | /// <para>9:Sleep</para> |
| | | /// 风速模式 |
| | | /// <para>5:自动</para> |
| | | /// <para>6:Smart</para> |
| | | /// <para>15:手动</para> |
| | | /// </summary> |
| | | public int currentSystemMode = 0; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int currentFanMode = 0; |
| | | /// <summary> |
| | | /// 风速档位 |
| | | /// <para>1:低风</para> |
| | | /// <para>2:中风</para> |
| | | /// <para>3:高风 </para> |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int currentFanSpeed = 0; |
| | | /// <summary> |
| | | /// 风扇状态 |
| | | /// <para>0:关闭 </para> |
| | | /// <para>4:打开 </para> |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public int currentFanStatus = 0; |
| | | |
| | | /// <summary> |
| | | /// 关闭 |
| | | /// </summary> |
| | | /// <returns>The close.</returns> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> Close() |
| | | { |
| | | return await SetFanModeAsync(FanMode.Off); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 开启 |
| | | /// </summary> |
| | | /// <returns>The open.</returns> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> Open() |
| | | { |
| | | return await SetFanModeAsync(FanMode.On); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 高风 |
| | | /// </summary> |
| | | /// <returns>The close.</returns> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetHighSpeed() |
| | | { |
| | | return await SetFanModeAsync(FanMode.High); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 低风 |
| | | /// </summary> |
| | | /// <returns>The open.</returns> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetLowSpeed() |
| | | { |
| | | return await SetFanModeAsync(FanMode.Low); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 手动 |
| | | /// </summary> |
| | | /// <returns>The close.</returns> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetManual() |
| | | { |
| | | return await SetFanModeAsync(FanMode.Manual); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 自动 |
| | | /// </summary> |
| | | /// <returns>The open.</returns> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetAuto() |
| | | { |
| | | return await SetFanModeAsync(FanMode.Auto); |
| | | } |
| | | |
| | | ///<summary > |
| | | ///设置恒温器设备当前工作模式. |
| | | ///设置恒温器设备当前风速. |
| | | /// </summary> |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetSystemModeAsync(AcMode acMode) |
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> SetFanModeAsync(FanMode fanMode) |
| | | { |
| | | if (Gateway == null) |
| | | { |
| | |
| | | |
| | | 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 + "/" + "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) |
| | |
| | | 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", 28 }, { "AttributeDataType", 48 }, { "AttributeData", (int)acMode } }; |
| | | var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", 514 }, { "Command", 120 } }; |
| | | var data = new JObject { { "Undivided", 0 }, { "AttributeId", 0 }, { "AttributeDataType", 48 }, { "AttributeData", (int)fanMode } }; |
| | | jObject.Add("Data", data); |
| | | Gateway.Send("SetWritableValue", jObject.ToString()); |
| | | } |
| | |
| | | }); |
| | | } |
| | | |
| | | public enum AcMode |
| | | |
| | | #region ◆ 当前新风开关状态____________________ |
| | | |
| | | /// <summary> |
| | | /// 当前新风开关状态 |
| | | /// </summary> |
| | | /// <param name="freshAir"></param> |
| | | /// <returns></returns> |
| | | public bool IsOpen(FreshAir freshAir) |
| | | { |
| | | if (freshAir.currentFanStatus == 4) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | | /// 风速档位 |
| | | /// </summary> |
| | | public enum FanMode |
| | | { |
| | | /// <summary> |
| | | /// 关闭模式(测试恒温面板时发现:2,5,6,7,8,9都是可以打开的) |
| | | /// 关闭 |
| | | /// </summary> |
| | | Off = 0, |
| | | /// <summary> |
| | | /// 自动模式 |
| | | /// 低风 |
| | | /// </summary> |
| | | Auto = 1, |
| | | Low = 1, |
| | | /// <summary> |
| | | /// 制冷模式 |
| | | /// 中风 |
| | | /// </summary> |
| | | Cool = 3, |
| | | Medium = 2, |
| | | /// <summary> |
| | | /// 制热模式 |
| | | /// 高风 |
| | | /// </summary> |
| | | Heat = 4, |
| | | High = 3, |
| | | /// <summary> |
| | | /// 紧急制热模式 |
| | | /// 打开 |
| | | /// </summary> |
| | | EmergencyHeating = 5, |
| | | On = 4, |
| | | /// <summary> |
| | | /// 预冷模式 |
| | | /// 自动 |
| | | /// </summary> |
| | | Precooling = 6, |
| | | Auto = 5, |
| | | /// <summary> |
| | | /// 只有风速模式 |
| | | /// Smart |
| | | /// </summary> |
| | | FanOnly = 7, |
| | | Smart = 6, |
| | | /// <summary> |
| | | /// 干燥模式 |
| | | /// 手动 |
| | | /// </summary> |
| | | Dry = 8, |
| | | /// <summary> |
| | | /// 睡眠模式 |
| | | /// </summary> |
| | | Sleep = 9 |
| | | } |
| | | |
| | | /// <summary>
|
| | | /// 关闭
|
| | | /// </summary>
|
| | | /// <returns>The close.</returns>
|
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> Close()
|
| | | {
|
| | | return await SetSystemModeAsync(AcMode.Off);
|
| | | Manual = 15, |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 开启
|
| | | /// </summary>
|
| | | /// <returns>The open.</returns>
|
| | | /// <param name="acMode">Ac mode.</param>
|
| | | public async System.Threading.Tasks.Task<SetWritableValueResponAllData> Open(AcMode acMode = AcMode.Cool)
|
| | | {
|
| | | return await SetSystemModeAsync(acMode);
|
| | | } |
| | | } |
| | | } |