1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543 |
-
- using System;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Threading.Tasks;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.SCCore;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Communications;
- using TSC = Aitex.Sorter.Common;
- using Aitex.Core.Common;
- using MECF.Framework.Common.SubstrateTrackings;
- using Aitex.Core.Util;
- using System.IO.Ports;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDK;
- using Aitex.Core.RT.OperationCenter;
- namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.Hirata
- {
- public enum HirataSystemStatus
- {
- Normal =0x30,
- RecoverableError = 0x41,
- UnrecoverableError = 0x45,
- }
- public enum HirataMode
- {
- Online=0x30,
- Teaching=0x31,
- Maintenance =0x32,
- }
- public enum HirataInitPosMovement
- {
- OperationStatus=0x30,
- HomePosStatus=0x31,
- LoadStatus=0x32,
- }
- public enum HirataOperationStatus
- {
- DuringStop=0x30,
- DuringOperation=0x31,
- }
- public enum HirataContainerStatus
- {
- Absence=0x30,
- NormalMount=0x31,
- MountError=0x32,
- }
- public enum HirataPosition
- {
- Open=0x30,
- Close=0x31,
- TBD =0x3F
- }
- public enum HirataVacummStatus
- {
- OFF=0x30,
- ON=0x31,
- }
- public enum HirataWaferProtrusion
- {
- ShadingStatus=0x30,
- LightIncidentStatus=0x31,
- }
- public enum HirataElevatorAxisPosition
- {
- UP=0x30,
- Down=0x31,
- MappingStartPos=0x32,
- MappingEndPos=0x33,
- TBD = 0x3F,
- }
- public enum HirataDockPosition
- {
- Undock=0x30,
- Dock=0x31,
- TBD = 0x3F,
- }
- public enum HirataMapPosition
- {
- MeasurementPos=0x30,
- WaitingPost=0x31,
- TBD = 0x3F,
- }
- public enum HirataMappingStatus
- {
- NotPerformed=0x30,
- NormalEnd=0x31,
- ErrorStop=0x32,
- }
- public enum HirataModel
- {
- Type1=0x30,
- Type2=0x31,
- Type3=0x32,
- Type4=0x33,
- Type5=0x34,
- }
- public class HirataLoadPort : LoadPort
- {
- private bool _isTcpConnection;
- public HirataLoadPort(string module, string name,bool IsTCPconnection = false) : base(module, name)
- {
- _isTcpConnection = IsTCPconnection;
- }
- private HirataLoadPortConnection _connection;
- public HirataLoadPortConnection Connection
- {
- get => _connection;
- }
- private HirataLoadPortTcpConnection _tcpconnection;
- public HirataLoadPortTcpConnection TCPconnection => _tcpconnection;
- public HirataSystemStatus SystemStatus { get; set; }
- public HirataMode Mode { get; set; }
- public HirataInitPosMovement InitPosMovement { get; set; }
- public HirataOperationStatus OperationStatus { get; set; }
- public byte HostErrorCode { get; set; }
- public byte LoadPortErrorCode { get; set; }
- public HirataContainerStatus ContainerStatus { get; set; }
- public HirataPosition ClampPosition { get; set; }
- public HirataPosition DoorLatchPosition { get; set; }
- public HirataVacummStatus VacuumStatus { get; set; }
- public HirataPosition DoorPosition { get; set;}
- public HirataWaferProtrusion WaferProtrusion { get; set; }
- public HirataElevatorAxisPosition ElevatorAxisPosition { get; set; }
- public HirataDockPosition DockPosition { get; set; }
- public HirataMapPosition MapperPostion { get; set; }
- public HirataMappingStatus MappingStatus { get; set; }
- public HirataModel Model { get; set; }
- private PeriodicJob _thread;
- private static Object _locker = new Object();
- private LinkedList<HandlerBase> _lstHandler = new LinkedList<HandlerBase>();
- private bool _enableLog = true;
- //private bool _commErr = false;
- private R_TRIG _trigError = new R_TRIG();
- private R_TRIG _trigWarningMessage = new R_TRIG();
- private R_TRIG _trigCommunicationError = new R_TRIG();
- private R_TRIG _trigRetryConnect = new R_TRIG();
- public override bool IsBusy
- {
- get
- {
- if (_isTcpConnection)
- return (_lstHandler.Count > 0 || _tcpconnection.IsBusy);
- return _lstHandler.Count > 0 || _connection.IsBusy;
- }
- }
- public override bool Initialize()
- {
- base.Initialize();
- IsMapWaferByLoadPort = true;
- if (_isTcpConnection)
- {
- string ipaddress = SC.GetStringValue($"LoadPort.{Name}.Address");
- _enableLog = SC.GetValue<bool>($"LoadPort.{Name}.EnableLogMessage");
- _tcpconnection = new HirataLoadPortTcpConnection(this, ipaddress);
- _tcpconnection.EnableLog(_enableLog);
- }
- else
- {
- string portName = SC.GetStringValue($"LoadPort.{Name}.PortName");
- int bautRate = SC.GetValue<int>($"LoadPort.{Name}.BaudRate");
- int dataBits = SC.GetValue<int>($"LoadPort.{Name}.DataBits");
- Enum.TryParse(SC.GetStringValue($"LoadPort.{Name}.Parity"), out Parity parity);
- Enum.TryParse(SC.GetStringValue($"LoadPort.{Name}.StopBits"), out StopBits stopBits);
- //_deviceAddress = SC.GetValue<int>($"{Name}.DeviceAddress");
- _enableLog = SC.GetValue<bool>($"LoadPort.{Name}.EnableLogMessage");
- _connection = new HirataLoadPortConnection(this, portName, bautRate, dataBits, parity, stopBits);
- _connection.EnableLog(_enableLog);
- }
- int count = SC.ContainsItem("System.ComPortRetryCount") ? SC.GetValue<int>("System.ComPortRetryCount") : 5;
- int sleep = SC.ContainsItem("System.ComPortRetryDelayTime") ? SC.GetValue<int>("System.ComPortRetryDelayTime") : 2;
- if (sleep <= 0 || sleep > 10)
- sleep = 2;
- int retry = 0;
- do
- {
- _connection.Disconnect();
- Thread.Sleep(sleep * 1000);
- if (_connection.Connect())
- {
- //LOG.Write($"Connected with {Module}.{Name} .");
- EV.PostInfoLog(Module, $"Connected with {Module}.{Name} .");
- break;
- }
- if (count > 0 && retry++ > count)
- {
- LOG.Write($"Retry connect {Module}.{Name} stop retry.");
- EV.PostAlarmLog(Module, $"Can't connect to {Module}.{Name}.");
- break;
- }
- } while (true);
- _thread = new PeriodicJob(100, OnTimer, $"{Module}.{Name} MonitorHandler", true);
- return true;
- }
- private bool OnTimer()
- {
- try
- {
- if (_isTcpConnection)
- {
- _tcpconnection.MonitorTimeout();
- if (!_tcpconnection.IsConnected || _tcpconnection.IsCommunicationError)
- {
- lock (_locker)
- {
- _lstHandler.Clear();
- }
- _trigRetryConnect.CLK = !_tcpconnection.IsConnected;
- if (_trigRetryConnect.Q)
- {
-
- if (!_tcpconnection.Connect())
- {
- EV.PostAlarmLog(Module, $"Can not connect with {_tcpconnection.Address}, {Module}.{Name}");
- }
- }
- return true;
- }
- HandlerBase handler = null;
- if (!_tcpconnection.IsBusy)
- {
- lock (_locker)
- {
- if (_lstHandler.Count == 0)
- {
- //_lstHandler.AddLast(new SingleTransactionHandler(this, TazmoCommand.RequeststatusStatus, null));
- //_lstHandler.AddLast(new SingleTransactionHandler(this, TazmoCommand.Requeststatus2Status, null));
- }
- if (_lstHandler.Count > 0)
- {
- handler = _lstHandler.First.Value;
- if (handler != null) _tcpconnection.Execute(handler);
- _lstHandler.RemoveFirst();
- }
- }
- }
- }
- else
- {
- _connection.MonitorTimeout();
- if (!_connection.IsConnected || _connection.IsCommunicationError)
- {
- lock (_locker)
- {
- _lstHandler.Clear();
- }
- _trigRetryConnect.CLK = !_connection.IsConnected;
- if (_trigRetryConnect.Q)
- {
- _connection.SetPortAddress(SC.GetStringValue($"{Name}.Address"));
- if (!_connection.Connect())
- {
- EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
- }
- }
- return true;
- }
- HandlerBase handler = null;
- if (!_connection.IsBusy)
- {
- lock (_locker)
- {
- if (_lstHandler.Count == 0)
- {
- //_lstHandler.AddLast(new SingleTransactionHandler(this, TazmoCommand.RequeststatusStatus, null));
- //_lstHandler.AddLast(new SingleTransactionHandler(this, TazmoCommand.Requeststatus2Status, null));
- }
- if (_lstHandler.Count > 0)
- {
- handler = _lstHandler.First.Value;
- if (handler != null) _connection.Execute(handler);
- _lstHandler.RemoveFirst();
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- return true;
- }
- private LoadportCassetteState _cassetteState = LoadportCassetteState.None;
- public override LoadportCassetteState CassetteState
- {
- get { return _cassetteState; }
- set
- {
- _cassetteState = value;
- }
- }
- public void SetCassetteState(LoadportCassetteState state)
- {
- _cassetteState = state;
- if (state == LoadportCassetteState.Normal)
- {
- if (!_isPlaced)
- {
- OnCarrierPlaced();
- }
- if (!_isPresent)
- {
- OnCarrierPresent();
- }
- }
- }
- public override void Terminate()
- {
- if (_isTcpConnection)
- _tcpconnection.Disconnect();
- else
- _connection.Disconnect();
- }
- public override void Monitor()
- {
- base.Monitor();
- try
- {
- if (_isTcpConnection)
- {
- _tcpconnection.EnableLog(_enableLog);
- _trigCommunicationError.CLK = _tcpconnection.IsCommunicationError;
- if (_trigCommunicationError.Q)
- {
- EV.PostAlarmLog(Module, $"{Module}.{Name} communication error, {_tcpconnection.LastCommunicationError}");
- }
- }
- else
- {
- _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()
- {
- base.Reset();
- _trigError.RST = true;
- _trigWarningMessage.RST = true;
- if (_isTcpConnection)
- _tcpconnection.SetCommunicationError(false, "");
- else
- _connection.SetCommunicationError(false, "");
- _trigCommunicationError.RST = true;
- lock (_locker)
- {
- _lstHandler.Clear();
- }
- _enableLog = SC.GetValue<bool>($"LoadPort.{Name}.EnableLogMessage");
- _trigRetryConnect.RST = true;
- }
- public override bool IsEnableMapWafer()
- {
- if (IsIdle
- && _isPresent
- && _isPlaced
- && DoorState == FoupDoorState.Open
- && CassetteState == LoadportCassetteState.Normal
- )
- return true;
- return false;
- }
- public override bool IsEnableTransferWafer()
- {
- if (IsIdle
- && _isPresent
- && _isPlaced
- && DoorState == FoupDoorState.Open
- && CassetteState == LoadportCassetteState.Normal
- )
- return true;
- return false;
- }
- public override bool IsEnableTransferWafer(out string reason)
- {
- reason = "";
- if (IsIdle
- && _isPresent
- && _isPlaced
- && DoorState == FoupDoorState.Open
- && CassetteState == LoadportCassetteState.Normal
- )
- return true;
- return false;
- }
-
- public override bool ClearError(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.Clear();
- _lstHandler.AddLast(new SetHandler(this, "RESET", null));
- }
- return true;
- }
- public override bool Init(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.Clear();
- _lstHandler.AddLast(new SetHandler(this, "INITL", null));
- }
- return true;
- }
- public override bool Home(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
-
- _lstHandler.Clear();
- _lstHandler.AddLast(new MoveHandler(this, "ORGSH", null));
- _lstHandler.AddLast(new GetHandler(this, "STATE", null));
- _lstHandler.AddLast(new ModHandler(this, "ONMGV", null));
- }
- return true;
- }
- public override bool ForceHome(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.Clear();
- _lstHandler.AddLast(new MoveHandler(this, "ABORG", null));
- }
- return true;
- }
- public override bool LoadWithoutMap(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "CLOAD", null));
- }
- return true;
- }
- public override bool Load(out string reason) //map and loads
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "CLDMP", null));
- }
- return true;
- }
- public override bool Unload(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "CULOD", null));
- }
- return true;
- }
- public override bool Clamp(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "PODCL", null));
- }
- return true;
- }
- public override bool Unclamp(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "PODOP", null));
- }
- return true;
- }
- public override bool Dock(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "CLDDK", null));
- }
- return true;
- }
- public override bool Undock(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "CULFC", null));
- }
- return true;
- }
- public override bool OpenDoor(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "CLMPO", null));
- }
- return true;
-
- }
- public override bool OpenDoorNoMap(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "CLDOP", null));
- }
- return true;
-
- }
- public override bool CloseDoor(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new MoveHandler(this, "CULDK", null));
- }
- return true;
-
- }
- public override bool SetIndicator(Indicator light, IndicatorState op, out string reason)
- {
- reason = string.Empty;
- return true;
- }
- public bool SetOnlineMode(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new ModHandler(this, "ONMGV", null));
- }
- return true;
- }
- public override bool QueryState(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new GetHandler(this, "STATE", null));
- }
- return true;
- }
- public override bool QueryIndicator(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new GetHandler(this, "LEDST", null));
- }
- return true;
- }
- public override bool QueryWaferMap(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new GetHandler(this, "MAPDT", null));
- }
- return true;
- }
- public bool OnEvent(out string reason)
- {
- reason = string.Empty;
- lock (_locker)
- {
- _lstHandler.AddLast(new GetHandler(this, "STATE", null));
- }
- return true;
- }
- public void OnCarrierNotPlaced()
- {
- _isPlaced = false;
- ConfirmRemoveCarrier();
- }
- public void OnCarrierNotPresent()
- {
- _isPresent = false;
- //ConfirmRemoveCarrier();
- }
- public void OnCarrierPlaced()
- {
- _isPlaced = true;
- ConfirmAddCarrier();
- QueryState(out _);
- }
- public void OnCarrierPresent()
- {
- _isPresent = true;
- //ConfirmAddCarrier();
- }
- public void OnSwitchKey1()
- {
- _isAccessSwPressed = true;
- }
- public void OnSwitchKey2()
- {
- }
- public void OffSwitchKey1()
- {
- _isAccessSwPressed = false;
- }
- public void OffSwitchKey2()
- {
- }
- public override bool ReadRfId(out string reason)
- {
- OP.DoOperation("ReadCarrierId", Name);
- reason = "";
- return true;
- }
- }
- }
- // public string Address { get; set; }
- // public bool IsConnected
- // {
- // get { return _port.IsOpen(); }
- // }
- // public bool UnlockKey
- // {
- // set
- // {
- // }
- // }
- // public bool Enable
- // {
- // set
- // {
- // if (_enableTrigger != null)
- // {
- // _enableTrigger.SetTrigger(value, out _);
- // }
- // }
- // }
- // public bool FFUIsOK { get; set; }
- // private LoadportCassetteState _cassetteState = LoadportCassetteState.None;
- // public override LoadportCassetteState CassetteState
- // {
- // get { return _cassetteState; }
- // set
- // {
- // _cassetteState = value;
- // }
- // }
- // public bool Processed { get; set; }
- // public bool Communication
- // {
- // get
- // {
- // return _port == null ? !_commErr : !_commErr && _port.IsOpen();
- // }
- // }
- // //
- // public override bool IsBusy
- // {
- // get { return _foregroundHandler != null || _handlers.Count > 0; }
- // }
- // public override bool IsMoving
- // {
- // get { return _foregroundHandler != null && _handlers.Count > 0; }
- // }
- // public const string delimiter = "\r";
- // public const int min_len = 3; //S00
- // private static Object _locker = new Object();
- // private AsyncSerial _port;
- // private bool _commErr = false;
- // private IHandler _eventHandler = null;
- // private IHandler _foregroundHandler = null; //moving
- // private Queue<IHandler> _handlers = new Queue<IHandler>();
- // private IoSensor _sensorEnable = null;
- // private IoTrigger _enableTrigger = null;
- // public HirataLoadPort(string module, string name, string port, IoSensor sensorEnable, IoTrigger triggerEnable,
- // EnumLoadPortType portType = EnumLoadPortType.LoadPort)
- // : base(module, name)
- // {
- // _port = new AsyncSerial(port, 9600, 8);
- // _port.OnDataChanged += (OnDataChanged);
- // _port.OnErrorHappened += (OnErrorHandler);
- // _eventHandler = new handler<OnEventHandler>(Name);
- // _sensorEnable = sensorEnable;
- // _enableTrigger = triggerEnable;
- // Initalized = false;
- // IsMapWaferByLoadPort = portType == EnumLoadPortType.LoadPort;
- // PortType = portType;
- // IndicatiorLoad = IndicatorState.UNKNOW;
- // IndicatiorUnload = IndicatorState.UNKNOW;
- // IndicatiorPresence = IndicatorState.UNKNOW;
- // IndicatorAlarm = IndicatorState.UNKNOW;
- // IndicatiorPlacement = IndicatorState.UNKNOW;
- // IndicatiorOpAccess = IndicatorState.UNKNOW;
- // IndicatiorStatus1 = IndicatorState.UNKNOW;
- // IndicatiorStatus2 = IndicatorState.UNKNOW;
- // DoorState = FoupDoorState.Unknown;
- // ClampState = FoupClampState.Unknown;
- // CassetteState = LoadportCassetteState.Unknown;
- // //if (!this.QueryState(out string reason))
- // //{
- // // EV.PostAlarmLog(module,$"Query state error.{reason}");
- // //}
- // Enable = true;
- // Address = port;
- // }
- // public void SetCassetteState(LoadportCassetteState state)
- // {
- // _cassetteState = state;
- // if (state == LoadportCassetteState.Normal)
- // {
- // if (!_isPlaced)
- // {
- // OnCarrierPlaced();
- // }
- // if (!_isPresent)
- // {
- // OnCarrierPresent();
- // }
- // }
- // }
- // public override bool Initialize()
- // {
- // base.Initialize();
- // _commErr = true;
- // ConnectionManager.Instance.Subscribe($"{Name}", this);
- // Connect();
- // //if (!RetryInstance.Instance().Execute<bool>(
- // // ()=> _port.Open(),
- // // SC.GetValue<int>("System.ComPortRetryDelayTime"),
- // // SC.GetValue<int>("System.ComPortRetryCount"),
- // // true
- // //))
- // //{
- // // return false;
- // //}
- // return true;
- // }
- // public override bool Connect()
- // {
- // _commErr = false;
- // Task.Factory.StartNew(() =>
- // {
- // int count = SC.ContainsItem("System.ComPortRetryCount") ? SC.GetValue<int>("System.ComPortRetryCount") : 5;
- // int sleep = SC.ContainsItem("System.ComPortRetryDelayTime") ? SC.GetValue<int>("System.ComPortRetryDelayTime") : 2;
- // if (sleep <= 0 || sleep > 10)
- // sleep = 2;
- // int retry = 0;
- // do
- // {
- // _port.Close();
- // Thread.Sleep(sleep * 1000);
- // if (_port.Open())
- // {
- // //LOG.Write($"Connected with {Module}.{Name} .");
- // EV.PostInfoLog(Module, $"Connected with {Module}.{Name} .");
- // break;
- // }
- // if (count > 0 && retry++ > count)
- // {
- // LOG.Write($"Retry connect {Module}.{Name} stop retry.");
- // EV.PostAlarmLog(Module, $"Can't connect to {Module}.{Name}.");
- // break;
- // }
- // Thread.Sleep(sleep * 1000);
- // LOG.Write($"Retry connect {Module}.{Name} for the {retry + 1} time.");
- // } while (true);
- // });
- // return true;
- // }
- // public bool Disconnect()
- // {
- // return true;
- // }
- // public override bool IsEnableMapWafer()
- // {
- // if (IsIdle
- // && _isPresent
- // && _isPlaced
- // && DoorState == FoupDoorState.Open
- // && CassetteState == LoadportCassetteState.Normal
- // )
- // return true;
- // return false;
- // }
- // public override bool IsEnableTransferWafer()
- // {
- // return IsEnableTransferWafer(out _);
- // }
- // public override bool IsEnableTransferWafer(out string reason)
- // {
- // reason = "";
- // if (_isPlaced
- // && _isPresent
- // && _isMapped
- // && IsIdle
- // && DoorState == FoupDoorState.Open
- // && CassetteState == LoadportCassetteState.Normal
- // && IsWaferEnableTransfer()
- // ) return true;
- // return false;
- // }
- // /// <summary>
- // ///The Indicator is for EAP/Operator
- // /// LOAD READY: LoadPort Ready to receive FOUP
- // /// UNLOAD READY: FOUP ready to remove
- // ///
- // /// </summary>
- // public void OnStateUpdated()
- // {
- // if (!SC.ContainsItem("Process.OptionLoadportMonitor") || !SC.GetValue<bool>("Process.OptionLoadportMonitor"))
- // return;
- // if (_isPresent && _isPlaced && this.ClampState == FoupClampState.Open && this.DockPOS == TDKY_AxisPos.Undock)
- // {
- // if (IndicatiorUnload != IndicatorState.ON)
- // SetIndicator(Indicator.UNLOAD, IndicatorState.ON);
- // if (IndicatiorLoad != IndicatorState.OFF)
- // SetIndicator(Indicator.LOAD, IndicatorState.OFF);
- // return;
- // }
- // if (!_isPresent || !_isPlaced)
- // {
- // if (IndicatiorUnload != IndicatorState.OFF)
- // SetIndicator(Indicator.UNLOAD, IndicatorState.OFF);
- // if (IndicatiorLoad != IndicatorState.ON)
- // SetIndicator(Indicator.LOAD, IndicatorState.ON);
- // return;
- // }
- // if (IndicatiorUnload != IndicatorState.OFF)
- // SetIndicator(Indicator.UNLOAD, IndicatorState.OFF);
- // if (IndicatiorLoad != IndicatorState.OFF)
- // SetIndicator(Indicator.LOAD, IndicatorState.OFF);
- // }
- // public void OnAccessButtonPushed()
- // {
- // if (_isPresent && _isPlaced)
- // {
- // }
- // }
- // /// <summary>
- // ///reset load port error
- // ///
- // /// </summary>
- // public override void Reset()
- // {
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // FFUIsOK = true;
- // _commErr = false;
- // Enable = true;
- // Error = false;
- // base.Reset();
- // }
- // public override bool Home(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<HomeHandler>(Name), out reason);
- // }
- // public override bool ForceHome(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<ForceHomeHandler>(Name), out reason);
- // }
- // public override bool FOSBMode(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<FOSBModeHandler>(Name), out reason);
- // }
- // public override bool FOUPMode(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<FOUPModeHandler>(Name), out reason);
- // }
- // public override bool FOSBDock(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<DockPosHandler>(Name), out reason);
- // }
- // public override bool FOSBUnDock(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<UnDockPosHandler>(Name), out reason);
- // }
- // public override bool FOSBDoorOpen(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<DoorOpenHandler>(Name), out reason);
- // }
- // public override bool FOSBDoorClose(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<DoorCloseHandler>(Name), out reason);
- // }
- // public override bool FOSBDoorUp(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<DoorUpHandler>(Name), out reason);
- // }
- // public override bool FOSBDoorDown(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<DoorDownHandler>(Name), out reason);
- // }
- // /// <summary>
- // /// Clear LP error
- // /// </summary>
- // public override bool ClearError(out string reason)
- // {
- // reason = string.Empty;
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<ResetHandler>(Name), out reason);
- // }
- // public override bool Stop(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // _foregroundHandler = null;
- // _handlers.Clear();
- // }
- // return execute(new handler<MovHandler>(Name, MovType.STOP_), out reason);
- // }
- // public override bool Load(out string reason) //map and loads
- // {
- // return Move(MovType.CLDMP, out reason);
- // }
- // public override bool LoadWithoutMap(out string reason)
- // {
- // return Move(MovType.CLOAD, out reason);
- // }
- // public override bool Unload(out string reason)
- // {
- // return Move(MovType.CULOD, out reason);
- // }
- // public override bool Clamp(out string reason)
- // {
- // return Move(MovType.PODCL, out reason);
- // }
- // public override bool Unclamp(out string reason)
- // {
- // return Move(MovType.PODOP, out reason);
- // }
- // public override bool Dock(out string reason)
- // {
- // return Move(MovType.CLDDK, out reason);
- // }
- // public override bool Undock(out string reason)
- // {
- // return Move(MovType.CULFC, out reason); //????
- // }
- // public override bool OpenDoor(out string reason)
- // {
- // return Move(MovType.CLMPO, out reason);
- // }
- // public override bool OpenDoorNoMap(out string reason)
- // {
- // return Move(MovType.CLDOP, out reason);
- // }
- // public override bool CloseDoor(out string reason)
- // {
- // return Move(MovType.CULDK, out reason);
- // }
- // public override bool SetIndicator(Indicator light, IndicatorState op, out string reason)
- // {
- // reason = string.Empty;
- // return execute(new handler<IndicatorHandler>(Name, light, op), out reason);
- // }
- // public bool SetOnlineMode(out string reason)
- // {
- // reason = string.Empty;
- // return execute(new handler<ModHandler>(Name, Mode.ONMGV), out reason);
- // }
- // public override bool QueryState(out string reason)
- // {
- // reason = string.Empty;
- // return execute(new handler<QueryStateHandler>(Name), out reason);
- // }
- // public override bool QueryIndicator(out string reason)
- // {
- // reason = string.Empty;
- // return execute(new handler<QueryIndicatorHandler>(Name), out reason);
- // }
- // public override bool QueryWaferMap(out string reason)
- // {
- // reason = string.Empty;
- // return execute(new handler<QueryWaferMappingHandler>(DeviceID), out reason);
- // }
- // public override bool QueryFOSBMode(out string reason)
- // {
- // reason = string.Empty;
- // return execute(new handler<QueryFOSBModeHandler>(DeviceID), out reason);
- // }
- // public bool Move(MovType fun, out string reason)
- // {
- // reason = string.Empty;
- // return execute(new handler<MovHandler>(Name, fun), out reason);
- // }
- // //public bool Query(QueryType type, out string reason)
- // //{
- // // reason = string.Empty;
- // // return execute(new handler<QueryWaferMappingHandler>(Name), out reason);
- // //}
- // public bool SetEvent(EvtType fun, out string reason)
- // {
- // reason = string.Empty;
- // return execute(new handler<SetEventHandler>(Name, fun), out reason);
- // }
- // public bool OnEvent(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // if (!execute(new handler<QueryStateHandler>(Name), out reason))
- // return false;
- // //execute(new handler<QueryIndicatorHandler>(Name), out reason);
- // //LoadLight();
- // //UnloadLight();
- // return execute(new handler<QueryIndicatorHandler>(Name), out reason);
- // }
- // }
- // private bool execute(IHandler handler1, out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // if (_foregroundHandler == null)
- // {
- // if (!handler1.Execute(ref _port))
- // {
- // reason = "Communication failed, please recovery it.";
- // return false;
- // }
- // _foregroundHandler = handler1;
- // }
- // else
- // {
- // var type = handler1.GetType();
- // string name = type.Name;
- // if (type.GenericTypeArguments.Length > 0)
- // name = type.GenericTypeArguments[0].Name;
- // LOG.Info(string.Format("Add command {0}", name));
- // _handlers.Enqueue(handler1);
- // }
- // }
- // return true;
- // }
- // private bool execute(out string reason)
- // {
- // reason = string.Empty;
- // lock (_locker)
- // {
- // if (_handlers.Count > 0)
- // {
- // IHandler handler = _handlers.Dequeue();
- // if (!handler.Execute(ref _port))
- // {
- // reason = " communication failed, please recovery it.";
- // LOG.Error(reason);
- // EV.PostMessage(Name, EventEnum.DefaultWarning, "【Reader】" + reason);
- // return false;
- // }
- // _foregroundHandler = handler;
- // }
- // }
- // return true;
- // }
- // private void OnDataChanged(string package)
- // {
- // try
- // {
- // package = package.ToUpper();
- // string[] msgs = Regex.Split(package, delimiter);
- // foreach (string msg in msgs)
- // {
- // if (msg.Length > min_len)
- // {
- // bool completed = false;
- // string resp = msg.Substring(3, msg.Length - min_len);
- // lock (_locker)
- // {
- // if (_foregroundHandler != null && _foregroundHandler.OnMessage(ref _port, resp, out completed))
- // {
- // string reason = string.Empty;
- // if (!_foregroundHandler.IsBackground)
- // {
- // _foregroundHandler = null;
- // execute(out reason);
- // OnActionDone(true);
- // }
- // else
- // {
- // if (completed)
- // {
- // _foregroundHandler = null;
- // QueryState(out reason);
- // if (_foregroundHandler is handler<HomeHandler>)
- // {
- // QueryIndicator(out reason);
- // }
- // }
- // }
- // }
- // else
- // {
- // _eventHandler.OnMessage(ref _port, resp, out completed); //process event
- // }
- // }
- // }
- // }
- // }
- // catch (ExcuteFailedException ex)
- // {
- // EV.PostWarningLog(Module, $"{Name} action failed, " + ex.Message);
- // _foregroundHandler = null;
- // OnError($"{ Name} action failed");
- // }
- // catch (InvalidPackageException ex)
- // {
- // EV.PostWarningLog(Module, $"{Name} received unprocessed message, {ex.Message}");
- // OnError($"{Name} received unprocessed message");
- // }
- // catch (Exception ex)
- // {
- // LOG.Write($" {Name} has exception:" + ex.Message);
- // }
- // }
- // private void OnErrorHandler(ErrorEventArgs args)
- // {
- // _commErr = true;
- // Initalized = false;
- // EV.PostAlarmLog(Module, $"{Display} Communication error, {args.Reason}");
- // OnError($"{Display} Communication error");
- // }
- // public void OnCarrierNotPlaced()
- // {
- // _isPlaced = false;
- // ConfirmRemoveCarrier();
- // }
- // public void OnCarrierNotPresent()
- // {
- // _isPresent = false;
- // //ConfirmRemoveCarrier();
- // }
- // public void OnCarrierPlaced()
- // {
- // _isPlaced = true;
- // ConfirmAddCarrier();
- // QueryState(out _);
- // }
- // public void OnCarrierPresent()
- // {
- // _isPresent = true;
- // //ConfirmAddCarrier();
- // }
- // public void OnSwitchKey1()
- // {
- // _isAccessSwPressed = true;
- // }
- // public void OnSwitchKey2()
- // {
- // }
- // public void OffSwitchKey1()
- // {
- // _isAccessSwPressed = false;
- // }
- // public void OffSwitchKey2()
- // {
- // }
- // public void SetIndicator(Indicator led, IndicatorState state)
- // {
- // SetIndicator(led, state, out string reason);
- // }
- // //impment E84 interface
- // public bool ReadyForLoad()
- // {
- // return CassetteState == LoadportCassetteState.Absent;
- // }
- // public bool ReadyForUnload()
- // {
- // return CassetteState == LoadportCassetteState.Normal;
- // }
- // public bool FoupArrirved()
- // {
- // return CassetteState == LoadportCassetteState.Normal;
- // }
- // public bool FoupRemoved()
- // {
- // return CassetteState == LoadportCassetteState.Absent;
- // }
- // public LPTransferState GetTransferState()
- // {
- // return LPTransferState.IN_SERVICE;
- // }
- // public LPAccessMode GetAccessMode()
- // {
- // return LPAccessMode.AUTO;
- // }
- // public LPReservedState GetReservedState()
- // {
- // return LPReservedState.NOT_RESERVED;
- // }
- // public void LPTSTrans(LPTransferState lpts)
- // {
- // return;
- // }
- // public bool IsSystemAutoMode()
- // {
- // return false;
- // }
- // public void SetAccessMode(bool isauto)
- // {
- // return;
- // }
- // public void E84Retry()
- // {
- // throw new NotImplementedException();
- // }
- // public void SetCompleted()
- // {
- // return;
- // }
- // }
- //}
|