123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853 |
- using System;
- using System.Collections.Generic;
- using System.IO.Ports;
- using System.Linq;
- using System.Text;
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using MECF.Framework.Common.Communications;
- using MECF.Framework.Common.Device.Bases;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Common;
- using Newtonsoft.Json;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.Common.SubstrateTrackings;
- using System.Threading;
- using Aitex.Core.Common;
- using Aitex.Core.RT.DataCenter;
- using System.Text.RegularExpressions;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.AlignersBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.JEL;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
- namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Aligners.JelAligner
- {
- public class JelAlignerWithCylinderSmec : JelAligner
- {
- /* SAL3262HV model: for 2-inch to 6-inch wafer
- SAL3362HV model: for 3-inch to 6-inch wafer
- SAL3482HV model: for 4-inch to 8-inch wafer
- SAL38C3HV model: for 8-inch to 12-inch wafer*/
- public JelAlignerWithCylinderSmec(string module, string name, string scRoot, IoSensor[] dis, IoTrigger[] dos, int alignerType = 0, string robotModel = "") :
- base(module, name, scRoot, null, null, alignerType, robotModel)
- {
- _scRoot = scRoot;
- if (dis != null)
- {
- _diWaferPresent = dis[0];
- _diCylinderExtend = dis[1];
- _diCylinderRetract = dis[2];
- }
- if (dos != null)
- {
- _doCylinderExtend = dos[0];
- _doCylinderRetract = dos[1];
- }
- SubscribeSpecialOperation();
- }
- private void SubscribeSpecialOperation()
- {
- DEVICE.Register(String.Format("{0}.{1}", Name, "OCRExtend"), (out string reason, int time, object[] param) =>
- {
- if(!IsReady())
- {
- reason = "AlignerNotReady";
- return false;
- }
- _doCylinderExtend.SetTrigger(true, out _);
- _doCylinderRetract.SetTrigger(false, out _);
- reason = "";
- return true;
- });
- DEVICE.Register(String.Format("{0}.{1}", Name, "OCRRetract"), (out string reason, int time, object[] param) =>
- {
- if (!IsReady())
- {
- reason = "AlignerNotReady";
- return false;
- }
- _doCylinderExtend.SetTrigger(false, out _);
- _doCylinderRetract.SetTrigger(true, out _);
- reason = "";
- return true;
- });
- }
- private IoSensor _diWaferPresent;
- private IoSensor _diCylinderExtend;
- private IoSensor _diCylinderRetract;
- private IoTrigger _doCylinderExtend;
- private IoTrigger _doCylinderRetract;
- private int _bodyNumber;
- private string _robotModel; //T-00902H
- //public int BodyNumber { get => _bodyNumber; }
- private string _address = "";
- //public string Address { get => _address; }
- private bool isSimulatorMode;
- private string _scRoot;
- private PeriodicJob _thread;
- //protected JelAlignerConnection _connection;
- private R_TRIG _trigError = new R_TRIG();
- private R_TRIG _trigCommunicationError = new R_TRIG();
- private R_TRIG _trigRetryConnect = new R_TRIG();
- private R_TRIG _trigActionDone = new R_TRIG();
- private LinkedList<HandlerBase> _lstMoveHandler = new LinkedList<HandlerBase>();
- private LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
- private bool _isAligned;
- private bool _isOnHomedPostion;
- //public int TimelimitAlginerHome { get; private set; }
- //public int TimelimitForAlignWafer { get; private set; }
- private object _locker = new object();
- private bool _enableLog;
- public override bool OnTimer()
- {
- try
- {
- if (!_connection.IsConnected || _connection.IsCommunicationError)
- {
- lock (_locker)
- {
- _lstMoveHandler.Clear();
- }
- _trigRetryConnect.CLK = !_connection.IsConnected;
- if (_trigRetryConnect.Q)
- {
- _connection.SetPortAddress(SC.GetStringValue($"{_scRoot}.{Name}.PortName"));
- if (!_connection.Connect())
- {
- EV.PostAlarmLog(Module, $"Can not connect with {_connection.Address}, {Module}.{Name}");
- }
- else
- {
- }
- }
- return true;
- }
- HandlerBase handler = null;
- DateTime dtstart = DateTime.Now;
- lock (_locker)
- {
- while (_lstMoveHandler.Count > 0 && _lstMonitorHandler.Count == 0)
- {
- if (!_connection.IsBusy)
- {
- if (YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd &&
- XAxisStatus == JelAxisStatus.NormalEnd)
- {
- handler = _lstMoveHandler.First.Value;
- _connection.Execute(handler);
- _lstMoveHandler.RemoveFirst();
- }
- else
- {
- _connection.Execute(new JelAlignerReadHandler(this, ""));
- }
- }
- else
- {
- _connection.MonitorTimeout();
- _trigCommunicationError.CLK = _connection.IsCommunicationError;
- if (_trigCommunicationError.Q)
- {
- _lstMoveHandler.Clear();
- OnError($"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
- }
- }
- if (DateTime.Now - dtstart > TimeSpan.FromSeconds(150))
- {
- _lstMonitorHandler.Clear();
- _lstMoveHandler.Clear();
- OnError("Robot action timeout");
- }
- }
- while (_lstMonitorHandler.Count > 0)
- {
- if (!_connection.IsBusy)
- {
- handler = _lstMonitorHandler.First.Value;
- _connection.Execute(handler);
- _lstMonitorHandler.RemoveFirst();
- }
- if (DateTime.Now - dtstart > TimeSpan.FromSeconds(150))
- {
- _lstMonitorHandler.Clear();
- _lstMoveHandler.Clear();
- OnError("Robot action timeout");
- }
- }
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- return true;
- }
- public override bool IsNeedChangeWaferSize(WaferSize wz)
- {
- return false;
- }
- protected override bool fReset(object[] param)
- {
- if (!_connection.IsConnected)
- {
- _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
- _bodyNumber = SC.GetValue<int>($"{_scRoot}.{Name}.BodyNumber");
- PortName = SC.GetStringValue($"{_scRoot}.{Name}.PortName");
- //TimelimitAlginerHome = SC.GetValue<int>($"{_scRoot}.{Name}.TimeLimitAlignerHome");
- _connection = new JelAlignerConnection(PortName);
- _connection.EnableLog(_enableLog);
- if (_connection.Connect())
- {
- EV.PostInfoLog(Module, $"{Module}.{Name} connected");
- }
- }
- _trigError.RST = true;
- _connection.SetCommunicationError(false, "");
- _trigCommunicationError.RST = true;
- _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
- _connection.EnableLog(_enableLog);
- _trigRetryConnect.RST = true;
- _lstMoveHandler.Clear();
- _lstMonitorHandler.Clear();
- _connection.ForceClear();
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelAlignerRawCommandHandler(this, $"${BodyNumber}RD\r"));
- _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, ""));
- //_lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, "WIS1"));
- _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));
- }
- _doCylinderExtend.SetTrigger(false, out _);
- _doCylinderRetract.SetTrigger(true, out _);
- _dtActionStart = DateTime.Now;
- return true;
- }
- protected override bool fMonitorReset(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
- {
- OnError("Reset timeout");
- }
- if (_diCylinderExtend.Value || !_diCylinderRetract.Value)
- return false;
- _isAligned = false;
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- return true;
- return false;
- }
- protected override bool fStartInit(object[] param)
- {
- _doCylinderExtend.SetTrigger(false, out _);
- _doCylinderRetract.SetTrigger(true, out _);
- int wCount = 0;
- while(true)
- {
- if(!_diCylinderExtend.Value && _diCylinderRetract.Value)
- {
- break;
- }
- Thread.Sleep(100);
- wCount ++;
- if(wCount > 100)
- {
- OnError("MoveCylinderTimeout");
- return false;
- }
- }
- lock (_locker)
- {
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "W0"));
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- //_lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WIS1"));
- if (SC.ContainsItem($"{_scRoot}.{Name}.JelWaferType"))
- {
- int wafertype = SC.GetValue<int>($"{_scRoot}.{Name}.JelWaferType");
- _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WAT", wafertype.ToString()));
- }
- string strpara = _currentSetWaferSize.ToString().Replace("WS", "");
- _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", strpara));
- }
-
- _isAligned = false;
- _isOnHomedPostion = false;
- _dtActionStart = DateTime.Now;
- return true;
- }
- private DateTime _dtActionStart;
- protected override bool fMonitorInit(object[] param)
- {
- _isAligned = false;
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
- {
- OnError("Init timeout");
- }
- if (_lstMoveHandler.Count == 0
- && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
- && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
- {
- if (IsWaferPresent(0) && WaferManager.Instance.CheckNoWafer(RobotModuleName, 0))
- {
- WaferManager.Instance.CreateWafer(RobotModuleName, 0,
- WaferStatus.Normal, GetCurrentWaferSize());
- }
- if (!IsWaferPresent(0) && WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
- {
- WaferManager.Instance.DeleteWafer(RobotModuleName, 0);
- }
- return true;
- }
- if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
- _connection.Execute(new JelAlignerReadHandler(this, ""));
- return false;
- }
- protected override bool fStartHome(object[] param)
- {
- _doCylinderExtend.SetTrigger(false, out _);
- _doCylinderRetract.SetTrigger(true, out _);
- int wCount = 0;
- while (true)
- {
- if (!_diCylinderExtend.Value && _diCylinderRetract.Value)
- {
- break;
- }
- Thread.Sleep(100);
- wCount++;
- if (wCount > 100)
- {
- OnError("MoveCylinderTimeout");
- return false;
- }
- }
- lock (_locker)
- {
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "W0"));
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- //_lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WIS1"));
- if (SC.ContainsItem($"{_scRoot}.{Name}.JelWaferType"))
- {
- int wafertype = SC.GetValue<int>($"{_scRoot}.{Name}.JelWaferType");
- _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WAT", wafertype.ToString()));
- }
- //if (WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
- //{
- // string strpara;
- // switch (WaferManager.Instance.GetWaferSize(RobotModuleName, 0))
- // {
- // case WaferSize.WS2:
- // case WaferSize.WS3:
- // case WaferSize.WS4:
- // case WaferSize.WS5:
- // case WaferSize.WS6:
- // case WaferSize.WS8:
- // strpara = _currentSetWaferSize.ToString().Replace("WS", "");
- // break;
- // case WaferSize.WS12:
- // strpara = "9";
- // break;
- // default:
- // return false;
- // }
- // _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", strpara));
- //}
- string strpara = _currentSetWaferSize.ToString().Replace("WS", "");
- _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", strpara));
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));
- }
- _isAligned = false;
- _dtActionStart = DateTime.Now;
- return true;
- }
- protected override bool fMonitorHome(object[] param)
- {
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
- {
- OnError("Home timeout");
- }
- if (_lstMoveHandler.Count == 0
- && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
- && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
- {
- IsBusy = false;
- _isOnHomedPostion = true;
- return true;
- }
- if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
- _connection.Execute(new JelAlignerReadHandler(this, ""));
- return false;
- }
- public override bool IsReady()
- {
- return AlignerState == AlignerStateEnum.Idle && !IsBusy;
- }
- public override bool IsWaferPresent(int slotindex)
- {
- if (_diWaferPresent != null)
- return _diWaferPresent.Value;
- return WaferManager.Instance.CheckHasWafer(RobotModuleName, slotindex);
- }
- public override bool IsNeedPrepareBeforePlaceWafer()
- {
- return !_isOnHomedPostion;
- }
- protected override bool fStartLiftup(object[] param) //Ungrip
- {
- _dtActionStart = DateTime.Now;
- lock (_locker)
- {
- }
- return true;
- }
- protected override bool fMonitorLiftup(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
- OnError("Liftup timeout");
-
- //if (_lstMoveHandler.Count == 0
- // && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
- // && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
- //{
- // IsBusy = false;
- // _isAligned = false;
- // _isOnHomedPostion = false;
- // return true;
- //}
- //if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
- // _connection.Execute(new JelAlignerReadHandler(this, ""));
- return false;
- }
- protected override bool fStartLiftdown(object[] param)
- {
- _dtActionStart = DateTime.Now;
- lock (_locker)
- {
- }
- return true;
- }
- protected override bool fMonitorLiftdown(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
- OnError("Liftdown timeout");
-
- return false;
- }
- protected override bool fStartAlign(object[] param)
- {
- _doCylinderExtend.SetTrigger(false, out _);
- _doCylinderRetract.SetTrigger(true, out _);
- int wCount = 0;
- while (true)
- {
- if (!_diCylinderExtend.Value && _diCylinderRetract.Value)
- {
- break;
- }
- Thread.Sleep(100);
- wCount++;
- if (wCount > 100)
- {
- OnError("MoveCylinderTimeout");
- return false;
- }
- }
- _dtActionStart = DateTime.Now;
-
- WaferSize wz = WaferManager.Instance.GetWaferSize(RobotModuleName, 0);
- if (wz != GetCurrentWaferSize())
- {
- EV.PostAlarmLog("System", "Wafer size is not match, can't do alignment");
- return false;
- }
- double aligneangle = (double)param[0];
- while (aligneangle < 0 || aligneangle > 360)
- {
- if (aligneangle < 0)
- aligneangle += 360;
- if (aligneangle > 360)
- aligneangle -= 360;
- }
- //int speed = SC.GetValue<int>($"{_scRoot}.{Name}.AlignSpeed");
- int intangle = (int)(aligneangle * 76799 / 360);
- CurrentNotch = aligneangle;
- lock (_locker)
- {
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WC")); //Close grip
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WD")); //Align
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- //_lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WA")); //Move down
- //_lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- _lstMoveHandler.AddLast(new JelAlignerSetHandler(this, "WOP", intangle.ToString()));
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WOF"));
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WU")); //Move Up
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC")); //Ungrip
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WT"));
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- }
- return true;
- }
- protected override bool fMonitorAligning(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
- OnError("Alignment timeout");
- if (_lstMoveHandler.Count == 0
- && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
- && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
- {
- _isAligned = true;
- _isOnHomedPostion = true;
- return true;
- }
- if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
- _connection.Execute(new JelAlignerReadHandler(this, ""));
- return false;
- }
- protected override bool fStop(object[] param)
- {
- return true;
- }
- protected override bool FsmAbort(object[] param)
- {
- return true;
- }
- protected override bool fClear(object[] param)
- {
- return true;
- }
- protected override bool fStartReadData(object[] param)
- {
- return true;
- }
- protected override bool fStartSetParameters(object[] param)
- {
- _dtActionStart = DateTime.Now;
- _currentSetParameter = param[0].ToString();
- switch (_currentSetParameter)
- {
- case "WaferSize":
- if (GetWaferState() != RobotArmWaferStateEnum.Absent)
- {
- EV.PostAlarmLog("System", "Can't set wafersize when wafer is not absent");
- return false;
- }
- _currentSetWaferSize = (WaferSize)param[1];
- if (WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
- {
- WaferManager.Instance.UpdateWaferSize(RobotModuleName, 0, _currentSetWaferSize);
- }
- string strpara;
- switch (_currentSetWaferSize)
- {
- case WaferSize.WS2:
- case WaferSize.WS3:
- case WaferSize.WS4:
- case WaferSize.WS5:
- case WaferSize.WS6:
- case WaferSize.WS8:
- strpara = _currentSetWaferSize.ToString().Replace("WS", "");
- break;
- case WaferSize.WS12:
- strpara = "9";
- break;
- default:
- return false;
- }
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", strpara));
- _lstMonitorHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));
- _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));
- }
- break;
- }
- return true;
- }
- private string _currentSetParameter;
- public override WaferSize GetCurrentWaferSize()
- {
- return _currentSetWaferSize;
- }
- private WaferSize _currentSetWaferSize = WaferSize.WS8;
- protected override bool fMonitorSetParamter(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))
- OnError("Set parameter timeout");
- switch (_currentSetParameter)
- {
- case "WaferSize":
- if (_lstMonitorHandler.Count == 0 && _lstMoveHandler.Count == 0 && !_connection.IsBusy)
- {
- if (_currentSetWaferSize != Size)
- {
- OnError($"Fail to set wafer size,set:{_currentSetWaferSize},return:{Size}");
- }
- if (_currentSetWaferSize == WaferSize.WS12)
- {
- return true;
- }
- if (_currentSetWaferSize == WaferSize.WS8)
- {
- return true;
- }
- return true;
- }
- break;
- }
- return false;
- }
- protected override bool fStartUnGrip(object[] param)
- {
- lock (_locker)
- {
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC"));
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- }
- _diStartUngrip = DateTime.Now;
- return true;
- }
- private DateTime _diStartUngrip;
- protected override bool fMonitorUnGrip(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _diStartUngrip > TimeSpan.FromSeconds(10))
- OnError("UnGrip timeout");
- if (_lstMoveHandler.Count != 0 || _connection.IsBusy || XAxisStatus != JelAxisStatus.NormalEnd
- || YAxisAndThetaAxisStatus != JelAxisStatus.NormalEnd)
- {
- if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
- _connection.Execute(new JelAlignerReadHandler(this, ""));
- return false;
- }
- return true;
- }
- protected override bool fStartGrip(object[] param)
- {
- lock (_locker)
- {
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WC"));
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- }
- _diStartUngrip = DateTime.Now;
- return true;
- }
- protected override bool fMonitorGrip(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _diStartUngrip > TimeSpan.FromSeconds(10))
- OnError("Grip timeout");
-
- if (_lstMoveHandler.Count == 0
- && !_connection.IsBusy)
- {
- if (XAxisStatus == JelAxisStatus.NormalEnd && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
- {
- return true;
- }
- else
- {
- _connection.Execute(new JelAlignerReadHandler(this, ""));
- }
- }
- return false;
- }
- protected override bool fResetToReady(object[] param)
- {
- return true;
- }
- protected override bool fError(object[] param)
- {
- return true;
- }
- public override void OnError(string errortext)
- {
- _isAligned = false;
- _isOnHomedPostion = false;
- _lstMonitorHandler.Clear();
- _lstMoveHandler.Clear();
- base.OnError(errortext);
- }
- public override bool IsNeedRelease
- {
- get
- {
- return true;
- }
- }
- protected override bool fStartPrepareAccept(object[] param)
- {
- _dtActionStart = DateTime.Now;
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelAlignerRawCommandHandler(this, $"${BodyNumber}RD\r"));
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WU"));
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WUC"));
- _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));
- }
- return true;
- }
- protected override bool fMonitorPrepareAccept(object[] param)
- {
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))
- OnError("PrepareAccept timeout");
- if (_lstMoveHandler.Count == 0
- && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd
- && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)
- {
- IsBusy = false;
- _isAligned = false;
- _isOnHomedPostion = true;
- return true;
- }
- if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)
- _connection.Execute(new JelAlignerReadHandler(this, ""));
- return false;
- }
- }
- }
|