134 lines
3.6 KiB
C#
134 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO.Ports;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Aurora.Api;
|
|
using Aurora.Api.DataType;
|
|
using Hermes;
|
|
|
|
namespace AuroraChiller
|
|
{
|
|
public class DongShinChillerMock : DongShinChillerBase {
|
|
public const string OP_GET = "01";
|
|
public const int OP_GET_COOLING_STATUS = 1;
|
|
public const int OP_GET_TARGET_TEMP = 2;
|
|
public const int OP_GET_LOW_TEMP1 = 3;
|
|
public const int OP_GET_LOW_TEMP2 = 4;
|
|
public const int OP_GET_HIGH_TEMP1 = 5;
|
|
public const int OP_GET_HIGH_TEMP2 = 6;
|
|
public const int OP_GET_CURRENT_TEMP = 7;
|
|
public const int OP_GET_ERROR = 8;
|
|
|
|
public const string OP_SET_COOLING_STATUS = "11";
|
|
public const string OP_SET_TARGET_TEMP = "12";
|
|
public const string OP_SET_LOW_TEMP1 = "13";
|
|
public const string OP_SET_LOW_TEMP2 = "14";
|
|
public const string OP_SET_HIGH_TEMP1 = "15";
|
|
public const string OP_SET_HIGH_TEMP2 = "16";
|
|
|
|
public const byte BYTE_STX = 0x02; // 02
|
|
public const byte BYTE_CR = 0x0D; // 13
|
|
public const byte BYTE_0 = 0x30; // 48
|
|
public const byte BYTE_1 = 0x31; // 49
|
|
public const byte BYTE_5 = 0x35; // 53
|
|
|
|
private bool coolingState = false;
|
|
private double targetTemp = 0.0;
|
|
private double lowTemp1 = 0.0;
|
|
private double lowTemp2 = 0.0;
|
|
private double highTemp1 = 0.0;
|
|
private double highTemp2 = 0.0;
|
|
|
|
public DongShinChillerMock(string deviceId) : base(deviceId) {
|
|
}
|
|
|
|
protected override int DoActivate(IDeviceConfig config) {
|
|
return Init();
|
|
}
|
|
|
|
private int Init() {
|
|
coolingState = true;
|
|
targetTemp = 200;
|
|
lowTemp1 = 0.0;
|
|
lowTemp2 = 0.0;
|
|
highTemp1 = 0.0;
|
|
highTemp2 = 0.0;
|
|
|
|
return E1.OK;
|
|
}
|
|
|
|
protected override int DoDeactivate() {
|
|
return E1.OK;
|
|
}
|
|
|
|
#region Set
|
|
public override bool SetCooling(bool bOn) {
|
|
coolingState = bOn;
|
|
return true;
|
|
}
|
|
|
|
public override bool SetTargetTemp(double temp) {
|
|
targetTemp = temp;
|
|
return true;
|
|
}
|
|
|
|
public override bool SetLowTemp1(double temp) {
|
|
lowTemp1 = temp;
|
|
return true;
|
|
}
|
|
|
|
public override bool SetLowTemp2(double temp) {
|
|
lowTemp2 = temp;
|
|
return true;
|
|
}
|
|
|
|
public override bool SetHighTemp1(double temp) {
|
|
highTemp1 = temp;
|
|
return true;
|
|
}
|
|
|
|
public override bool SetHighTemp2(double temp) {
|
|
highTemp2 = temp;
|
|
return true;
|
|
}
|
|
#endregion
|
|
|
|
#region Get
|
|
public override int GetCoolingOnStatus() {
|
|
coolingState = !coolingState;
|
|
return Convert.ToInt32(coolingState);
|
|
}
|
|
|
|
public override double GetTargetTemp() {
|
|
return targetTemp;
|
|
}
|
|
|
|
public override double GetLowTemp1() {
|
|
return lowTemp1;
|
|
}
|
|
|
|
public override double GetLowTemp2() {
|
|
return lowTemp2;
|
|
}
|
|
|
|
public override double GetHighTemp1() {
|
|
return highTemp1;
|
|
}
|
|
|
|
public override double GetHighTemp2() {
|
|
return highTemp2;
|
|
}
|
|
|
|
public override double GetCurrentTemp() {
|
|
return (new Random()).Next(100, 200);
|
|
}
|
|
|
|
public override int GetError() {
|
|
return 0;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|