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 = 104; //SimpleControl.R.MyInternationalizationString.FoolHeat;
}
///
/// 工作模式
/// 0制热,1制冷,2,3
///
public byte WorkingMode = 0;
///
/// 温度模式
/// 1 = Normal, 2 = Day , 3 = Night, 4 = Away, 5 = Timer
///
public byte TemperatureType;
///
/// 正常模式工作温度
///
public byte NormalTemperature;
///
/// 白天模式工作温度
///
public byte DayTemperature;
///
/// 晚上模式工作温度
///
public byte NightTemperature;
///
/// 离开模式工作温度
///
public byte AwayTemperature;
///
/// 时间模式工作标记
/// 0 = Day, 1 = Night
///
public byte Timer;//
///
/// 开关状态
///
public byte Status;
///
/// 阀的开关状态(0--关 1--开)
///
public byte PWDStatus;
public byte PWDValue;//0-100
///
/// 清洗标记
///
public byte WateringFlag;
///
/// 清洗时间
///
public byte WateringTime;
///
/// 工作温度
///
public byte WorkingTemperature =5;
///
/// The PIDS peed.
///
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, updataBytes[0]);
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,
}
}
}