| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Threading.Tasks;
 
- using System.Xml;
 
- using Aitex.Core.Common;
 
- using Aitex.Core.RT.DataCenter;
 
- using Aitex.Core.RT.Device;
 
- using Aitex.Core.RT.Device.Unit;
 
- using Aitex.Core.RT.Event;
 
- using Aitex.Core.RT.Fsm;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.RT.OperationCenter;
 
- using Aitex.Core.RT.RecipeCenter;
 
- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Core.Util;
 
- using Aitex.Core.Utilities;
 
- using FurnaceRT.Equipments.Boats;
 
- using FurnaceRT.Equipments.CarrierRobots;
 
- using FurnaceRT.Equipments.FIMSs;
 
- using FurnaceRT.Equipments.LPs;
 
- using FurnaceRT.Equipments.PMs;
 
- using FurnaceRT.Equipments.PMs.RecipeExecutions;
 
- using FurnaceRT.Equipments.Stockers;
 
- using FurnaceRT.Equipments.WaferRobots;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using MECF.Framework.RT.Core.Applications;
 
- using MECF.Framework.RT.Core.IoProviders;
 
- namespace FurnaceRT.Equipments.Systems
 
- {
 
-     public partial class EquipmentManager
 
-     {
 
-         private CarrierRobotModule _cassetteRobotModule;
 
-         private WaferRobotModule _waferRobotModule;
 
-         private LoadPortModule _lp1Module;
 
-         private LoadPortModule _lp2Module;
 
-         private LoadPortModule _lp3Module;
 
-         private LoadPortModule _lp4Module;
 
-         private FIMSModule _fims1Module;
 
-         private FIMSModule _fims2Module;
 
-         private BoatModule _boatModule;
 
-         private RD_TRIG _pauseTrig = new RD_TRIG();
 
-         private IoSensor _sensorEMSTP;
 
-         private IoSensor _sensorEnableTP;
 
-         private IoSensor _sensorPort1LockUnlock;
 
-         private IoSensor _sensorPort2LockUnlock;
 
-         private IoSensor _sensorBuzzerOff;
 
-         private IoSensor _sensorIn;
 
-         private IoSensor _sensorOut;
 
-         private IoSensor _sensorMECHIlkReset;
 
-         private IoSensor _sensorTXPauseFront;
 
-         private IoSensor _sensorELVPauseFront;
 
-         private IoSensor _sensorTXPauseBack;
 
-         private IoSensor _sensorELVPauseBack;
 
-         private IoTrigger _trigPort1LockUnlockLight;
 
-         private IoTrigger _trigPort2LockUnlockLight;
 
-         private IoTrigger _trigBuzzerOffLight;
 
-         private IoTrigger _trigCassetteInLight;
 
-         private IoTrigger _trigCassetteOutLight;
 
-         private IoTrigger _trigMECHIlkResetLight;
 
-         private IoTrigger _trigTXPauseFrontLight;
 
-         private IoTrigger _trigELVPauseFrontLight;
 
-         private IoTrigger _trigTXPauseBackLight;
 
-         private IoTrigger _trigELVPauseBackLight;
 
-         private int _TXPauseTrigCount = 0;
 
-         private int _ELVPauseTrigCount = 0;
 
-         private PeriodicJob _monitorInCommandJob;
 
-         private List<IoSensor> _inCommandLst;
 
-         private Dictionary<string, RD_TRIG> _inCommandTirgs = new Dictionary<string, RD_TRIG>();
 
-         protected virtual void InitModules()
 
-         {
 
-             for (int i = 1; i <= 30; i++)
 
-             {
 
-                 if (SC.ContainsItem($"System.SetUp.IsStocker{i}Installed") && SC.GetValue<bool>($"System.SetUp.IsStocker{i}Installed"))
 
-                 {
 
-                     var module = ModuleHelper.Converter($"Stocker{i}");
 
-                     var stocker = new StockerModule(module);
 
-                     Modules[module] = stocker;
 
-                 }
 
-             }
 
-             Modules[ModuleName.PM1] = new PMModule(ModuleName.PM1);
 
-             if (SC.GetValue<bool>($"System.SetUp.IsLP1Installed"))
 
-             {
 
-                 _lp1Module = new LoadPortModule(ModuleName.LP1);
 
-                 Modules[ModuleName.LP1] = _lp1Module;
 
-             }
 
-             if (SC.GetValue<bool>($"System.SetUp.IsLP2Installed"))
 
-             {
 
-                 _lp2Module = new LoadPortModule(ModuleName.LP2);
 
-                 Modules[ModuleName.LP2] = _lp2Module;
 
-             }
 
-             if (SC.GetValue<bool>($"System.SetUp.IsLP3Installed"))
 
-             {
 
-                 _lp3Module = new LoadPortModule(ModuleName.LP3);
 
-                 Modules[ModuleName.LP3] = _lp3Module;
 
-             }
 
-             if (SC.GetValue<bool>($"System.SetUp.IsLP4Installed"))
 
-             {
 
-                 _lp4Module = new LoadPortModule(ModuleName.LP4);
 
-                 Modules[ModuleName.LP4] = _lp4Module;
 
-             }
 
-             _cassetteRobotModule = new CarrierRobotModule(ModuleName.CarrierRobot);
 
-             Modules[ModuleName.CarrierRobot] = _cassetteRobotModule;
 
-             _waferRobotModule = new WaferRobotModule(ModuleName.WaferRobot);
 
-             Modules[ModuleName.WaferRobot] = _waferRobotModule;
 
-             if (SC.GetValue<bool>($"System.SetUp.IsFIMS1Installed"))
 
-             {
 
-                 _fims1Module = new FIMSModule(ModuleName.FIMS1);
 
-                 Modules[ModuleName.FIMS1] = _fims1Module;
 
-             }
 
-             if (SC.GetValue<bool>($"System.SetUp.IsFIMS2Installed"))
 
-             {
 
-                 _fims2Module = new FIMSModule(ModuleName.FIMS2);
 
-                 Modules[ModuleName.FIMS2] = _fims2Module;
 
-             }
 
-             _boatModule = new BoatModule(ModuleName.Boat);
 
-             Modules[ModuleName.Boat] = _boatModule;
 
-             foreach (var modulesValue in Modules.Values)
 
-             {
 
-                 modulesValue.Initialize();
 
-             }
 
-             //_monitorInCommandJob = new PeriodicJob(50, ModulesOnTimer, "Modules monitor thread", true);
 
-         }
 
-         private bool ModulesOnTimer()
 
-         {
 
-             return true;
 
-             foreach (var item in _inCommandLst)
 
-             {
 
-                 if (item == null)
 
-                     continue;
 
-                 if (!_inCommandTirgs.ContainsKey(item.Name))
 
-                 {
 
-                     _inCommandTirgs.Add(item.Name, new RD_TRIG());
 
-                 }
 
-                 _inCommandTirgs[item.Name].CLK = item.Value;
 
-             }
 
-             if ((_inCommandTirgs.ContainsKey(_sensorTXPauseFront?.Name) && _inCommandTirgs[_sensorTXPauseFront?.Name].R) ||
 
-                 (_inCommandTirgs.ContainsKey(_sensorTXPauseBack?.Name) && _inCommandTirgs[_sensorTXPauseBack?.Name].R))
 
-             {
 
-                 _TXPauseTrigCount++;
 
-                 if (_TXPauseTrigCount % 2 == 1)
 
-                 {
 
-                     _trigTXPauseFrontLight?.SetTrigger(true, out _);
 
-                     _trigTXPauseBackLight?.SetTrigger(true, out _);
 
-                     _cassetteRobotModule.CarrierRobotDevice.SetPauseResume(true);
 
-                     _waferRobotModule.WaferRobotDevice.SetPauseResume(true);
 
-                     _fims1Module.FIMSDevice.SetPauseResume(true);
 
-                     _fims2Module.FIMSDevice.SetPauseResume(true);
 
-                 }
 
-                 else
 
-                 {
 
-                     _trigTXPauseFrontLight?.SetTrigger(false, out _);
 
-                     _trigTXPauseBackLight?.SetTrigger(false, out _);
 
-                     _cassetteRobotModule.CarrierRobotDevice.SetPauseResume(false);
 
-                     _waferRobotModule.WaferRobotDevice.SetPauseResume(false);
 
-                     _fims1Module.FIMSDevice.SetPauseResume(false);
 
-                     _fims2Module.FIMSDevice.SetPauseResume(false);
 
-                 }
 
-             }
 
-             if ((_inCommandTirgs.ContainsKey(_sensorELVPauseFront?.Name) && _inCommandTirgs[_sensorELVPauseFront?.Name].R) ||
 
-                 (_inCommandTirgs.ContainsKey(_sensorELVPauseBack?.Name) && _inCommandTirgs[_sensorELVPauseBack?.Name].R))
 
-             {
 
-                 _ELVPauseTrigCount++;
 
-                 if (_ELVPauseTrigCount % 2 == 1)
 
-                 {
 
-                     _trigELVPauseFrontLight?.SetTrigger(true, out _);
 
-                     _trigELVPauseBackLight?.SetTrigger(true, out _);
 
-                     _boatModule.ZAxisDevice.SetPauseResume(true);
 
-                     _boatModule.RAxisDevice.SetPauseResume(true);
 
-                 }
 
-                 else
 
-                 {
 
-                     _trigELVPauseFrontLight?.SetTrigger(false, out _);
 
-                     _trigELVPauseBackLight?.SetTrigger(false, out _);
 
-                     _boatModule.ZAxisDevice.SetPauseResume(false);
 
-                     _boatModule.RAxisDevice.SetPauseResume(false);
 
-                 }
 
-             }
 
-             foreach (var modulesValue in Modules.Values)
 
-             {
 
-                 if (modulesValue != null)
 
-                     modulesValue.Monitor();
 
-             }
 
-             return true;
 
-         }
 
-         protected virtual void InitDevices()
 
-         {
 
-             _sensorEMSTP = DEVICE.GetDevice<IoSensor>($"System.SensorEMSTP");
 
-             _sensorEnableTP = DEVICE.GetDevice<IoSensor>($"System.SensorEnableTP");
 
-             _sensorPort1LockUnlock = DEVICE.GetDevice<IoSensor>($"System.SensorPort1LockUnlock");
 
-             _sensorPort2LockUnlock = DEVICE.GetDevice<IoSensor>($"System.SensorPort2LockUnlock");
 
-             _sensorBuzzerOff = DEVICE.GetDevice<IoSensor>($"System.SensorBuzzerOff");
 
-             _sensorIn = DEVICE.GetDevice<IoSensor>($"System.SensorIn");
 
-             _sensorOut = DEVICE.GetDevice<IoSensor>($"System.SensorOut");
 
-             _sensorMECHIlkReset = DEVICE.GetDevice<IoSensor>($"System.SensorMECHIlkReset");
 
-             _sensorTXPauseFront = DEVICE.GetDevice<IoSensor>($"System.SensorTXPauseFront");
 
-             _sensorELVPauseFront = DEVICE.GetDevice<IoSensor>($"System.SensorELVPauseFront");
 
-             _sensorTXPauseBack = DEVICE.GetDevice<IoSensor>($"System.SensorTXPauseBack");
 
-             _sensorELVPauseBack = DEVICE.GetDevice<IoSensor>($"System.SensorELVPauseBack");
 
-             _trigPort1LockUnlockLight = DEVICE.GetDevice<IoTrigger>($"System.TrigPort1LockUnlockLight");
 
-             _trigPort2LockUnlockLight = DEVICE.GetDevice<IoTrigger>($"System.TrigPort2LockUnlockLight");
 
-             _trigBuzzerOffLight = DEVICE.GetDevice<IoTrigger>($"System.TrigBuzzerOffLight");
 
-             _trigCassetteInLight = DEVICE.GetDevice<IoTrigger>($"System.TrigCassetteInLight");
 
-             _trigCassetteOutLight = DEVICE.GetDevice<IoTrigger>($"System.TrigCassetteOutLight");
 
-             _trigMECHIlkResetLight = DEVICE.GetDevice<IoTrigger>($"System.TrigMECHIlkResetLight");
 
-             _trigTXPauseFrontLight = DEVICE.GetDevice<IoTrigger>($"System.TrigTXPauseFrontLight");
 
-             _trigELVPauseFrontLight = DEVICE.GetDevice<IoTrigger>($"System.TrigELVPauseFrontLight");
 
-             _trigTXPauseBackLight = DEVICE.GetDevice<IoTrigger>($"System.TrigTXPauseBackLight");
 
-             _trigELVPauseBackLight = DEVICE.GetDevice<IoTrigger>($"System.TrigELVPauseBackLight");
 
-             if (_trigTXPauseFrontLight != null && _trigTXPauseFrontLight.Value)
 
-                 _TXPauseTrigCount = 1;
 
-             if (_trigELVPauseFrontLight != null && _trigELVPauseFrontLight.Value)
 
-                 _ELVPauseTrigCount = 1;
 
-             _inCommandLst = new List<IoSensor>()
 
-             {
 
-                 _sensorEMSTP,
 
-                 _sensorEnableTP,
 
-                 _sensorPort1LockUnlock,
 
-                 _sensorPort2LockUnlock,
 
-                 _sensorBuzzerOff,
 
-                 _sensorIn,
 
-                 _sensorOut,
 
-                 _sensorMECHIlkReset,
 
-                 _sensorTXPauseFront,
 
-                 _sensorELVPauseFront,
 
-                 _sensorTXPauseBack,
 
-                 _sensorELVPauseBack,
 
-             };
 
-             this.OnDeviceAlarmStateChanged += OnModuleDeviceAlarmStateChanged;
 
-         }
 
-         public bool GetJobRecipeInfor(string jobRecipeName, out string processRecipe, out string layoutRecipe, out int coolTimeSec, out string reason)
 
-         {
 
-             processRecipe = "";
 
-             layoutRecipe = "";
 
-             reason = "";
 
-             coolTimeSec = 0;
 
-             string abortRecipeName = SC.ContainsItem("System.Recipe.Abort Recipe") ? SC.GetStringValue("System.Recipe.Abort Recipe") : string.Empty;
 
-             if (string.IsNullOrEmpty(abortRecipeName))
 
-             {
 
-                 reason = $"Load abort recipe failed, recipe file is null";
 
-                 return false;
 
-             }
 
-             if (!RecipeParser.Parse(abortRecipeName, ModuleName.PM1.ToString(), out var abortRecipeHead, out var abortRecipeSteps, out reason, "Abort"))
 
-             {
 
-                 reason = $"Load abort recipe {abortRecipeName} failed, {reason}";
 
-                 return false;
 
-             }
 
-             var module = "PM1";
 
-             var processType = SC.GetStringValue("System.Recipe.SupportedJobType");
 
-             var prefixPath = $"Furnace\\{processType}";
 
-             var recipeContent = RecipeFileManager.Instance.LoadRecipe(prefixPath, jobRecipeName, false);
 
-             if (string.IsNullOrEmpty(recipeContent))
 
-             {
 
-                 reason = $"{prefixPath}\\{jobRecipeName} is empty, please confirm the file is valid.";
 
-                 return false;
 
-             }
 
-             var doc = new XmlDocument();
 
-             doc.LoadXml(recipeContent);
 
-             var nodeModule = doc.SelectSingleNode($"Aitex/TableRecipeData/Module[@Name='{module}']/Step");
 
-             XmlElement stepNode = nodeModule as XmlElement;
 
-             if (nodeModule == null)
 
-             {
 
-                 reason = $"{prefixPath}\\{jobRecipeName} is empty, please confirm the file is valid.";
 
-                 return false;
 
-             }
 
-             var strCoolTime = "";
 
-             foreach (XmlAttribute att in stepNode.Attributes)
 
-             {
 
-                 switch (att.Name)
 
-                 {
 
-                     case "ProcessRecipe":
 
-                         processRecipe = att.Value;
 
-                         break;
 
-                     case "LayoutRecipe":
 
-                         layoutRecipe = att.Value;
 
-                         break;
 
-                     case "CoolTime":
 
-                         strCoolTime = att.Value;
 
-                         break;
 
-                 }
 
-             }
 
-             if (!string.IsNullOrEmpty(strCoolTime))
 
-             {
 
-                 if (System.Text.RegularExpressions.Regex.Match(strCoolTime, @"[a-zA-Z]").Success)
 
-                 {
 
-                     if (SC.ContainsItem($"PM1.RecipeEditParameter.CoolTime.{strCoolTime}"))
 
-                     {
 
-                         var time = DateTime.Parse(SC.GetStringValue($"PM1.RecipeEditParameter.CoolTime.{strCoolTime}"));
 
-                         coolTimeSec = time.Second + time.Minute * 60 + time.Hour * 3600;
 
-                     }
 
-                     else
 
-                     {
 
-                         reason = $"Configuration does not contains cool time config {strCoolTime}";
 
-                         return false;
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     if (DateTime.TryParse(strCoolTime, out DateTime time))
 
-                     {
 
-                         coolTimeSec = time.Second + time.Minute * 60 + time.Hour * 3600;
 
-                     }
 
-                     else if (Int32.TryParse(strCoolTime, out int timeInSec))
 
-                     {
 
-                         coolTimeSec = timeInSec;
 
-                     }
 
-                     else
 
-                     {
 
-                         reason = $"Cool time {strCoolTime} is invalid";
 
-                         return false;
 
-                     }
 
-                 }
 
-             }
 
-             return true;
 
-         }
 
-     }
 
- }
 
 
  |