首次上传
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
|
||||
{
|
||||
public interface IEfemFfuCallback
|
||||
{
|
||||
}
|
||||
|
||||
public interface IEfemAlignerCallback
|
||||
{
|
||||
}
|
||||
|
||||
public interface IEfemBufferCallback
|
||||
{
|
||||
}
|
||||
|
||||
public interface IEfemLoadPortCallback
|
||||
{
|
||||
void NoteStatus(string data1, string data2);
|
||||
void NoteSlotMap(string slotMap);
|
||||
}
|
||||
|
||||
public interface IEfemRobotCallback
|
||||
{
|
||||
void NoteFailed(string error);
|
||||
void NoteComplete();
|
||||
void NoteCancel(string error);
|
||||
}
|
||||
|
||||
public interface IEfemSignalTowerCallback
|
||||
{
|
||||
}
|
||||
|
||||
public interface IEfemSystemCallback
|
||||
{
|
||||
void NoteStatus(string data1, string data2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,582 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Aitex.Core.RT.DataCenter;
|
||||
using Aitex.Core.RT.Device;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Core.Util;
|
||||
using Aitex.Sorter.Common;
|
||||
using MECF.Framework.Common.Communications;
|
||||
using MECF.Framework.Common.Device.Bases;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
using MECF.Framework.Common.SubstrateTrackings;
|
||||
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
|
||||
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDK;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
|
||||
{
|
||||
public interface IRorzeEfemController : IEfemController
|
||||
{
|
||||
void SetLoadPortCallback(ModuleName module, IEfemLoadPortCallback lpCallback);
|
||||
void SetRobotCallback(ModuleName module, IEfemRobotCallback robotCallback);
|
||||
void SetAlignerCallback(ModuleName module, IEfemAlignerCallback alignerCallback);
|
||||
void SetSignalTowerCallback(ModuleName module, IEfemSignalTowerCallback signalTowerCallback);
|
||||
void SetBufferCallback(ModuleName module, IEfemBufferCallback bufferCallback);
|
||||
}
|
||||
|
||||
public class RorzeEfem : BaseDevice, IDevice, IConnectionContext, IRorzeEfemController
|
||||
{
|
||||
#region Connection Config
|
||||
|
||||
public int RetryConnectIntervalMs => 500;
|
||||
|
||||
public int MaxRetryConnectCount => 3;
|
||||
|
||||
public bool EnableCheckConnection => true;
|
||||
|
||||
public string Address => "127.0.0.1:13000";
|
||||
|
||||
public bool IsAscii => true;
|
||||
|
||||
public string NewLine => "\r";
|
||||
|
||||
public bool EnableLog => true;
|
||||
|
||||
#endregion
|
||||
|
||||
private R_TRIG _trigError = new R_TRIG();
|
||||
private R_TRIG _trigWarningMessage = new R_TRIG();
|
||||
|
||||
private LinkedList<HandlerBase> _lstHandler = new LinkedList<HandlerBase>();
|
||||
private LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
|
||||
|
||||
private object _locker = new object();
|
||||
|
||||
private string _scRoot;
|
||||
|
||||
protected IEfemAlignerCallback _aligner;
|
||||
protected IEfemRobotCallback _robot;
|
||||
protected IEfemSignalTowerCallback _signalTower;
|
||||
protected IEfemFfuCallback _ffu;
|
||||
protected IEfemSystemCallback _system;
|
||||
|
||||
protected Dictionary<ModuleName, IEfemLoadPortCallback> _lpCallback = new Dictionary<ModuleName, IEfemLoadPortCallback>();
|
||||
|
||||
public RorzeEfemConnection Connection
|
||||
{
|
||||
get
|
||||
{
|
||||
return _connection;
|
||||
}
|
||||
}
|
||||
|
||||
private RorzeEfemConnection _connection;
|
||||
|
||||
|
||||
public event Action<string, EventLevel, string> AlarmGenerated;
|
||||
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
public bool IsCommunicationReady { get; set; }
|
||||
|
||||
public RorzeEfem(string module, string name, string scRoot) : base(module, name, name, name)
|
||||
{
|
||||
_scRoot = scRoot;
|
||||
|
||||
//string scBasePath = node.GetAttribute("scBasePath");
|
||||
//if (string.IsNullOrEmpty(scBasePath))
|
||||
// scBasePath = $"{Module}.{Name}";
|
||||
//else
|
||||
//{
|
||||
// scBasePath = scBasePath.Replace("{module}", Module);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
public virtual bool Initialize()
|
||||
{
|
||||
_connection = new RorzeEfemConnection(this);
|
||||
|
||||
_connection.OnDisconnected += OnDisconnected;
|
||||
_connection.OnConnected += OnConnected;
|
||||
_connection.OnError += OnError;
|
||||
_connection.Name = $"{Module}.{Name}";
|
||||
|
||||
_connection.Initialize();
|
||||
|
||||
_connection.AddEventHandler(RorzeEfemBasicMessage.MAPDT, new RorzeEfemHandlerMapdt(this, ModuleName.System, true));
|
||||
_connection.AddEventHandler(RorzeEfemBasicMessage.SIGSTAT, new RorzeEfemHandlerSigStat(this, ModuleName.System));
|
||||
_connection.AddEventHandler(RorzeEfemBasicMessage.TRANSREQ, new RorzeEfemHandlerTransReq(this, ModuleName.System));
|
||||
_connection.AddEventHandler(RorzeEfemBasicMessage.READY, new RorzeEfemHandlerReady(this, ModuleName.System));
|
||||
|
||||
DATA.Subscribe($"{Module}.{Name}.Status", () => _connection.StringFsmStatus);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void IEfemController.Initialize()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected)
|
||||
{
|
||||
EV.PostWarningLog("System", $"EFEM can not do initialize, not connected");
|
||||
return;
|
||||
}
|
||||
|
||||
IsInitialized = false;
|
||||
|
||||
if (!_connection.Execute(new RorzeEfemHandlerInit(this, ModuleName.System), out string reason))
|
||||
{
|
||||
EV.PostWarningLog("System", $"EFEM can not do initialize, {reason}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearError()
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected)
|
||||
{
|
||||
EV.PostWarningLog("System", $"EFEM can not do clear error, not connected");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_connection.Execute(new RorzeEfemHandlerError(this, false), out string reason))
|
||||
{
|
||||
EV.PostWarningLog("System", $"EFEM can not do clear error, {reason}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLoadPortCallback(ModuleName module, IEfemLoadPortCallback lpCallback)
|
||||
{
|
||||
lock (_locker)
|
||||
{
|
||||
_lpCallback[module] = lpCallback;
|
||||
}
|
||||
}
|
||||
public void SetRobotCallback(ModuleName module, IEfemRobotCallback robotCallback)
|
||||
{
|
||||
_robot = robotCallback;
|
||||
}
|
||||
public void SetAlignerCallback(ModuleName module, IEfemAlignerCallback alignerCallback)
|
||||
{
|
||||
_aligner = alignerCallback;
|
||||
}
|
||||
public void SetBufferCallback(ModuleName module, IEfemBufferCallback bufferCallback)
|
||||
{
|
||||
|
||||
}
|
||||
public void SetSignalTowerCallback(ModuleName module, IEfemSignalTowerCallback signalTowerCallback)
|
||||
{
|
||||
_signalTower = signalTowerCallback;
|
||||
}
|
||||
public void SetSystemCallback(ModuleName module, IEfemSystemCallback systemCallback)
|
||||
{
|
||||
_system = systemCallback;
|
||||
}
|
||||
public void SetFfuCallback(ModuleName module, IEfemFfuCallback ffuCallback)
|
||||
{
|
||||
_ffu = ffuCallback;
|
||||
}
|
||||
|
||||
protected virtual void OnError(string obj)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(obj))
|
||||
EV.PostAlarmLog(Module, obj);
|
||||
}
|
||||
|
||||
protected virtual void OnConnected()
|
||||
{
|
||||
EV.PostInfoLog(Module, $"{Name} connected.");
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnDisconnected()
|
||||
{
|
||||
EV.PostWarningLog(Module, $"{Name} disconnected.");
|
||||
}
|
||||
|
||||
public virtual void Monitor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
if (_connection != null)
|
||||
{
|
||||
_connection.Terminate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool AlarmIsTripped()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool IsOperable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Home(out string reason)
|
||||
{
|
||||
Init();
|
||||
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool QueryWaferPresence(out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public event Action<string> CarrierArrived;
|
||||
public event Action<string> CarrierRemoved;
|
||||
public event Action<string, string> CarrierPresenceStateError;
|
||||
public event Action<string, bool> CarrierPresenceStateChanged;
|
||||
public event Action<string> CarrierDoorClosed;
|
||||
public event Action<string> CarrierDoorOpened;
|
||||
public event Action<string> E84HandOffStart;
|
||||
public event Action<string> E84HandOffComplete;
|
||||
public bool HomeLoadPort(string lp, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool LoadPortClearAlarm(string lp, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool UnclampCarrier(string lp, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool ClampCarrier(string lp, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool MoveCarrierPort(string lp, string position, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool OpenCarrierDoor(string lp, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool OpenDoorAndMapCarrier(string lp, out string slotMap, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool CloseCarrierDoor(string lp, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool GetLoadPortStatus(string lp, out LoadportCassetteState cassetteState, out FoupClampState clampState,
|
||||
out FoupDockState dockState, out FoupDoorState doorState, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool MapCarrier(string lp, out string slotMap, out string reason)
|
||||
{
|
||||
slotMap = string.Empty;
|
||||
if (_connection == null || !_connection.IsConnected)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerWafsh(this, ModuleHelper.Converter(lp), true), out reason);
|
||||
}
|
||||
|
||||
public bool QueryMapResult(string lp, out string reason)
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerMapdt(this, ModuleHelper.Converter(lp), true), out reason);
|
||||
|
||||
}
|
||||
|
||||
public bool ReadCarrierId(string lp, out string carrierId, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool HomeWaferAligner(out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool AlignWafer(double angle, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool AlignerMapWaferPresence(out string slotMap, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool HomeAllAxes(out string reason)
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerHome(this, ModuleName.EfemRobot), out reason);
|
||||
}
|
||||
|
||||
public bool QueryRobotWaferPresence(out string slotMap, out string reason)
|
||||
{
|
||||
slotMap = string.Empty;
|
||||
if (_connection == null || !_connection.IsConnected || !IsInitialized)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerState(this, RorzeEfemStateType.TRACK), out reason);
|
||||
}
|
||||
|
||||
public bool GetTwoWafers(ModuleName chamber, int slot, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool PutTwoWafers(ModuleName chamber, int slot, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool GetWafer(ModuleName chamber, int slot, Hand hand, out string reason)
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected || !IsInitialized)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerLoad(this, chamber, slot, hand, WaferManager.Instance.GetWaferSize(chamber, slot)), out reason);
|
||||
}
|
||||
|
||||
public bool PutWafer(ModuleName chamber, int slot, Hand hand, out string reason)
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected || !IsInitialized)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerUnload(this, chamber, slot, hand, WaferManager.Instance.GetWaferSize(ModuleName.EfemRobot, (int)hand)), out reason);
|
||||
}
|
||||
|
||||
public bool MoveToReadyGet(ModuleName chamber, int slot, Hand hand, out string reason)
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected || !IsInitialized)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerGoto(this, chamber, slot, hand, true), out reason);
|
||||
}
|
||||
|
||||
public bool MoveToReadyPut(ModuleName chamber, int slot, Hand hand, out string reason)
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected || !IsInitialized)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerGoto(this, chamber, slot, hand, false), out reason);
|
||||
}
|
||||
|
||||
public bool SetSignalLight(STLightTypes type, SignalTowerActions state, out string reason)
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected || !IsCommunicationReady)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerSigout(this, ModuleName.System, type, state), out reason);
|
||||
}
|
||||
|
||||
public bool SetLoadPortLight(ModuleName chamber, Indicator light, IndicatorState state)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool SetLoadPortLight(ModuleName chamber, IndicatorType light, IndicatorState state, out string reason)
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected || !IsCommunicationReady)
|
||||
{
|
||||
reason = "not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
return _connection.Execute(new RorzeEfemHandlerSigout(this, chamber, light, state), out reason);
|
||||
}
|
||||
|
||||
public bool SetE84Available(string lp, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool SetE84Unavailable(string lp, out string reason)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
if (_connection != null)
|
||||
{
|
||||
_connection.Reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
if (_connection != null)
|
||||
{
|
||||
_connection.InvokeConnect();
|
||||
}
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
if (_connection != null)
|
||||
{
|
||||
_connection.InvokeDisconnect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public bool CheckIsBusy(ModuleName module)
|
||||
{
|
||||
return _connection.IsBusy((int)module);
|
||||
}
|
||||
|
||||
public bool Map(ModuleName module, out string reason)
|
||||
{
|
||||
if (_connection == null || !_connection.IsConnected)
|
||||
{
|
||||
reason = "Not connected";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_connection.Execute(new RorzeEfemHandlerMapdt(this, module, true), out reason))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void QueryState(ModuleName module)
|
||||
{
|
||||
if (_connection != null && _connection.IsConnected)
|
||||
{
|
||||
if (!_connection.Execute(new RorzeEfemHandlerSigStat(this, module), out string reason))
|
||||
{
|
||||
EV.PostWarningLog(Module, reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void NoteStateEvent(ModuleName module, string data1, string data2)
|
||||
{
|
||||
if (ModuleHelper.IsLoadPort(module) && _lpCallback.ContainsKey(module))
|
||||
_lpCallback[module].NoteStatus(data1, data2);
|
||||
}
|
||||
|
||||
internal void NoteFailed(ModuleName module, string error)
|
||||
{
|
||||
switch (module)
|
||||
{
|
||||
case ModuleName.EfemRobot:
|
||||
_robot.NoteFailed(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteCancel(ModuleName module, string error)
|
||||
{
|
||||
switch (module)
|
||||
{
|
||||
case ModuleName.EfemRobot:
|
||||
_robot.NoteCancel(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteComplete(ModuleName module)
|
||||
{
|
||||
switch (module)
|
||||
{
|
||||
case ModuleName.EfemRobot:
|
||||
_robot.NoteComplete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal void NoteWaferMapResult(ModuleName module, string slotMap)
|
||||
{
|
||||
if (ModuleHelper.IsLoadPort(module))
|
||||
{
|
||||
_lpCallback[module].NoteSlotMap(slotMap);
|
||||
}
|
||||
}
|
||||
|
||||
public void NoteInitialized()
|
||||
{
|
||||
IsInitialized = true;
|
||||
}
|
||||
|
||||
public void NoteCommunicationReady()
|
||||
{
|
||||
IsCommunicationReady = true;
|
||||
}
|
||||
|
||||
public virtual void NoteWaferTrack(string waferInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected virtual void OnCarrierArrived(string obj)
|
||||
{
|
||||
CarrierArrived?.Invoke(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
|
||||
{
|
||||
public class RorzeEfemAbsError
|
||||
{
|
||||
public static Dictionary<string, string> AbsCode = new Dictionary<string, string>()
|
||||
{
|
||||
{"VAC", "Lack of vacuum source"},
|
||||
{"AIR", " Lack of positive source pressure"},
|
||||
{"STALL", " Stall"},
|
||||
{"LIMIT", " Limit"},
|
||||
{"EMS", " Controller emergency stop"},
|
||||
{"COMM", " Internal communication error"},
|
||||
{"VACON", " Vacuum on error"},
|
||||
{"VACON2", " Vacuum pressure drops during transfer"},
|
||||
{"VACOF", " Vacuum OFF error"},
|
||||
{"CLAMPON", " Clamp error (*)"},
|
||||
{"CLAMPOF", " Clamp OFF error"},
|
||||
{"PRTWAF", " Wafer protrusion"},
|
||||
{"CRSWAF", " Cross wafer detection"},
|
||||
{"THICKWAF", " Wafer thickness error detection (Thick)"},
|
||||
{"THINWAF", " Wafer thickness error detection (Thin)"},
|
||||
{"DBLWAF", " Double wafers detection"},
|
||||
{"BOWWAF", " Wafer front down detection"},
|
||||
{"COMMAND", " Robot command error"},
|
||||
|
||||
{"PODNG", " Carrier placement error"},
|
||||
{"VAC_S", " Vacuum sensor error"},
|
||||
{"UNIWIRE", " Uniwire error"},
|
||||
{"SAFTY", " Pinch sensor reaction"},
|
||||
{"LOCKNG", " Carrier lock disabled"},
|
||||
{"UNLOCKNG", " Carrier unlock disabled"},
|
||||
{"L-KEY_OV", " Latch key over-rotation"},
|
||||
{"L-KEY_LK", " Latch key reverse disabled"},
|
||||
{"L-KEY_UL", " Latch key release disabled"},
|
||||
{"MAP_S1", " Mapping sensor ready disabled"},
|
||||
{"MAP_S2", " Mapping sensor return disabled"},
|
||||
{"NONWAF", " No wafer on arm"},
|
||||
{"ALIGNNG", " Alignment failure"},
|
||||
{"ORG_NG", " Origin search uncompleted"},
|
||||
{"HARDWARE", " Hardware error"},
|
||||
{"UNSETUP", " Setting data is not set"},
|
||||
{"SETUPDT_NG", " Setting data error"},
|
||||
{"CONTROLLER", " Controller malfunction"},
|
||||
{"SYSTEM", " System (unit)malfunction"},
|
||||
|
||||
{"SYSTEM_FFxx", " System (unit) malfunction"},
|
||||
{"N2", " Lack of N2 source pressure"},
|
||||
{"PURGE", " N2 purge error"},
|
||||
{"INTERNAL", " Internal error"},
|
||||
{"UNDEFINITION", " Undefined error"},
|
||||
};
|
||||
|
||||
|
||||
public static string GetError(string code)
|
||||
{
|
||||
if (AbsCode.ContainsKey(code))
|
||||
return AbsCode[code];
|
||||
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
|
||||
{
|
||||
public enum RorzeEfemBasicMessage
|
||||
{
|
||||
READY, //Ready , ACK, INF
|
||||
INIT, //EFEM initialization MOV, ACK, INF
|
||||
ORGSH, //Origin search
|
||||
|
||||
LOCK, //Pod lock MOV, ACK, INF
|
||||
UNLOCK, //Pod unlock
|
||||
DOCK, //Moving to pod dock position MOV, ACK, INF
|
||||
UNDOCK, //Moving to pod undock position MOV, ACK, INF
|
||||
OPEN, //Pod open MOV, ACK, INF
|
||||
CLOSE, //Pod close MOV, ACK, INF
|
||||
|
||||
WAFSH, //Wafer mapping MOV, ACK, INF
|
||||
MAPDT, //Wafer map information GET, ACK, INF, EVT
|
||||
|
||||
LOAD, //Wafer carry-out MOV, ACK, INF
|
||||
UNLOAD, //Wafer carry-in MOV, ACK, INF
|
||||
|
||||
GOTO, //Move to specified object MOV, ACK, INF
|
||||
TRANS, //Wafer transfer MOV, ACK, INF
|
||||
CHANGE, //Wafer exchange MOV, ACK, INF
|
||||
|
||||
ALIGN, //Alignment MOV, SET, ACK, INF
|
||||
|
||||
HOME, //Home MOV, ACK, INF
|
||||
HOLD, //Hold MOV, ACK, INF
|
||||
RESTR, //Restart MOV, ACK
|
||||
ABORT, //Abort termination MOV, ACK, INF
|
||||
EMS, //Emergency stop MOV, ACK, INF
|
||||
ERROR, //Error GET, SET, ACK, INF
|
||||
|
||||
CLAMP, //Clamp output, get state GET, SET, ACK, INF
|
||||
STATE, //Get status GET, ACK, INF
|
||||
|
||||
MODE, //E84 mode setting GET, SET, ACK, INF
|
||||
TRANSREQ, //E84 automatic transfer request MOV, GET, ACK, INF, EVT
|
||||
|
||||
SIGOUT, //Signal output SET, ACK
|
||||
SIGSTAT, //Signal input/output information GET, ACK, INF, EVT
|
||||
|
||||
|
||||
EVENT, //Event setting GET, SET, ACK, INF
|
||||
CSTID, //Carrier ID GET, ACK, INF
|
||||
|
||||
USDEFINE, //User Define
|
||||
|
||||
FFU, //Ffu SET,ACK,INF
|
||||
WTYPE, //Wtype Set and acquire wafer type SET,ACK,GET,ACK,INF
|
||||
PURGE, //Purge SET,ACK,GET,ACK,INF
|
||||
ADPLOCK, //Adplock MOV,ACK,INF
|
||||
ADPUNLOCK, //Adpunlock SET,ACK,INF
|
||||
LED, //Led SET,ACK,INF
|
||||
WORKCHK, //Workchk MOV,ACK,INF
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+314
@@ -0,0 +1,314 @@
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.Common.Communications;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
|
||||
{
|
||||
|
||||
public class RorzeEfemMessage : AsciiMessage
|
||||
{
|
||||
public ModuleName TargetModule { get; set; }
|
||||
|
||||
public RorzeEfemMessageType MessageType { get; set; }
|
||||
|
||||
public RorzeEfemBasicMessage BasicMessage { get; set; }
|
||||
|
||||
public string Parameter { get; set; }
|
||||
|
||||
public string NakFactor { get; set; }
|
||||
|
||||
public bool WaitAck { get; set; }
|
||||
|
||||
public bool WaitInf { get; set; }
|
||||
|
||||
//ABS : Message* | ERROR / Parameter1 / Parameter2 ;
|
||||
//ERROR / Parameter1 / Parameter2
|
||||
public string AbsError { get; set; }
|
||||
|
||||
//CAN : Message* | Factor / Place ;
|
||||
//Factor / Place
|
||||
public string CanError { get; set; }
|
||||
}
|
||||
|
||||
public class RorzeEfemConnection : FsmConnection
|
||||
{
|
||||
private string _cachedBuffer = string.Empty;
|
||||
|
||||
private object _lockerHandler = new object();
|
||||
|
||||
private IConnectionContext _config;
|
||||
|
||||
List<HandlerBase> _handlers = new List<HandlerBase>();
|
||||
|
||||
private Dictionary<RorzeEfemBasicMessage, HandlerBase> _eventHandler = new Dictionary<RorzeEfemBasicMessage, HandlerBase>();
|
||||
|
||||
public RorzeEfemConnection(IConnectionContext config)
|
||||
{
|
||||
_config = config;
|
||||
}
|
||||
|
||||
|
||||
public bool IsBusy(int mutexId)
|
||||
{
|
||||
lock (_lockerHandler)
|
||||
{
|
||||
foreach (var handlerBase in _handlers)
|
||||
{
|
||||
if (handlerBase.MutexId == mutexId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddEventHandler(RorzeEfemBasicMessage type, RorzeEfemHandler handler)
|
||||
{
|
||||
System.Diagnostics.Debug.Assert(!_eventHandler.ContainsKey(type));
|
||||
|
||||
_eventHandler[type] = handler;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
base.Initialize(100, new SocketClient(_config), _config);
|
||||
}
|
||||
|
||||
protected override void OnConnect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDisconnect()
|
||||
{
|
||||
lock (_lockerHandler)
|
||||
{
|
||||
_cachedBuffer = string.Empty;
|
||||
_handlers.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnConnectMonitor()
|
||||
{
|
||||
MonitorTimeout();
|
||||
|
||||
base.OnConnectMonitor();
|
||||
}
|
||||
|
||||
private HandlerBase MonitorTimeout()
|
||||
{
|
||||
HandlerBase result = null;
|
||||
lock (_lockerHandler)
|
||||
{
|
||||
foreach (var handlerBase in _handlers)
|
||||
{
|
||||
if (handlerBase.CheckTimeout())
|
||||
{
|
||||
EV.PostWarningLog("System", $"execute {handlerBase.Name} timeout");
|
||||
result = handlerBase;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
_handlers.Remove(result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool Execute(HandlerBase handler, out string reason)
|
||||
{
|
||||
lock (_lockerHandler)
|
||||
{
|
||||
foreach (var handlerBase in _handlers)
|
||||
{
|
||||
if (handlerBase.MutexId == handler.MutexId && handler.MutexId!=-1)
|
||||
{
|
||||
reason = $"Can not execute {handler.Name} while execute {handlerBase.Name}";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_handlers.Add(handler);
|
||||
|
||||
handler.SetState(EnumHandlerState.Sent);
|
||||
|
||||
if (_config.IsAscii)
|
||||
{
|
||||
InvokeSendData(handler.SendText);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeSendData(handler.SendBinary);
|
||||
}
|
||||
}
|
||||
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
InvokeReset();
|
||||
}
|
||||
|
||||
protected override void OnReceiveData(string message)
|
||||
{
|
||||
_cachedBuffer += message;
|
||||
|
||||
int enderIndex = _cachedBuffer.IndexOf(";\r");
|
||||
while (enderIndex != -1)
|
||||
{
|
||||
if (enderIndex > 0)
|
||||
{
|
||||
ProceedResponse(_cachedBuffer.Substring(0, enderIndex));
|
||||
}
|
||||
|
||||
_cachedBuffer = _cachedBuffer.Remove(0, enderIndex + 2);
|
||||
enderIndex = _cachedBuffer.IndexOf(";\r");
|
||||
}
|
||||
}
|
||||
|
||||
private void AckInfo(string message)
|
||||
{
|
||||
if (message.StartsWith("INF:"))
|
||||
{
|
||||
InvokeSendData(message.Replace("INF:", "ACK:") + ";\r");
|
||||
}
|
||||
else if (message.StartsWith("ABS:"))
|
||||
{
|
||||
InvokeSendData(message.Replace("ABS:", "ACK:") + ";\r");
|
||||
}
|
||||
else if (message.StartsWith("NAK:"))
|
||||
{
|
||||
InvokeSendData(message.Replace("NAK:", "ACK:") + ";\r");
|
||||
}
|
||||
else if (message.StartsWith("CAN:"))
|
||||
{
|
||||
InvokeSendData(message.Replace("CAN:", "ACK:") + ";\r");
|
||||
}
|
||||
}
|
||||
protected void ProceedResponse(string rawMessage)
|
||||
{
|
||||
RorzeEfemMessage msg = new RorzeEfemMessage();
|
||||
msg.RawMessage = rawMessage;
|
||||
if (rawMessage == "INF:READY/COMM")
|
||||
{
|
||||
_eventHandler[RorzeEfemBasicMessage.READY].HandleMessage(msg, out _);
|
||||
|
||||
AckInfo(rawMessage);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
string[] words = rawMessage.Split(new char[5] { ':', '/', '>', '|', ';' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
msg.MessagePart = words;
|
||||
|
||||
if (!Enum.TryParse<RorzeEfemMessageType>(words[0], out RorzeEfemMessageType type))
|
||||
{
|
||||
LOG.Write($"{rawMessage} is not a valid EFEM message format");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == RorzeEfemMessageType.MOV || type == RorzeEfemMessageType.GET ||
|
||||
type == RorzeEfemMessageType.SET)
|
||||
{
|
||||
LOG.Write($"{rawMessage} is not a valid EFEM message format, {type} is TO EFEM");
|
||||
return;
|
||||
}
|
||||
|
||||
msg.MessageType = type;
|
||||
msg.IsEvent = msg.MessageType == RorzeEfemMessageType.EVT;
|
||||
|
||||
int messageIndex = msg.MessageType == RorzeEfemMessageType.NAK ? 2 : 1;
|
||||
|
||||
if (words.Length <= messageIndex || !Enum.TryParse<RorzeEfemBasicMessage>(words[messageIndex], out RorzeEfemBasicMessage basicMessage))
|
||||
{
|
||||
LOG.Write($"{rawMessage} is not a valid EFEM message format");
|
||||
return;
|
||||
}
|
||||
msg.BasicMessage = basicMessage;
|
||||
|
||||
if (msg.MessageType == RorzeEfemMessageType.NAK)
|
||||
{
|
||||
msg.NakFactor = words[1];
|
||||
msg.Parameter = rawMessage.Substring(rawMessage.IndexOf('/') + 1);
|
||||
}
|
||||
else if (msg.MessageType == RorzeEfemMessageType.CAN)
|
||||
{
|
||||
msg.CanError = rawMessage.Substring(rawMessage.IndexOf('|'));
|
||||
msg.Parameter = rawMessage.Substring(rawMessage.IndexOf('/') + 1, rawMessage.IndexOf('|') - rawMessage.IndexOf('/'));
|
||||
}
|
||||
else if (msg.MessageType == RorzeEfemMessageType.ABS)
|
||||
{
|
||||
msg.AbsError = rawMessage.Substring(rawMessage.IndexOf('|'));
|
||||
msg.Parameter = rawMessage.Substring(rawMessage.IndexOf('/') + 1, rawMessage.IndexOf('|') - rawMessage.IndexOf('/'));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Parameter = rawMessage.Substring(rawMessage.IndexOf('/') + 1);
|
||||
}
|
||||
|
||||
if (msg.IsEvent)
|
||||
{
|
||||
ProceedEvent(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
ProceedMessage(msg);
|
||||
}
|
||||
|
||||
private void ProceedMessage(RorzeEfemMessage msg)
|
||||
{
|
||||
lock (_lockerHandler)
|
||||
{
|
||||
HandlerBase handlerDone = null;
|
||||
|
||||
bool matchMessage = false;
|
||||
foreach (var handler in _handlers)
|
||||
{
|
||||
matchMessage = handler.HandleMessage(msg, out bool completed);
|
||||
if (completed)
|
||||
{
|
||||
handlerDone = handler;
|
||||
AckInfo(msg.RawMessage);
|
||||
break;
|
||||
}
|
||||
|
||||
if (matchMessage)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!matchMessage)
|
||||
{
|
||||
LOG.Write($"No handler for message, {msg.RawMessage}");
|
||||
return;
|
||||
}
|
||||
|
||||
_handlers.Remove(handlerDone);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProceedEvent(RorzeEfemMessage msg)
|
||||
{
|
||||
if (_eventHandler.ContainsKey(msg.BasicMessage))
|
||||
{
|
||||
_eventHandler[msg.BasicMessage].HandleMessage(msg, out _);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG.Write($"No handler for event {msg.RawMessage}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+887
@@ -0,0 +1,887 @@
|
||||
using Aitex.Core.Common;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Sorter.Common;
|
||||
using MECF.Framework.Common.Communications;
|
||||
using MECF.Framework.Common.Device.Bases;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
|
||||
{
|
||||
public abstract class RorzeEfemHandler : HandlerBase
|
||||
{
|
||||
public static Dictionary<string, ModuleName> ParameterModuleMap = new Dictionary<string, ModuleName>()
|
||||
{
|
||||
{"SYSTEM", ModuleName.System},
|
||||
{"ROB", ModuleName.EfemRobot},
|
||||
{"P1", ModuleName.LP1},
|
||||
{"P2", ModuleName.LP2},
|
||||
{"P3", ModuleName.LP3},
|
||||
{"P4", ModuleName.LP4},
|
||||
{"LLA", ModuleName.LL1},
|
||||
{"LLB", ModuleName.LL2},
|
||||
{"BF1", ModuleName.Buffer},
|
||||
};
|
||||
public RorzeEfem Device { get; }
|
||||
public ModuleName Module
|
||||
{
|
||||
get { return _module; }
|
||||
}
|
||||
|
||||
private ModuleName _module;
|
||||
|
||||
private RorzeEfemMessageType _type;
|
||||
private RorzeEfemBasicMessage _basicMessage;
|
||||
private string _parameter;
|
||||
private bool _waitInfo;
|
||||
|
||||
protected RorzeEfemHandler(RorzeEfem device, ModuleName module,
|
||||
RorzeEfemMessageType type, RorzeEfemBasicMessage basicMessage, string parameter, bool waitInfo)
|
||||
: base(BuildMessage(type, basicMessage, parameter))
|
||||
{
|
||||
Device = device;
|
||||
_module = module;
|
||||
_waitInfo = waitInfo;
|
||||
_basicMessage = basicMessage;
|
||||
_parameter = parameter;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public static string BuildMessage(RorzeEfemMessageType type, RorzeEfemBasicMessage basicMessage, string parameter)
|
||||
{
|
||||
return string.IsNullOrEmpty(parameter) ? $"{type}:{basicMessage};\r" : $"{type}:{basicMessage}/{parameter};\r";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
transactionComplete = false;
|
||||
RorzeEfemMessage message = baseMessage as RorzeEfemMessage;
|
||||
if (!MatchMessage(message))
|
||||
return false;
|
||||
|
||||
if (message.MessageType == RorzeEfemMessageType.ACK)
|
||||
{
|
||||
OnAcked();
|
||||
|
||||
if (!_waitInfo)
|
||||
{
|
||||
OnComplete();
|
||||
transactionComplete = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (message.MessageType == RorzeEfemMessageType.INF)
|
||||
{
|
||||
transactionComplete = true;
|
||||
|
||||
ProceedInfo(message);
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
if (message.MessageType == RorzeEfemMessageType.ABS)
|
||||
{
|
||||
transactionComplete = true;
|
||||
|
||||
ProceedAbs(message);
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
|
||||
if (message.MessageType == RorzeEfemMessageType.NAK)
|
||||
{
|
||||
transactionComplete = true;
|
||||
|
||||
ProceedNak(message);
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
if (message.MessageType == RorzeEfemMessageType.CAN)
|
||||
{
|
||||
transactionComplete = true;
|
||||
|
||||
ProceedCancel(message);
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual void ProceedNak(RorzeEfemMessage message)
|
||||
{
|
||||
Device.NoteCancel(Module, $"Can not {Name}, " + RorzeEfemAbsError.GetError(message.NakFactor));
|
||||
}
|
||||
|
||||
protected virtual void ProceedCancel(RorzeEfemMessage message)
|
||||
{
|
||||
Device.NoteCancel(Module, $"Can not {Name}, " + RorzeEfemAbsError.GetError(message.CanError));
|
||||
}
|
||||
|
||||
protected virtual void ProceedAbs(RorzeEfemMessage message)
|
||||
{
|
||||
Device.NoteFailed(Module, $"Failed {Name}, " + RorzeEfemAbsError.GetError(message.AbsError));
|
||||
}
|
||||
|
||||
protected virtual bool ProceedInfo(RorzeEfemMessage msg)
|
||||
{
|
||||
Device.NoteComplete(Module);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected bool MatchMessage(RorzeEfemMessage msg)
|
||||
{
|
||||
if (msg.BasicMessage != _basicMessage && msg.Parameter != _parameter)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string ConvertModuleToParameter(ModuleName module)
|
||||
{
|
||||
if (ParameterModuleMap.Values.Contains(module))
|
||||
{
|
||||
foreach (var moduleName in ParameterModuleMap)
|
||||
{
|
||||
if (moduleName.Value == module)
|
||||
return moduleName.Key;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
public static bool ConvertParameterToModule(string parameter, out ModuleName module)
|
||||
{
|
||||
if (ParameterModuleMap.ContainsKey(parameter))
|
||||
{
|
||||
module = ParameterModuleMap[parameter];
|
||||
return true;
|
||||
}
|
||||
|
||||
module = ModuleName.System;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//READY
|
||||
public class RorzeEfemHandlerReady : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerReady(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.READY, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = $"Ready {module}";
|
||||
MutexId = -1;
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
Device.NoteCommunicationReady();
|
||||
|
||||
transactionComplete = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//INIT
|
||||
public class RorzeEfemHandlerInit : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerInit(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.INIT, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = $"Initialize {module}";
|
||||
MutexId = (int)module;
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
Device.NoteInitialized();
|
||||
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//ORGSH
|
||||
public class RorzeEfemHandlerOrgsh : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerOrgsh(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ORGSH, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = $"Home {module}";
|
||||
MutexId = (int)module;
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//LOCK
|
||||
public class RorzeEfemHandlerLock : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerLock(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.LOCK, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.LOCK.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//UNLOCK
|
||||
public class RorzeEfemHandlerUnlock : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerUnlock(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.UNLOCK, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.UNLOCK.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//DOCK
|
||||
public class RorzeEfemHandlerDock : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerDock(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.DOCK, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.DOCK.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//UNDOCK
|
||||
public class RorzeEfemHandlerUndock : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerUndock(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.UNDOCK, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.UNDOCK.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//OPEN
|
||||
public class RorzeEfemHandlerOpen : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerOpen(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.OPEN, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.OPEN.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//CLOSE
|
||||
public class RorzeEfemHandlerClose : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerClose(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.CLOSE, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.CLOSE.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//WAFSH
|
||||
public class RorzeEfemHandlerWafsh : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerWafsh(RorzeEfem device, ModuleName target, bool mapByRobot)
|
||||
: base(device, mapByRobot ? ModuleName.EfemRobot : target, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.WAFSH, ConvertModuleToParameter(target), true)
|
||||
{
|
||||
Name = $"Map wafer of {target}";
|
||||
MutexId = (int)ModuleName.EfemRobot;
|
||||
}
|
||||
|
||||
public RorzeEfemHandlerWafsh(RorzeEfem device, ModuleName target, bool mapByRobot, int thicknessIndex)
|
||||
: base(device, mapByRobot ? ModuleName.EfemRobot : target, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.WAFSH, BuildParameter(target, thicknessIndex), true)
|
||||
{
|
||||
Name = $"Map wafer of {target}";
|
||||
MutexId = (int)ModuleName.EfemRobot;
|
||||
}
|
||||
|
||||
|
||||
public static string BuildParameter(ModuleName target, int thicknessIndex)
|
||||
{
|
||||
string para1 = ConvertModuleToParameter(target);
|
||||
return $"{para1}/{thicknessIndex}";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//MAPDT
|
||||
public class RorzeEfemHandlerMapdt : RorzeEfemHandler
|
||||
{
|
||||
private ModuleName _target;
|
||||
|
||||
public RorzeEfemHandlerMapdt(RorzeEfem device, ModuleName target, bool mapByRobot)
|
||||
: base(device, mapByRobot ? ModuleName.EfemRobot : target, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.MAPDT, ConvertModuleToParameter(target), true)
|
||||
{
|
||||
Name = $"Get wafer map result of {target}";
|
||||
|
||||
_target = target;
|
||||
MutexId = (int)ModuleName.EfemRobot;
|
||||
}
|
||||
|
||||
protected override bool ProceedInfo(RorzeEfemMessage msg)
|
||||
{
|
||||
if (ConvertParameterToModule(msg.MessagePart[2], out ModuleName target))
|
||||
{
|
||||
Device.NoteWaferMapResult(target, msg.MessagePart[3]);
|
||||
}
|
||||
|
||||
if (!msg.IsEvent)
|
||||
{
|
||||
Device.NoteComplete(Module);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//GOTO
|
||||
public class RorzeEfemHandlerGoto : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerGoto(RorzeEfem device, ModuleName target, int slot, Hand blade, bool isPick)
|
||||
: base(device, ModuleName.EfemRobot, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.GOTO, BuildParameter(target, slot, blade, isPick), true)
|
||||
{
|
||||
Name = $"Goto from {target} slot {slot + 1}";
|
||||
|
||||
MutexId = (int)ModuleName.EfemRobot;
|
||||
}
|
||||
|
||||
public static string BuildParameter(ModuleName target, int slot, Hand blade, bool isPick)
|
||||
{
|
||||
string para1 = ConvertModuleToParameter(target);
|
||||
string para2 = blade == Hand.Blade1 ? "ARM2" : (blade == Hand.Blade2 ? "ARM1" : "ARM3");
|
||||
string para3 = isPick ? "DOWN":"UP";
|
||||
return $"{para1}{slot + 1:D2}/{para2}/{para3}";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//LOAD
|
||||
public class RorzeEfemHandlerLoad : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerLoad(RorzeEfem device, ModuleName target, int slot, Hand blade, WaferSize waferSize)
|
||||
: base(device, ModuleName.EfemRobot, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.LOAD, BuildParameter(target, slot, blade, waferSize), true)
|
||||
{
|
||||
Name = $"Pick from {target} slot {slot + 1}";
|
||||
|
||||
MutexId = (int)ModuleName.EfemRobot;
|
||||
}
|
||||
|
||||
public static string BuildParameter(ModuleName target, int slot, Hand blade, WaferSize waferSize)
|
||||
{
|
||||
string para1 = ConvertModuleToParameter(target);
|
||||
string para2 = blade == Hand.Blade1 ? "ARM2" : (blade == Hand.Blade2 ? "ARM1" : "ARM3");
|
||||
string para3 = waferSize.ToString();
|
||||
return $"{para1}{slot + 1:D2}/{para2}/{para3}";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//UNLOAD
|
||||
public class RorzeEfemHandlerUnload : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerUnload(RorzeEfem device, ModuleName target, int slot, Hand blade, WaferSize waferSize)
|
||||
: base(device, ModuleName.EfemRobot, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.UNLOAD, BuildParameter(target, slot, blade, waferSize), true)
|
||||
{
|
||||
Name = $"Place to {target} slot {slot + 1}";
|
||||
MutexId = (int)ModuleName.EfemRobot;
|
||||
}
|
||||
|
||||
public static string BuildParameter(ModuleName target, int slot, Hand blade, WaferSize waferSize)
|
||||
{
|
||||
string para1 = ConvertModuleToParameter(target);
|
||||
string para2 = blade == Hand.Blade1 ? "ARM2" : (blade == Hand.Blade2 ? "ARM1" : "ARM3");
|
||||
string para3 = waferSize.ToString();
|
||||
return $"{para1}{slot + 1:D2}/{para2}/{para3}";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//TRANS
|
||||
public class RorzeEfemHandlerTrans : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerTrans(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.TRANS, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.TRANS.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//CHANGE
|
||||
public class RorzeEfemHandlerChange : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerChange(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.CHANGE, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.CHANGE.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//ALIGN
|
||||
public class RorzeEfemHandlerAlign : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerAlign(RorzeEfem device, ModuleName module, bool isMov)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ALIGN, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.ALIGN.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//HOME
|
||||
public class RorzeEfemHandlerHome : RorzeEfemHandler
|
||||
{
|
||||
|
||||
public RorzeEfemHandlerHome(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.HOME, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.HOME.ToString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//HOLD
|
||||
public class RorzeEfemHandlerHold : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerHold(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.HOLD, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.HOLD.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//RESTR
|
||||
public class RorzeEfemHandlerRestr : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerRestr(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.RESTR, ConvertModuleToParameter(module), false)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.RESTR.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//ABORT
|
||||
public class RorzeEfemHandlerAbort : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerAbort(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ABORT, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.ABORT.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//EMS
|
||||
public class RorzeEfemHandlerEms : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerEms(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.EMS, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.EMS.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//ERROR
|
||||
public class RorzeEfemHandlerError : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerError(RorzeEfem device, bool isQuery)
|
||||
: base(device, ModuleName.System, isQuery ? RorzeEfemMessageType.GET : RorzeEfemMessageType.SET, RorzeEfemBasicMessage.ERROR, isQuery ? "" : "CLEAR", isQuery)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.ERROR.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//CLAMP
|
||||
public class RorzeEfemHandlerClamp : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerClamp(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.CLAMP, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.CLAMP.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//STATE
|
||||
public class RorzeEfemHandlerState : RorzeEfemHandler
|
||||
{
|
||||
private RorzeEfemStateType _state;
|
||||
public RorzeEfemHandlerState(RorzeEfem device, RorzeEfemStateType state)
|
||||
: base(device, ModuleName.System, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.STATE, state.ToString(), true)
|
||||
{
|
||||
Name = "Query State";
|
||||
_state = state;
|
||||
}
|
||||
|
||||
protected override bool ProceedInfo(RorzeEfemMessage msg)
|
||||
{
|
||||
if (_state == RorzeEfemStateType.TRACK)
|
||||
{
|
||||
Device.NoteWaferTrack(msg.MessagePart[3]);
|
||||
}
|
||||
Device.NoteComplete(Module);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//LED
|
||||
public class RorzeEfemHandlerLed : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerLed(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.LED, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.LED.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//WORKCHK
|
||||
public class RorzeEfemHandlerWorkChk : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerWorkChk(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.WORKCHK, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.WORKCHK.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//FFU
|
||||
public class RorzeEfemHandlerFfu : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerFfu(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.FFU, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.FFU.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//WTYPE
|
||||
public class RorzeEfemHandlerWType : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerWType(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.WTYPE, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.WTYPE.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//PURGE
|
||||
public class RorzeEfemHandlerPurge : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerPurge(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.PURGE, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.PURGE.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//ADPLOCK
|
||||
public class RorzeEfemHandlerAdpLock : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerAdpLock(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ADPLOCK, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.ADPLOCK.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//ADPUNLOCK
|
||||
public class RorzeEfemHandlerAdpUnlock : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerAdpUnlock(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.ADPUNLOCK, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.ADPUNLOCK.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//MODE
|
||||
public class RorzeEfemHandlerMode : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerMode(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.MODE, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.MODE.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//TRANSREQ
|
||||
public class RorzeEfemHandlerTransReq : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerTransReq(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.TRANSREQ, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.TRANSREQ.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
//SIGOUT
|
||||
public class RorzeEfemHandlerSigout : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerSigout(RorzeEfem device, ModuleName module, IndicatorType type, IndicatorState state)
|
||||
: base(device, module, RorzeEfemMessageType.SET, RorzeEfemBasicMessage.SIGOUT, BuildParameter(module, type, state), false)
|
||||
{
|
||||
Name = $"Set Signal Tower";
|
||||
MutexId = -1;
|
||||
}
|
||||
|
||||
public RorzeEfemHandlerSigout(RorzeEfem device, ModuleName module, STLightTypes type, SignalTowerActions state)
|
||||
: base(device, module, RorzeEfemMessageType.SET, RorzeEfemBasicMessage.SIGOUT, BuildParameter(module, type, state), false)
|
||||
{
|
||||
Name = $"Set Signal Tower";
|
||||
MutexId = -1;
|
||||
}
|
||||
|
||||
public static string BuildParameter(ModuleName target, IndicatorType type, IndicatorState state)
|
||||
{
|
||||
Dictionary<IndicatorType, string> mapLightType = new Dictionary<IndicatorType, string>()
|
||||
{
|
||||
{IndicatorType.Busy, "BUSY"},
|
||||
{IndicatorType.Complete, "COMPLETE"},
|
||||
};
|
||||
|
||||
Dictionary<IndicatorState, string> mapLightState = new Dictionary<IndicatorState, string>()
|
||||
{
|
||||
{IndicatorState.ON, "ON"},
|
||||
{IndicatorState.OFF, "OFF"},
|
||||
{IndicatorState.BLINK, "BLINK"},
|
||||
};
|
||||
|
||||
string par1 = ConvertModuleToParameter(target);
|
||||
string par2 = mapLightType[type];
|
||||
string par3 = mapLightState[state];
|
||||
return $"{par1}/{par2}/{par3}";
|
||||
}
|
||||
|
||||
public static string BuildParameter(ModuleName target, STLightTypes type, SignalTowerActions state)
|
||||
{
|
||||
if (type == STLightTypes.Buzzer)
|
||||
{
|
||||
type = state == SignalTowerActions.Customized ? STLightTypes.Buzzer2 : STLightTypes.Buzzer1;
|
||||
state = state == SignalTowerActions.Off ? SignalTowerActions.Off : SignalTowerActions.On;
|
||||
}
|
||||
|
||||
Dictionary<STLightTypes, string> mapLightType = new Dictionary<STLightTypes, string>()
|
||||
{
|
||||
{STLightTypes.Red, "RED"},
|
||||
{STLightTypes.Yellow, "YELLOW"},
|
||||
{STLightTypes.Green, "GREEN"},
|
||||
{STLightTypes.Blue, "BLUE"},
|
||||
{STLightTypes.White, "WHITE"},
|
||||
{STLightTypes.Buzzer1, "BUZZER1"},
|
||||
{STLightTypes.Buzzer2, "BUZZER2"},
|
||||
};
|
||||
|
||||
Dictionary<SignalTowerActions, string> mapLightState = new Dictionary<SignalTowerActions, string>()
|
||||
{
|
||||
{SignalTowerActions.On, "ON"},
|
||||
{SignalTowerActions.Off, "OFF"},
|
||||
{SignalTowerActions.Customized, "BLINK"},
|
||||
};
|
||||
|
||||
string par1 = "STOWER";
|
||||
string par2 = mapLightType[type];
|
||||
string par3 = mapLightState[state];
|
||||
return $"{par1}/{par2}/{par3}";
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SIGSTAT
|
||||
/// EVT:/SIGSTAT/PARAMETER/DATA1/DATA2
|
||||
/// </summary>
|
||||
public class RorzeEfemHandlerSigStat : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerSigStat(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.GET, RorzeEfemBasicMessage.SIGSTAT, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.SIGSTAT.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
if (baseMessage.IsEvent)
|
||||
{
|
||||
var msg = baseMessage as RorzeEfemMessage;
|
||||
|
||||
if (!ConvertParameterToModule(msg.MessagePart[2], out ModuleName module))
|
||||
{
|
||||
EV.PostWarningLog(Device.Module, $"Parameter unrecognized, {msg.RawMessage}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Device.NoteStateEvent(module, msg.MessagePart[3], msg.MessagePart[4]);
|
||||
}
|
||||
|
||||
transactionComplete = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
//CSTID
|
||||
public class RorzeEfemHandlerCstid : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerCstid(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.CSTID, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.CSTID.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//EVENT
|
||||
public class RorzeEfemHandlerEvent : RorzeEfemHandler
|
||||
{
|
||||
public RorzeEfemHandlerEvent(RorzeEfem device, ModuleName module)
|
||||
: base(device, module, RorzeEfemMessageType.MOV, RorzeEfemBasicMessage.EVENT, ConvertModuleToParameter(module), true)
|
||||
{
|
||||
Name = RorzeEfemBasicMessage.EVENT.ToString();
|
||||
}
|
||||
|
||||
public override bool HandleMessage(MessageBase baseMessage, out bool transactionComplete)
|
||||
{
|
||||
return base.HandleMessage(baseMessage, out transactionComplete);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
|
||||
{
|
||||
public enum RorzeEfemMessageType
|
||||
{
|
||||
//Message which is issued by E/C with active
|
||||
MOV,
|
||||
GET,
|
||||
SET,
|
||||
|
||||
//Event report of completion or information for messages issued by E/C
|
||||
INF,
|
||||
ABS,
|
||||
EVT,
|
||||
|
||||
//Response message to the above primary message.
|
||||
ACK,
|
||||
NAK,
|
||||
CAN,
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
|
||||
{
|
||||
public enum RorzeEfemStateType
|
||||
{
|
||||
VER,
|
||||
TRACK,
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+350
@@ -0,0 +1,350 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using Aitex.Core.RT.Log;
|
||||
using MECF.Framework.Common.Communications;
|
||||
|
||||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Efems.Rorzes
|
||||
{
|
||||
public class SocketClient : IDisposable, IConnectable
|
||||
{
|
||||
public class ClientStateObject
|
||||
{
|
||||
// Client socket.
|
||||
public Socket workSocket = null;
|
||||
// Size of receive buffer.
|
||||
public static int BufferSize = 256;
|
||||
// Receive buffer.
|
||||
public byte[] buffer = new byte[BufferSize];
|
||||
// Received data string.
|
||||
public StringBuilder sb = new StringBuilder();
|
||||
|
||||
public ClientStateObject(int bufferSize = 256)
|
||||
{
|
||||
BufferSize = bufferSize;
|
||||
buffer = new byte[bufferSize];
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<string> OnCommunicationError;
|
||||
public event Action<string> OnAsciiDataReceived;
|
||||
public event Action<byte[]> OnBinaryDataReceived;
|
||||
|
||||
public bool IsConnected { get { return (_socket != null && _socket.Connected); } }
|
||||
|
||||
|
||||
private Socket _socket;
|
||||
|
||||
private int _bufferSize = 256;
|
||||
private static Object _lockerSocket = new Object();
|
||||
|
||||
private IConnectionContext _config;
|
||||
|
||||
public SocketClient(IConnectionContext config)
|
||||
{
|
||||
_config = config;
|
||||
}
|
||||
|
||||
|
||||
~SocketClient()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Connect()
|
||||
{
|
||||
try
|
||||
{
|
||||
string ip = _config.Address.Split(':')[0];
|
||||
int port = int.Parse(_config.Address.Split(':')[1]);
|
||||
|
||||
IPAddress ipAddress = IPAddress.Parse(ip);
|
||||
IPEndPoint remoteEP = new IPEndPoint(ipAddress, port);
|
||||
|
||||
lock (_lockerSocket)
|
||||
{
|
||||
Dispose();
|
||||
|
||||
if (_socket == null)
|
||||
{
|
||||
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
}
|
||||
|
||||
_socket.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), _socket);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Error($"Failed connect, " + ex);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ConnectCallback(IAsyncResult ar)
|
||||
{
|
||||
try
|
||||
{
|
||||
Socket client = (Socket)ar.AsyncState;
|
||||
|
||||
if (client.Connected)
|
||||
{
|
||||
client.EndConnect(ar);
|
||||
|
||||
ClientStateObject state = new ClientStateObject(_bufferSize);
|
||||
state.workSocket = _socket;
|
||||
|
||||
_socket.BeginReceive(state.buffer, 0, ClientStateObject.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Error($"Failed connect, " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Connect(out string reason)
|
||||
{
|
||||
Connect( );
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Disconnect(out string reason)
|
||||
{
|
||||
Dispose();
|
||||
|
||||
reason = string.Empty;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CheckIsConnected()
|
||||
{
|
||||
if (!IsConnected)
|
||||
return false;
|
||||
|
||||
lock (_lockerSocket)
|
||||
{
|
||||
if ((_socket.Poll(0, SelectMode.SelectWrite)) && (!_socket.Poll(0, SelectMode.SelectError)))
|
||||
{
|
||||
//byte[] buffer = new byte[1];
|
||||
//_socket.ReceiveTimeout
|
||||
//if (_socket.Receive(buffer, SocketFlags.Peek) == 0)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
return true;
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool SendBinaryData(byte[] data)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_lockerSocket)
|
||||
{
|
||||
_socket.BeginSend(data, 0, data.Length, 0, new AsyncCallback(SendCallback), _socket);
|
||||
|
||||
if (_config.EnableLog)
|
||||
{
|
||||
LOG.Info($"Communication {_config.Address} Send {string.Join(" ", data)}." );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Info($"Failed send {string.Join(" ", data)}, " + ex);
|
||||
NotifyError(ex.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SendAsciiData(string data)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_lockerSocket)
|
||||
{
|
||||
byte[] byteData = Encoding.ASCII.GetBytes(data);
|
||||
_socket.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), _socket);
|
||||
|
||||
if (_config.EnableLog)
|
||||
{
|
||||
LOG.Info($"Communication {_config.Address} Send {string.Join(" ", data)}.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Info($"Failed send {string.Join(" ", data)}, " + ex);
|
||||
NotifyError(ex.Message);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void ReceiveCallback(IAsyncResult ar)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClientStateObject state = (ClientStateObject)ar.AsyncState;
|
||||
Socket client = state.workSocket;
|
||||
|
||||
int bytesRead = client.EndReceive(ar);
|
||||
if (bytesRead > 0)
|
||||
{
|
||||
string receiveMessage = Encoding.ASCII.GetString(state.buffer, 0, bytesRead);
|
||||
state.sb.Append(receiveMessage);
|
||||
|
||||
if (!_config.IsAscii)
|
||||
{
|
||||
byte[] recvBuff = new byte[bytesRead];
|
||||
for (int i = 0; i < bytesRead; i++)
|
||||
{
|
||||
recvBuff[i] = state.buffer[i];
|
||||
}
|
||||
if (_config.EnableLog)
|
||||
{
|
||||
LOG.Info($"Communication {_config.Address} receive {string.Join(" ", recvBuff)}.");
|
||||
}
|
||||
|
||||
if (OnBinaryDataReceived != null)
|
||||
{
|
||||
OnBinaryDataReceived(recvBuff);
|
||||
}
|
||||
|
||||
state.sb.Clear();
|
||||
}
|
||||
else if (state.sb.Length > _config.NewLine.Length)
|
||||
{
|
||||
if (state.sb.ToString().Substring(state.sb.Length - _config.NewLine.Length).Equals(_config.NewLine))
|
||||
{
|
||||
string msg = state.sb.ToString();
|
||||
if (_config.EnableLog)
|
||||
{
|
||||
LOG.Info($"Communication {_config.Address} receive {msg}.");
|
||||
}
|
||||
|
||||
if (OnAsciiDataReceived != null)
|
||||
{
|
||||
OnAsciiDataReceived(state.sb.ToString());
|
||||
}
|
||||
state.sb.Clear();
|
||||
}
|
||||
}
|
||||
// Get the rest of the data.
|
||||
client.BeginReceive(state.buffer, 0, ClientStateObject.BufferSize, 0, new AsyncCallback(ReceiveCallback), state);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Info($"Failed receive data, " + ex);
|
||||
NotifyError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SendCallback(IAsyncResult ar)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Retrieve the socket from the state object.
|
||||
Socket client = (Socket)ar.AsyncState;
|
||||
// Complete sending the data to the remote device.
|
||||
int bytesSent = client.EndSend(ar);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Info($"Failed send data, " + ex);
|
||||
NotifyError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源(Dispose)
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_socket != null)
|
||||
{
|
||||
if (IsConnected)
|
||||
{
|
||||
_socket.Shutdown(SocketShutdown.Both);
|
||||
}
|
||||
|
||||
_socket.Close();
|
||||
_socket.Dispose();
|
||||
_socket = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.Write($"Dispose {_config.Address} resource exception, {ex}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void NotifyError(string reason)
|
||||
{
|
||||
if (OnCommunicationError != null)
|
||||
OnCommunicationError(reason);
|
||||
}
|
||||
|
||||
private bool PingConnect()
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
if (_socket != null && _socket.Connected)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
Ping pingTest = new Ping();
|
||||
PingReply reply = pingTest.Send(_config.Address.Split(':')[0]);
|
||||
if (reply.Status != IPStatus.Success)
|
||||
result = false;
|
||||
}
|
||||
catch (PingException) { result = false; }
|
||||
|
||||
if (_socket.Poll(1000, SelectMode.SelectRead) && (_socket.Available == 0))
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user