using OrpaonEMS.Core.Enums; using OrpaonEMS.Core.EventHandMsg; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace OrpaonEMS.Core { /// /// 液冷自动控制 /// public class CoolAutoControl { public CoolAutoControl() { _CurCoolState = CoolState.AutoCycle; } /// /// 事件 /// public event EventHandler CoolCmdHandler; /// /// 设置的目标温度 /// public double SetTargetTemp { get; set; } = 25; /// /// 是否报警 /// public bool IsAlarm { get; set; } = false; /// /// 更新液冷状态 /// public void UpdateCoolState(bool AlarmState) { IsAlarm = AlarmState; } /// /// 更新回水温度值 /// public void UpdateValue(double OutTempValue) { //如果报警了,则不要进行下面的设置数据 if (IsAlarm) { CurCoolState = CoolState.Stop; return; } if (OutTempValue > 30)//大于30 启动制冷 { //设置制冷模式 CurCoolState = CoolState.Cool; return; } if (OutTempValue < 20) { //设置加热模式 CurCoolState = CoolState.Heat; return; } //达到目标值就会停止 if (OutTempValue <= (SetTargetTemp + 1) && OutTempValue >= (SetTargetTemp - 1)) { //设置停止模式 CurCoolState = CoolState.Stop; return; } } private CoolState _CurCoolState; /// /// 当前液冷状态 /// public CoolState CurCoolState { get { return _CurCoolState; } set { if (_CurCoolState != value) { switch (value) { case CoolState.Stop: CoolCmdHandler(this, new CoolValue() { CmdType = CoolState.Stop, TargetTemp = SetTargetTemp }); break; case CoolState.Cool: CoolCmdHandler(this, new CoolValue() { CmdType = CoolState.Cool, TargetTemp = SetTargetTemp }); break; case CoolState.Heat: CoolCmdHandler(this, new CoolValue() { CmdType = CoolState.Heat, TargetTemp = SetTargetTemp }); break; case CoolState.AutoCycle: CoolCmdHandler(this, new CoolValue() { CmdType = CoolState.AutoCycle, TargetTemp = SetTargetTemp }); break; default: break; } _CurCoolState = value; } } } } }