1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206 |
- 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.LoadPorts;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
- using MECF.Framework.Common.CommonData;
- using Aitex.Core.RT.IOCore;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Flipper.FlipperBase;
- namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.JEL
- {
- public class JelC5000RobotFlippe : RobotBaseDevice, IConnection
- {
- 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 JelC5000RobotFlippeConnection _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();
- protected LinkedList<HandlerBase> _lstMonitorHandler = new LinkedList<HandlerBase>();
- protected AOAccessor _aoBladeRegulator { get; set; }
- protected object _locker = new object();
- private bool _enableLog;
- public string PortName;
- public bool IsConnected { get; }
- public bool Connect()
- {
- return true;
- }
- protected int _lowerArmWaferSensorIndex
- {
- get
- {
- if (SC.ContainsItem($"Robot.{RobotModuleName}.LowerArmWaferSensorIndex"))
- return SC.GetValue<int>($"Robot.{RobotModuleName}.LowerArmWaferSensorIndex");
- return 1;
- }
- }
- public bool Disconnect()
- {
- return true;
- }
- public JelC5000RobotFlippe(string module, string name, string scRoot, AOAccessor aoBladeRegulator, string robotModel = "") : base(module, name)
- {
- _robotModel = robotModel;
- isSimulatorMode = SC.ContainsItem("System.IsSimulatorMode") ? SC.GetValue<bool>("System.IsSimulatorMode") : false;
- _scRoot = scRoot;
- //base.Initialize();
- ResetPropertiesAndResponses();
- RegisterSpecialData();
-
- _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
- _bodyNumber = SC.GetValue<int>($"{_scRoot}.{Name}.BodyNumber");
- PortName = SC.GetStringValue($"{_scRoot}.{Name}.PortName");
- _aoBladeRegulator = aoBladeRegulator;
- _connection = new JelC5000RobotFlippeConnection(this,PortName);
- _connection.EnableLog(_enableLog);
- if (_connection.Connect())
- {
-
- EV.PostInfoLog(Module, $"{Module}.{Name} connected");
- }
- _thread = new PeriodicJob(100, OnTimer, $"{Module}.{Name} MonitorHandler", true);
- }
- #region Properties
- public JelAxisStatus JelC5000RobotStatus { get; private set; }
- public JelAxisStatus AxisStatus { get; private set; }
- public float XAxisPostion { get; private set; }
- public float ThetaAxisPostion { get; private set; }
- public float YAxisPostion { get; private set; }
- public float ZAxisPostion { get; private set; }
- public Int32[] AData { get; private set; } = new Int32[1000];
- public JelParameterData[] RobotParameters { get; private set; } = new JelParameterData[2000];
- public string ReadBankNumber { get; private set; } = "";
- public int ReadCassetNumber { get; private set; }
- public int ReadSlotNumber { get; private set; }
- public bool IsVacuumSensorON { get; protected set; } = true;
-
- public bool IsEchoBack { get; private set; }
- public JelCommandStatus CurrentCompoundCommandStatus { get; set; }
- public string StopPostionOfCompoundCommand { get; private set; }
- public string[] MainRoutines { get; private set; } = new string[320];
- public string[] SubRoutines { get; private set; } = new string[16];
- public string CurrentReadRoutine { get; private set; }
- public int HighSpeed { get; private set; }
- public int LowSpeed { get; private set; }
- public int DomainOfAccDec { get; private set; }
- public int AccDecSpeed { get; private set; }
- public int MagnificationOfFrequency { get; private set; }
- public int PulsePostionOfManualSlowDown { get; private set; }
- public int CurrentReadSpeedData { get; private set; }
- public Int32 CurrentReadAData { get; private set; }
- public Int32 ReadPosXAxisPostion { get; private set; }
- public Int32 ReadPosYAxisPostion { get; private set; }
- public Int32 ReadPosThetaAxisPostion { get; private set; }
- public Int32 ReadPosZAxisPostion { get; private set; }
- public float ReadParameterMin { get; private set; }
- public float ReadParameterMax { get; private set; }
- public float ReadParameterValue { get; private set; }
- //Mapping Data
- public float MappingFirstSlotPosition { get; private set; }
- public float MappingTopSlotPostion { get; private set; }
- public int MappingSlotsNumber { get; private set; }
- public float MappingMinDetectWidth { get; private set; }
- public float MappingMaxDetectWidth { get; private set; }
- public float MappingGateWidth { get; private set; }
- public float MappingStopPostion { get; private set; }
- public float MappingSpeed { get; private set; }
- public bool IsMappingSensorON { get; private set; }
- public string MappingWaferResult { get; private set; } = string.Empty;
- public string MappingWidthResult { get; private set; } = string.Empty;
- public override bool Blade1Enable => true;
- public override bool Blade2Enable => false;
- protected ModuleName LastTargeModule { get; set; }
- #endregion
- #region ParseHandler
- public virtual void ParseData(string command,string parameter,string data)
- {
- try
- {
- string datavalue = data.Replace($"${BodyNumber}", "").Replace("\r", "");
- if(command == "SPA")
- {
- CurrentReadSpeedData = Convert.ToInt32(datavalue);
- }
- if (command == "") ParseRobotStatus(datavalue); // Read Robot Status
- if (command == "6" || command == "6M") ParseRobotPostion(parameter, datavalue); //Read Postion Data
- if (command == "A") // Read A data
- {
- int _index;
- if (!int.TryParse(parameter.Replace("D", ""), out _index)) return;
- AData[_index] = Convert.ToInt32(datavalue);
- CurrentReadAData = Convert.ToInt32(datavalue);
- }
- if (command == "BC")
- {
- ReadBankNumber = datavalue;
- }
- if (command == "WCP")
- {
- string[] strvalues = datavalue.Split(',');
- ReadCassetNumber = Convert.ToInt32(strvalues[0]);
- ReadSlotNumber = Convert.ToInt32(strvalues[1]);
- }
- if (command == $"CS{_lowerArmWaferSensorIndex}")
- {
- IsVacuumSensorON = datavalue == "1";
-
- }
- if (command == "DTD")
- {
- int _index;
- if (!int.TryParse(parameter, out _index)) return;
- string[] paradata = datavalue.Split(',');
- //if (paradata.Length < 3) return;
- RobotParameters[_index].Value = paradata[0];
- RobotParameters[_index].MinValue = paradata[1];
- RobotParameters[_index].MaxValue = paradata[2];
- }
- if (command == "EE")
- {
- IsEchoBack = datavalue == "E";
- }
- if (command == "G")
- {
- if (datavalue == "0") CurrentCompoundCommandStatus = JelCommandStatus.NormalEnd;
- if (datavalue == "1") CurrentCompoundCommandStatus = JelCommandStatus.InExecution;
- if (datavalue == "P") CurrentCompoundCommandStatus = JelCommandStatus.InPause;
- if (datavalue == "E") CurrentCompoundCommandStatus = JelCommandStatus.InError;
- }
- if (command == "GER")
- {
- LOG.Write("Compaund command stop postion:" + datavalue);
- }
- if (command == "IR")
- {
- int _index;
- if (!int.TryParse(parameter, out _index)) return;
- if (_index < 0 || _index > 319) return;
- MainRoutines[_index] = datavalue;
- CurrentReadRoutine = datavalue;
- }
- if (command == "IRS")
- {
- int _index = Convert.ToInt32(parameter, 16);
- if (_index < 0 || _index > 15) return;
- SubRoutines[_index] = datavalue;
- CurrentReadRoutine = datavalue;
- }
- if (command == "O")
- {
- CurrentReadSpeedData = Convert.ToInt32(datavalue);
- if (parameter == "H")
- HighSpeed = Convert.ToInt32(datavalue);
- if (parameter == "L")
- LowSpeed = Convert.ToInt32(datavalue);
- if (parameter == "S")
- DomainOfAccDec = Convert.ToInt32(datavalue);
- if (parameter == "G")
- AccDecSpeed = Convert.ToInt32(datavalue);
- if (parameter == "X")
- MagnificationOfFrequency = Convert.ToInt32(datavalue);
- if (parameter == "D")
- PulsePostionOfManualSlowDown = Convert.ToInt32(datavalue);
- }
- if (command == "PSD")
- {
- string[] stradata = datavalue.Split(',');
- ReadPosXAxisPostion = Convert.ToInt32(stradata[0].ToString());
- ReadPosYAxisPostion = Convert.ToInt32(stradata[1].ToString());
- ReadPosThetaAxisPostion = Convert.ToInt32(stradata[2].ToString());
- ReadPosZAxisPostion = Convert.ToInt32(stradata[3].ToString());
- }
- if (command == "DTD")
- {
- string[] stradata = datavalue.Split(',');
- ReadParameterValue = Convert.ToSingle(stradata[0].ToString());
- ReadParameterMin = Convert.ToSingle(stradata[1].ToString());
- ReadParameterMax = Convert.ToSingle(stradata[2].ToString());
- }
- if (command == "WLO") // Obtaining the postion data of mapping 1st slot detected
- MappingFirstSlotPosition = Convert.ToSingle(datavalue);
- if(command == "WHI")
- MappingTopSlotPostion = Convert.ToSingle(datavalue);
- if(command == "WFC")
- MappingSlotsNumber = Convert.ToInt32(datavalue);
- if(command == "WWN")
- MappingMinDetectWidth = Convert.ToSingle(datavalue);
- if(command == "WWM")
- MappingMaxDetectWidth = Convert.ToSingle(datavalue);
- if(command == "WWG")
- MappingGateWidth = Convert.ToSingle(datavalue);
- if(command == "WEND")
- MappingStopPostion = Convert.ToSingle(datavalue);
- if(command == "WSP")
- MappingSpeed = Convert.ToSingle(datavalue);
- if(command == "WFK")
- {
- MappingWaferResult = datavalue;
- NotifySlotMapResult(CurrentInteractModule, datavalue.Replace(",", "").Replace("E", "?"));
- }
- if (command == "WFW")
- {
- MappingWidthResult = datavalue;
- List<double> tempThickness = new List<double>();
- foreach(var strThick in datavalue.Split(','))
- {
- if (string.IsNullOrEmpty(strThick)) continue;
- if (double.TryParse(strThick, out double dvalue))
- tempThickness.Add(dvalue);
- }
- NotifySlotMapThicknessResult(CurrentInteractModule,tempThickness.ToArray());
- }
-
- }
- catch(Exception ex)
- {
- LOG.Write($"Parse {command}.{parameter??parameter} data {data} error:" + ex.ToString());
- OnError($"Parse data error:{command}.{parameter ?? parameter} data {data}");
- }
-
- }
- private void ParseRobotStatus(string data)
- {
- if (data.Length < 2) return;
- int intRobostatus = Convert.ToInt16(data.ToArray()[0].ToString(), 16);
- if (intRobostatus == 0)
- JelC5000RobotStatus = (JelAxisStatus)Convert.ToInt16(data.ToArray()[0].ToString(), 16);
- if((intRobostatus & 0x1) == 0x1)
- {
- JelC5000RobotStatus = JelAxisStatus.InOperation;
- }
- if ((intRobostatus & 0x2) == 0x2)
- {
- JelC5000RobotStatus = JelAxisStatus.SensorError;
- OnError(JelC5000RobotStatus.ToString());
- }
- if ((intRobostatus & 0x4) == 0x4)
- {
- JelC5000RobotStatus = JelAxisStatus.SensorErrorOrStoppedByAlarm;
- OnError(JelC5000RobotStatus.ToString());
- }
- if ((intRobostatus & 0x8) == 0x8)
- {
- JelC5000RobotStatus = JelAxisStatus.CommandError;
- OnError(JelC5000RobotStatus.ToString());
- }
- if (data.ToArray()[1] == '0')
- AxisStatus = JelAxisStatus.NormalEnd;
- else
- AxisStatus = JelAxisStatus.InOperation;
- }
- private void ParseRobotPostion(string axis,string data)
- {
- float _floatvalue;
- if (!float.TryParse(data, out _floatvalue)) return;
- if (axis == "1")
- {
- PositionAxis1 = _floatvalue;
- }
- if (axis == "2")
- {
- PositionAxis2 = _floatvalue;
- }
- if (axis == "3")
- {
- PositionAxis3 = _floatvalue;
- }
- if (axis == "4")
- {
- PositionAxis4 = _floatvalue;
- }
- if (axis == "X")
- {
- XAxisPostion = _floatvalue;
- }
- if (axis == "Y")
- {
- YAxisPostion = _floatvalue;
- }
- if (axis == "U")
- {
- ThetaAxisPostion = _floatvalue;
- }
- if (axis == "Z")
- {
- ZAxisPostion = _floatvalue;
- }
- }
- #endregion
- private bool OnTimer()
- {
- try
- {
- if (!_connection.IsConnected || _connection.IsCommunicationError)
- {
- lock (_locker)
- {
- _lstMonitorHandler.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)
- {
- if(_lstMonitorHandler.Count > 0)
- {
- if (!_connection.IsBusy)
- {
- handler = _lstMonitorHandler.First.Value;
- _connection.Execute(handler);
- _lstMonitorHandler.RemoveFirst();
- }
- else
- {
- _connection.MonitorTimeout();
- _trigCommunicationError.CLK = _connection.IsCommunicationError;
- if (_trigCommunicationError.Q)
- {
- _lstMonitorHandler.Clear();
- OnError($"{Module}.{Name} communication error, {_connection.LastCommunicationError}");
- }
- }
-
- }
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- return true;
- }
- private void RegisterSpecialData()
- {
- DATA.Subscribe($"{Module}.{Name}.CurrentReadRoutine", () => CurrentReadRoutine);
- DATA.Subscribe($"{Module}.{Name}.CurrentReadSpeedData", () => CurrentReadSpeedData);
-
- DATA.Subscribe($"{Module}.{Name}.CurrentReadAData", () => CurrentReadAData);
- DATA.Subscribe($"{Module}.{Name}.IsVacuumSensorON", () => IsVacuumSensorON);
- DATA.Subscribe($"{Module}.{Name}.JelC5000RobotStatus", () => JelC5000RobotStatus.ToString());
- DATA.Subscribe($"{Module}.{Name}.AxisStatus", () => AxisStatus.ToString());
- DATA.Subscribe($"{Module}.{Name}.CurrentCompoundCommandStatus", () => CurrentCompoundCommandStatus.ToString());
- DATA.Subscribe($"{Module}.{Name}.ReadCassetNumber", () => ReadCassetNumber.ToString());
- DATA.Subscribe($"{Module}.{Name}.ReadSlotNumber", () => ReadSlotNumber.ToString());
- DATA.Subscribe($"{Module}.{Name}.ReadBankNumber", () => ReadBankNumber.ToString());
- DATA.Subscribe($"{Module}.{Name}.ReadPosXAxisPostion", () => ReadPosXAxisPostion);
- DATA.Subscribe($"{Module}.{Name}.ReadPosYAxisPostion", () => ReadPosYAxisPostion);
- DATA.Subscribe($"{Module}.{Name}.ReadPosZAxisPostion", () => ReadPosZAxisPostion);
- DATA.Subscribe($"{Module}.{Name}.ReadPosThetaAxisPostion", () => ReadPosThetaAxisPostion);
- DATA.Subscribe($"{Module}.{Name}.ReadParameterMax", () => ReadParameterMax.ToString());
- DATA.Subscribe($"{Module}.{Name}.ReadParameterMin", () => ReadParameterMin.ToString());
- DATA.Subscribe($"{Module}.{Name}.ReadParameterValue", () => ReadParameterValue.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingFirstSlotPosition", () => MappingFirstSlotPosition.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingGateWidth", () => MappingGateWidth.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingMaxDetectWidth", () => MappingMaxDetectWidth.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingMinDetectWidth", () => MappingMinDetectWidth.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingSlotsNumber", () => MappingSlotsNumber.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingSpeed", () => MappingSpeed.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingStopPostion", () => MappingStopPostion.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingTopSlotPostion", () => MappingTopSlotPostion.ToString());
- DATA.Subscribe($"{Module}.{Name}.IsMappingSensorON", () => IsMappingSensorON.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingWaferResult", () => MappingWaferResult.ToString());
- DATA.Subscribe($"{Module}.{Name}.MappingWidthResult", () => MappingWidthResult.ToString());
- DATA.Subscribe($"{Name}.RobotSpeed", () => CurrentReadSpeedData);
- DATA.Subscribe($"{Name}.CurrentReadRoutine", () => CurrentReadRoutine);
- DATA.Subscribe($"{Name}.CurrentReadSpeedData", () => CurrentReadSpeedData);
- DATA.Subscribe($"{Name}.CurrentReadAData", () => CurrentReadAData);
- DATA.Subscribe($"{Name}.IsVacuumSensorON", () => IsVacuumSensorON);
- DATA.Subscribe($"{Name}.JelC5000RobotStatus", () => JelC5000RobotStatus.ToString());
- DATA.Subscribe($"{Name}.AxisStatus", () => AxisStatus.ToString());
- DATA.Subscribe($"{Name}.CurrentCompoundCommandStatus", () => CurrentCompoundCommandStatus.ToString());
- DATA.Subscribe($"{Name}.ReadCassetNumber", () => ReadCassetNumber.ToString());
- DATA.Subscribe($"{Name}.ReadSlotNumber", () => ReadSlotNumber.ToString());
- DATA.Subscribe($"{Name}.ReadBankNumber", () => ReadBankNumber.ToString());
- DATA.Subscribe($"{Name}.ReadPosXAxisPostion", () => ReadPosXAxisPostion.ToString());
- DATA.Subscribe($"{Name}.ReadPosYAxisPostion", () => ReadPosYAxisPostion.ToString());
- DATA.Subscribe($"{Name}.ReadPosZAxisPostion", () => ReadPosZAxisPostion.ToString());
- DATA.Subscribe($"{Name}.ReadPosThetaAxisPostion", () => ReadPosThetaAxisPostion.ToString());
- DATA.Subscribe($"{Name}.XAxisPostion", () => XAxisPostion.ToString());
- DATA.Subscribe($"{Name}.YAxisPostion", () => YAxisPostion.ToString());
- DATA.Subscribe($"{Name}.ZAxisPostion", () => ZAxisPostion.ToString());
- DATA.Subscribe($"{Name}.ThetaAxisPostion", () => ThetaAxisPostion.ToString());
- DATA.Subscribe($"{Name}.ReadParameterMax", () => ReadParameterMax.ToString());
- DATA.Subscribe($"{Name}.ReadParameterMin", () => ReadParameterMin.ToString());
- DATA.Subscribe($"{Name}.ReadParameterValue", () => ReadParameterValue.ToString());
- DATA.Subscribe($"{Name}.MappingFirstSlotPosition", () => MappingFirstSlotPosition.ToString());
- DATA.Subscribe($"{Name}.MappingGateWidth", () => MappingGateWidth.ToString());
- DATA.Subscribe($"{Name}.MappingMaxDetectWidth", () => MappingMaxDetectWidth.ToString());
- DATA.Subscribe($"{Name}.MappingMinDetectWidth", () => MappingMinDetectWidth.ToString());
- DATA.Subscribe($"{Name}.MappingSlotsNumber", () => MappingSlotsNumber.ToString());
- DATA.Subscribe($"{Name}.MappingSpeed", () => MappingSpeed.ToString());
- DATA.Subscribe($"{Name}.MappingStopPostion", () => MappingStopPostion.ToString());
- DATA.Subscribe($"{Name}.MappingTopSlotPostion", () => MappingTopSlotPostion.ToString());
- DATA.Subscribe($"{Name}.IsMappingSensorON", () => IsMappingSensorON.ToString());
- DATA.Subscribe($"{Name}.MappingWaferResult", () => MappingWaferResult.ToString());
- DATA.Subscribe($"{Name}.MappingWidthResult", () => MappingWidthResult.ToString());
- DATA.Subscribe($"{Name}.BladeRegulatorRatio", () => BladeRegulatorRatio);
- OP.Subscribe(String.Format("{0}.{1}", Name, "FlippeTo0Degree"), (out string reason, int time, object[] param) =>
- {
- bool ret = ExecuteCommand(param);
- if (ret)
- {
- reason = string.Format("{0} {1}", Name, "Execute command succesfully");
- return true;
- }
- reason = $"{Name} execute failed";
- return false;
- });
- }
- private int BladeRegulatorRatio
- {
- get
- {
- if (_aoBladeRegulator == null)
- return 0;
- return (int)(_aoBladeRegulator.Value / 100);
- }
- }
- private void ResetPropertiesAndResponses()
- {
-
- }
- protected override bool fReset(object[] param)
- {
- _trigError.RST = true;
- _connection.SetCommunicationError(false, "");
- _trigCommunicationError.RST = true;
- _enableLog = SC.GetValue<bool>($"{_scRoot}.{Name}.EnableLogMessage");
- _connection.EnableLog(_enableLog);
- _trigRetryConnect.RST = true;
- _lstMonitorHandler.Clear();
- //_lstMonitorHandler.Clear();
- _connection.ForceClear();
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeRawCommandHandler(this, $"RD"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, ""));
- }
- return true;
- }
- protected override bool fMonitorReset(object[] param)
- {
- IsBusy = false;
- if (JelC5000RobotStatus == JelAxisStatus.NormalEnd
- && (AxisStatus == JelAxisStatus.NormalEnd)
- && _lstMonitorHandler.Count == 0
- && !_connection.IsBusy)
- {
- IsBusy = false;
- return true;
- }
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- _connection.Execute(new JelC5000RobotFlippeReadHandler(this, ""));
- return false;
- }
- protected override bool fStartMove(object[] param)
- {
- if (param.Length < 4) return false;
- int axis,intdirect;
- if (!int.TryParse(param[0].ToString(), out axis)) return false;
- if (axis > 4 || axis < 0) return false;
- if (!int.TryParse(param[1].ToString(), out intdirect)) return false;
- if (intdirect > 1 || intdirect < 0) return false;
- RobotMoveDirectionEnum direction = (RobotMoveDirectionEnum)Convert.ToInt16(param[1].ToString());
- uint instance;
- if (!uint.TryParse(param[2].ToString(), out instance)) return false;
- if (instance > 8388607) instance = 8388607;
- string movebasetype = Regex.Replace(param[3].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- if (movebasetype != "0" && movebasetype != "1") return false;
- string commandstr = "";
- if (movebasetype == "0") commandstr = "3";
- if(movebasetype == "1")
- {
- if (direction == RobotMoveDirectionEnum.Fwd) commandstr = "4";
- else commandstr = "5";
- }
- if (string.IsNullOrEmpty(commandstr)) return false;
- string speedtype = string.Empty;
- if (param.Length > 4)
- speedtype = Regex.Replace(param[4].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
-
- if (speedtype != "" && speedtype != "M" && speedtype != "L") return false;
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "2", instance.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeMoveHandler(this, commandstr + "M", axis.ToString() + speedtype));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, ""));
- }
- return true;
- }
- protected override bool fMonitorMoving(object[] param)
- {
- if (JelC5000RobotStatus == JelAxisStatus.NormalEnd
- && (AxisStatus == JelAxisStatus.NormalEnd)
- && _lstMonitorHandler.Count == 0
- && !_connection.IsBusy)
- {
- IsBusy = false;
- return true;
- }
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- _connection.Execute(new JelC5000RobotFlippeReadHandler(this, ""));
- return false;
- }
- protected override bool fMonitorGoTo(object[] param)
- {
- if (JelC5000RobotStatus == JelAxisStatus.NormalEnd
- && (AxisStatus == JelAxisStatus.NormalEnd)
- && _lstMonitorHandler.Count == 0
- && !_connection.IsBusy)
- {
- IsBusy = false;
- return true;
- }
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- _connection.Execute(new JelC5000RobotFlippeReadHandler(this, ""));
- return false;
- }
- protected override bool fStartInit(object[] param)
- {
- //string speedtype = string.Empty;
- //if (param != null && param.Length >0)
- // speedtype = Regex.Replace(param[0].ToString().Replace("(", "(").Replace(")", ")"), @"\([^\(]*\)", "");
- //if (speedtype != "" && speedtype != "M" && speedtype != "L") return false;
- _dtActionStart = DateTime.Now;
- int compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.InitCmdNO");
- int Robotspeed = SC.GetValue<int>($"Robot.{Name}.RobotSpeed");
- if (Robotspeed < 0)
- Robotspeed = 0;
- if (Robotspeed > 99)
- Robotspeed = 99;
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeCompaundCommandHandler(this, compaundcmdNO.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, ""));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "BC")); // Read bank number
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WCP")); // Read Cassette Number
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "1"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "2"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "3"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "4"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "X"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "Y"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "U"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "Z"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "SPA", Robotspeed.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "SPA"));
- }
- return true;
- }
- protected override bool fMonitorInit(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(RobotCommandTimeout))
- {
- HandlerError("InitTimeout");
- return true;
- }
-
- if (_lstMonitorHandler.Count ==0 && !_connection.IsBusy)
- {
- if (CurrentCompoundCommandStatus == JelCommandStatus.NormalEnd &&
- JelC5000RobotStatus == JelAxisStatus.NormalEnd
- && AxisStatus == JelAxisStatus.NormalEnd)
- {
- Blade1Target = ModuleName.System;
- Blade2Target = ModuleName.System;
- CmdTarget = ModuleName.System;
- LastTargeModule = ModuleName.System;
- MoveInfo = new RobotMoveInfo()
- {
- Action = RobotAction.Picking,
- ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
- BladeTarget = BuildBladeTarget(),
- };
- if(IsVacuumSensorON && WaferManager.Instance.CheckNoWafer(RobotModuleName,0))
- {
- EV.PostAlarmLog("Robot", $"There's unknown wafer on {RobotModuleName}.");
- WaferManager.Instance.CreateWafer(RobotModuleName, 0, WaferStatus.Normal);
- }
- if (!IsVacuumSensorON && WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
- {
- EV.PostAlarmLog("Robot", $"There's a wafer on {RobotModuleName} but robot didn't detect.");
- }
- return true;
- }
- if (CurrentCompoundCommandStatus != JelCommandStatus.NormalEnd)
- {
- if (CurrentCompoundCommandStatus == JelCommandStatus.InError)
- {
- OnError("Init Compaund command execution error");
- return false;
- }
- }
- }
- return false;
- }
- protected override bool fStartReadData(object[] param)
- {
- if(param.Length <1) return false;
- string readcommand = param[0].ToString();
- switch(readcommand)
- {
- case "CurrentStatus":
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, ""));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G")); // Read out the compaund command status
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "BC")); // Read bank number
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WCP")); // Read Cassette Number
- }
- break;
- case "CurrentPositionData":
- lock(_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "1"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "2"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "3"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "4"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "X"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "Y"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "U"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "6", "Z"));
- }
- break;
- case "CompaundCommand":
- if (param.Length < 3) return false;
- string routineselction = param[1].ToString();
- if(routineselction == "MainRoutine")
- {
- int routineno;
- if (!int.TryParse(param[2].ToString(), out routineno)) return false;
- if (routineno > 319 || routineno < 1) return false;
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "IR",routineno.ToString().PadLeft(3,'0')));
- }
- if (routineselction == "SubRoutine")
- {
- char routineno;
- if (!char.TryParse(param[2].ToString(), out routineno)) return false;
- if (routineno > 'F' || routineno < 1) return false;
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "IRS", routineno.ToString()));
- }
- break;
- case "RobotSpeed":
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "SPA"));
- break;
- case "AData":
- if (param.Length < 2) return false;
- int datano;
- if (!int.TryParse(param[1].ToString(), out datano)) return false;
- if (datano < 0 || datano > 999) return false;
- lock(_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "A", datano.ToString("D3")+"D"));
- }
- break;
- case "EPData":
- if (param.Length < 2) return false;
- if (param[1].ToString() == "AData")
- {
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeRawCommandHandler (this, $"AL"));
- }
- }
- break;
- case "PositionData":
- if (param.Length < 2) return false;
- int posNO;
- if (!int.TryParse(param[1].ToString(), out posNO)) return false;
- if (posNO > 999 || posNO < 0) return false;
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "PSD", posNO.ToString("D3")));
- }
- break;
- case "RobotParameter":
- if (param.Length < 2) return false;
- uint parano;
- if(!uint.TryParse(param[1].ToString(), out parano)) return false;
- lock(_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "DTD", parano.ToString()));
- }
- break;
- case "MappingData":
- lock(_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WLO"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WHI"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WFC"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WWN"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WWM"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WWG"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WEND"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WSP"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WFK"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WFW"));
- }
- break;
- }
- return true;
- }
- protected override bool fMonitorReadData(object[] param)
- {
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- {
- IsBusy = false;
- return true;
- }
- return false;
- }
- protected override bool fStartSetParameters(object[] param)
- {
- try
- {
-
- string setcommand = param[0].ToString();
- switch (setcommand)
- {
- case "CompaundCommand":
- if (param.Length < 4) return false;
- string routineselction = param[1].ToString();
- if (routineselction == "MainRoutine")
- {
- int routineno;
- if (!int.TryParse(param[2].ToString(), out routineno)) return false;
- if (routineno > 319 || routineno < 1) return false;
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "I", routineno.ToString().PadLeft(3, '0')));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeRawCommandHandler(this, param[3].ToString()));
- }
- if (routineselction == "SubRoutine")
- {
- char routineno;
- if (!char.TryParse(param[2].ToString(), out routineno)) return false;
- if (routineno > 'F' || routineno < 1) return false;
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "IS", routineno.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeRawCommandHandler(this, param[3].ToString()));
- }
- break;
- case "RobotSpeed":
- //if (param.Length < 3) return false;
- //string speedtype = param[1].ToString().Split('(')[0];
- //Int32 speedvalue;
- //if (!Int32.TryParse(param[2].ToString(), out speedvalue)) return false;
- //_lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "O" + speedtype, speedvalue.ToString().PadLeft(5, '0')));
- Int32 speedvalue;
- if (!Int32.TryParse(param[2].ToString(), out speedvalue)) return false;
- if(SC.ContainsItem($"Robot.{RobotModuleName}.RobotSpeed"))
- {
- SC.SetItemValue($"Robot.{RobotModuleName}.RobotSpeed", speedvalue);
- }
- if (speedvalue < 0)
- speedvalue = 0;
- if (speedvalue > 99)
- speedvalue = 99;
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "SPA" , speedvalue.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "SPA"));
- break;
- case "AData":
- if (param.Length < 3) return false;
- Int32 datano, datavalue;
- if (!Int32.TryParse(param[1].ToString(), out datano)) return false;
- if (!Int32.TryParse(param[2].ToString(), out datavalue)) return false;
- if (datano > 999 || datano < 0) return false;
- if (datavalue > 8388607 || datavalue < -8388608) return false;
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "A", datano.ToString("D3") + datavalue.ToString()));
- }
- break;
- case "EPData":
- if (param.Length < 2) return false;
- if (param[1].ToString() == "AData")
- {
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "AW"));
- }
- }
- break;
- case "PositionData":
- if (param.Length < 6) return false;
- Int32 posno, rightarmpos, thetapos, leftarmpos, zpos;
- if (!Int32.TryParse(param[1].ToString(), out posno)) return false;
- if (!Int32.TryParse(param[2].ToString(), out rightarmpos)) return false;
- if (!Int32.TryParse(param[3].ToString(), out thetapos)) return false;
- if (!Int32.TryParse(param[4].ToString(), out leftarmpos)) return false;
- if (!Int32.TryParse(param[5].ToString(), out zpos)) return false;
- if (posno > 999 || posno < 0) return false;
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "PS",
- $"{posno.ToString("D3")}{rightarmpos},{thetapos},{leftarmpos},{zpos}"));
- }
- return true;
- case "CurrentPositionData":
- Int32 currentpos = Int32.Parse(param[1].ToString());
- if (currentpos > 999 || currentpos < 0) return false;
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "PS",
- $"{currentpos.ToString("D3")}"));
- }
- break;
- case "RobotParameter":
- if (param.Length < 3) return false;
- Int32 parano, paravalue;
- if (!Int32.TryParse(param[1].ToString(), out parano)) return false;
- if (!Int32.TryParse(param[2].ToString(), out paravalue)) return false;
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "DTSVAL", $"{parano},{paravalue}"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "DW"));
- }
- break;
- case "MappingData":
- lock(_locker)
- {
-
- if (!string.IsNullOrEmpty(param[1].ToString()))
- {
- float tempvalue = float.Parse(param[1].ToString());
- string strtempvalue;
- if (tempvalue <0)
- {
- strtempvalue = "-" +(-tempvalue).ToString().PadLeft(7, '0');
- }
- else
- strtempvalue = tempvalue.ToString().PadLeft(8, '0');
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WLO",strtempvalue));
- }
- if (!string.IsNullOrEmpty(param[2].ToString()))
- {
- float tempvalue = float.Parse(param[2].ToString());
- string strtempvalue;
- if (tempvalue < 0)
- {
- strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
- }
- else
- strtempvalue = tempvalue.ToString().PadLeft(8, '0');
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WHI",strtempvalue));
- }
- if (!string.IsNullOrEmpty(param[3].ToString()))
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WFC",
- (Convert.ToInt16(param[3].ToString()).ToString("D2"))));
- if (!string.IsNullOrEmpty(param[4].ToString()))
- {
- float tempvalue = float.Parse(param[4].ToString());
- string strtempvalue;
- if (tempvalue < 0)
- {
- strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
- }
- else
- strtempvalue = tempvalue.ToString().PadLeft(8, '0');
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WWN", strtempvalue));
- }
- if (!string.IsNullOrEmpty(param[5].ToString()))
- {
- float tempvalue = float.Parse(param[5].ToString());
- string strtempvalue;
- if (tempvalue < 0)
- {
- strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
- }
- else
- strtempvalue = tempvalue.ToString().PadLeft(8, '0');
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WWM", strtempvalue));
- }
- if (!string.IsNullOrEmpty(param[6].ToString()))
- {
- float tempvalue = float.Parse(param[6].ToString());
- string strtempvalue;
- if (tempvalue < 0)
- {
- strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
- }
- else
- strtempvalue = tempvalue.ToString().PadLeft(8, '0');
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WWG", strtempvalue));
- }
- if (!string.IsNullOrEmpty(param[7].ToString()))
- {
- float tempvalue = float.Parse(param[7].ToString());
- string strtempvalue;
- if (tempvalue < 0)
- {
- strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
- }
- else
- strtempvalue = tempvalue.ToString().PadLeft(8, '0');
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WEND", strtempvalue));
- }
- if (!string.IsNullOrEmpty(param[8].ToString()))
- {
- float tempvalue = float.Parse(param[8].ToString());
- string strtempvalue;
- if (tempvalue < 0)
- {
- strtempvalue = "-" + (-tempvalue).ToString().PadLeft(7, '0');
- }
- else
- strtempvalue = tempvalue.ToString().PadLeft(8, '0');
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WSP", strtempvalue));
- }
- }
- break;
- case "MappingCommand":
- lock(_locker)
- {
- //_lstMonitorHandler.AddLast(new JelC5000RobotMoveHandler(this, "WFS"));
- //_lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WFK"));
- //_lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WFW"));
- }
- break;
- case "BankNumber":
- lock (_locker)
- {
- if (param.Length > 1 && !string.IsNullOrEmpty(param[1].ToString()))
- {
- int bankno = Convert.ToInt16(param[1].ToString());
- if (bankno <= 15 && bankno >= 0)
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "BC", bankno.ToString("X")));
- }
- if (param.Length > 2 && !string.IsNullOrEmpty(param[2].ToString()))
- {
- int cassetteno = Convert.ToInt16(param[2].ToString());
- if (cassetteno <=5 && cassetteno <= 1)
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WCP", cassetteno.ToString()));
- }
- if (param.Length > 3 && !string.IsNullOrEmpty(param[3].ToString()))
- {
- int slotno = Convert.ToInt16(param[3].ToString());
- if (slotno <= 25 && slotno >= 1)
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WCD", slotno.ToString()));
- }
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "BC"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WCP"));
- }
- break;
- }
- }
- catch (Exception )
- {
- string reason = "";
- if(param!=null)
- {
- foreach(var para in param)
- {
- reason += para.ToString() + ",";
- }
- }
- EV.PostAlarmLog(Name, "Set command parameter valid:" + reason);
- return false;
- }
- return true;
- }
- protected override bool fMonitorSetParamter(object[] param)
- {
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- {
- IsBusy = false;
- return true;
- }
- return base.fMonitorSetParamter(param);
- }
- public override bool IsReady()
- {
- return RobotState == RobotStateEnum.Idle && !IsBusy;
- }
- protected override bool fClear(object[] param)
- {
- return true;
- }
- protected override bool fStartTransferWafer(object[] param)
- {
- return false;
- }
- protected override bool fStartUnGrip(object[] param)
- {
- if (param == null || param.Length < 1) return false;
- RobotArmEnum arm = (RobotArmEnum)((int)param[0]);
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "DS", "10"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, ""));
- }
- return true;
- }
- protected override bool fMonitorUnGrip(object[] param)
- {
- IsBusy = false;
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- {
- if (JelC5000RobotStatus != JelAxisStatus.NormalEnd
- || AxisStatus != JelAxisStatus.NormalEnd)
- {
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, ""));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
- }
- return false;
- }
- RobotArmEnum arm = (RobotArmEnum)((int)CurrentParamter[0]);
- //if(IsVacuumSensorON)
- // HandlerError("UnGrip wafer failed!");
- IsBusy = false;
- return true;
- }
- return false;
- }
- protected override bool fStartGrip(object[] param)
- {
- if(param == null || param.Length <1) return false;
- RobotArmEnum arm = (RobotArmEnum)((int)param[0]);
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "DS", "11"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, ""));
- }
- return true;
- }
- protected override bool fMonitorGrip(object[] param)
- {
- IsBusy = false;
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- {
- if (JelC5000RobotStatus != JelAxisStatus.NormalEnd
- || AxisStatus != JelAxisStatus.NormalEnd)
- {
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, ""));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
- }
- return false;
- }
- //if (!IsVacuumSensorON)
- // HandlerError("UnGrip wafer failed!");
- IsBusy = false;
- return true;
- }
-
- return false;
- }
- protected override bool fStop(object[] param)
- {
- IsBusy = false;
- _lstMonitorHandler.Clear();
- _connection.ForceClear();
- _connection.Execute(new JelC5000RobotFlippeSetHandler(this, "S"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "GE"));
- return ReadStatus();
-
- }
- protected override bool fStartGoTo(object[] param)
- {
- return false;
- }
- protected override bool fStartMapWafer(object[] param)
- {
- try
- {
- _dtActionStart = DateTime.Now;
- ModuleName tempmodule = (ModuleName)Enum.Parse(typeof(ModuleName), param[0].ToString());
- WaferSize wz = WaferSize.WS12;
- int compaundcmdNO = 0;
- if(SC.ContainsItem($"Robot.{Name}.MapCmdNO"))
- {
- compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.MapCmdNO");
- }
- if (ModuleHelper.IsLoadPort(tempmodule))
- {
- LoadPortBaseDevice lp = DEVICE.GetDevice<LoadPortBaseDevice>(tempmodule.ToString());
-
- if(SC.ContainsItem($"CarrierInfo.Carrier{lp.InfoPadCarrierIndex}.{lp.LPModuleName}MapCmdNO"))
- {
- compaundcmdNO = SC.GetValue<int>($"CarrierInfo.Carrier{lp.InfoPadCarrierIndex}.{lp.LPModuleName}MapCmdNO");
- }
- else
- {
- OnError("Not find Compaund Command");
- return false;
- }
- if (lp != null)
- {
- wz = lp.GetCurrentWaferSize();
- lp.NoteTransferStart();
- }
- }
- if (!GetBankAndCassetteNumber(tempmodule, wz, false, out int bankno, out int cassetteNO))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} can't find the bankno or cassette no for {tempmodule}");
- OnError("ParseStationError");
- return false;
- }
-
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "BC", bankno.ToString("X")));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WCP", cassetteNO.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WCD", "1"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "BC"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WCP"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeRawCommandHandler(this, $"RD"));
- }
- DateTime readstarttime = DateTime.Now;
- while (_lstMonitorHandler.Count != 0 || _connection.IsBusy)
- {
- if (DateTime.Now - readstarttime > TimeSpan.FromSeconds(20))
- {
- OnError("Set Timeout.");
- return false;
- }
- }
- if (ReadBankNumber != bankno.ToString("X") || cassetteNO != ReadCassetNumber)
- {
- OnError("Set data failed.");
- return false;
- }
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeCompaundCommandHandler(this, compaundcmdNO.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WFK"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WFW"));
- }
- EV.PostInfoLog("Robot", $"{RobotModuleName} start to map {tempmodule}");
- }
- catch (Exception ex)
- {
- string reason = "";
- if (param != null)
- foreach (var strpara in param)
- reason += strpara.ToString();
- OnError($"{Name} Map command valid:" + reason);
- LOG.Write(ex);
- return false;
- }
- return true;
- }
- protected override bool fMonitorMap(object[] param)
- {
- IsBusy = false;
- //return true;
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- {
- ModuleName sourcemodule;
- if (!Enum.TryParse(CurrentParamter[0].ToString(), out sourcemodule)) return false;
- if (ModuleHelper.IsLoadPort(sourcemodule))
- {
- LoadPortBaseDevice lp = DEVICE.GetDevice<LoadPortBaseDevice>(sourcemodule.ToString());
- if (lp != null)
- lp.NoteTransferStop();
- }
- return true;
- }
- return false;
- }
- protected override bool fStartSwapWafer(object[] param)
- {
- return false;
-
- }
- protected DateTime _dtActionStart;
- protected override bool fMonitorSwap(object[] param)
- {
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- {
- if (CurrentCompoundCommandStatus == JelCommandStatus.NormalEnd)
- {
- RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
- ModuleName sourcemodule;
- if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
- int Sourceslotindex;
- if (!int.TryParse(CurrentParamter[2].ToString(), out Sourceslotindex)) return false;
- if (arm == RobotArmEnum.Lower)
- {
- WaferManager.Instance.WaferMoved(sourcemodule, Sourceslotindex, RobotModuleName, 0);
- WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
- }
- if (arm == RobotArmEnum.Upper)
- {
- WaferManager.Instance.WaferMoved(sourcemodule, Sourceslotindex, RobotModuleName, 1);
- WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
- }
- if (arm == RobotArmEnum.Both)
- {
-
- }
-
- IsBusy = false;
- return true;
-
- }
- if (CurrentCompoundCommandStatus == JelCommandStatus.InExecution ||
- CurrentCompoundCommandStatus == JelCommandStatus.None)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G"));
- }
- if (CurrentCompoundCommandStatus == JelCommandStatus.InError)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "GER"));
- OnError("Compaund Comand execution failed");
- }
- }
- return false;
- }
- protected override bool fStartPlaceWafer(object[] param)
- {
- _dtActionStart = DateTime.Now;
- try
- {
- RobotArmEnum arm = (RobotArmEnum)param[0];
- ModuleName tempmodule = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
- int slotindex = int.Parse(param[2].ToString());
- //JelC5000RobotArm jelarm = (JelC5000RobotArm)(int)arm;
- var wz = WaferManager.Instance.GetWaferSize(RobotModuleName, arm == RobotArmEnum.Both ? 0 : (int)arm);
- int wzindex = 0;
- if (!GetBankAndCassetteNumber(tempmodule, wz, false, out int bankno, out int cassetteNO))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} can't find the bankno or cassette no for {tempmodule}");
- OnError("ParseStationError");
- return false;
- }
-
- int compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.PlaceCmdNO");
- int compaundcmdNOforSafe = SC.GetValue<int>($"Robot.{Name}.SafeCmdNO");
- if (!ModuleHelper.IsLoadPort(tempmodule) && Blade1ActionPosture == BladePostureEnum.Degree180)
- {
- if (!GetBankAndCassetteNumber(tempmodule, wz, true, out bankno, out cassetteNO))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} can't find the bankno or cassette no for {tempmodule}");
- OnError("ParseStationError");
- return false;
- }
- compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.OverPlaceCmdNO");
- compaundcmdNOforSafe = SC.GetValue<int>($"Robot.{Name}.SafeCmdNO");
- }
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "BC"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WCP"));
- }
- DateTime readstarttime = DateTime.Now;
- while (_lstMonitorHandler.Count != 0 || _connection.IsBusy)
- {
- if (DateTime.Now - readstarttime > TimeSpan.FromSeconds(10))
- {
- OnError("Read bankno and cassette no for place Timeout.");
- return false;
- }
- }
- if (ModuleHelper.IsLoadPort(tempmodule))
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(tempmodule.ToString());
- if (lp != null)
- lp.NoteTransferStart();
- }
- lock (_locker)
- {
- if(LastTargeModule != tempmodule) //(ReadBankNumber != bankno.ToString("X") || cassetteNO != ReadCassetNumber)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeCompaundCommandHandler(this, compaundcmdNOforSafe.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G"));
- }
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "BC", bankno.ToString("X")));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WCP", cassetteNO.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WCD", (slotindex+1).ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "BC"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WCP"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeCompaundCommandHandler(this, compaundcmdNO.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
- }
- Blade1Target = tempmodule;
- Blade2Target = tempmodule;
- CmdTarget = tempmodule;
- LastTargeModule = tempmodule;
- MoveInfo = new RobotMoveInfo()
- {
- Action = RobotAction.Placing,
- ArmTarget = RobotArm.Both, // CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
- BladeTarget = BuildBladeTarget(),
- };
- }
- catch (Exception ex)
- {
- string reason = "";
- if (param != null)
- foreach (var strpara in param)
- reason += strpara.ToString();
- OnError($"{Name} Pick command valid:" + reason);
- LOG.Write(ex);
- return false;
- }
- return true;
- }
- protected override bool fStartPickWafer(object[] param)
- {
- _dtActionStart = DateTime.Now;
- try
- {
- //RobotArmEnum arm = (RobotArmEnum)param[0];
- ModuleName tempmodule = (ModuleName)Enum.Parse(typeof(ModuleName), param[1].ToString());
-
- int slotindex = int.Parse(param[2].ToString());
- //JelC5000RobotArm jelarm = (JelC5000RobotArm)(int)arm;
- var wz = WaferManager.Instance.GetWaferSize(tempmodule, slotindex);
-
- if (!GetBankAndCassetteNumber(tempmodule, wz,false, out int bankno, out int cassetteNO))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} can't find the bankno or cassette no for {tempmodule}");
- OnError("ParseStationError");
- return false;
- }
-
- int compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.PickCmdNO");
- int compaundcmdNOforSafe = SC.GetValue<int>($"Robot.{Name}.SafeCmdNO");
- if(!ModuleHelper.IsLoadPort(tempmodule) && Blade1ActionPosture == BladePostureEnum.Degree180)
- {
- if (!GetBankAndCassetteNumber(tempmodule, wz, true, out bankno, out cassetteNO))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} can't find the bankno or cassette no for {tempmodule}");
- OnError("ParseStationError");
- return false;
- }
- compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.OverPickCmdNO");
- compaundcmdNOforSafe = SC.GetValue<int>($"Robot.{Name}.SafeCmdNO");
- }
- if (ModuleHelper.IsLoadPort(tempmodule))
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(tempmodule.ToString());
- if (lp != null)
- lp.NoteTransferStart();
- }
- lock (_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "BC"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WCP"));
- }
- DateTime readstarttime = DateTime.Now;
- while (_lstMonitorHandler.Count != 0 || _connection.IsBusy)
- {
- if (DateTime.Now - readstarttime > TimeSpan.FromSeconds(20))
- {
- OnError("Read bankno and cassette no for pick Timeout.");
- return false;
- }
- }
-
- lock (_locker)
- {
- if(LastTargeModule != tempmodule)//(ReadBankNumber != bankno.ToString("X") || cassetteNO != ReadCassetNumber)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeCompaundCommandHandler(this, compaundcmdNOforSafe.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G"));
- }
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "BC", bankno.ToString("X")));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WCP", cassetteNO.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeSetHandler(this, "WCD", (slotindex+1).ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "BC"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "WCP"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeCompaundCommandHandler(this,compaundcmdNO.ToString()));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
-
- }
- Blade1Target = tempmodule;
- Blade2Target = tempmodule;
- CmdTarget = tempmodule;
- LastTargeModule = tempmodule;
- MoveInfo = new RobotMoveInfo()
- {
- Action = RobotAction.Picking,
- ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
- BladeTarget = BuildBladeTarget(),
- };
- }
- catch (Exception ex)
- {
- string reason = "";
- if (param != null)
- {
- foreach (var strpara in param)
- reason += strpara.ToString();
- }
- LOG.Write(ex);
- OnError($"{Name} Pick command valid:" + reason);
-
- return false;
- }
- return true;
- }
- protected override bool fMonitorPlace(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(RobotCommandTimeout))
- {
- OnError("Place wafer timeout");
- return true;
- }
-
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- {
- if (CurrentCompoundCommandStatus == JelCommandStatus.NormalEnd)
- {
- RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
- ModuleName sourcemodule;
- if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
- int Sourceslotindex;
- if (!int.TryParse(CurrentParamter[2].ToString(), out Sourceslotindex)) return false;
- if (IsVacuumSensorON)
- {
- OnError("Vacuum sensor on blade is ON");
- return false;
- }
- if (arm == RobotArmEnum.Lower)
- WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
- if (arm == RobotArmEnum.Upper)
- WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
- if (arm == RobotArmEnum.Both)
- {
- WaferManager.Instance.WaferMoved(RobotModuleName, 0, sourcemodule, Sourceslotindex);
- WaferManager.Instance.WaferMoved(RobotModuleName, 1, sourcemodule, Sourceslotindex);
- }
- Blade1Target = ModuleName.System;
- Blade2Target = ModuleName.System;
- if (ModuleHelper.IsLoadPort(sourcemodule))
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(sourcemodule.ToString());
- if (lp != null)
- lp.NoteTransferStop();
- }
- IsBusy = false;
- CmdTarget = ModuleName.System;
- MoveInfo = new RobotMoveInfo()
- {
- Action = RobotAction.Picking,
- ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
- BladeTarget = BuildBladeTarget(),
- };
- return true;
-
- }
-
- if (CurrentCompoundCommandStatus == JelCommandStatus.InError)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "GER"));
- HandlerError("PlaceFailed");
- }
-
- }
- return false;
- }
- protected override bool fMonitorPick(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(RobotCommandTimeout))
- {
- OnError("Pick wafer timeout");
- return true;
- }
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- {
- if (CurrentCompoundCommandStatus == JelCommandStatus.NormalEnd)
- {
- RobotArmEnum arm = (RobotArmEnum)CurrentParamter[0];
- ModuleName sourcemodule;
- if (!Enum.TryParse(CurrentParamter[1].ToString(), out sourcemodule)) return false;
- int SourceslotIndex;
- if (!int.TryParse(CurrentParamter[2].ToString(), out SourceslotIndex)) return false;
- if(!IsVacuumSensorON)
- {
- OnError("Vacuum sensor is not ON");
- return false;
- }
- if (arm == RobotArmEnum.Lower)
- WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
- if (arm == RobotArmEnum.Upper)
- WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
- if(arm == RobotArmEnum.Both)
- {
- WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 0);
- WaferManager.Instance.WaferMoved(sourcemodule, SourceslotIndex, RobotModuleName, 1);
- }
- Blade1Target = ModuleName.System;
- Blade2Target = ModuleName.System;
- if (ModuleHelper.IsLoadPort(sourcemodule))
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(sourcemodule.ToString());
- if (lp != null)
- lp.NoteTransferStop();
- }
- IsBusy = false;
- CmdTarget = ModuleName.System;
- MoveInfo = new RobotMoveInfo()
- {
- Action = RobotAction.Picking,
- ArmTarget = CmdRobotArm == RobotArmEnum.Lower ? RobotArm.ArmA : RobotArm.ArmB,
- BladeTarget = BuildBladeTarget(),
- };
- return true;
- }
- if(CurrentCompoundCommandStatus == JelCommandStatus.InError)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "GER"));
- OnError("Compaund Comand execution failed");
- }
- else
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
- }
-
- }
- return false;
- }
- protected override bool fStartExecuteCommand(object[] param)
- {
- string command = param[0].ToString();
- if (string.IsNullOrEmpty(command))
- return false;
- _dtActionStart = DateTime.Now;
- lock (_locker)
- {
- if(command == "RobotFlippe")
- {
- int compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.FlippeTo0CmdNO");
- if(!Convert.ToBoolean(param[1]))
- compaundcmdNO = SC.GetValue<int>($"Robot.{Name}.FlippeTo180CmdNO");
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeCompaundCommandHandler(this, compaundcmdNO.ToString()));
- return true;
- }
- if(command == "SetRegulator")
- {
- int ratio = Convert.ToInt32(param[1]);
- if(_aoBladeRegulator != null)
- _aoBladeRegulator.Value = (short)(100 * ratio);
- _dtActionStart = DateTime.Now;
- return true;
- }
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeRawCommandHandler(this, command));
- }
- _dtActionStart = DateTime.Now;
- return true;
- }
- protected override bool fMonitorExecuting(object[] param)
- {
- IsBusy = false;
- if (DateTime.Now - _dtActionStart > TimeSpan.FromSeconds(RobotCommandTimeout))
- {
- OnError("Command execution timeout");
- return true;
- }
- if (_lstMonitorHandler.Count == 0 && !_connection.IsBusy)
- return true;
- return false;
- }
- public override bool RobotFlippe(bool to0degree)
- {
- return CheckToPostMessage(RobotMsg.ExecuteCommand, new object[] { "RobotFlippe", to0degree });
- }
- protected override bool fResetToReady(object[] param)
- {
- return true;
- }
-
- protected override bool fError(object[] param)
- {
- return true;
- }
- protected override bool fStartExtendForPick(object[] param)
- {
- return true;
- }
- protected override bool fStartExtendForPlace(object[] param)
- {
- return true;
- }
- protected override bool fStartRetractFromPick(object[] param)
- {
- return true;
- }
- protected override bool fStartRetractFromPlace(object[] param)
- {
- return true;
- }
- public override RobotArmWaferStateEnum GetWaferState(RobotArmEnum arm)
- {
- bool ispresent = WaferManager.Instance.CheckHasWafer(RobotModuleName, 0);
- if (IsVacuumSensorON == ispresent)
- return ispresent ? RobotArmWaferStateEnum.Present : RobotArmWaferStateEnum.Absent;
- return RobotArmWaferStateEnum.Unknown;
- }
- public bool ReadStatus()
- {
- lock(_locker)
- {
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, ""));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, $"CS{_lowerArmWaferSensorIndex}"));
- _lstMonitorHandler.AddLast(new JelC5000RobotFlippeReadHandler(this, "G"));
- }
- return true;
- }
- public override bool SetWaferSize(RobotArmEnum arm, WaferSize size)
- {
- if (WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
- WaferManager.Instance.UpdateWaferSize(RobotModuleName, 0, size);
- return true;
- }
- public override WaferSize GetCurrentWaferSize()
- {
- if (WaferManager.Instance.CheckHasWafer(RobotModuleName, 0))
- return WaferManager.Instance.GetWaferSize(RobotModuleName, 0);
- return WaferSize.WS0;
- }
- public void HandlerError(string errorMsg)
- {
- _lstMonitorHandler.Clear();
- OnError(errorMsg);
- }
- protected string BuildBladeTarget()
- {
- return (CmdRobotArm == RobotArmEnum.Upper ? "ArmB" : "ArmA") + "." + CmdTarget;
- }
- public bool GetBankAndCassetteNumber(ModuleName module, WaferSize wz,bool isFromOver, out int BankNum, out int CassetteNum)
- {
- BankNum = 0;
- CassetteNum = 0;
- int wzindex = 0;
- if(!isFromOver)
- {
- if (ModuleHelper.IsLoadPort(module))
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
- if (lp != null)
- {
- wzindex = lp.InfoPadCarrierIndex;
- }
- else
- {
- var lp1 = DEVICE.GetDevice<LoadPort>(module.ToString());
- wzindex = lp.InfoPadCarrierIndex;
- }
- if (SC.ContainsItem($"CarrierInfo.{module}BankNumber{wzindex}"))
- BankNum = SC.GetValue<int>($"CarrierInfo.{module}BankNumber{wzindex}");
- else if (SC.ContainsItem($"CarrierInfo.Carrier{wzindex}.{module}BankNumber"))
- BankNum = SC.GetValue<int>($"CarrierInfo.Carrier{wzindex}.{module}BankNumber");
- else if (SC.ContainsItem($"CarrierInfo.Carrier{wzindex}.{module}Station"))
- {
- string[] stationInfo = SC.GetStringValue($"CarrierInfo.Carrier{wzindex}.{module}Station").Split('.');
- if (stationInfo.Length < 2) return false;
- if (!int.TryParse(stationInfo[0], out BankNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
- return false;
- }
- if (!int.TryParse(stationInfo[1], out CassetteNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- else
- {
- return false;
- }
- if (SC.ContainsItem($"CarrierInfo.{module}CassetteNumber{wzindex}"))
- CassetteNum = SC.GetValue<int>($"CarrierInfo.{module}CassetteNumber{wzindex}");
- else if (SC.ContainsItem($"CarrierInfo.Carrier{wzindex}.{module}CassetteNumber"))
- CassetteNum = SC.GetValue<int>($"CarrierInfo.Carrier{wzindex}.{module}CassetteNumber");
- else
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- if (ModuleHelper.IsTurnOverStation(module))
- {
- var flipper = DEVICE.GetDevice<FlipperBaseDevice>(module.ToString());
- if (SC.ContainsItem($"CarrierInfo.{module}{flipper.CurrentFlipperPosition}Station"))
- {
- string[] stationInfo = SC.GetStringValue($"CarrierInfo.{module}{flipper.CurrentFlipperPosition}Station").Split('.');
- if (stationInfo.Length < 2) return false;
- if (!int.TryParse(stationInfo[0], out BankNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
- return false;
- }
- if (!int.TryParse(stationInfo[1], out CassetteNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- }
- if (wz == WaferSize.WS12) wzindex = 12;
- if (wz == WaferSize.WS8) wzindex = 8;
- if (wz == WaferSize.WS6) wzindex = 6;
- if (wz == WaferSize.WS4) wzindex = 4;
- if (wz == WaferSize.WS3) wzindex = 3;
- if (SC.ContainsItem($"CarrierInfo.{module}Station"))
- {
- string[] stationInfo = SC.GetStringValue($"CarrierInfo.{module}Station").Split('.');
- if (stationInfo.Length < 2) return false;
- if (!int.TryParse(stationInfo[0], out BankNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
- return false;
- }
- if (!int.TryParse(stationInfo[1], out CassetteNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- if (SC.ContainsItem($"CarrierInfo.{module}Station{wzindex}"))
- {
- string[] stationInfo = SC.GetStringValue($"CarrierInfo.{module}Station{wzindex}").Split('.');
- if (stationInfo.Length < 2) return false;
- if (!int.TryParse(stationInfo[0], out BankNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
- return false;
- }
- if (!int.TryParse(stationInfo[1], out CassetteNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- if (SC.ContainsItem($"CarrierInfo.{module}BankNumber{wzindex}"))
- BankNum = SC.GetValue<int>($"CarrierInfo.{module}BankNumber{wzindex}");
- else
- return false;
- if (SC.ContainsItem($"CarrierInfo.{module}CassetteNumber{wzindex}"))
- CassetteNum = SC.GetValue<int>($"CarrierInfo.{module}CassetteNumber{wzindex}");
- else
- return false;
- return true;
- }
- else
- {
- if (ModuleHelper.IsLoadPort(module))
- {
- var lp = DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString());
- if (lp != null)
- {
- wzindex = lp.InfoPadCarrierIndex;
- }
- else
- {
- var lp1 = DEVICE.GetDevice<LoadPort>(module.ToString());
- wzindex = lp.InfoPadCarrierIndex;
- }
- if (SC.ContainsItem($"CarrierInfo.Over{module}BankNumber{wzindex}"))
- BankNum = SC.GetValue<int>($"CarrierInfo.Over{module}BankNumber{wzindex}");
- else if (SC.ContainsItem($"CarrierInfo.Carrier{wzindex}.Over{module}BankNumber"))
- BankNum = SC.GetValue<int>($"CarrierInfo.Carrier{wzindex}.Over{module}BankNumber");
- else if (SC.ContainsItem($"CarrierInfo.Carrier{wzindex}.Over{module}Station"))
- {
- string[] stationInfo = SC.GetStringValue($"CarrierInfo.Carrier{wzindex}.Over{module}Station").Split('.');
- if (stationInfo.Length < 2) return false;
- if (!int.TryParse(stationInfo[0], out BankNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
- return false;
- }
- if (!int.TryParse(stationInfo[1], out CassetteNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- else
- {
- return false;
- }
- if (SC.ContainsItem($"CarrierInfo.Over{module}CassetteNumber{wzindex}"))
- CassetteNum = SC.GetValue<int>($"CarrierInfo.Over{module}CassetteNumber{wzindex}");
- else if (SC.ContainsItem($"CarrierInfo.Carrier{wzindex}.Over{module}CassetteNumber"))
- CassetteNum = SC.GetValue<int>($"CarrierInfo.Carrier{wzindex}.Over{module}CassetteNumber");
- else
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- if (ModuleHelper.IsTurnOverStation(module))
- {
- var flipper = DEVICE.GetDevice<FlipperBaseDevice>(module.ToString());
- if (SC.ContainsItem($"CarrierInfo.Over{module}{flipper.CurrentFlipperPosition}Station"))
- {
- string[] stationInfo = SC.GetStringValue($"CarrierInfo.Over{module}{flipper.CurrentFlipperPosition}Station").Split('.');
- if (stationInfo.Length < 2) return false;
- if (!int.TryParse(stationInfo[0], out BankNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
- return false;
- }
- if (!int.TryParse(stationInfo[1], out CassetteNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- }
- if (wz == WaferSize.WS12) wzindex = 12;
- if (wz == WaferSize.WS8) wzindex = 8;
- if (wz == WaferSize.WS6) wzindex = 6;
- if (wz == WaferSize.WS4) wzindex = 4;
- if (wz == WaferSize.WS3) wzindex = 3;
- if (SC.ContainsItem($"CarrierInfo.Over{module}Station"))
- {
- string[] stationInfo = SC.GetStringValue($"CarrierInfo.Over{module}Station").Split('.');
- if (stationInfo.Length < 2) return false;
- if (!int.TryParse(stationInfo[0], out BankNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
- return false;
- }
- if (!int.TryParse(stationInfo[1], out CassetteNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- if (SC.ContainsItem($"CarrierInfo.Over{module}Station{wzindex}"))
- {
- string[] stationInfo = SC.GetStringValue($"CarrierInfo.Over{module}Station{wzindex}").Split('.');
- if (stationInfo.Length < 2) return false;
- if (!int.TryParse(stationInfo[0], out BankNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse bank number failed");
- return false;
- }
- if (!int.TryParse(stationInfo[1], out CassetteNum))
- {
- EV.PostAlarmLog("Robot", $"{RobotModuleName} parse cassette number failed");
- return false;
- }
- return true;
- }
- if (SC.ContainsItem($"CarrierInfo.Over{module}BankNumber{wzindex}"))
- BankNum = SC.GetValue<int>($"CarrierInfo.Over{module}BankNumber{wzindex}");
- else
- return false;
- if (SC.ContainsItem($"CarrierInfo.Over{module}CassetteNumber{wzindex}"))
- CassetteNum = SC.GetValue<int>($"CarrierInfo.Over{module}CassetteNumber{wzindex}");
- else
- return false;
- return true;
- }
- }
- }
- }
|