| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434 | 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 JelAlignerVacWithOcrCylinder : JelAligner, IConnection    {        /* 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 JelAlignerVacWithOcrCylinder(string module, string name, string scRoot, IoSensor[] dis, IoTrigger[] dos,WaferSize[] sizes, int alignerType = 0, string robotModel = "") :             base(module, name,scRoot,null,null,alignerType,robotModel)        {                        _diWaferPresent = dis[0];            _diOcrOnWaferSize1 = dis[1];            _diOcrOnWaferSize2 = dis[2];            _doOcrToWaferSize1 = dos[0];            _doOcrToWaferSize2 = dos[1];            _size1 = sizes[0];            _size2 = sizes[1];            DEVICE.Register(String.Format("{0}.{1}", Name, "OcrMoveTo6Inch"), (out string reason, int time, object[] param) =>            {                _doOcrToWaferSize1.SetTrigger(true,out _);                _doOcrToWaferSize2.SetTrigger(false, out _);                lock (_locker)                {                    _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", "6"));                    _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));                }                reason = string.Format("{0} {1}", Name, "MoveTo6Inch");                return true;                            });            DEVICE.Register(String.Format("{0}.{1}", Name, "OcrMoveTo8Inch"), (out string reason, int time, object[] param) =>            {                _doOcrToWaferSize1.SetTrigger(false, out _);                _doOcrToWaferSize2.SetTrigger(true, out _);                lock (_locker)                {                    _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", "8"));                    _lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));                }                reason = string.Format("{0} {1}", Name, "MoveTo8Inch");                return true;            });        }        private IoSensor _diOcrOnWaferSize1;        private IoSensor _diOcrOnWaferSize2;        private IoTrigger _doOcrToWaferSize1;        private IoTrigger _doOcrToWaferSize2;        private IoSensor _diWaferPresent;        private WaferSize _size1;        private WaferSize _size2;               #region ParseHandler                #endregion        public override bool IsNeedChangeWaferSize(WaferSize wz)        {            if (wz != GetCurrentWaferSize())                return true;            if (wz != Size)                return true;            return false;        }                protected override bool fStartInit(object[] param)        {            lock (_locker)            {                int alignspeed = AlginerSpeedSetPoint * 8191 / 100;                _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;                    var currentWafersize = WaferManager.Instance.GetWaferSize(RobotModuleName, 0);                }                _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));                _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));            }            _isAligned = false;            _isOnHomedPostion = false;            _dtActionStart = DateTime.Now;            return true;        }                public override WaferSize GetCurrentWaferSize()        {            if (_diOcrOnWaferSize1.Value && !_diOcrOnWaferSize2.Value &&                    _doOcrToWaferSize1.Value && !_doOcrToWaferSize2.Value)                return _size1;            if (!_diOcrOnWaferSize1.Value && _diOcrOnWaferSize2.Value &&                !_doOcrToWaferSize1.Value && _doOcrToWaferSize2.Value)                return _size2;            return WaferSize.WS0;        }        private DateTime _dtActionStart;        protected override bool fMonitorInit(object[] param)        {            _isAligned = false;            if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds((double)TimelimitAlginerHome))                OnError("Init timeout");            if (_lstMoveHandler.Count == 0                && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd                && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)            {                IsBusy = false;                _isOnHomedPostion = true;                if (IsWaferPresent(0) && WaferManager.Instance.CheckNoWafer(RobotModuleName, 0))                {                    WaferManager.Instance.CreateWafer(RobotModuleName, 0,                         WaferStatus.Normal, GetCurrentWaferSize());                }                if (!IsWaferPresent(0) && WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))                {                    EV.PostAlarmLog("System", $"There's no phisical wafer on {RobotModuleName},but it has wafer information on.");                    //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)        {            lock (_locker)            {                int alignspeed = AlginerSpeedSetPoint * 8191 / 100;                _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;                    var currentWafersize = WaferManager.Instance.GetWaferSize(RobotModuleName, 0);                    //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", "");                    //        if (_doOcrTo200 != null && _doOcrTo200.DoTrigger != null)                    //            _doOcrTo200.SetTrigger(true, out _);                    //        if (_doOcrTo300 != null && _doOcrTo300.DoTrigger != null)                    //            _doOcrTo300.SetTrigger(false, out _);                    //        break;                    //    case WaferSize.WS12:                    //        strpara = "9";                    //        if (_doOcrTo200 != null && _doOcrTo200.DoTrigger != null)                    //            _doOcrTo200.SetTrigger(false, out _);                    //        if (_doOcrTo300 != null && _doOcrTo300.DoTrigger != null)                    //            _doOcrTo300.SetTrigger(true, out _);                    //        break;                    //    default:                    //        return false;                    //}                    //_lstMonitorHandler.AddLast(new JelAlignerMoveHandler(this, "WAS", strpara));                }                _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WMC"));                _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, "WAS"));            }            _isAligned = false;            _isOnHomedPostion = 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 IsWaferPresent(int slotindex)        {            if (_diWaferPresent != null)                return _diWaferPresent.Value;            return WaferManager.Instance.CheckHasWafer(RobotModuleName, slotindex);        }        public override bool IsNeedPrepareBeforePlaceWafer()        {            return !_isOnHomedPostion;        }        protected override bool fStartLiftdown(object[] param)        {            _dtActionStart = DateTime.Now;            lock (_locker)            {                _lstMoveHandler.AddLast(new JelAlignerMoveHandler(this, "WD"));                _lstMoveHandler.AddLast(new JelAlignerReadHandler(this, ""));            }            return true;        }        protected override bool fMonitorLiftdown(object[] param)        {            if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(TimelimitForAlignWafer))                OnError("Aligner lift down timeout");            if (_lstMoveHandler.Count == 0                && !_connection.IsBusy && XAxisStatus == JelAxisStatus.NormalEnd                && YAxisAndThetaAxisStatus == JelAxisStatus.NormalEnd)            {                IsBusy = false;                _isAligned = true;                _isOnHomedPostion = false;                return true;            }            if (_lstMoveHandler.Count == 0 && !_connection.IsBusy)                _connection.Execute(new JelAlignerReadHandler(this, ""));            return false;        }               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:                            strpara = _currentSetWaferSize.ToString().Replace("WS", "");                            break;                        case WaferSize.WS8:                            strpara = _currentSetWaferSize.ToString().Replace("WS", "");                                                       break;                        case WaferSize.WS12:                            strpara = "9";                                                       break;                        default:                            return false;                    }                    if(_currentSetWaferSize == _size1)                    {                        _doOcrToWaferSize1.SetTrigger(true, out _);                        _doOcrToWaferSize2.SetTrigger(false, out _);                    }                    if (_currentSetWaferSize == _size2)                    {                        _doOcrToWaferSize2.SetTrigger(true, out _);                        _doOcrToWaferSize1.SetTrigger(false, out _);                    }                    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;        private WaferSize _currentSetWaferSize = WaferSize.WS0;        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 != GetCurrentWaferSize())                        {                            return false;                        }                        return true;                    }                    break;            }            return false;        }                        }}
 |