refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
+376
@@ -0,0 +1,376 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aitex.Core.Common.DeviceData;
|
||||
using Aitex.Core.RT.DataCenter;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Core.RT.Log;
|
||||
using Aitex.Core.RT.SCCore;
|
||||
using Aitex.Core.Util;
|
||||
using MECF.Framework.Common.Communications;
|
||||
using MECF.Framework.Common.Device.Bases;
|
||||
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TurboPumps.Pfeiffer
|
||||
{
|
||||
|
||||
public class PumpMagpower : PumpBase
|
||||
{
|
||||
public override bool IsError
|
||||
{
|
||||
get { return !string.IsNullOrEmpty(_errorCode); }
|
||||
}
|
||||
|
||||
public string ErrorCode { get { return _errorCode; } }
|
||||
|
||||
public override bool IsOn
|
||||
{
|
||||
get { return _isOn; }
|
||||
}
|
||||
|
||||
public override float Speed
|
||||
{
|
||||
get { return _speed; }
|
||||
}
|
||||
|
||||
public override float Temperature
|
||||
{
|
||||
get { return _temperature; }
|
||||
}
|
||||
|
||||
public override bool IsStable
|
||||
{
|
||||
get { return _isStable; }
|
||||
}
|
||||
|
||||
public bool IsRemote
|
||||
{
|
||||
get { return _isRemote; }
|
||||
}
|
||||
|
||||
public override AITPumpData DeviceData
|
||||
{
|
||||
get
|
||||
{
|
||||
AITPumpData data = new AITPumpData()
|
||||
{
|
||||
DeviceName = Name,
|
||||
DeviceSchematicId = DeviceID,
|
||||
DisplayName = Display,
|
||||
|
||||
DeviceModule = Module,
|
||||
|
||||
IsError = IsError,
|
||||
IsOn = _isOn,
|
||||
|
||||
Speed = _speed,
|
||||
Temperature = _temperature,
|
||||
|
||||
AtSpeed = _isAtSpeed,
|
||||
OverTemp = _isOverTemp,
|
||||
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
private PumpMagpowerConnection _connection;
|
||||
|
||||
public string DeviceAddress { get; set; } = "001";
|
||||
|
||||
//private string DeviceAddress = "001";
|
||||
|
||||
private int _speed;
|
||||
private int _temperature;
|
||||
private bool _isOn;
|
||||
private int _power;
|
||||
private bool _isAccelerate;
|
||||
private bool _isAtSpeed;
|
||||
private bool _isOverTemp;
|
||||
private bool _isStable;
|
||||
private bool _isRemote;
|
||||
private bool _activeMonitorStatus;
|
||||
|
||||
private string _errorCode;
|
||||
|
||||
private RD_TRIG _trigPumpOnOff = new RD_TRIG();
|
||||
private R_TRIG _trigError = new R_TRIG();
|
||||
private R_TRIG _trigOverTemp = new R_TRIG();
|
||||
|
||||
private R_TRIG _trigWarningMessage = new R_TRIG();
|
||||
private string _lastError = string.Empty;
|
||||
private R_TRIG _trigCommunicationError = new R_TRIG();
|
||||
private R_TRIG _trigRetryConnect = new R_TRIG();
|
||||
|
||||
private PeriodicJob _thread;
|
||||
|
||||
private LinkedList<HandlerBase> _lstHandler = new LinkedList<HandlerBase>();
|
||||
private object _locker = new object();
|
||||
|
||||
private bool _enableLog = true;
|
||||
|
||||
private string _scRoot;
|
||||
private bool _isNormalSpeed;
|
||||
|
||||
public bool IsNormalSpeed { get { return _isNormalSpeed; } }
|
||||
|
||||
public PumpMagpower(string module, string name, string scRoot) : base(module, name)
|
||||
{
|
||||
_scRoot = scRoot;
|
||||
|
||||
_activeMonitorStatus = true;
|
||||
|
||||
_power = 0;
|
||||
}
|
||||
|
||||
public override bool Initialize()
|
||||
{
|
||||
if (_connection != null && _connection.IsConnected)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
base.Initialize();
|
||||
|
||||
DATA.Subscribe($"{Module}.{Name}.Power", () => _power);
|
||||
|
||||
DATA.Subscribe($"{Module}.{Name}.ErrorCode", () => _errorCode);
|
||||
DATA.Subscribe($"{Module}.{Name}.IsAtSpeed", () => _isAtSpeed);
|
||||
DATA.Subscribe($"{Module}.{Name}.IsAccelerate", () => _isAccelerate);
|
||||
|
||||
string portName = SC.GetStringValue($"{(!string.IsNullOrEmpty(_scRoot) ? _scRoot+"." : "")}{Module}.{Name}.Address");
|
||||
int address = SC.ContainsItem($"{(!string.IsNullOrEmpty(_scRoot) ? _scRoot + "." : "")}{Module}.{Name}.DeviceAddress") ? SC.GetValue<int>($"{(!string.IsNullOrEmpty(_scRoot) ? _scRoot + "." : "")}{Module}.{Name}.DeviceAddress") : 0;
|
||||
DeviceAddress = address.ToString("D3");
|
||||
_enableLog = SC.GetValue<bool>($"{(!string.IsNullOrEmpty(_scRoot) ? _scRoot + "." : "")}{Module}.{Name}.EnableLogMessage");
|
||||
|
||||
_connection = new PumpMagpowerConnection(portName);
|
||||
_connection.EnableLog(_enableLog);
|
||||
|
||||
if (_connection.Connect())
|
||||
{
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} connected");
|
||||
}
|
||||
|
||||
_thread = new PeriodicJob(300, OnTimer, $"{Module}.{Name} MonitorHandler", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool OnTimer()
|
||||
{
|
||||
try
|
||||
{
|
||||
//_connection.MonitorTimeout();
|
||||
|
||||
if (!_connection.IsConnected || _connection.IsCommunicationError)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.Clear();
|
||||
}
|
||||
|
||||
_trigRetryConnect.CLK = !_connection.IsConnected;
|
||||
if (_trigRetryConnect.Q)
|
||||
{
|
||||
_connection.SetPortAddress(SC.GetStringValue($"{Module}.{Name}.Address"));
|
||||
if (!_connection.Connect())
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
HandlerBase handler = null;
|
||||
if (!_connection.IsBusy)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (_lstHandler.Count == 0 && _activeMonitorStatus)
|
||||
{
|
||||
_lstHandler.AddLast(new MagpowerQueryErrorHandler(this));
|
||||
_lstHandler.AddLast(new MagpowerQuerySpeedHandler(this));
|
||||
_lstHandler.AddLast(new MagpowerQueryStatusHandler(this));
|
||||
_lstHandler.AddLast(new MagpowerQueryOptionHandler(this));
|
||||
}
|
||||
|
||||
if (_lstHandler.Count > 0)
|
||||
{
|
||||
handler = _lstHandler.First.Value;
|
||||
|
||||
_lstHandler.RemoveFirst();
|
||||
}
|
||||
}
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
_connection.Execute(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Monitor()
|
||||
{
|
||||
try
|
||||
{
|
||||
_connection.EnableLog(_enableLog);
|
||||
|
||||
_trigPumpOnOff.CLK = _isOn;
|
||||
if (_trigPumpOnOff.R)
|
||||
{
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} is on");
|
||||
}
|
||||
|
||||
if (_trigPumpOnOff.T)
|
||||
{
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} is off");
|
||||
}
|
||||
|
||||
_trigError.CLK = IsError;
|
||||
if (_trigError.Q)
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"{Module}.{Name} is error, error code {_errorCode:D3}");
|
||||
}
|
||||
|
||||
_trigOverTemp.CLK = _isOverTemp;
|
||||
if (_trigOverTemp.Q)
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"{Module}.{Name} is over temperature");
|
||||
}
|
||||
|
||||
_trigCommunicationError.CLK = _connection.IsCommunicationError;
|
||||
if (_trigCommunicationError.Q)
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
_trigError.RST = true;
|
||||
_trigOverTemp.RST = true;
|
||||
_trigWarningMessage.RST = true;
|
||||
|
||||
_connection.SetCommunicationError(false, "");
|
||||
_trigCommunicationError.RST = true;
|
||||
|
||||
_enableLog = SC.GetValue<bool>($"{Module}.{Name}.EnableLogMessage");
|
||||
|
||||
_trigRetryConnect.RST = true;
|
||||
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
public override void SetPumpOnOff(bool isOn)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new MagpowerPumpStationHandler(this, isOn));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Echo(bool isOn)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new MagpowerPumpStationHandler(this, isOn));
|
||||
}
|
||||
}
|
||||
public void SwitchSpeed(bool isNormal)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new MagpowerSwitchSpeedHandler(this, isNormal));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetActiveMonitor(bool active)
|
||||
{
|
||||
_activeMonitorStatus = active;
|
||||
}
|
||||
|
||||
|
||||
internal void NoteOnOff(bool isOn)
|
||||
{
|
||||
_isOn = isOn;
|
||||
}
|
||||
internal void NoteRemote(bool isRemote)
|
||||
{
|
||||
_isRemote = isRemote;
|
||||
}
|
||||
internal void NoteNormalSpeed(bool isNormal)
|
||||
{
|
||||
_isNormalSpeed = isNormal;
|
||||
}
|
||||
|
||||
public void SetSpeed(int speed)
|
||||
{
|
||||
_speed = speed;
|
||||
}
|
||||
|
||||
public void SetTemperature(int temperature)
|
||||
{
|
||||
_temperature = temperature;
|
||||
}
|
||||
|
||||
public void SetErrorCode(string errorCode)
|
||||
{
|
||||
_errorCode = errorCode;
|
||||
}
|
||||
|
||||
public void SetAtSpeed(bool atSpeed)
|
||||
{
|
||||
_isAtSpeed = atSpeed;
|
||||
}
|
||||
|
||||
public void SetOverTemp(bool overTemp)
|
||||
{
|
||||
_isOverTemp = overTemp;
|
||||
}
|
||||
|
||||
public void NoteStable(bool stable)
|
||||
{
|
||||
if(_isStable != stable)
|
||||
_isStable = stable;
|
||||
}
|
||||
|
||||
public void NoteAccelerate(bool isAccelerate)
|
||||
{
|
||||
_isAccelerate = isAccelerate;
|
||||
}
|
||||
|
||||
public void NoteError(string reason)
|
||||
{
|
||||
_trigWarningMessage.CLK = true;
|
||||
if (_trigWarningMessage.Q)
|
||||
{
|
||||
EV.PostWarningLog(Module, $"{Module}.{Name} error, {reason}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void NoteInfo(string info)
|
||||
{
|
||||
_trigWarningMessage.CLK = true;
|
||||
if (_trigWarningMessage.Q)
|
||||
{
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} info, {info}");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TurboPumps.Pfeiffer
|
||||
{
|
||||
|
||||
public class MagpowerMessage : AsciiMessage
|
||||
{
|
||||
public string DeviceAddress { get; set; }
|
||||
//public string Action { get; set; }
|
||||
//public string Parameter { get; set; }
|
||||
//public int DataLength { get; set; }
|
||||
public string Data { get; set; }
|
||||
public string ErrorText { get; set; }
|
||||
}
|
||||
|
||||
public class PumpMagpowerConnection : SerialPortConnectionBase
|
||||
{
|
||||
public PumpMagpowerConnection(string portName) : base(portName)
|
||||
{
|
||||
|
||||
}
|
||||
//#adr,ok
|
||||
//#adr,nnnnn,sssss,00000,0,ccccc,eeeee,ddddd,pppp,qqqq,jj,kk,lll,mmm
|
||||
//#adr,nnnnn rpm
|
||||
protected override MessageBase ParseResponse(string rawText)
|
||||
{
|
||||
MagpowerMessage msg = new MagpowerMessage();
|
||||
msg.RawMessage = rawText;
|
||||
|
||||
if (rawText.Length <= 4)
|
||||
{
|
||||
LOG.Error($"response length check failed, " + rawText);
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
msg.MessagePart = new string[2];
|
||||
int seperatorIndex = rawText.IndexOf(',');
|
||||
if(seperatorIndex != 4)
|
||||
{
|
||||
LOG.Error($"response format check failed, " + rawText);
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
msg.MessagePart[0] = rawText.Substring(1, 3); //device address
|
||||
msg.MessagePart[1] = rawText.Substring(5, rawText.Length - 6); //data
|
||||
msg.DeviceAddress = msg.MessagePart[0];
|
||||
msg.Data = msg.MessagePart[1];
|
||||
|
||||
if (msg.Data.Contains("Err"))
|
||||
{
|
||||
msg.IsError = true;
|
||||
}
|
||||
|
||||
msg.IsResponse = true;
|
||||
msg.IsAck = true;
|
||||
msg.IsComplete = true;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
using System.Linq;
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TurboPumps.Pfeiffer
|
||||
{
|
||||
|
||||
public abstract class PumpMagpowerHandler : HandlerBase
|
||||
{
|
||||
protected const string QueryDataText = "=?";
|
||||
|
||||
protected PumpMagpower _pump;
|
||||
|
||||
protected PumpMagpowerHandler(PumpMagpower pump, string command, string parameter = null)
|
||||
: base(BuildMessage(pump.DeviceAddress, command, parameter))
|
||||
{
|
||||
_pump = pump;
|
||||
}
|
||||
|
||||
|
||||
private static string BuildMessage(string deviceAddress, string command, string parameter)
|
||||
{
|
||||
string msg = parameter == null ? $"#{deviceAddress}{command}" : $"#{deviceAddress}{command} {parameter}";
|
||||
|
||||
return msg + "\r";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int CalcSum(string value)
|
||||
{
|
||||
int sum = 0;
|
||||
foreach (var item in value)
|
||||
{
|
||||
sum += (int)item;
|
||||
}
|
||||
|
||||
return sum % 256;
|
||||
}
|
||||
}
|
||||
|
||||
public class MagpowerPumpStationHandler : PumpMagpowerHandler
|
||||
{
|
||||
public MagpowerPumpStationHandler(PumpMagpower pump, bool isOn)
|
||||
: base(pump, isOn ? "TMPON" : "TMPOFF")
|
||||
{
|
||||
Name = "Pump " + (isOn ? "On" : "Off");
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as MagpowerMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
_pump.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pump.NoteOnOff(Name == "Pump On");
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//023
|
||||
public class MagpowerSwitchSpeedHandler : PumpMagpowerHandler
|
||||
{
|
||||
public MagpowerSwitchSpeedHandler(PumpMagpower pump, bool isNormal)
|
||||
: base(pump, isNormal ? "NSP" : "SBY")
|
||||
{
|
||||
Name = "SwitchSpeed " + (isNormal ? "Normal" : "Standby");
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as MagpowerMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
_pump.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pump.NoteNormalSpeed(Name.Contains("Normal"));
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//303
|
||||
public class MagpowerQueryErrorHandler : PumpMagpowerHandler
|
||||
{
|
||||
public MagpowerQueryErrorHandler(PumpMagpower pump)
|
||||
: base(pump, "DEF")
|
||||
{
|
||||
Name = "Query Error";
|
||||
}
|
||||
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as MagpowerMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
_pump.SetErrorCode(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pump.SetErrorCode("");
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//398
|
||||
public class MagpowerQuerySpeedHandler : PumpMagpowerHandler
|
||||
{
|
||||
public MagpowerQuerySpeedHandler(PumpMagpower pump)
|
||||
: base(pump, "SPD")
|
||||
{
|
||||
Name = "Query Speed";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as MagpowerMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
_pump.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dataArray = result.Data.Split(' ');
|
||||
if (dataArray.Count() == 2 && int.TryParse(dataArray[0], out int value))
|
||||
{
|
||||
_pump.SetSpeed(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pump.NoteError(result.Data + "format error");
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//346
|
||||
public class MagpowerQueryStatusHandler : PumpMagpowerHandler
|
||||
{
|
||||
public MagpowerQueryStatusHandler(PumpMagpower pump)
|
||||
: base(pump, "STA")
|
||||
{
|
||||
Name = "Query Status";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
//sss, rrrrr, vvv, www, xxx, yyy, zzz, aa, bbbbb, ccc, ddd, ggggggggggggggggggggggggg
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
var result = msg as MagpowerMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
_pump.NoteError(result.Data);
|
||||
return true;
|
||||
}
|
||||
var dataArray = result.Data.Split(',');
|
||||
bool isFormat = dataArray.Count() == 12;
|
||||
|
||||
if (!isFormat)
|
||||
{
|
||||
_pump.NoteError(result.Data + "format error");
|
||||
return true;
|
||||
}
|
||||
|
||||
string sss = dataArray[0].Trim();
|
||||
isFormat = sss.Length == 3;
|
||||
if (!isFormat)
|
||||
{
|
||||
_pump.NoteError(result.Data + "format error");
|
||||
return true;
|
||||
}
|
||||
int pumpStatus = sss.ElementAt(1);
|
||||
_pump.NoteStable((pumpStatus & 0b_0000_1000) > 0);
|
||||
_pump.NoteAccelerate((pumpStatus & 0b_0000_0100) > 0);
|
||||
|
||||
|
||||
int valveStatus = sss.ElementAt(2);
|
||||
_pump.SetAtSpeed((valveStatus & 0b_0100_0000) > 0);
|
||||
|
||||
string ccc = dataArray[9].Trim();
|
||||
_pump.SetTemperature(int.Parse(ccc));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class MagpowerQueryOptionHandler : PumpMagpowerHandler
|
||||
{
|
||||
public MagpowerQueryOptionHandler(PumpMagpower pump)
|
||||
: base(pump, "SEL10")
|
||||
{
|
||||
Name = "Query Status";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
//a,u,1,b,r
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
var result = msg as MagpowerMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
_pump.NoteError(result.Data);
|
||||
return true;
|
||||
}
|
||||
var dataArray = result.Data.Split(',');
|
||||
bool isFormat = dataArray.Count() == 5;
|
||||
|
||||
if (!isFormat)
|
||||
{
|
||||
_pump.NoteError(result.Data + "format error");
|
||||
return true;
|
||||
}
|
||||
|
||||
string r = dataArray[4].Trim();
|
||||
if(r == "1")
|
||||
{
|
||||
_pump.NoteRemote(true);
|
||||
}
|
||||
else if(r == "0")
|
||||
{
|
||||
_pump.NoteRemote(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pump.NoteError(result.Data + "format error");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class MagpowerEchoHandler : PumpMagpowerHandler
|
||||
{
|
||||
public MagpowerEchoHandler(PumpMagpower pump, bool isOn)
|
||||
: base(pump, isOn ? "ECHON" : "ECHOFF")
|
||||
{
|
||||
Name = "Echo " + (isOn ? "On" : "Off");
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as MagpowerMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
_pump.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pump.NoteInfo(Name);
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TurboPumps.PfeifferHipace
|
||||
{
|
||||
public class HipaceMessage : AsciiMessage
|
||||
{
|
||||
public string DeviceAddress { get; set; }
|
||||
public string Action { get; set; }
|
||||
public string Parameter { get; set; }
|
||||
public int DataLength { get; set; }
|
||||
public string Data { get; set; }
|
||||
public string ErrorText { get; set; }
|
||||
}
|
||||
|
||||
public class HipaceConnection : SerialPortConnectionBase
|
||||
{
|
||||
public HipaceConnection(string portName) : base(portName)
|
||||
{
|
||||
|
||||
}
|
||||
protected override MessageBase ParseResponse(string rawText)
|
||||
{
|
||||
HipaceMessage msg = new HipaceMessage();
|
||||
msg.RawMessage = rawText;
|
||||
|
||||
if (rawText.Length <= 14)
|
||||
{
|
||||
LOG.Error($"text length check failed, " + rawText);
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
msg.MessagePart = new string[6];
|
||||
|
||||
msg.MessagePart[0] = rawText.Substring(0, 3); //device address
|
||||
msg.MessagePart[1] = rawText.Substring(3, 2); // action
|
||||
msg.MessagePart[2] = rawText.Substring(5, 3); //parameter
|
||||
msg.MessagePart[3] = rawText.Substring(8, 2); //length
|
||||
|
||||
if (!int.TryParse(msg.MessagePart[3], out int length))
|
||||
{
|
||||
LOG.Error($"text {msg.MessagePart[3]} not valid, " + rawText);
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
msg.MessagePart[4] = rawText.Substring(10, length); //data
|
||||
|
||||
msg.MessagePart[5] = rawText.Substring(10 + length, 3);
|
||||
|
||||
if (!int.TryParse(msg.MessagePart[5], out int sum))
|
||||
{
|
||||
LOG.Error($"text {msg.MessagePart[5]} not valid, " + rawText);
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
int checkSum = 0;
|
||||
string checkText = rawText.Substring(0, rawText.Length - 3 - 1);
|
||||
|
||||
foreach (var item in checkText)
|
||||
{
|
||||
checkSum += (int)item;
|
||||
}
|
||||
|
||||
if (checkSum % 256 != sum)
|
||||
{
|
||||
LOG.Error($"check sum failed, " + rawText);
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
msg.DeviceAddress = msg.MessagePart[0];
|
||||
msg.Action = msg.MessagePart[1];
|
||||
msg.Parameter = msg.MessagePart[2];
|
||||
msg.DataLength = length;
|
||||
msg.Data = msg.MessagePart[4];
|
||||
|
||||
if (msg.Data == "NO_DEF" || msg.Data=="_RANGE" || msg.Data=="_LOGIC")
|
||||
{
|
||||
msg.IsError = true;
|
||||
}
|
||||
|
||||
msg.IsResponse = true;
|
||||
msg.IsAck = true;
|
||||
msg.IsComplete = true;
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+343
@@ -0,0 +1,343 @@
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TurboPumps.PfeifferHipace
|
||||
{
|
||||
public abstract class HipaceHandler : HandlerBase
|
||||
{
|
||||
protected const string QueryDataText = "=?";
|
||||
|
||||
public HipaceTurboPump PumpDevice { get; }
|
||||
|
||||
protected HipaceHandler(HipaceTurboPump pump, string deviceAddress, bool isQuery, string parameter, string data)
|
||||
: base(BuildMessage(deviceAddress, isQuery, parameter, data))
|
||||
{
|
||||
PumpDevice = pump;
|
||||
}
|
||||
|
||||
private static string BuildMessage(string deviceAddress, bool isQuery, string parameter, string data)
|
||||
{
|
||||
string msg = deviceAddress + (isQuery ? "00" : "10") + parameter + data.Length.ToString("D2") + data;
|
||||
|
||||
return msg + CalcSum(msg).ToString("D3") + "\r";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int CalcSum(string value)
|
||||
{
|
||||
int sum = 0;
|
||||
foreach (var item in value)
|
||||
{
|
||||
sum += (int)item;
|
||||
}
|
||||
|
||||
return sum % 256;
|
||||
}
|
||||
}
|
||||
|
||||
//010
|
||||
public class HipacePumpStationHandler : HipaceHandler
|
||||
{
|
||||
public HipacePumpStationHandler(HipaceTurboPump pump, string deviceAddress, bool isOn, bool isQuery)
|
||||
: base(pump, deviceAddress, isQuery, "010", isQuery ? QueryDataText : (isOn ? "111111" : "000000"))
|
||||
{
|
||||
Name = "Pump " + (isOn ? "On" : "Off");
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as HipaceMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
PumpDevice.SetError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.Data == "111111")
|
||||
{
|
||||
PumpDevice.NoteOnOff(true);
|
||||
}
|
||||
else if (result.Data == "000000")
|
||||
{
|
||||
PumpDevice.NoteOnOff(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PumpDevice.SetError(result.Data + " format error");
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//023
|
||||
public class HipaceMotorPumpHandler : HipaceHandler
|
||||
{
|
||||
public HipaceMotorPumpHandler(HipaceTurboPump pump, string deviceAddress, bool isOn)
|
||||
: base(pump, deviceAddress, false, "023", isOn ? "111111" : "000000")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as HipaceMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
PumpDevice.SetError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.Data == "111111")
|
||||
{
|
||||
PumpDevice.NoteOnOff(true);
|
||||
}
|
||||
else if (result.Data == "000000")
|
||||
{
|
||||
PumpDevice.NoteOnOff(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PumpDevice.SetError(result.Data + "format error");
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//303
|
||||
public class HipaceQueryErrorHandler : HipaceHandler
|
||||
{
|
||||
public HipaceQueryErrorHandler(HipaceTurboPump pump, string deviceAddress)
|
||||
: base(pump, deviceAddress, true, "303", QueryDataText)
|
||||
{
|
||||
Name = "Query Error";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as HipaceMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
PumpDevice.SetError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (int.TryParse(result.Data, out int code))
|
||||
{
|
||||
PumpDevice.SetErrorCode(code);
|
||||
}
|
||||
else
|
||||
{
|
||||
PumpDevice.SetError(result.Data + "format error");
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//398
|
||||
public class HipaceQuerySpeedHandler : HipaceHandler
|
||||
{
|
||||
public HipaceQuerySpeedHandler(HipaceTurboPump pump, string deviceAddress)
|
||||
: base(pump, deviceAddress, true, "398", QueryDataText)
|
||||
{
|
||||
Name = "Query Speed";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as HipaceMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
PumpDevice.SetError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (int.TryParse(result.Data, out int value))
|
||||
{
|
||||
PumpDevice.SetSpeed(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
PumpDevice.SetError(result.Data + "format error");
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//346
|
||||
public class HipaceQueryTemperatureHandler : HipaceHandler
|
||||
{
|
||||
public HipaceQueryTemperatureHandler(HipaceTurboPump pump, string deviceAddress)
|
||||
: base(pump, deviceAddress, true, "346", QueryDataText)
|
||||
{
|
||||
Name = "Query Temperature";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as HipaceMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
PumpDevice.SetError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (int.TryParse(result.Data, out int value))
|
||||
{
|
||||
PumpDevice.SetTemperature(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
PumpDevice.SetError(result.Data + "format error");
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//307
|
||||
public class HipaceAccelerateHandler : HipaceHandler
|
||||
{
|
||||
public HipaceAccelerateHandler(HipaceTurboPump pump, string deviceAddress)
|
||||
: base(pump, deviceAddress, true, "307", QueryDataText)
|
||||
{
|
||||
Name = "Query Accelerate";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as HipaceMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
PumpDevice.SetError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.Data == "111111")
|
||||
{
|
||||
PumpDevice.SetIsAccelerate(true);
|
||||
}
|
||||
else if (result.Data == "000000")
|
||||
{
|
||||
PumpDevice.SetIsAccelerate(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PumpDevice.SetError(result.Data + "format error");
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//306
|
||||
public class HipaceAtSpeedHandler : HipaceHandler
|
||||
{
|
||||
public HipaceAtSpeedHandler(HipaceTurboPump pump, string deviceAddress)
|
||||
: base(pump, deviceAddress, true, "306", QueryDataText)
|
||||
{
|
||||
Name = "Query At Speed";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as HipaceMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
PumpDevice.SetError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.Data == "111111")
|
||||
{
|
||||
PumpDevice.SetAtSpeed(true);
|
||||
}
|
||||
else if (result.Data == "000000")
|
||||
{
|
||||
PumpDevice.SetAtSpeed(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PumpDevice.SetError(result.Data + "format error");
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//305
|
||||
public class HipaceOverTempHandler : HipaceHandler
|
||||
{
|
||||
public HipaceOverTempHandler(HipaceTurboPump pump, string deviceAddress)
|
||||
: base(pump, deviceAddress, true, "305", QueryDataText)
|
||||
{
|
||||
Name = "Query over temp";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as HipaceMessage;
|
||||
if (result.IsError)
|
||||
{
|
||||
PumpDevice.SetError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.Data == "111111")
|
||||
{
|
||||
PumpDevice.SetOverTemp(true);
|
||||
}
|
||||
else if (result.Data == "000000")
|
||||
{
|
||||
PumpDevice.SetOverTemp(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
PumpDevice.SetError(result.Data + "format error");
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
handled = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+331
@@ -0,0 +1,331 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aitex.Core.Common.DeviceData;
|
||||
using Aitex.Core.RT.DataCenter;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Core.RT.Log;
|
||||
using Aitex.Core.RT.SCCore;
|
||||
using Aitex.Core.Util;
|
||||
using MECF.Framework.Common.Communications;
|
||||
using MECF.Framework.Common.Device.Bases;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.TurboPumps.PfeifferHipace
|
||||
{
|
||||
public class HipaceTurboPump : PumpBase
|
||||
{
|
||||
public override bool IsError
|
||||
{
|
||||
get { return _errorCode != 0; }
|
||||
}
|
||||
|
||||
public override bool IsOn
|
||||
{
|
||||
get { return _isOn; }
|
||||
}
|
||||
|
||||
public override float Speed
|
||||
{
|
||||
get { return _speed; }
|
||||
}
|
||||
|
||||
public override float Temperature
|
||||
{
|
||||
get { return _temperature; }
|
||||
}
|
||||
|
||||
public override bool IsStable
|
||||
{
|
||||
get { return _isAtSpeed; }
|
||||
}
|
||||
|
||||
public override AITPumpData DeviceData
|
||||
{
|
||||
get
|
||||
{
|
||||
AITPumpData data = new AITPumpData()
|
||||
{
|
||||
DeviceName = Name,
|
||||
DeviceSchematicId = DeviceID,
|
||||
DisplayName = Display,
|
||||
|
||||
DeviceModule = Module,
|
||||
|
||||
IsError = IsError,
|
||||
IsOn = _isOn,
|
||||
|
||||
Speed = _speed,
|
||||
Temperature = _temperature,
|
||||
|
||||
AtSpeed = _isAtSpeed,
|
||||
OverTemp = _isOverTemp,
|
||||
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
private HipaceConnection _connection;
|
||||
|
||||
private string _deviceAddress = "001";
|
||||
|
||||
private int _speed;
|
||||
private int _temperature;
|
||||
private bool _isOn;
|
||||
private int _power;
|
||||
private bool _isAccelerate;
|
||||
private bool _isAtSpeed;
|
||||
private bool _isOverTemp;
|
||||
|
||||
private bool _activeMonitorStatus;
|
||||
|
||||
private int _errorCode;
|
||||
|
||||
private RD_TRIG _trigPumpOnOff = new RD_TRIG();
|
||||
private R_TRIG _trigError = new R_TRIG();
|
||||
private R_TRIG _trigOverTemp = new R_TRIG();
|
||||
|
||||
private R_TRIG _trigWarningMessage = new R_TRIG();
|
||||
private string _lastError = string.Empty;
|
||||
private R_TRIG _trigCommunicationError = new R_TRIG();
|
||||
private R_TRIG _trigRetryConnect = new R_TRIG();
|
||||
|
||||
private PeriodicJob _thread;
|
||||
|
||||
private LinkedList<HandlerBase> _lstHandler = new LinkedList<HandlerBase>();
|
||||
private object _locker = new object();
|
||||
|
||||
private bool _enableLog = true;
|
||||
|
||||
private string _scRoot;
|
||||
|
||||
public HipaceTurboPump(string module, string name, string scRoot) : base(module, name)
|
||||
{
|
||||
_scRoot = scRoot;
|
||||
|
||||
_activeMonitorStatus = true;
|
||||
|
||||
_power = 0;
|
||||
}
|
||||
|
||||
public override bool Initialize()
|
||||
{
|
||||
if(_connection != null && _connection.IsConnected)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
base.Initialize();
|
||||
|
||||
DATA.Subscribe($"{Module}.{Name}.Power", () => _power);
|
||||
|
||||
DATA.Subscribe($"{Module}.{Name}.ErrorCode", () => _errorCode);
|
||||
DATA.Subscribe($"{Module}.{Name}.IsAtSpeed", () => _isAtSpeed);
|
||||
DATA.Subscribe($"{Module}.{Name}.IsAccelerate", () => _isAccelerate);
|
||||
|
||||
string portName = SC.GetStringValue($"{_scRoot}.{Module}.{Name}.Address");
|
||||
int address = SC.GetValue<int>($"{_scRoot}.{Module}.{Name}.DeviceAddress");
|
||||
_deviceAddress = address.ToString("D3");
|
||||
_enableLog = SC.GetValue<bool>($"{_scRoot}.{Module}.{Name}.EnableLogMessage");
|
||||
|
||||
_connection = new HipaceConnection(portName);
|
||||
_connection.EnableLog(_enableLog);
|
||||
|
||||
if (_connection.Connect())
|
||||
{
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} connected");
|
||||
}
|
||||
|
||||
_thread = new PeriodicJob(100, OnTimer, $"{Module}.{Name} MonitorHandler", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool OnTimer()
|
||||
{
|
||||
try
|
||||
{
|
||||
//temp comment ??
|
||||
//_connection.MonitorTimeout();
|
||||
|
||||
if (!_connection.IsConnected || _connection.IsCommunicationError)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.Clear();
|
||||
}
|
||||
|
||||
_trigRetryConnect.CLK = !_connection.IsConnected;
|
||||
if (_trigRetryConnect.Q)
|
||||
{
|
||||
_connection.SetPortAddress(SC.GetStringValue($"{Module}.{Name}.Address"));
|
||||
if (!_connection.Connect())
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
HandlerBase handler = null;
|
||||
if (!_connection.IsBusy)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (_lstHandler.Count == 0 && _activeMonitorStatus)
|
||||
{
|
||||
_lstHandler.AddLast(new HipaceQueryErrorHandler(this, _deviceAddress));
|
||||
_lstHandler.AddLast(new HipaceQuerySpeedHandler(this, _deviceAddress));
|
||||
|
||||
_lstHandler.AddLast(new HipaceQueryTemperatureHandler(this, _deviceAddress));
|
||||
_lstHandler.AddLast(new HipacePumpStationHandler(this, _deviceAddress, true, true));
|
||||
|
||||
_lstHandler.AddLast(new HipaceAtSpeedHandler(this, _deviceAddress));
|
||||
_lstHandler.AddLast(new HipaceAccelerateHandler(this, _deviceAddress));
|
||||
_lstHandler.AddLast(new HipaceOverTempHandler(this, _deviceAddress));
|
||||
}
|
||||
|
||||
if (_lstHandler.Count > 0)
|
||||
{
|
||||
handler = _lstHandler.First.Value;
|
||||
|
||||
_lstHandler.RemoveFirst();
|
||||
}
|
||||
}
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
_connection.Execute(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Monitor()
|
||||
{
|
||||
try
|
||||
{
|
||||
_connection.EnableLog(_enableLog);
|
||||
|
||||
_trigPumpOnOff.CLK = _isOn;
|
||||
if (_trigPumpOnOff.R)
|
||||
{
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} is on");
|
||||
}
|
||||
|
||||
if (_trigPumpOnOff.T)
|
||||
{
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} is off");
|
||||
}
|
||||
|
||||
_trigError.CLK = IsError;
|
||||
if (_trigError.Q)
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"{Module}.{Name} is error, error code {_errorCode:D3}");
|
||||
}
|
||||
|
||||
_trigOverTemp.CLK = _isOverTemp;
|
||||
if (_trigOverTemp.Q)
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"{Module}.{Name} is over temperature");
|
||||
}
|
||||
|
||||
_trigCommunicationError.CLK = _connection.IsCommunicationError;
|
||||
if (_trigCommunicationError.Q)
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
_trigError.RST = true;
|
||||
_trigOverTemp.RST = true;
|
||||
_trigWarningMessage.RST = true;
|
||||
|
||||
_connection.SetCommunicationError(false, "");
|
||||
_trigCommunicationError.RST = true;
|
||||
|
||||
_enableLog = SC.GetValue<bool>($"{Module}.{Name}.EnableLogMessage");
|
||||
|
||||
_trigRetryConnect.RST = true;
|
||||
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
public override void SetPumpOnOff(bool isOn)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new HipacePumpStationHandler(this, _deviceAddress, isOn, false));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetActiveMonitor(bool active)
|
||||
{
|
||||
_activeMonitorStatus = active;
|
||||
}
|
||||
|
||||
|
||||
internal void NoteOnOff(bool isOn)
|
||||
{
|
||||
_isOn = isOn;
|
||||
}
|
||||
|
||||
|
||||
public void SetSpeed(int speed)
|
||||
{
|
||||
_speed = speed;
|
||||
}
|
||||
|
||||
public void SetTemperature(int temperature)
|
||||
{
|
||||
_temperature = temperature;
|
||||
}
|
||||
|
||||
public void SetErrorCode(int errorCode)
|
||||
{
|
||||
_errorCode = errorCode;
|
||||
}
|
||||
|
||||
public void SetAtSpeed(bool atSpeed)
|
||||
{
|
||||
_isAtSpeed = atSpeed;
|
||||
}
|
||||
|
||||
public void SetOverTemp(bool overTemp)
|
||||
{
|
||||
_isOverTemp = overTemp;
|
||||
}
|
||||
|
||||
public void SetIsAccelerate(bool isAccelerate)
|
||||
{
|
||||
_isAccelerate = isAccelerate;
|
||||
}
|
||||
|
||||
public void SetError(string reason)
|
||||
{
|
||||
_trigWarningMessage.CLK = true;
|
||||
if (_trigWarningMessage.Q)
|
||||
{
|
||||
EV.PostWarningLog(Module, $"{Module}.{Name} error, {reason}");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user