123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- using Aitex.Core.RT.Device.Unit;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.SCCore;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.SMIFs.Brooks;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Threading.Tasks;
- namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.SMIF
- {
- public class BrooksSmifNcdSmec:BrooksSmifPort
- {
- public BrooksSmifNcdSmec(string module, string name, string scRoot, RobotBaseDevice robot, IoSensor[] dis,IoTrigger[] dos, bool mapbyLp = true)
- : base(module, name, scRoot, robot, mapbyLp)
- {
- _diCameraBusy = dis[0];
- _diCamera25Slot = dis[1];
- _diCamera13Slot = dis[2];
- _doCameraStart = dos[0];
- _doCameraReset = dos[1];
- }
- private IoSensor _diCameraBusy;
- private IoSensor _diCamera25Slot;
- private IoSensor _diCamera13Slot;
- private IoTrigger _doCameraStart;
- private IoTrigger _doCameraReset;
- private int _slotNumberParseFromCarrierId;
- private bool _isEnableCassetteCheckOnCamera => SC.GetValue<bool>($"LoadPort.{LPModuleName}.EnableCassetteCheckOnCamera");
- public override void OnCarrierIdRead(string carrierId, int readerIndex = 1, int startPage = 1, int length = 16, bool updateCarrierID = true)
- {
- base.OnCarrierIdRead(carrierId);
- string startstr = "TYPE:";
- string endstr = "LOT:";
- Regex rg = new Regex("(?<=(" + startstr + "))[.\\s\\S]*?(?=(" + endstr + "))", RegexOptions.Multiline | RegexOptions.Singleline);
- string tempStr = rg.Match(carrierId).Value.Replace(":", "").Trim();
- if(!int.TryParse(tempStr.Replace("BOX", "").Replace("CST", "").Substring(0, 2), out _slotNumberParseFromCarrierId))
- {
- OnError("Parse slot number error");
- }
- if(SC.GetValue<int>($"CarrierInfo.Carrier{InfoPadCarrierIndex}.CarrierSlotsNumber") != _slotNumberParseFromCarrierId)
- {
- for (int i = 0; i < 8; i++)
- {
- if (SC.ContainsItem($"CarrierInfo.Carrier{i}.EnableCarrier")
- && !SC.GetValue<bool>($"CarrierInfo.Carrier{i}.EnableCarrier"))
- continue;
- if (!SC.ContainsItem($"CarrierInfo.Carrier{i}.CarrierName"))
- continue;
- if (SC.GetValue<int>($"CarrierInfo.Carrier{i}.CarrierSlotsNumber") == _slotNumberParseFromCarrierId)
- {
- InfoPadCarrierIndex = i;
- break;
- }
- }
- }
- }
- protected override bool fMonitorLoad(object[] param)
- {
- IsBusy = false;
- LoadCassette((int)LpStepEnum.Step1, TimelimitAction, OnError);
- if (ExecuteResult.Item1)
- {
- return false;
- }
- if (_isEnableCassetteCheckOnCamera)
- {
- _doCameraStart.SetTrigger(true, out _);
- Stopwatch _timerAction = new Stopwatch();
- _timerAction.Start();
- while (!(_diCamera13Slot.Value ^ _diCamera25Slot.Value))
- {
- Thread.Sleep(10);
- if (_timerAction.ElapsedMilliseconds > 10000)
- {
- OnError("CameraTimeout");
- _doCameraStart.SetTrigger(false, out _);
- return true;
- }
- }
- _doCameraStart.SetTrigger(false, out _);
- if (string.IsNullOrEmpty(_carrierId))
- {
- if (!_diCamera25Slot.Value)
- {
- _slotNumberParseFromCarrierId = 25;
- EV.PostInfoLog("LoadPort", $"{LPModuleName} identify carrier to 25 slot");
- return true;
- }
- if (!_diCamera13Slot.Value)
- {
- _slotNumberParseFromCarrierId = 13;
- EV.PostInfoLog("LoadPort", $"{LPModuleName} identify carrier to 13 slot");
- return true;
- }
- }
- if (_slotNumberParseFromCarrierId == 25 && !_diCamera25Slot.Value)
- {
- EV.PostInfoLog("LoadPort", $"{LPModuleName} identify carrier to 25 slot");
- return true;
- }
- if (_slotNumberParseFromCarrierId == 13 && !_diCamera13Slot.Value)
- {
- EV.PostInfoLog("LoadPort", $"{LPModuleName} identify carrier to 13 slot");
- return true;
- }
- EV.PostAlarmLog("LoadPort", $"CarrierId identify slotnumer:{_slotNumberParseFromCarrierId} but camera identify:{(!_diCamera25Slot.Value ? "25" : "13")}");
- OnError("SlotNumberNotMatched");
- }
- return true;
- }
- public override bool SetCarrierIndex(int indexValue, out string reason)
- {
- reason = "";
-
- InfoPadCarrierIndex = indexValue;
- EV.PostInfoLog(Module, $"{Name} set carrier type index to {InfoPadCarrierIndex}");
- return true;
- }
- public override Tuple<int, string>[] ValidCarrierTypeList
- {
- get
- {
- List<Tuple<int, string>> ret = new List<Tuple<int, string>>();
- for (int i = 0; i < 8; i++)
- {
- if (!SC.ContainsItem($"CarrierInfo.Carrier{i}.CarrierName"))
- continue;
- if (SC.ContainsItem($"CarrierInfo.Carrier{i}.EnableCarrier")
- && !SC.GetValue<bool>($"CarrierInfo.Carrier{i}.EnableCarrier"))
- continue;
- if (!SC.ContainsItem($"CarrierInfo.Carrier{i}.CarrierName"))
- continue;
- if (SC.GetValue<int>($"CarrierInfo.Carrier{i}.CarrierSlotsNumber") != _slotNumberParseFromCarrierId)
- continue;
- string carriertype = "Carrier Type: " + SC.GetStringValue($"CarrierInfo.Carrier{i}.CarrierName");
- ret.Add(new Tuple<int, string>(i, carriertype));
- }
- return ret.ToArray();
- }
- }
- protected override bool fStartReset(object[] param)
- {
- _doCameraStart.SetTrigger(false, out _);
- _doCameraReset.SetTrigger(true, out _);
- Thread.Sleep(1000);
- _doCameraReset.SetTrigger(false, out _);
- lock (_locker)
- {
- SECSTransactionBuilder.BuildS2F41((int)BrooksSMIFRCMDEnum.Reset).Send(wshost);
- SECSTransactionBuilder.BuildS1F5(0).Send(wshost);
- }
- return true;
- }
- }
- }
|