123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.RT.RecipeCenter;
- using Aitex.Core.RT.SCCore;
- using Aitex.Core.Util;
- using Aitex.Sorter.Common;
- using MECF.Framework.Common.Equipment;
- using MECF.Framework.RT.ModuleLibrary.EfemModules;
- using MECF.Framework.RT.ModuleLibrary.LPModules;
- using SecsGem.Core.Application;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using VirgoRT.Devices.EFEM;
- using VirgoRT.Modules;
- namespace VirgoRT.Instances
- {
- public class SecsGemEquipment : IEquipmentCommand
- {
- #region 常量
- private const string EventTerminalMessage = "TerminalMessage";
- #endregion
- #region 内部变量
- private Dictionary<string, ModuleName> _dicPortModule = new Dictionary<string, ModuleName>()
- {
- {"1", ModuleName.LP1},
- {"2", ModuleName.LP2},
- {"3", ModuleName.LP3}
- };
- #endregion
- /// <summary>
- /// 初始化
- /// </summary>
- public void Initialize()
- {
- EV.Subscribe(new EventItem("Host", EventTerminalMessage, "{0}", EventLevel.Warning, EventType.EventUI_Notify));
- }
- public bool AbortControlJob(string controlJob)
- {
- return true;
- }
- public bool CheckAuto()
- {
- return Singleton<RouteManager>.Instance.IsAutoMode;
- }
- public bool CheckCreateControlJobCondition(List<string> modules, out string reason)
- {
- reason = "";
- return true;
- }
- public void CreateControlJob(string controlJobId, string carrierId, List<string> processJobs)
- {
- return;
- }
- public bool CreateProcessJob(string processJobId, string sequenceName, string carrierId, out string reason)
- {
- reason = "";
- return true;
- }
- /// <summary>
- /// 执行指令
- /// </summary>
- /// <param name="command"></param>
- /// <param name="paras"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- public bool ExcuteCommand(string command, object[] paras, out string reason)
- {
- reason = "";
- int portID;
- string jobID;
- string lotId;
- object[] sequence;
- switch (command.ToUpper())
- {
- case "PP-SELECT":
- portID = int.Parse(paras[0].ToString());
- jobID = paras[1].ToString();
- lotId = paras[2].ToString();
- sequence = (object[])paras[3];
- return PPselect(portID, jobID, lotId, sequence,out reason);
- case "STARTJOB":
- jobID = paras[0].ToString();
- OP.DoOperation("System.StartJob", new object[] { jobID });
- return true;
- case "ABORTJOB":
- jobID = paras[0].ToString();
- OP.DoOperation("System.AbortJob", new object[] { jobID });
- return true;
- case "PAUSEJOB":
- jobID = paras[0].ToString();
- OP.DoOperation("System.PauseJob", new object[] { jobID });
- return true;
- case "RESUMEJOB":
- jobID = paras[0].ToString();
- OP.DoOperation("System.ResumeJob", new object[] { jobID });
- return true;
- case "STOPJOB":
- jobID = paras[0].ToString();
- OP.DoOperation("System.StopJob", new object[] { jobID });
- return true;
- case "LOAD":
- portID = int.Parse(paras[0].ToString());
- return Load(portID, out reason);
- case "UNLOAD":
- portID = int.Parse(paras[0].ToString());
- return Unload(portID, out reason);
- case "LOCK":
- portID = int.Parse(paras[0].ToString());
- return Lock(portID, out reason);
- case "UNLOCK":
- portID = int.Parse(paras[0].ToString());
- return Unlock(portID, out reason);
- case "READID":
- portID = int.Parse(paras[0].ToString());
- return ReadId(portID, out reason);
- case "WRITEID":
- portID = int.Parse(paras[0].ToString());
- string carrierID = paras[1].ToString();
- return WriteId(portID, carrierID, out reason);
- case "READTAG":
- portID = int.Parse(paras[0].ToString());
- return ReadTag(portID, out reason);
- case "WRITETAG":
- portID = int.Parse(paras[0].ToString());
- string tagData = paras[1].ToString();
- return WriteId(portID, tagData, out reason);
- }
- return true;
- }
- #region LoadPort
- /// <summary>
- /// 创建Job
- /// </summary>
- /// <param name="portID"></param>
- /// <param name="jobID"></param>
- /// <param name="lotID"></param>
- /// <param name="sequence"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool PPselect(int portID,string jobID,string lotID, object[] sequence,out string reason)
- {
- if (!_dicPortModule.ContainsKey(portID.ToString()))
- {
- reason = $"{portID} not valid";
- return false;
- }
- var len = SC.GetValue<int>($"LoadPort.SlotNumber");
- if (len != sequence.Length)
- {
- reason = $"length is not match,length={len}";
- return false;
- }
- string[] slotsequence = new string[len];
- for (int i = 0; i < len; i++)
- {
- slotsequence[i] = sequence[i].ToString() == "*null*" ? "" : sequence[i].ToString();
- }
- if (!Singleton<RouteManager>.Instance.IsAutoMode)
- {
- reason = $"System not in auto mode";
- return false;
- }
- Dictionary<string, object> param = new Dictionary<string, object>()
- {
- {"JobId", jobID},
- {"LotId", lotID},
- {"Module", _dicPortModule[portID.ToString()].ToString()},
- {"SlotSequence", slotsequence},
- {"AutoStart", false},
- };
- OP.DoOperation("System.CreateJob", param);
- reason = string.Empty;
- return true;
- }
- /// <summary>
- /// Load指令
- /// </summary>
- /// <param name="portID"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool Load(int portID,out string reason)
- {
- reason = "";
- if (!_dicPortModule.ContainsKey(portID.ToString()))
- {
- reason = $"{portID} not valid";
- return false;
- }
- Loadport LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portID.ToString()]] as Loadport;
- if (LPDevice == null)
- {
- reason = $"{portID} not valid";
- return false;
- }
- if (!LPDevice.HasCassette)
- {
- reason = $"{portID} cassette not placed";
- return false;
- }
- if (LPDevice.Status == DeviceState.Error)
- {
- reason = $"{portID} port in error, need reset";
- return false;
- }
- OP.DoOperation($"{_dicPortModule[portID.ToString()]}.Load");
- return true;
- }
- /// <summary>
- /// Load指令
- /// </summary>
- /// <param name="portID"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool Unload(int portID, out string reason)
- {
- if (!_dicPortModule.ContainsKey(portID.ToString()))
- {
- reason = $"{portID} not valid";
- return false;
- }
- Loadport LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portID.ToString()]] as Loadport;
- if (LPDevice == null)
- {
- reason = $"{portID} not valid";
- return false;
- }
- if (!LPDevice.HasCassette)
- {
- reason = $"{portID} cassette not placed";
- return false;
- }
- if (LPDevice.Status == DeviceState.Error)
- {
- reason = $"{portID} port in error, need reset";
- return false;
- }
- if (SC.GetValue<bool>("EFEM.AutoUnlockAfterUnload"))
- {
- OP.DoOperation($"{_dicPortModule[portID.ToString()]}.Unload");
- }
- else
- {
- OP.DoOperation($"{_dicPortModule[portID.ToString()]}.Undock");
- }
- reason = string.Empty;
- return true;
- }
- /// <summary>
- /// Lock指令
- /// </summary>
- /// <param name="portID"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool Lock(int portID, out string reason)
- {
- if (!_dicPortModule.ContainsKey(portID.ToString()))
- {
- reason = $"{portID} not valid";
- return false;
- }
- Loadport LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portID.ToString()]] as Loadport;
- if (LPDevice == null)
- {
- reason = $"{portID} not valid";
- return false;
- }
- if (!LPDevice.HasCassette)
- {
- reason = $"{portID} cassette not placed";
- return false;
- }
- if (LPDevice.Status == DeviceState.Error)
- {
- reason = $"{portID} port in error, need reset";
- return false;
- }
- OP.DoOperation($"{_dicPortModule[portID.ToString()]}.Clamp");
- reason = string.Empty;
- return true;
- }
- /// <summary>
- /// Unlock指令
- /// </summary>
- /// <param name="portID"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool Unlock(int portID, out string reason)
- {
- if (!_dicPortModule.ContainsKey(portID.ToString()))
- {
- reason = $"{portID} not valid";
- return false;
- }
- Loadport LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portID.ToString()]] as Loadport;
- if (LPDevice == null)
- {
- reason = $"{portID} not valid";
- return false;
- }
- if (!LPDevice.HasCassette)
- {
- reason = $"{portID} cassette not placed";
- return false;
- }
- if (LPDevice.Status == DeviceState.Error)
- {
- reason = $"{portID} port in error, need reset";
- return false;
- }
- OP.DoOperation($"{_dicPortModule[portID.ToString()]}.Unclamp");
- reason = string.Empty;
- return true;
- }
- /// <summary>
- /// Read ID
- /// </summary>
- /// <param name="portID"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool ReadId(int portID, out string reason)
- {
- if (!_dicPortModule.ContainsKey(portID.ToString()))
- {
- reason = $"{portID} not valid";
- return false;
- }
- var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portID.ToString()]] as Loadport;
- if (LPDevice == null)
- {
- reason = $"{portID} not valid";
- return false;
- }
- if (!LPDevice.HasCassette)
- {
- reason = $"{portID} cassette not placed";
- return false;
- }
- if (LPDevice.Status == DeviceState.Error)
- {
- reason = $"{portID} port in error, need reset";
- return false;
- }
- OP.DoOperation($"{_dicPortModule[portID.ToString()]}.ReadCarrierId");
- reason = string.Empty;
- return true;
- }
- /// <summary>
- /// Write ID
- /// </summary>
- /// <param name="portID"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool WriteId(int portID,string carrierID, out string reason)
- {
- if (!_dicPortModule.ContainsKey(portID.ToString()))
- {
- reason = $"{portID} not valid";
- return false;
- }
- var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portID.ToString()]] as Loadport;
- if (LPDevice == null)
- {
- reason = $"{portID} not valid";
- return false;
- }
- if (!LPDevice.HasCassette)
- {
- reason = $"{portID} cassette not placed";
- return false;
- }
- if (LPDevice.Status == DeviceState.Error)
- {
- reason = $"{portID} port in error, need reset";
- return false;
- }
- OP.DoOperation($"{_dicPortModule[portID.ToString()]}.WriteCarrierID", carrierID);
- reason = string.Empty;
- return true;
- }
- /// <summary>
- /// Read ID
- /// </summary>
- /// <param name="portID"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool ReadTag(int portID, out string reason)
- {
- if (!_dicPortModule.ContainsKey(portID.ToString()))
- {
- reason = $"{portID} not valid";
- return false;
- }
- var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portID.ToString()]] as Loadport;
- if (LPDevice == null)
- {
- reason = $"{portID} not valid";
- return false;
- }
- if (!LPDevice.HasCassette)
- {
- reason = $"{portID} cassette not placed";
- return false;
- }
- if (LPDevice.Status == DeviceState.Error)
- {
- reason = $"{portID} port in error, need reset";
- return false;
- }
- OP.DoOperation($"{_dicPortModule[portID.ToString()]}.ReadTagData");
- reason = string.Empty;
- return true;
- }
- /// <summary>
- /// Write ID
- /// </summary>
- /// <param name="portID"></param>
- /// <param name="reason"></param>
- /// <returns></returns>
- private bool WriteTag(int portID, string tagData, out string reason)
- {
- if (!_dicPortModule.ContainsKey(portID.ToString()))
- {
- reason = $"{portID} not valid";
- return false;
- }
- var LPDevice = Singleton<RouteManager>.Instance.EFEM.EfemDevice[_dicPortModule[portID.ToString()]] as Loadport;
- if (LPDevice == null)
- {
- reason = $"{portID} not valid";
- return false;
- }
- if (!LPDevice.HasCassette)
- {
- reason = $"{portID} cassette not placed";
- return false;
- }
- if (LPDevice.Status == DeviceState.Error)
- {
- reason = $"{portID} port in error, need reset";
- return false;
- }
- OP.DoOperation($"{_dicPortModule[portID.ToString()]}.WriteTagData", tagData);
- reason = string.Empty;
- return true;
- }
- #endregion
- #region recipe
- /// <summary>
- /// 删除Sequence
- /// </summary>
- /// <param name="ppid"></param>
- /// <returns></returns>
- public bool deleteSequence(string ppid)
- {
- LOG.Warning("system not support update sequence");
- return false;
- //return RecipeFileManager.Instance.DeleteSequence(ppid);
- }
- /// <summary>
- /// S7F25
- /// </summary>
- /// <param name="ppid"></param>
- /// <returns></returns>
- public List<string> GetFormatedSequence(string ppid)
- {
- List<string> result = new List<string>();
- string reason = string.Empty;
- try
- {
- string content = string.Empty;
- if (RecipeFileManager.Instance.CheckSequenceFileExist(ppid))
- content = RecipeFileManager.Instance.GetSequence(ppid, false);
- if (string.IsNullOrEmpty(content))
- {
- bool enableFolder = SC.GetValue<bool>("System.RecipeFolderByType");
- if (enableFolder)
- {
- if (ppid.StartsWith("PMA") && !ppid.StartsWith("PMA\\Process") &&
- !ppid.StartsWith("PMA\\Clean"))
- ppid = ppid.Replace("PMA", "PMA\\Process");
- if (ppid.StartsWith("PMB") && !ppid.StartsWith("PMB\\Process") &&
- !ppid.StartsWith("PMB\\Clean"))
- ppid = ppid.Replace("PMB", "PMB\\Process");
- }
- content = RecipeFileManager.Instance.LoadRecipe("", ppid, false);
- }
- result.Add(content);
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- reason = ex.Message;
- }
- return result;
- }
- /// <summary>
- /// S7F5 获取recipe body
- /// </summary>
- /// <param name="ppid"></param>
- /// <returns></returns>
- /// <exception cref="NotImplementedException"></exception>
- public string GetSequenceBody(string ppid)
- {
- return RecipeFileManager.Instance.GetSequence(ppid, false);
- }
- /// <summary>
- /// S7F3 更新Recipe
- /// </summary>
- /// <param name="ppid"></param>
- /// <param name="body"></param>
- /// <returns></returns>
- public bool UpdateSequence(string ppid, string body)
- {
- LOG.Warning("system not support update sequence");
- return false;
- //bool ret = false;
- //string reason = string.Empty;
- //ret = RecipeFileManager.Instance.SaveSequence(ppid, body, false);
- //if (!ret)
- //{
- // reason = string.Format("save recipe content failed,recipeName:{0}", ppid);
- // LOG.Write(reason);
- //}
- //return ret;
- }
- /// <summary>
- /// 获取sequence集合 S7F19
- /// </summary>
- /// <returns></returns>
- public string[] GetSequenceList()
- {
- var recipeList = RecipeFileManager.Instance.GetSequenceNameList();
- return recipeList.ToArray();
- }
- #endregion
- public bool PauseControlJob(string controlJob)
- {
- throw new NotImplementedException();
- }
- public bool ResumeControlJob(string controlJob)
- {
- throw new NotImplementedException();
- }
- public void ShowTerminalMessage(string message)
- {
- EV.Notify("Host", EventTerminalMessage, message);
- }
- public bool StartControlJob(string controlJob)
- {
- throw new NotImplementedException();
- }
- public bool StopControlJob(string controlJob)
- {
- throw new NotImplementedException();
- }
- public void UpdateControlJobModule(string controlJobId, string moduleName)
- {
- throw new NotImplementedException();
- }
- public void UpdateProcessJobCarrierSlot(string processJobId, string moduleName, List<int> slots)
- {
- throw new NotImplementedException();
- }
- #region eap log write in RT
- public void WriteErrorLog(string message)
- {
- LOG.Error(message);
- }
- public void WriteInfoLog(string message)
- {
- LOG.Info(message);
- }
- public void WriteWarningLog(string message)
- {
- LOG.Warning(message);
- }
- #endregion
- }
- }
|