123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- using Aitex.Common.Util;
- 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.IOCore;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.Sorter.Common;
- using athosRT.tool;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.CarrierIdReaders.OmronBarcode;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.CarrierIdReaders.OmronRFID;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.FFUs.AAF;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.Fortrend;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.LoadPortBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.RobotBase;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots.Rorze;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Xml;
- using FortrendSmifPort = athosRT.Devices.LP.FortrendSmifPort;
- using RorzeRobot751 = athosRT.Modules.Robot.RorzeRobot751;
- using EV = athosRT.tool.EV;
- using DATA = Common.DataCenter.DATA;
- using athosRT.Devices.LP;
- using athosRT.Devices.PA;
- using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robot;
- using athosRT.Devices.FLP;
- using MECF.Framework.Common.SubstrateTrackings;
- namespace athosRT.Devices
- {
- public class DeviceManager : DeviceManagerBase
- {
- private static readonly int LoadPortQuantity = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(LoadPortQuantity)).GetValueOrDefault();
- private static readonly int LoadLockQuantity = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(LoadLockQuantity)).GetValueOrDefault();
- private static readonly int LoadLockSlot = Singleton<DeviceDefineManager>.Instance.GetValue<int>(nameof(LoadLockSlot)).GetValueOrDefault();
- private static readonly bool LoadLockDoorControlByStation = Singleton<DeviceDefineManager>.Instance.GetValue<bool>("LLDoorControlByStation").GetValueOrDefault();
- private static readonly bool DmcCardUsed = Singleton<DeviceDefineManager>.Instance.GetValue<bool>("DmcCardInstalled").GetValueOrDefault();
- private static readonly bool DisableSignalTower = Singleton<DeviceDefineManager>.Instance.GetValue<bool>(nameof(DisableSignalTower)).GetValueOrDefault();
- private readonly string[] _carrierIdReader = new string[10]
- {
- nameof (CarrierIdReader),
- nameof (CarrierIdReader),
- nameof (CarrierIdReader),
- nameof (CarrierIdReader),
- nameof (CarrierIdReader),
- nameof (CarrierIdReader),
- nameof (CarrierIdReader),
- nameof (CarrierIdReader),
- nameof (CarrierIdReader),
- nameof (CarrierIdReader)
- };
- private readonly string[] _carrierRfidReader = new string[10]
- {
- "RFID",
- "RFID",
- "RFID",
- "RFID",
- "RFID",
- "RFID",
- "RFID",
- "RFID",
- "RFID",
- "RFID"
- };
- private readonly ModuleName[] _lpNames = new ModuleName[10]
- {
- ModuleName.LP1,
- ModuleName.LP2,
- ModuleName.LP3,
- ModuleName.LP4,
- ModuleName.LP5,
- ModuleName.LP6,
- ModuleName.LP7,
- ModuleName.LP8,
- ModuleName.LP9,
- ModuleName.LP10
- };
- private readonly string[] _carrierIdReaderPortScName = new string[10]
- {
- "LoadPort.LoadPort1CarrierIdReaderPortName",
- "LoadPort.LoadPort2CarrierIdReaderPortName",
- "LoadPort.LoadPort3CarrierIdReaderPortName",
- "LoadPort.LoadPort4CarrierIdReaderPortName",
- "LoadPort.LoadPort5CarrierIdReaderPortName",
- "LoadPort.LoadPort6CarrierIdReaderPortName",
- "LoadPort.LoadPort7CarrierIdReaderPortName",
- "LoadPort.LoadPort8CarrierIdReaderPortName",
- "LoadPort.LoadPort9CarrierIdReaderPortName",
- "LoadPort.LoadPort10CarrierIdReaderPortName"
- };
- private readonly string[] _rfidReaderAddress = new string[10]
- {
- "LoadPort.LoadPort1CarrierIdReaderAddress",
- "LoadPort.LoadPort2CarrierIdReaderAddress",
- "LoadPort.LoadPort3CarrierIdReaderAddress",
- "LoadPort.LoadPort4CarrierIdReaderAddress",
- "LoadPort.LoadPort5CarrierIdReaderAddress",
- "LoadPort.LoadPort6CarrierIdReaderAddress",
- "LoadPort.LoadPort7CarrierIdReaderAddress",
- "LoadPort.LoadPort8CarrierIdReaderAddress",
- "LoadPort.LoadPort9CarrierIdReaderAddress",
- "LoadPort.LoadPort10CarrierIdReaderAddress"
- };
- private readonly string[] _rfidReaderPages = new string[10]
- {
- "LoadPort.LoadPort1CarrierIdReaderPage",
- "LoadPort.LoadPort2CarrierIdReaderPage",
- "LoadPort.LoadPort3CarrierIdReaderPage",
- "LoadPort.LoadPort4CarrierIdReaderPage",
- "LoadPort.LoadPort5CarrierIdReaderPage",
- "LoadPort.LoadPort6CarrierIdReaderPage",
- "LoadPort.LoadPort7CarrierIdReaderPage",
- "LoadPort.LoadPort8CarrierIdReaderPage",
- "LoadPort.LoadPort9CarrierIdReaderPage",
- "LoadPort.LoadPort10CarrierIdReaderPage"
- };
- private readonly string[] _rfidNames = new string[10]
- {
- "RFIDReaderA",
- "RFIDReaderB",
- "RFIDReaderC",
- "RFIDReaderD",
- "RFIDReaderE",
- "RFIDReaderF",
- "RFIDReaderG",
- "RFIDReaderH",
- "RFIDReaderI",
- "RFIDReaderJ"
- };
- private readonly string[] _lpPortNameSc = new string[10]
- {
- "LoadPort.LoadPort1PortName",
- "LoadPort.LoadPort2PortName",
- "LoadPort.LoadPort3PortName",
- "LoadPort.LoadPort4PortName",
- "LoadPort.LoadPort5PortName",
- "LoadPort.LoadPort6PortName",
- "LoadPort.LoadPort7PortName",
- "LoadPort.LoadPort8PortName",
- "LoadPort.LoadPort9PortName",
- "LoadPort.LoadPort10PortName"
- };
- private readonly string[] _llNames = new string[8]
- {
- "LL1",
- "LL2",
- "LL3",
- "LL4",
- "LL5",
- "LL6",
- "LL7",
- "LL8"
- };
- private char[] rfidInstallment;
- private char[] carrierIdInstallment;
- private char[] e84Support;
- public string[] CarrierIdReader => ((IEnumerable<string>)_carrierIdReader).Take<string>(DeviceManager.LoadPortQuantity).ToArray<string>();
- public string[] CarrierRfidReader => ((IEnumerable<string>)_carrierRfidReader).Take<string>(DeviceManager.LoadPortQuantity).ToArray<string>();
- public IEnumerable<ModuleName> LpNames => ((IEnumerable<ModuleName>)_lpNames).Take<ModuleName>(DeviceManager.LoadPortQuantity);
- private string[] CarrierIdReaderPortScName => ((IEnumerable<string>)_carrierIdReaderPortScName).Take<string>(DeviceManager.LoadPortQuantity).ToArray<string>();
- public string[] LpPortNameSc => ((IEnumerable<string>)_lpPortNameSc).Take<string>(DeviceManager.LoadPortQuantity).ToArray<string>();
- public string[] LLNames => ((IEnumerable<string>)_llNames).Take<string>(DeviceManager.LoadLockQuantity).ToArray<string>();
- public bool IsAnyLPIdle() => LpNames.Any<ModuleName>((Func<ModuleName, bool>)(moduleName => DEVICE.GetDevice<LoadPortBaseDevice>(moduleName.ToString()).IsIdle));
- public ModuleName[] GetAllLoadPortName() => LpNames as ModuleName[];
- public LoadPortBaseDevice[] GetAllLoadPorts() => LpNames.Select<ModuleName, LoadPortBaseDevice>((Func<ModuleName, LoadPortBaseDevice>)(lpName => DEVICE.GetDevice<LoadPortBaseDevice>(lpName.ToString()))).ToList<LoadPortBaseDevice>().ToArray();
- private OmronBarcodeReader GetBarcodeReader(string lp)
- {
- int index = Array.IndexOf((Array)LpNames.ToArray<ModuleName>(), (object)lp);
- return DEVICE.GetDevice<OmronBarcodeReader>(lp + "." + _carrierIdReader[index]);
- }
- public OmronRfidReader GetRfidReader(string lp)
- {
- int num = int.Parse(new Regex("[1-9]\\d*").Match(lp).ToString());
- return num <= LoadPortQuantity ? DEVICE.GetDevice<OmronRfidReader>(_rfidNames[num - 1]) : (OmronRfidReader)null;
- }
- public override bool Initialize()
- {
- foreach (FieldInfo field in typeof(DeviceModel).GetFields())
- field.SetValue(null, GetDevice(field.Name));
- DeviceModel.TrigSafetytoSMIF2.SetTrigger(true,out _);
- IoSensor[] ioSensorArray1 = new IoSensor[2]
- {
- DeviceModel.SensorPMASystemInterlock,
- DeviceModel.SensorPMBSystemInterlock
- };
- IoSensor[] ioSensorArray2 = new IoSensor[2]
- {
- DeviceModel.SensorRBNotExtendPMA,
- DeviceModel.SensorRBNotExtendPMB
- };
- IoTrigger[] ioTriggerArray1 = new IoTrigger[2]
- {
- DeviceModel.TrigSafetytoPMA,
- DeviceModel.TrigSafetytoPMB
- };
- IoTrigger[] ioTriggerArray2 = new IoTrigger[2]
- {
- DeviceModel.TrigRBNotExtendPMA,
- DeviceModel.TrigRBNotExtendPMB
- };
- IoSensor[] ioSensorArray3 = new IoSensor[2]
- {
- DeviceModel.SensorSMIF1PODOPEN,
- DeviceModel.SensorSMIF1PODOPEN
- };
- IoTrigger[] ioTriggerArray3 = new IoTrigger[2]
- {
- DeviceModel.TrigSafetytoPMA,
- DeviceModel.TrigSafetytoPMB
- };
- IoTrigger[] ioTriggerLP = new IoTrigger[2]
- {
- DeviceModel.TrigSafetytoSMIF1,
- DeviceModel.TrigSafetytoSMIF2
- };
- RorzeRobot751 RR751 = new RorzeRobot751(ModuleName.System.ToString(), "Robot", "Robot", null, null);
- RR751.InitializeRobot();
- for (int index = 0; index < LoadPortQuantity; ++index)
- {
- this.AddCustomDevice((IDevice)new HirataLoadPort(ModuleName.System.ToString(), this._lpNames[index].ToString(), "LoadPort", (RobotBaseDevice)null, ioTriggerLP), "LoadPort", typeof(LoadPortBaseDevice));
- }
- AddCustomDevice(RR751, "Robot", typeof(RobotBaseDevice));
- //添加PA 用于新的设备逻辑
-
-
- if (SC.GetValue<bool>("Aligner1.IsEnable"))
- {
- Singleton<WaferManager>.Instance.SubscribeLocation(ModuleName.Aligner1, 1);
- //AddCustomDevice(new RorzePreAligner(ModuleName.System.ToString(), "Aligner1", "Aligner1", "", ""), "Aligner1", typeof(PreAligner));
- }
- if (SC.GetValue<bool>("Aligner2.IsEnable"))
- {
- Singleton<WaferManager>.Instance.SubscribeLocation(ModuleName.Aligner1, 1);
- //AddCustomDevice(new RorzePreAligner(ModuleName.System.ToString(), "Aligner2", "Aligner2", "", ""), "Aligner2", typeof(PreAligner));
- }
- if (Singleton<DeviceDefineManager>.Instance.GetValue<bool>("FfuMemoBusControl").GetValueOrDefault())
- {
- AddCustomDevice(new Ffu("", "FFU", "01", SC.GetStringValue("System.FFUComPortName")), "FFU", typeof(Ffu));
- }
- for (int index = 0; index < LoadLockQuantity; ++index)
- {
- LoadLockDevice loadLockDevice = new LoadLockDevice("System", _llNames[index], DeviceManager.LoadLockSlot, ioSensorArray1[index], ioSensorArray2[index], ioTriggerArray1[index], ioTriggerArray2[index]);
- AddCustomDevice((IDevice)loadLockDevice, "LoadLockDevice", loadLockDevice.GetType());
- }
- if (DisableSignalTower)
- DeviceModel.SignalTower.CustomSignalTower(PathManager.GetCfgDir() + "SignalTower.xml");
- //DeviceModel.TurnOverStation;
- AddCustomDevice((IDevice)new EquipmentMonitor(), "EquipmentMonitor", typeof(EquipmentMonitor));//这里涉及RT状态的修改 file报错
- foreach (object childNode in DeviceModelNodes.ChildNodes)
- {
- XmlElement xmlElement = childNode as XmlElement;
- }
-
- AddCustomDevice(new SimpleBuffer("Buffer"), "Buffer", typeof(SimpleBuffer));
- OP.Subscribe(OperationName.ResetDevice, new Func<string, object[], bool>(InvokeResetDevice));
- OP.Subscribe("DeviceOperation", new Func<string, object[], bool>(InvokeDeviceOperation));
- OP.Subscribe("SetManualScanCode", new Func<string, object[], bool>(InvokeSetManualScanCode));
- OP.Subscribe("Scan", new Func<string, object[], bool>(InvokeScan));
- OP.Subscribe("Write", new Func<string, object[], bool>(InvokeWrite));
- OP.Subscribe("ReadCarrierId", new Func<string, object[], bool>(InvokeScan));
- OP.Subscribe("ReadFoupRFID", new Func<string, object[], bool>(InvokeReadRfid));
- OP.Subscribe("WriteFoupRFID", new Func<string, object[], bool>(InvokeWriteRfid));
- RR751.OnSlotMapRead += new Action<ModuleName, string>(Robot_OnSlotMapRead);
- return true;
- }
- private bool InvokeWrite(string arg1, object[] args)
- {
- string reason;
- if (GetRfidReader(args[0].ToString()).Write(args[1].ToString(), out reason))
- return true;
- EV.PostWarningLog(args[0].ToString(), "fail to write RFID, " + reason);
- return false;
- }
- private bool InvokeWriteRfid(string arg1, object[] arg2)
- {
- string reason;
- if (GetRfidReader(arg2[0].ToString()).Write(arg2[1].ToString(), out reason))
- return true;
- EV.PostWarningLog(arg1, "fail to write RFID, " + reason);
- return false;
- }
- private bool InvokeReadRfid(string arg1, object[] arg2)
- {
- string reason;
- if (GetRfidReader(arg2[0].ToString()).Read(out reason))
- return true;
- EV.PostWarningLog(arg1, "fail to read RFID, " + reason);
- return false;
- }
- private bool InvokeScan(string arg1, object[] args) => DEVICE.GetDevice<LoadPortBaseDevice>(args[0].ToString()).ReadCarrierID();
- private bool InvokeSetManualScanCode(string arg1, object[] args)
- {
- DEVICE.GetDevice<LoadPortBaseDevice>(args[0].ToString()).OnCarrierIdRead(args[1].ToString());
- return true;
- }
- private bool InvokeOffline(string arg1, object[] arg2) => true;
- private void Robot_OnSlotMapRead(ModuleName module, string slotMap) => DEVICE.GetDevice<LoadPortBaseDevice>(module.ToString())?.OnSlotMapRead(slotMap);
- private bool InvokeDeviceOperation(string arg1, object[] args)
- {
- string str = "";
- string cmd = "";
- try
- {
- str = (string)args[0];
- cmd = (string)args[1];
- if ((bool)DATA.Poll(ModuleName.System.ToString(), "IsMaintenanceMode"))
- {
- EV.PostMessage<EventEnum>("System", EventEnum.DefaultWarning, (object)string.Format("System in maintenance, can not execute {0}{1}", (object)str, (object)cmd));
- return false;
- }
- object[] objArray = new object[args.Length - 2];
- for (int index = 2; index < args.Length; ++index)
- objArray[index - 2] = (object)args[index].ToString();
- if (str == "SignalTower")
- {
- OP.DoOperation("System.SignalTower." + cmd);
- return true;
- }
- if (ModuleHelper.IsLoadPort(ModuleHelper.Converter(str)))
- OP.DoOperation(str + "." + cmd, objArray);
- else
- DeviceCmd(str, cmd, objArray);
- }
- catch (Exception ex)
- {
- LogObject.Error("DeviceManager",ex);
- EV.PostMessage<EventEnum>("System", EventEnum.DefaultWarning, (object)string.Format("Invalid parameters, can not execute {0}{1}", (object)str, (object)cmd));
- return false;
- }
- return true;
- }
- private bool InvokeResetDevice(string arg1, object[] arg2)
- {
- Singleton<DeviceEntity>.Instance.PostMsg<DeviceEntityT<DeviceManager>.MSG>(DeviceEntityT<DeviceManager>.MSG.RESET);
- return true;
- }
- private void DeviceCmd(string name, string cmd, params object[] args) => DEVICE.Do(string.Format("{0}.{1}", (object)name, (object)cmd), 0, true, args);
- }
- }
|