首次上传
This commit is contained in:
+723
@@ -0,0 +1,723 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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.RT.EquipmentLibrary.HardwareUnits.Common;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.VCE.BrooksVCE
|
||||
{
|
||||
public class BrooksVCE : SerialPortDevice, IConnection
|
||||
{
|
||||
public string Address { get { return _address; } }
|
||||
public bool IsConnected { get; }
|
||||
public bool Connect()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Disconnect()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public string PortStatus { get; set; } = "Closed";
|
||||
|
||||
private BrooksVCEConnection _connection;
|
||||
public BrooksVCEConnection Connection
|
||||
{
|
||||
get { return _connection; }
|
||||
}
|
||||
|
||||
private R_TRIG _trigError = new R_TRIG();
|
||||
|
||||
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 LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
|
||||
|
||||
public List<IOResponse> IOResponseList { get; set; } = new List<IOResponse>();
|
||||
|
||||
|
||||
private object _locker = new object();
|
||||
|
||||
private bool _enableLog;
|
||||
private string _scRoot;
|
||||
public BrooksVCE(string module, string name, string scRoot, string portName) : base(module, name)
|
||||
{
|
||||
_scRoot = scRoot;
|
||||
PortName = portName;
|
||||
}
|
||||
private void ResetPropertiesAndResponses()
|
||||
{
|
||||
|
||||
DoorClosed = null;
|
||||
DoorOpened = null;
|
||||
IsHalted = null;
|
||||
|
||||
|
||||
foreach (var ioResponse in IOResponseList)
|
||||
{
|
||||
ioResponse.ResonseContent = null;
|
||||
ioResponse.ResonseRecievedTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private string _address;
|
||||
public override bool Initialize(string portName)
|
||||
{
|
||||
base.Initialize(portName);
|
||||
|
||||
ResetPropertiesAndResponses();
|
||||
|
||||
if (_connection != null && _connection.IsConnected && PortName == portName)
|
||||
return true;
|
||||
|
||||
if (_connection != null && _connection.IsConnected)
|
||||
_connection.Disconnect();
|
||||
|
||||
PortName = portName;
|
||||
_address = SC.GetStringValue($"{_scRoot}.{Module}.{Name}.DeviceAddress");
|
||||
_enableLog = SC.GetValue<bool>($"{_scRoot}.{Module}.{Name}.EnableLogMessage");
|
||||
_connection = new BrooksVCEConnection(PortName);
|
||||
_connection.EnableLog(_enableLog);
|
||||
|
||||
if (_connection.Connect())
|
||||
{
|
||||
PortStatus = "Open";
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} connected");
|
||||
}
|
||||
|
||||
_thread = new PeriodicJob(100, OnTimer, $"{Module}.{Name} MonitorHandler", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool OnTimer()
|
||||
{
|
||||
try
|
||||
{
|
||||
//return true;
|
||||
//_connection.MonitorTimeout();
|
||||
|
||||
if (!_connection.IsConnected || _connection.IsCommunicationError)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.Clear();
|
||||
}
|
||||
|
||||
_trigRetryConnect.CLK = !_connection.IsConnected;
|
||||
if (_trigRetryConnect.Q)
|
||||
{
|
||||
_connection.SetPortAddress(SC.GetStringValue($"{ScBasePath}.{Name}.Address"));
|
||||
if (!_connection.Connect())
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
//_lstHandler.AddLast(new BrooksVCEQueryPinHandler(this, _deviceAddress));
|
||||
//_lstHandler.AddLast(new BrooksVCESetCommModeHandler(this, _deviceAddress, EnumRfPowerCommunicationMode.Host));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
HandlerBase handler = null;
|
||||
if (!_connection.IsBusy)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (_lstHandler.Count == 0)
|
||||
{
|
||||
foreach (var monitorHandler in _lstMonitorHandler)
|
||||
{
|
||||
_lstHandler.AddLast(monitorHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_lstHandler.Count > 0)
|
||||
{
|
||||
handler = _lstHandler.First.Value;
|
||||
|
||||
_lstHandler.RemoveFirst();
|
||||
}
|
||||
}
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
_connection.Execute(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void NoteCommonActionResult(string command)
|
||||
{
|
||||
if(command == "JD")
|
||||
{
|
||||
|
||||
}
|
||||
else if (command == "JU")
|
||||
{
|
||||
|
||||
}
|
||||
else if (command == "LOAD")
|
||||
{
|
||||
LoadCompleted = true;
|
||||
}
|
||||
else if (command == "LP")
|
||||
{
|
||||
LoadPosition = true;
|
||||
}
|
||||
else if (command == "PI")
|
||||
{
|
||||
RetractPosition = true;
|
||||
}
|
||||
else if (command == "PICK")
|
||||
{
|
||||
Picked = true;
|
||||
}
|
||||
else if (command == "PLACE")
|
||||
{
|
||||
Placed = true;
|
||||
}
|
||||
else if (command == "PO")
|
||||
{
|
||||
ExtendPosition = true;
|
||||
}
|
||||
else if (command == "UNLOAD")
|
||||
{
|
||||
Unloaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteZAxisPosition(string pos)
|
||||
{
|
||||
ZAxisPosition = pos;
|
||||
}
|
||||
|
||||
internal void NoteHomed(bool homed)
|
||||
{
|
||||
Homed = homed;
|
||||
}
|
||||
|
||||
internal void NoteMoveResult(string position)
|
||||
{
|
||||
MovedPosition = position;
|
||||
}
|
||||
|
||||
public override void Monitor()
|
||||
{
|
||||
try
|
||||
{
|
||||
//_connection.EnableLog(_enableLog);
|
||||
|
||||
|
||||
_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;
|
||||
|
||||
_connection.SetCommunicationError(false, "");
|
||||
_trigCommunicationError.RST = true;
|
||||
|
||||
//_enableLog = SC.GetValue<bool>($"{ScBasePath}.{Name}.EnableLogMessage");
|
||||
|
||||
_trigRetryConnect.RST = true;
|
||||
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
public override bool Home(out string reason)
|
||||
{
|
||||
return base.Home(out reason);
|
||||
}
|
||||
|
||||
|
||||
#region Command Functions
|
||||
|
||||
public void PerformRawCommand(string commandType)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCERawCommandHandler(this, commandType, ""));
|
||||
}
|
||||
}
|
||||
public void PerformRawCommand(string commandType, string command)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCERawCommandHandler(this, commandType, command));
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteCurrentCommunicationMode(string data)
|
||||
{
|
||||
CurrentCommunicationMode = data;
|
||||
}
|
||||
|
||||
public void PerformRawCommand(string commandType, string command, string comandArgument)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCERawCommandHandler(this, commandType,command, comandArgument));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void MonitorRawCommand(bool isSelected, string commandType, string command, string comandArgument)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
string msg = comandArgument == null ? $"{command}\r" : $"{command} {comandArgument}\r";//??
|
||||
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksVCERawCommandHandler) && ((BrooksVCERawCommandHandler)handler).IsSendText(commandType, command, comandArgument));
|
||||
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksVCERawCommandHandler(this, commandType,command, comandArgument));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteCurrentACEStatus(string data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal void NoteCurrentErrorStatus(string data)
|
||||
{
|
||||
CurrentErrorStatus = data;
|
||||
}
|
||||
|
||||
internal void NoteIsLoadPositon(string data)
|
||||
{
|
||||
InLoadPositon = data.Last() == 'Y';
|
||||
}
|
||||
|
||||
public void RequestArmRPositon(bool isSelected, string axisPosition)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestArmRPositonHandler) && handler.SendText.Contains(axisPosition));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestArmRPositonHandler(this, axisPosition));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteCurrentMappingInfo(string data)
|
||||
{
|
||||
CurrentMappingInfo = data;
|
||||
}
|
||||
|
||||
internal void NoteIsPlatformPosition(string data)
|
||||
{
|
||||
InPlatformPosition = data.Last() == 'Y';
|
||||
}
|
||||
|
||||
public void RequestArmZPositon(bool isSelected, string axisPosition)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestArmZPositonHandler) && handler.SendText.Contains(axisPosition));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestArmZPositonHandler(this, axisPosition));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestCommunicationMode(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestCommModeHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestCommModeHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestErrorStatus(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestErrorStatusHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestErrorStatusHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void RequestVCEStatus(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestVCEStatusHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestVCEStatusHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestLoadPositon(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestLoadPositionHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestLoadPositionHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RequestMappingInfo(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestMappingInfoHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestMappingInfoHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RequestPlatformPosition(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestPlatformPositionHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestPlatformPositionHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Abort()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCEAbortHandler(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseDoor()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECloseDoorHandler(this));
|
||||
}
|
||||
}
|
||||
public void OpenDoor()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCEOpenDoorHandler(this));
|
||||
}
|
||||
}
|
||||
public void JogDown()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "JD"));
|
||||
}
|
||||
}
|
||||
public void JogUp()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "JU"));
|
||||
}
|
||||
}
|
||||
public void Load()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "LOAD"));
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveToLoadPositon()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "LP"));
|
||||
}
|
||||
}
|
||||
public void MapCassette()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "LP"));
|
||||
}
|
||||
}
|
||||
public void Move(string axis, string type, string value)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCEMoveHandler(this, axis, type, value));
|
||||
}
|
||||
}
|
||||
public void RoateRAxisToRetractPosition()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "PI"));
|
||||
}
|
||||
}
|
||||
public void RoateRAxisToExtendPosition()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "PO"));
|
||||
}
|
||||
}
|
||||
public void Pick()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "PICK"));
|
||||
}
|
||||
}
|
||||
public void Place()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "PLACE"));
|
||||
}
|
||||
}
|
||||
public void Unload()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCECommonActionHandler(this, "UNLOAD"));
|
||||
}
|
||||
}
|
||||
public void GotoZ(string direction)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCEGotoZHandler(this, direction));
|
||||
}
|
||||
}
|
||||
public void Home(string axis)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCEHomeHandler(this,axis));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCommunicationMode(string commMode)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new BrooksVCESetCommunicationModeHandler(this, commMode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public string DoorClosed { get; private set; }
|
||||
public string DoorOpened { get; private set; }
|
||||
public string IsHalted { get; private set; }
|
||||
|
||||
public string Error { get; private set; }
|
||||
public string ArmRPosition { get; private set; }
|
||||
public string CommunicationMode { get; private set; }
|
||||
public string ZAxisPosition { get; private set; }
|
||||
public bool Homed { get; private set; }
|
||||
public bool LoadCompleted { get; private set; }
|
||||
public bool LoadPosition { get; private set; }
|
||||
public bool RetractPosition { get; private set; }
|
||||
|
||||
public bool Picked { get; private set; }
|
||||
public bool Placed { get; private set; }
|
||||
public bool ExtendPosition { get; private set; }
|
||||
public bool Unloaded { get; private set; }
|
||||
public string MovedPosition { get; private set; }
|
||||
public string ArmZPosition { get; private set; }
|
||||
public string CurrentCommunicationMode { get; private set; }
|
||||
public string CurrentErrorStatus { get; private set; }
|
||||
public bool InLoadPositon { get; private set; }
|
||||
public string CurrentMappingInfo { get; private set; }
|
||||
public bool InPlatformPosition { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Note Functions
|
||||
private R_TRIG _trigWarningMessage = new R_TRIG();
|
||||
|
||||
public void NoteError(string reason)
|
||||
{
|
||||
if (reason != null)
|
||||
{
|
||||
_trigWarningMessage.CLK = true;
|
||||
if (_trigWarningMessage.Q)
|
||||
{
|
||||
EV.PostWarningLog(Module, $"{Module}.{Name} error, {reason}");
|
||||
}
|
||||
Error = reason;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = null;
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteDoorClosed(bool isClosed)
|
||||
{
|
||||
DoorClosed = isClosed ? "true" : "false";
|
||||
DoorOpened = isClosed ? "false" : "true";
|
||||
}
|
||||
|
||||
internal void NoteIsHalted(bool isHalted)
|
||||
{
|
||||
IsHalted = isHalted ? "true" : "false";
|
||||
}
|
||||
|
||||
|
||||
internal void NoteRawCommandInfo(string commandType, string command, string data)
|
||||
{
|
||||
var curIOResponse = IOResponseList.Find(res => res.SourceCommandName == command);
|
||||
if (curIOResponse != null)
|
||||
{
|
||||
IOResponseList.Remove(curIOResponse);
|
||||
}
|
||||
IOResponseList.Add(new IOResponse() { SourceCommandType = commandType,SourceCommand = command, ResonseContent = data, ResonseRecievedTime = DateTime.Now });
|
||||
}
|
||||
|
||||
internal void NoteArmRPositon(string armRPosition)
|
||||
{
|
||||
ArmRPosition = armRPosition;
|
||||
}
|
||||
internal void NoteArmZPositon(string armPosition)
|
||||
{
|
||||
ArmZPosition = armPosition;
|
||||
}
|
||||
internal void NoteCommunicationMode(string mode)
|
||||
{
|
||||
CommunicationMode = mode;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
using System.IO.Ports;
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.VCE.BrooksVCE
|
||||
{
|
||||
public class BrooksVCEMessage : AsciiMessage
|
||||
{
|
||||
public string Data { get; set; }
|
||||
public string ErrorText { get; set; }
|
||||
public bool IsRDY { get; set; }
|
||||
}
|
||||
|
||||
public class BrooksVCEConnection : SerialPortConnectionBase
|
||||
{
|
||||
//private bool _isBKGPlusMode = true;//should read from config file
|
||||
|
||||
private string _cachedBuffer = string.Empty;
|
||||
|
||||
public BrooksVCEConnection(string portName, int baudRate = 9600, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One)
|
||||
: base(portName, baudRate, dataBits, parity, stopBits, "\r", true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool SendMessage(byte[] message)
|
||||
{
|
||||
return base.SendMessage(message);
|
||||
}
|
||||
|
||||
|
||||
//1) Format: id,X,category,data<LF><CR>
|
||||
|
||||
|
||||
//2) request response
|
||||
//00,R,ARM,R,EX
|
||||
//00,X,ARM,R,EX,0169500
|
||||
|
||||
//3) action response
|
||||
|
||||
//S,BUFFER,NS,2
|
||||
//_RDY
|
||||
//_BKGRDY
|
||||
|
||||
//A,DO
|
||||
//_RDY
|
||||
//_BKGERR A6
|
||||
|
||||
//BAD,COMMAND
|
||||
//_ERR S4
|
||||
//_RDY
|
||||
|
||||
protected override MessageBase ParseResponse(string rawText)
|
||||
{
|
||||
BrooksVCEMessage msg = new BrooksVCEMessage();
|
||||
msg.RawMessage = rawText;
|
||||
|
||||
if (rawText.Length <= 0)
|
||||
{
|
||||
LOG.Error($"empty response,");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
rawText = rawText.Remove(rawText.Length - 1).Substring(3);
|
||||
if (rawText.Contains("_ERR"))
|
||||
{
|
||||
msg.IsError = true;
|
||||
msg.IsAck = true;
|
||||
|
||||
var rewTextArray = rawText.Split(' ');
|
||||
msg.Data = rewTextArray[1];
|
||||
}
|
||||
else if (rawText.Contains("_BKGERR"))
|
||||
{
|
||||
msg.IsError = true;
|
||||
msg.IsComplete = true;
|
||||
|
||||
var rewTextArray = rawText.Split(' ');
|
||||
msg.Data = rewTextArray[1];
|
||||
}
|
||||
|
||||
else if (rawText == "_RDY")
|
||||
{
|
||||
msg.IsRDY = true;
|
||||
}
|
||||
else if (rawText == "_BKGRDY")
|
||||
{
|
||||
msg.Data = rawText;
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
//Request response axisPosition
|
||||
//R,ARM,R,RE
|
||||
//X,ARM,R,RE,0000000
|
||||
else
|
||||
{
|
||||
msg.MessagePart = rawText.Split(',');
|
||||
if (msg.MessagePart.Length < 2)
|
||||
{
|
||||
LOG.Error($"too short response,");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
if (msg.MessagePart[0] != "X")
|
||||
{
|
||||
LOG.Error($"invalid record type for response ,");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
if (msg.MessagePart.Length > 2)
|
||||
{
|
||||
msg.Data = string.Join(",", msg.MessagePart, 2, msg.MessagePart.Length - 2);
|
||||
}
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+384
@@ -0,0 +1,384 @@
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.VCE.BrooksVCE
|
||||
{
|
||||
public abstract class BrooksVCEHandler : HandlerBase
|
||||
{
|
||||
public BrooksVCE Device { get; set; }
|
||||
|
||||
protected string _commandType;
|
||||
protected string _command;
|
||||
protected string _parameter;
|
||||
|
||||
public bool IsSendText(string commandType, string command, string commandArgumen)
|
||||
{
|
||||
return _commandType == commandType && _command == command && _parameter == commandArgumen;
|
||||
}
|
||||
protected BrooksVCEHandler(BrooksVCE device, string commandType, string command, string parameter = null)
|
||||
: base(BuildMessage(device.Address, commandType, command, parameter))
|
||||
{
|
||||
Device = device;
|
||||
_commandType = commandType;
|
||||
_command = command;
|
||||
_parameter = parameter;
|
||||
Name = command;
|
||||
}
|
||||
private static string BuildMessage(string address, string commandType, string command, string parameter)
|
||||
{
|
||||
string strCommand = $"{address},{commandType}";
|
||||
if(!string.IsNullOrEmpty(command))
|
||||
{
|
||||
strCommand += "," + command;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(parameter))
|
||||
{
|
||||
strCommand += "," + parameter;
|
||||
}
|
||||
return strCommand + "\r";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
|
||||
handled = msg.IsComplete;
|
||||
|
||||
|
||||
if (result.IsError)
|
||||
{
|
||||
Device.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
}
|
||||
|
||||
if (result.IsComplete)
|
||||
{
|
||||
SetState(EnumHandlerState.Completed);
|
||||
}
|
||||
if (result.IsAck)
|
||||
{
|
||||
SetState(EnumHandlerState.Acked);
|
||||
}
|
||||
|
||||
if (result.IsRDY)
|
||||
{
|
||||
if (IsAcked)
|
||||
{
|
||||
SetState(EnumHandlerState.Completed);
|
||||
handled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetState(EnumHandlerState.Acked);
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class BrooksVCERawCommandHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksVCERawCommandHandler(BrooksVCE device, string commandType, string command, string parameter = null)
|
||||
: base(device, commandType, command, parameter)
|
||||
{
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
base.HandleMessage(msg, out handled);
|
||||
|
||||
var result = msg as BrooksVCEMessage;
|
||||
Device.NoteRawCommandInfo(_commandType,_command, result.RawMessage);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class BrooksVCEAbortHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksVCEAbortHandler(BrooksVCE device)
|
||||
: base(device, "E", "")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if(base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteIsHalted(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class BrooksVCECommonActionHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksVCECommonActionHandler(BrooksVCE device, string command)
|
||||
: base(device, "A", command)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteCommonActionResult(_command);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksVCEMoveHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksVCEMoveHandler(BrooksVCE device, string axis, string type, string value)
|
||||
: base(device, "A", "MOVE", axis + "," + type + "," + value)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteMoveResult(_parameter);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class BrooksVCECloseDoorHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksVCECloseDoorHandler(BrooksVCE device)
|
||||
: base(device, "A", "DC")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteDoorClosed(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class BrooksVCEOpenDoorHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksVCEOpenDoorHandler(BrooksVCE device)
|
||||
: base(device, "A", "DO")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteDoorClosed(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksVCEHomeHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksVCEHomeHandler(BrooksVCE device, string axis)
|
||||
: base(device, "A", "HM", axis)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteHomed(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksVCEGotoZHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksVCEGotoZHandler(BrooksVCE device, string direction)
|
||||
: base(device, "A", "GOTO", "ARM,Z," + direction)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
|
||||
Device.NoteZAxisPosition(_parameter.Split(',')[2]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class BrooksVCESetCommunicationModeHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksVCESetCommunicationModeHandler(BrooksVCE device, string commMode)
|
||||
: base(device, "S", "COMM", "FLOW," + commMode)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
if (result.IsComplete)
|
||||
{
|
||||
Device.NoteCommunicationMode(this._parameter.Split(',')[2]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class BrooksACERequestArmRPositonHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksACERequestArmRPositonHandler(BrooksVCE device, string axisPosition)
|
||||
: base(device, "R", "ARM", "R,"+ axisPosition)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
Device.NoteArmRPositon(result.Data.Split(',')[2]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class BrooksACERequestArmZPositonHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksACERequestArmZPositonHandler(BrooksVCE device, string axisPosition)
|
||||
: base(device, "R", "ARM", "Z," + axisPosition)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
Device.NoteArmZPositon(result.Data.Split(',')[2]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksACERequestCommModeHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksACERequestCommModeHandler(BrooksVCE device)
|
||||
: base(device, "R", "COMM", "FLOW")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
Device.NoteCurrentCommunicationMode(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksACERequestErrorStatusHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksACERequestErrorStatusHandler(BrooksVCE device)
|
||||
: base(device, "R", "ER")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
Device.NoteCurrentErrorStatus(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksACERequestVCEStatusHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksACERequestVCEStatusHandler(BrooksVCE device)
|
||||
: base(device, "R", "STAT", "ALL")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
Device.NoteCurrentACEStatus(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class BrooksACERequestLoadPositionHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksACERequestLoadPositionHandler(BrooksVCE device)
|
||||
: base(device, "R", "LP")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
Device.NoteIsLoadPositon(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksACERequestMappingInfoHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksACERequestMappingInfoHandler(BrooksVCE device)
|
||||
: base(device, "R", "MI")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
Device.NoteCurrentMappingInfo(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class BrooksACERequestPlatformPositionHandler : BrooksVCEHandler
|
||||
{
|
||||
public BrooksACERequestPlatformPositionHandler(BrooksVCE device)
|
||||
: base(device, "R", "LP")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as BrooksVCEMessage;
|
||||
Device.NoteIsPlatformPosition(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+707
@@ -0,0 +1,707 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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;
|
||||
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Common;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.VCE.SiasunVCE
|
||||
{
|
||||
public class SiasunVCE : VCEBase, IConnection
|
||||
{
|
||||
public string Address { get { return _address; } }
|
||||
public override bool IsConnected => _connection.IsConnected;
|
||||
public bool Connect()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Disconnect()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public string PortStatus { get; set; } = "Closed";
|
||||
|
||||
private SiasunVCEConnection _connection;
|
||||
public SiasunVCEConnection Connection
|
||||
{
|
||||
get { return _connection; }
|
||||
}
|
||||
|
||||
private R_TRIG _trigError = new R_TRIG();
|
||||
|
||||
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 LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
|
||||
|
||||
public List<IOResponse> IOResponseList { get; set; } = new List<IOResponse>();
|
||||
|
||||
|
||||
private object _locker = new object();
|
||||
|
||||
private bool _enableLog;
|
||||
private string _scRoot;
|
||||
private string _portName;
|
||||
public SiasunVCE(string module, string name, string scRoot) : base(module, name)
|
||||
{
|
||||
_scRoot = scRoot;
|
||||
}
|
||||
|
||||
private void ResetPropertiesAndResponses()
|
||||
{
|
||||
DoorClosed = null;
|
||||
DoorOpened = null;
|
||||
IsHalted = null;
|
||||
|
||||
foreach (var ioResponse in IOResponseList)
|
||||
{
|
||||
ioResponse.ResonseContent = null;
|
||||
ioResponse.ResonseRecievedTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
private string _address = "00";
|
||||
public override bool Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
ResetPropertiesAndResponses();
|
||||
|
||||
if (_connection != null && _connection.IsConnected)
|
||||
return true;
|
||||
|
||||
if (string.IsNullOrEmpty(_scRoot))
|
||||
{
|
||||
_portName = SC.GetStringValue($"{Name}.DeviceAddress");
|
||||
_enableLog = SC.GetValue<bool>($"{Name}.EnableLogMessage");
|
||||
}
|
||||
else
|
||||
{
|
||||
_portName = SC.GetStringValue($"{_scRoot}.{Module}.{Name}.DeviceAddress");
|
||||
_enableLog = SC.GetValue<bool>($"{_scRoot}.{Module}.{Name}.EnableLogMessage");
|
||||
}
|
||||
|
||||
_connection = new SiasunVCEConnection(_portName);
|
||||
_connection.EnableLog(_enableLog);
|
||||
|
||||
if (_connection.Connect())
|
||||
{
|
||||
PortStatus = "Open";
|
||||
EV.PostInfoLog(Module, $"{Module}.{Name} connected");
|
||||
}
|
||||
|
||||
_thread = new PeriodicJob(100, OnTimer, $"{Module}.{Name} MonitorHandler", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool OnTimer()
|
||||
{
|
||||
try
|
||||
{
|
||||
//return true;
|
||||
//_connection.MonitorTimeout();
|
||||
|
||||
if (!_connection.IsConnected || _connection.IsCommunicationError)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.Clear();
|
||||
}
|
||||
|
||||
_trigRetryConnect.CLK = !_connection.IsConnected;
|
||||
if (_trigRetryConnect.Q)
|
||||
{
|
||||
_connection.SetPortAddress(SC.GetStringValue($"{ScBasePath}.{Name}.Address"));
|
||||
if (!_connection.Connect())
|
||||
{
|
||||
EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
//_lstHandler.AddLast(new SiasunVCEQueryPinHandler(this, _deviceAddress));
|
||||
//_lstHandler.AddLast(new SiasunVCESetCommModeHandler(this, _deviceAddress, EnumRfPowerCommunicationMode.Host));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
HandlerBase handler = null;
|
||||
if (!_connection.IsBusy)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
if (_lstHandler.Count == 0)
|
||||
{
|
||||
foreach (var monitorHandler in _lstMonitorHandler)
|
||||
{
|
||||
_lstHandler.AddLast(monitorHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (_lstHandler.Count > 0)
|
||||
{
|
||||
handler = _lstHandler.First.Value;
|
||||
|
||||
_lstHandler.RemoveFirst();
|
||||
}
|
||||
}
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
_connection.Execute(handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write(ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void NoteCommonActionResult(string command)
|
||||
{
|
||||
if (command == "JD")
|
||||
{
|
||||
|
||||
}
|
||||
else if (command == "JU")
|
||||
{
|
||||
|
||||
}
|
||||
else if (command == "LOAD")
|
||||
{
|
||||
LoadCompleted = true;
|
||||
}
|
||||
else if (command == "LP")
|
||||
{
|
||||
LoadPosition = true;
|
||||
}
|
||||
else if (command == "PI")
|
||||
{
|
||||
RetractPosition = true;
|
||||
}
|
||||
else if (command == "PICK")
|
||||
{
|
||||
Picked = true;
|
||||
}
|
||||
else if (command == "PLACE")
|
||||
{
|
||||
Placed = true;
|
||||
}
|
||||
else if (command == "PO")
|
||||
{
|
||||
ExtendPosition = true;
|
||||
}
|
||||
else if (command == "UNLOAD")
|
||||
{
|
||||
Unloaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteZAxisPosition(string pos)
|
||||
{
|
||||
ZAxisPosition = pos;
|
||||
}
|
||||
|
||||
internal void NoteHomed(bool homed)
|
||||
{
|
||||
Homed = homed;
|
||||
}
|
||||
|
||||
internal void NoteMoveResult(string position)
|
||||
{
|
||||
MovedPosition = position;
|
||||
}
|
||||
|
||||
public override void Monitor()
|
||||
{
|
||||
try
|
||||
{
|
||||
//_connection.EnableLog(_enableLog);
|
||||
|
||||
|
||||
_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;
|
||||
|
||||
_connection.SetCommunicationError(false, "");
|
||||
_trigCommunicationError.RST = true;
|
||||
|
||||
//_enableLog = SC.GetValue<bool>($"{ScBasePath}.{Name}.EnableLogMessage");
|
||||
|
||||
_trigRetryConnect.RST = true;
|
||||
|
||||
base.Reset();
|
||||
}
|
||||
|
||||
public override bool Home(out string reason)
|
||||
{
|
||||
return base.Home(out reason);
|
||||
}
|
||||
|
||||
|
||||
#region Command Functions
|
||||
|
||||
public void PerformRawCommand(string commandType)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCERawCommandHandler(this, commandType, ""));
|
||||
}
|
||||
}
|
||||
public void PerformRawCommand(string commandType, string command)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCERawCommandHandler(this, commandType, command));
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteCurrentCommunicationMode(string data)
|
||||
{
|
||||
CurrentCommunicationMode = data;
|
||||
}
|
||||
|
||||
public void PerformRawCommand(string commandType, string command, string comandArgument)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCERawCommandHandler(this, commandType, command, comandArgument));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void MonitorRawCommand(bool isSelected, string commandType, string command, string comandArgument)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
string msg = comandArgument == null ? $"{command}\r" : $"{command} {comandArgument}\r";//??
|
||||
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(SiasunVCERawCommandHandler) && ((SiasunVCERawCommandHandler)handler).IsSendText(commandType, command, comandArgument));
|
||||
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new SiasunVCERawCommandHandler(this, commandType, command, comandArgument));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteCurrentACEStatus(string data)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal void NoteCurrentErrorStatus(string data)
|
||||
{
|
||||
CurrentErrorStatus = data;
|
||||
}
|
||||
|
||||
internal void NoteIsLoadPositon(string data)
|
||||
{
|
||||
InLoadPositon = data.Last() == 'Y';
|
||||
}
|
||||
|
||||
public void RequestArmRPositon(bool isSelected, string axisPosition)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestArmRPositonHandler) && handler.SendText.Contains(axisPosition));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestArmRPositonHandler(this, axisPosition));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteCurrentMappingInfo(string data)
|
||||
{
|
||||
CurrentMappingInfo = data;
|
||||
}
|
||||
|
||||
internal void NoteIsPlatformPosition(string data)
|
||||
{
|
||||
InPlatformPosition = data.Last() == 'Y';
|
||||
}
|
||||
|
||||
public void RequestArmZPositon(bool isSelected, string axisPosition)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestArmZPositonHandler) && handler.SendText.Contains(axisPosition));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestArmZPositonHandler(this, axisPosition));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestCommunicationMode(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestCommModeHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestCommModeHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestErrorStatus(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestErrorStatusHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestErrorStatusHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void RequestVCEStatus(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestVCEStatusHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestVCEStatusHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestLoadPositon(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestLoadPositionHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestLoadPositionHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RequestMappingInfo(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestMappingInfoHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestMappingInfoHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void RequestPlatformPosition(bool isSelected)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
var existHandlers = _lstMonitorHandler.Where(handler => handler.GetType() == typeof(BrooksACERequestPlatformPositionHandler));
|
||||
if (isSelected)
|
||||
{
|
||||
if (!existHandlers.Any())
|
||||
_lstMonitorHandler.AddFirst(new BrooksACERequestPlatformPositionHandler(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existHandlers.Any())
|
||||
{
|
||||
_lstMonitorHandler.Remove(existHandlers.First());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void CloseDoor()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCECloseDoorHandler(this));
|
||||
}
|
||||
}
|
||||
public void OpenDoor()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCEOpenDoorHandler(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
//_lstHandler.AddLast(new SiasunVCECommonActionHandler(this, "LOAD"));
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveToLoadPositon()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCECommonActionHandler(this, "LP"));
|
||||
}
|
||||
}
|
||||
public void MapCassette()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCECommonActionHandler(this, "MP"));
|
||||
}
|
||||
}
|
||||
public void Move(string axis, string type, string value)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCEMoveHandler(this, axis, type, value));
|
||||
}
|
||||
}
|
||||
public void RoateRAxisToRetractPosition()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
//_lstHandler.AddLast(new SiasunVCECommonActionHandler(this, "PI"));
|
||||
}
|
||||
}
|
||||
public void RoateRAxisToExtendPosition()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
//_lstHandler.AddLast(new SiasunVCECommonActionHandler(this, "PO"));
|
||||
}
|
||||
}
|
||||
public void Pick()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
//_lstHandler.AddLast(new SiasunVCECommonActionHandler(this, "PICK"));
|
||||
}
|
||||
}
|
||||
public void Place()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
//_lstHandler.AddLast(new SiasunVCECommonActionHandler(this, "PLACE"));
|
||||
}
|
||||
}
|
||||
public void Unload()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
//_lstHandler.AddLast(new SiasunVCECommonActionHandler(this, "UNLOAD"));
|
||||
}
|
||||
}
|
||||
public void GotoZ(int slot)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCEGotoZHandler(this, slot));
|
||||
}
|
||||
}
|
||||
public void Home()
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lstHandler.AddLast(new SiasunVCEHomeHandler(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCommunicationMode(string commMode)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
//_lstHandler.AddLast(new SiasunVCESetCommunicationModeHandler(this, commMode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public string DoorClosed { get; private set; }
|
||||
public string DoorOpened { get; private set; }
|
||||
public string IsHalted { get; private set; }
|
||||
|
||||
public string Error { get; private set; }
|
||||
public string ArmRPosition { get; private set; }
|
||||
public string CommunicationMode { get; private set; }
|
||||
public string ZAxisPosition { get; private set; }
|
||||
public bool Homed { get; private set; }
|
||||
public bool LoadCompleted { get; private set; }
|
||||
public bool LoadPosition { get; private set; }
|
||||
public bool RetractPosition { get; private set; }
|
||||
|
||||
public bool Picked { get; private set; }
|
||||
public bool Placed { get; private set; }
|
||||
public bool ExtendPosition { get; private set; }
|
||||
public bool Unloaded { get; private set; }
|
||||
public string MovedPosition { get; private set; }
|
||||
public string ArmZPosition { get; private set; }
|
||||
public string CurrentCommunicationMode { get; private set; }
|
||||
public string CurrentErrorStatus { get; private set; }
|
||||
public bool InLoadPositon { get; private set; }
|
||||
public string CurrentMappingInfo { get; private set; }
|
||||
public bool InPlatformPosition { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Note Functions
|
||||
private R_TRIG _trigWarningMessage = new R_TRIG();
|
||||
|
||||
public void NoteError(string reason)
|
||||
{
|
||||
if (reason != null)
|
||||
{
|
||||
_trigWarningMessage.CLK = true;
|
||||
if (_trigWarningMessage.Q)
|
||||
{
|
||||
EV.PostWarningLog(Module, $"{Module}.{Name} error, {reason}");
|
||||
}
|
||||
Error = reason;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = null;
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteDoorClosed(bool isClosed)
|
||||
{
|
||||
DoorClosed = isClosed ? "true" : "false";
|
||||
DoorOpened = isClosed ? "false" : "true";
|
||||
}
|
||||
|
||||
internal void NoteIsHalted(bool isHalted)
|
||||
{
|
||||
IsHalted = isHalted ? "true" : "false";
|
||||
}
|
||||
|
||||
internal void NoteRawCommandInfo(string commandType, string command, string data)
|
||||
{
|
||||
var curIOResponse = IOResponseList.Find(res => res.SourceCommandName == command);
|
||||
if (curIOResponse != null)
|
||||
{
|
||||
IOResponseList.Remove(curIOResponse);
|
||||
}
|
||||
IOResponseList.Add(new IOResponse() { SourceCommandType = commandType, SourceCommand = command, ResonseContent = data, ResonseRecievedTime = DateTime.Now });
|
||||
}
|
||||
|
||||
internal void NoteArmRPositon(string armRPosition)
|
||||
{
|
||||
ArmRPosition = armRPosition;
|
||||
}
|
||||
internal void NoteArmZPositon(string armPosition)
|
||||
{
|
||||
ArmZPosition = armPosition;
|
||||
}
|
||||
internal void NoteCommunicationMode(string mode)
|
||||
{
|
||||
CommunicationMode = mode;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
using System.IO.Ports;
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.VCE.SiasunVCE
|
||||
{
|
||||
public class SiasunVCEMessage : AsciiMessage
|
||||
{
|
||||
public string Data { get; set; }
|
||||
public string ErrorText { get; set; }
|
||||
public bool IsRDY { get; set; }
|
||||
}
|
||||
|
||||
public class SiasunVCEConnection : SerialPortConnectionBase
|
||||
{
|
||||
//private bool _isBKGPlusMode = true;//should read from config file
|
||||
|
||||
private string _cachedBuffer = string.Empty;
|
||||
|
||||
public SiasunVCEConnection(string portName, int baudRate = 9600, int dataBits = 8, Parity parity = Parity.None, StopBits stopBits = StopBits.One)
|
||||
: base(portName, baudRate, dataBits, parity, stopBits, "\r", true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool SendMessage(byte[] message)
|
||||
{
|
||||
return base.SendMessage(message);
|
||||
}
|
||||
|
||||
|
||||
//1) Format: id,X,category,data<LF><CR>
|
||||
|
||||
|
||||
//2) request response
|
||||
//00,R,ARM,R,EX
|
||||
//00,X,ARM,R,EX,0169500
|
||||
|
||||
//3) action response
|
||||
|
||||
//S,BUFFER,NS,2
|
||||
//_RDY
|
||||
//_BKGRDY
|
||||
|
||||
//A,DO
|
||||
//_RDY
|
||||
//_BKGERR A6
|
||||
|
||||
//BAD,COMMAND
|
||||
//_ERR S4
|
||||
//_RDY
|
||||
|
||||
protected override MessageBase ParseResponse(string rawText)
|
||||
{
|
||||
SiasunVCEMessage msg = new SiasunVCEMessage();
|
||||
msg.RawMessage = rawText;
|
||||
|
||||
if (rawText.Length <= 0)
|
||||
{
|
||||
LOG.Error($"empty response,");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
rawText = rawText.Remove(rawText.Length - 1).Substring(3);
|
||||
if (rawText.Contains("_ERR"))
|
||||
{
|
||||
msg.IsError = true;
|
||||
msg.IsAck = true;
|
||||
|
||||
var rewTextArray = rawText.Split(' ');
|
||||
msg.Data = rewTextArray[1];
|
||||
}
|
||||
else if (rawText.Contains("_BKGERR"))
|
||||
{
|
||||
msg.IsError = true;
|
||||
msg.IsComplete = true;
|
||||
|
||||
var rewTextArray = rawText.Split(' ');
|
||||
msg.Data = rewTextArray[1];
|
||||
}
|
||||
|
||||
else if (rawText == "_RDY")
|
||||
{
|
||||
msg.IsRDY = true;
|
||||
}
|
||||
else if (rawText == "_BKGRDY")
|
||||
{
|
||||
msg.Data = rawText;
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
//Request response axisPosition
|
||||
//R,ARM,R,RE
|
||||
//X,ARM,R,RE,0000000
|
||||
else
|
||||
{
|
||||
msg.MessagePart = rawText.Split(',');
|
||||
if (msg.MessagePart.Length < 2)
|
||||
{
|
||||
LOG.Error($"too short response,");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
if (msg.MessagePart[0] != "X")
|
||||
{
|
||||
LOG.Error($"invalid record type for response ,");
|
||||
msg.IsFormatError = true;
|
||||
return msg;
|
||||
}
|
||||
|
||||
if (msg.MessagePart.Length > 2)
|
||||
{
|
||||
msg.Data = string.Join(",", msg.MessagePart, 2, msg.MessagePart.Length - 2);
|
||||
}
|
||||
msg.IsComplete = true;
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+384
@@ -0,0 +1,384 @@
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.VCE.SiasunVCE
|
||||
{
|
||||
public abstract class SiasunVCEHandler : HandlerBase
|
||||
{
|
||||
public SiasunVCE Device { get; set; }
|
||||
|
||||
protected string _commandType;
|
||||
protected string _command;
|
||||
protected string _parameter;
|
||||
|
||||
public bool IsSendText(string commandType, string command, string commandArgumen)
|
||||
{
|
||||
return _commandType == commandType && _command == command && _parameter == commandArgumen;
|
||||
}
|
||||
protected SiasunVCEHandler(SiasunVCE device, string commandType, string command, string parameter = null)
|
||||
: base(BuildMessage(device.Address, commandType, command, parameter))
|
||||
{
|
||||
Device = device;
|
||||
_commandType = commandType;
|
||||
_command = command;
|
||||
_parameter = parameter;
|
||||
Name = command;
|
||||
}
|
||||
private static string BuildMessage(string address, string commandType, string command, string parameter)
|
||||
{
|
||||
string strCommand = $"{address},{commandType}";
|
||||
if (!string.IsNullOrEmpty(command))
|
||||
{
|
||||
strCommand += "," + command;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(parameter))
|
||||
{
|
||||
strCommand += "," + parameter;
|
||||
}
|
||||
return strCommand + "\r";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
|
||||
handled = msg.IsComplete;
|
||||
|
||||
|
||||
if (result.IsError)
|
||||
{
|
||||
Device.NoteError(result.Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteError(null);
|
||||
}
|
||||
|
||||
if (result.IsComplete)
|
||||
{
|
||||
SetState(EnumHandlerState.Completed);
|
||||
}
|
||||
if (result.IsAck)
|
||||
{
|
||||
SetState(EnumHandlerState.Acked);
|
||||
}
|
||||
|
||||
if (result.IsRDY)
|
||||
{
|
||||
if (IsAcked)
|
||||
{
|
||||
SetState(EnumHandlerState.Completed);
|
||||
handled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetState(EnumHandlerState.Acked);
|
||||
}
|
||||
}
|
||||
|
||||
ResponseMessage = msg;
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class SiasunVCERawCommandHandler : SiasunVCEHandler
|
||||
{
|
||||
public SiasunVCERawCommandHandler(SiasunVCE device, string commandType, string command, string parameter = null)
|
||||
: base(device, commandType, command, parameter)
|
||||
{
|
||||
}
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
base.HandleMessage(msg, out handled);
|
||||
|
||||
var result = msg as SiasunVCEMessage;
|
||||
Device.NoteRawCommandInfo(_commandType, _command, result.RawMessage);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class SiasunVCEAbortHandler : SiasunVCEHandler
|
||||
{
|
||||
public SiasunVCEAbortHandler(SiasunVCE device)
|
||||
: base(device, "E", "")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteIsHalted(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class SiasunVCECommonActionHandler : SiasunVCEHandler
|
||||
{
|
||||
public SiasunVCECommonActionHandler(SiasunVCE device, string command)
|
||||
: base(device, "A", command)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteCommonActionResult(_command);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class SiasunVCEMoveHandler : SiasunVCEHandler
|
||||
{
|
||||
public SiasunVCEMoveHandler(SiasunVCE device, string axis, string type, string value)
|
||||
: base(device, "A", "MOVE", axis + "," + type + "," + value)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteMoveResult(_parameter);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class SiasunVCECloseDoorHandler : SiasunVCEHandler
|
||||
{
|
||||
public SiasunVCECloseDoorHandler(SiasunVCE device)
|
||||
: base(device, "A", "DC")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteDoorClosed(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class SiasunVCEOpenDoorHandler : SiasunVCEHandler
|
||||
{
|
||||
public SiasunVCEOpenDoorHandler(SiasunVCE device)
|
||||
: base(device, "A", "DO")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteDoorClosed(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class SiasunVCEHomeHandler : SiasunVCEHandler
|
||||
{
|
||||
public SiasunVCEHomeHandler(SiasunVCE device)
|
||||
: base(device, "A", "HM", "")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
Device.NoteHomed(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class SiasunVCEGotoZHandler : SiasunVCEHandler
|
||||
{
|
||||
public SiasunVCEGotoZHandler(SiasunVCE device, int slot)
|
||||
: base(device, "A", "GOTO", slot.ToString())
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
|
||||
Device.NoteZAxisPosition(_parameter.Split(',')[2]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class SiasunVCESetCommunicationModeHandler : SiasunVCEHandler
|
||||
{
|
||||
public SiasunVCESetCommunicationModeHandler(SiasunVCE device, string commMode)
|
||||
: base(device, "S", "COMM", "FLOW," + commMode)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
if (result.IsComplete)
|
||||
{
|
||||
Device.NoteCommunicationMode(this._parameter.Split(',')[2]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class BrooksACERequestArmRPositonHandler : SiasunVCEHandler
|
||||
{
|
||||
public BrooksACERequestArmRPositonHandler(SiasunVCE device, string axisPosition)
|
||||
: base(device, "R", "ARM", "R," + axisPosition)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
Device.NoteArmRPositon(result.Data.Split(',')[2]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class BrooksACERequestArmZPositonHandler : SiasunVCEHandler
|
||||
{
|
||||
public BrooksACERequestArmZPositonHandler(SiasunVCE device, string axisPosition)
|
||||
: base(device, "R", "ARM", "Z," + axisPosition)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
Device.NoteArmZPositon(result.Data.Split(',')[2]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksACERequestCommModeHandler : SiasunVCEHandler
|
||||
{
|
||||
public BrooksACERequestCommModeHandler(SiasunVCE device)
|
||||
: base(device, "R", "COMM", "FLOW")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
Device.NoteCurrentCommunicationMode(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksACERequestErrorStatusHandler : SiasunVCEHandler
|
||||
{
|
||||
public BrooksACERequestErrorStatusHandler(SiasunVCE device)
|
||||
: base(device, "R", "ER")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
Device.NoteCurrentErrorStatus(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksACERequestVCEStatusHandler : SiasunVCEHandler
|
||||
{
|
||||
public BrooksACERequestVCEStatusHandler(SiasunVCE device)
|
||||
: base(device, "R", "STAT", "ALL")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
Device.NoteCurrentACEStatus(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class BrooksACERequestLoadPositionHandler : SiasunVCEHandler
|
||||
{
|
||||
public BrooksACERequestLoadPositionHandler(SiasunVCE device)
|
||||
: base(device, "R", "LP")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
Device.NoteIsLoadPositon(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BrooksACERequestMappingInfoHandler : SiasunVCEHandler
|
||||
{
|
||||
public BrooksACERequestMappingInfoHandler(SiasunVCE device)
|
||||
: base(device, "R", "MI")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
Device.NoteCurrentMappingInfo(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public class BrooksACERequestPlatformPositionHandler : SiasunVCEHandler
|
||||
{
|
||||
public BrooksACERequestPlatformPositionHandler(SiasunVCE device)
|
||||
: base(device, "R", "LP")
|
||||
{
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase msg, out bool handled)
|
||||
{
|
||||
if (base.HandleMessage(msg, out handled))
|
||||
{
|
||||
var result = msg as SiasunVCEMessage;
|
||||
Device.NoteIsPlatformPosition(result.Data);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user