using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using Shared.SimpleControl.Phone;
|
|
namespace Shared
|
{
|
[System.Serializable]
|
public class FoolHeat:Common
|
{
|
public FoolHeat ()
|
{
|
this.Type = DeviceType.FoolHeat;;
|
DeviceTextID = SimpleControl.R.MyInternationalizationString.FoolHeat;
|
}
|
|
/// <summary>
|
/// 工作模式
|
/// 0制热,1制冷,2,3
|
/// </summary>
|
public byte WorkingMode = 0;
|
/// <summary>
|
/// 温度模式
|
/// </summary>
|
public byte TemperatureTypeValue;
|
|
/// <summary>
|
/// 温度模式
|
/// 1 = Normal, 2 = Day , 3 = Night, 4 = Away, 5 = Timer
|
/// </summary>
|
public byte TemperatureType;
|
|
public byte NormalTemperature;
|
|
public byte DayTemperature;
|
|
public byte NightTemperature;
|
|
public byte AwayTemperature;
|
|
public byte Timer;//0 = Day, 1 = Night
|
|
public byte Status;
|
/// <summary>
|
/// 阀的开关状态(0--关 1--开)
|
/// </summary>
|
public byte PWDStatus;
|
public byte PWDValue;//0-100
|
|
public byte WateringFlag;
|
|
public byte WateringTime;
|
|
/// <summary>
|
/// 工作温度
|
/// </summary>
|
public byte WorkingTemperature =5;
|
public byte PIDSpeed;
|
public byte IndoorTemperature;
|
public byte FloorTemperature;
|
|
public byte[] FH_Bytes;
|
|
public FoolHeat Serverx_FH_CMD (CommandType commandType, byte[] updataBytes = null)
|
{
|
if (updataBytes != null)
|
FH_Bytes = updataBytes;
|
if (commandType == CommandType.Read) {
|
FH_Bytes = Control.ControlBytesSendHasReturn (Command.ReadFoolHeat, SubnetID, DeviceID, new byte [] { LoopID });
|
return this;
|
}
|
if (FH_Bytes == null)
|
return this;
|
if (commandType == CommandType.Switch || commandType == CommandType.WorkMode) {
|
FH_Bytes = Control.ControlBytesSendHasReturn (Command.SetFoolHeat, SubnetID, DeviceID, new byte [] { LoopID, (byte)(Status + WorkingMode * 16), FH_Bytes [2], FH_Bytes [3], FH_Bytes [4], FH_Bytes [5], FH_Bytes [6], FH_Bytes [7], 0, 0 });
|
return this;
|
} else if (commandType == CommandType.Temperatrue) {
|
switch (TemperatureType) {
|
case 1://普通
|
FH_Bytes [4] = this.WorkingTemperature;
|
break;
|
case 2://白天
|
FH_Bytes [5] = this.WorkingTemperature;
|
break;
|
case 3://夜晚
|
FH_Bytes [6] = this.WorkingTemperature;
|
break;
|
case 4://离开
|
FH_Bytes [7] = this.WorkingTemperature;
|
break;
|
case 5://时间模式
|
if (FH_Bytes [8] == 1)//时间模式的时间段标志 (0:白天,1:夜晚) (1byte) //20110112加时间段标志
|
FH_Bytes [4] = this.WorkingTemperature;
|
else
|
FH_Bytes [5] = this.WorkingTemperature;
|
break;
|
}
|
FH_Bytes = Control.ControlBytesSendHasReturn (Command.SetFoolHeat, SubnetID, DeviceID, new byte [] { LoopID, FH_Bytes [1], FH_Bytes [2], FH_Bytes [3], FH_Bytes [4], FH_Bytes [5], FH_Bytes [6], FH_Bytes [7], 0, 0 });
|
return this;
|
} else if (commandType == CommandType.TemperatrueMode) {
|
FH_Bytes = Control.ControlBytesSendHasReturn (Command.SetFoolHeat, SubnetID, DeviceID, new byte [] { LoopID, FH_Bytes [1], FH_Bytes [2], TemperatureType, FH_Bytes [4], FH_Bytes [5], FH_Bytes [6], FH_Bytes [7], 0, 0 });
|
return this;
|
}
|
|
this.WorkingMode = FH_Bytes [1] > 10 ? (byte)1 : (byte)0;
|
this.Status = (byte)(FH_Bytes [1] % 2);
|
this.TemperatureType = FH_Bytes [3];
|
switch (FH_Bytes [3]) {
|
case 1://普通
|
this.WorkingTemperature = FH_Bytes [4];
|
break;
|
case 2://白天
|
this.WorkingTemperature = FH_Bytes [5];
|
break;
|
case 3://夜晚
|
this.WorkingTemperature = FH_Bytes [6];
|
break;
|
case 4://离开
|
this.WorkingTemperature = FH_Bytes [7];
|
break;
|
case 5://时间模式
|
if (FH_Bytes [8] == 1)//时间模式的时间段标志 (0:白天,1:夜晚) (1byte) //20110112加时间段标志
|
this.WorkingTemperature = FH_Bytes [5];
|
else
|
this.WorkingTemperature = FH_Bytes [6];
|
break;
|
}
|
this.IndoorTemperature = FH_Bytes [9] > 128 ? (byte)(0 - (FH_Bytes [9] - 128)) : FH_Bytes [9];
|
this.PWDStatus = FH_Bytes [10];
|
this.PWDValue = FH_Bytes [11];
|
this.WateringFlag = FH_Bytes [12];
|
this.WateringTime = FH_Bytes [13];
|
if (updataBytes != null && commandType == CommandType.Null) {
|
if (Application.IsPad) {
|
//SimpleControl.Pad.UserFHPage.UpdateStatus (this);
|
} else {
|
UserDeviceToFH.UpdateStatus (this);
|
UserFHPage.UpdateStatus (this);
|
UserRoom.UpdataDeviceStatus (this);
|
}
|
}
|
IO.FileUtils.SaveEquipmentMessage (this, this.LoopID.ToString ());
|
return this;
|
}
|
|
public enum CommandType
|
{
|
Read = 0,
|
Switch = 1,
|
Temperatrue =3,
|
TemperatrueMode = 7,
|
WorkMode = 9,
|
Null = 999,
|
}
|
}
|
}
|