From b58d3c89f4a9249cfe7acb540d0c0f204c47eb3d Mon Sep 17 00:00:00 2001 From: HCL <1625932291@qq.com> Date: Wed, 19 Jun 2024 11:05:29 +0800 Subject: [PATCH] =?UTF-8?q?1.GemManager=E5=A2=9E=E5=8A=A0Try=20Catch?= =?UTF-8?q?=E6=8D=95=E8=8E=B7=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../MECF/Framework/Common/Gem/GemManager.cs | 416 ++++++++++-------- 2 files changed, 223 insertions(+), 194 deletions(-) diff --git a/.gitignore b/.gitignore index fa06879..235e934 100644 --- a/.gitignore +++ b/.gitignore @@ -368,3 +368,4 @@ FodyWeavers.xsd *.DotSettings Output/ BuildTools/ +*.json diff --git a/MECF.Framework.Common/MECF/Framework/Common/Gem/GemManager.cs b/MECF.Framework.Common/MECF/Framework/Common/Gem/GemManager.cs index d2909fb..0dea79e 100644 --- a/MECF.Framework.Common/MECF/Framework/Common/Gem/GemManager.cs +++ b/MECF.Framework.Common/MECF/Framework/Common/Gem/GemManager.cs @@ -506,140 +506,163 @@ namespace MECF.Framework.Common.Gem private void Log_NewMessage(LogType loggingType, string customizedLogTypeName, DateTime timeStamp, string processName, int threadID, string source, string message) { - // make a filter, do not show SML logging message at current window - if (message.Contains("SECS MSG Recv") || message.Contains("SECS MSG Sent")) + try { - return; - } + // make a filter, do not show SML logging message at current window + if (message.Contains("SECS MSG Recv") || message.Contains("SECS MSG Sent")) + { + return; + } - ProgramLog += $"{timeStamp.ToString("yyyy/MM/dd HH:mm:ss,fff")} {source} 线程ID:{threadID} 内容:{message}\r\n"; + ProgramLog += $"{timeStamp.ToString("yyyy/MM/dd HH:mm:ss,fff")} {source} 线程ID:{threadID} 内容:{message}\r\n"; + } + catch (Exception ex) + { + LOG.Error(ex.Message, ex); + } } private void DataMessageReceived(string equipmentName, string connectionName, DateTime time, Kxware.Automation.Secs.DataMessage message) { - if (connectionName == _equipment.MasterConnectionName) + try { - string msg = $"{time.ToString("yyyy/MM/dd HH:mm:ss.fff")} 【接受】\r\n{message.ToSML()}\r\n"; - Kxware.Common.Log.Info("GEM", msg); - SecsLog += msg; + if (connectionName == _equipment.MasterConnectionName) + { + string msg = $"{time.ToString("yyyy/MM/dd HH:mm:ss.fff")} 【接受】\r\n{message.ToSML()}\r\n"; + Kxware.Common.Log.Info("GEM", msg); + SecsLog += msg; - //if (SecsLog.Length > 10000) - //{ - // SecsLog = SecsLog.Substring(SecsLog.Length - 10000); - //} + //if (SecsLog.Length > 10000) + //{ + // SecsLog = SecsLog.Substring(SecsLog.Length - 10000); + //} + } + } + catch (Exception ex) + { + LOG.Error(ex.Message, ex); } } private void EventTriggered(string equipmentName, string connectionName, ulong eventID, string eventName, string eventDescription, Kxware.Common.VariableData[] associatedVariables, Kxware.Automation.Secs.DataMessage eventSecsMessage) { - if (connectionName == _equipment.MasterConnectionName) + try { - var associatedDataInfo = ""; - if (associatedVariables.Length > 0) + if (connectionName == _equipment.MasterConnectionName) { - associatedDataInfo = "关联数据:" + string.Join(",", associatedVariables.Select(p => p.Name + " " + p.Value.ToSML(Kxware.Common.SmlFormat.RoundBracket))); + var associatedDataInfo = ""; + if (associatedVariables.Length > 0) + { + associatedDataInfo = "关联数据:" + string.Join(",", associatedVariables.Select(p => p.Name + " " + p.Value.ToSML(Kxware.Common.SmlFormat.RoundBracket))); + } + EventInfoList.Add($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} 编号:{eventID} 事件名:{eventName} {associatedDataInfo}"); } - EventInfoList.Add($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} 编号:{eventID} 事件名:{eventName} {associatedDataInfo}"); + } + catch (Exception ex) + { + LOG.Error(ex.Message, ex); } } private enumRemoteCommandAckCode OnReceivedRemoteCommand(string connectionName, string objSpec, string remoteCommand, List remoteCommandParameters) { - //只接受从MasterConnection 收到的控制命令 - if (connectionName != _equipment.MasterConnectionName) - return enumRemoteCommandAckCode.CannotPerformNow; - - //判断控制状态,在Local 状态下只接受GO-REMOTE命令 - var currentCtrlState = _equipment.GetControlState(); - if (currentCtrlState != GEMControlStates.Online_Remote) + try { - if (remoteCommand.ToUpper() != "GO-REMOTE") + //只接受从MasterConnection 收到的控制命令 + if (connectionName != _equipment.MasterConnectionName) return enumRemoteCommandAckCode.CannotPerformNow; - } - var result = enumRemoteCommandAckCode.NoSuchObjectExists; - switch (remoteCommand) - { - case "GO-LOCAL": - { - if (currentCtrlState == GEMControlStates.Online_Remote) + //判断控制状态,在Local 状态下只接受GO-REMOTE命令 + var currentCtrlState = _equipment.GetControlState(); + if (currentCtrlState != GEMControlStates.Online_Remote) + { + if (remoteCommand.ToUpper() != "GO-REMOTE") + return enumRemoteCommandAckCode.CannotPerformNow; + } + + var result = enumRemoteCommandAckCode.NoSuchObjectExists; + switch (remoteCommand) + { + case "GO-LOCAL": { - _equipment.OnlineLocal(_equipment.MasterConnectionName); - result = enumRemoteCommandAckCode.AcknowledgeCommandPerformed; + if (currentCtrlState == GEMControlStates.Online_Remote) + { + _equipment.OnlineLocal(_equipment.MasterConnectionName); + result = enumRemoteCommandAckCode.AcknowledgeCommandPerformed; + } + else + result = enumRemoteCommandAckCode.RejectedAlreadyInDesiredCondition; } - else - result = enumRemoteCommandAckCode.RejectedAlreadyInDesiredCondition; - } - break; + break; - case "GO-REMOTE": - { - if (currentCtrlState == GEMControlStates.Online_Remote) + case "GO-REMOTE": { - result = enumRemoteCommandAckCode.RejectedAlreadyInDesiredCondition; + if (currentCtrlState == GEMControlStates.Online_Remote) + { + result = enumRemoteCommandAckCode.RejectedAlreadyInDesiredCondition; + } + else if (!_equipment.OnlineRemote(_equipment.MasterConnectionName, out string error)) + result = enumRemoteCommandAckCode.CannotPerformNow; + else + result = enumRemoteCommandAckCode.AcknowledgeCommandPerformed; } - else if (!_equipment.OnlineRemote(_equipment.MasterConnectionName, out string error)) - result = enumRemoteCommandAckCode.CannotPerformNow; - else - result = enumRemoteCommandAckCode.AcknowledgeCommandPerformed; - } - break; + break; - //PP-SELECT指令附加参数(PPID&LotID) - case "PP-SELECT": - { - try + //PP-SELECT指令附加参数(PPID&LotID) + case "PP-SELECT": + { + try + { + if (RtStatus != "AutoIdle") + { + Kxware.Common.Log.Warn("GEM", $"Cannot perform 'PP-SELECT' command. Equipment State is not in AutoIdle."); + result = enumRemoteCommandAckCode.CannotPerformNow; + } + else if (remoteCommandParameters.Find(p => p.CPNAME == "PPID") == null) + { + Kxware.Common.Log.Warn("GEM", $"Cannot perform 'PP-SELECT' command. PPID is not specified."); + result = enumRemoteCommandAckCode.AtLeastOneParameterIsInvalid; + } + else if (remoteCommandParameters.Find(p => p.CPNAME == "LotID") == null) + { + Kxware.Common.Log.Warn("GEM", $"Cannot perform 'PP-SELECT' command. LotID is not specified."); + result = enumRemoteCommandAckCode.AtLeastOneParameterIsInvalid; + } + else + { + string PPID = remoteCommandParameters.Find(p => p.CPNAME == "PPID").CPVAL.GetValueAsString(); + PPIDNoExtension = PPID.Replace(@"Sequence\", "").Replace(".seq", ""); + LotID = remoteCommandParameters.Find(p => p.CPNAME == "LotID").CPVAL.GetValueAsString(); + Kxware.Common.Log.Info("GEM", $"Received 'PP-SELECT' command. PPID={PPID}, LotID={LotID}"); + + //Check if rcpID is exist. if not exist, returen enumRemoteCommandAckCode.AtLeastOneParameterIsInvalid + + result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; + } + } + catch (Exception) + { + result = enumRemoteCommandAckCode.AtLeastOneParameterIsInvalid; + } + } + break; + + //CREATE-JOB指令没有附加参数 + case "CREATE-JOB": { if (RtStatus != "AutoIdle") { - Kxware.Common.Log.Warn("GEM", $"Cannot perform 'PP-SELECT' command. Equipment State is not in AutoIdle."); + Kxware.Common.Log.Warn("GEM", $"Cannot perform 'CREATE-JOB' command. Equipment State is not in AutoIdle."); result = enumRemoteCommandAckCode.CannotPerformNow; } - else if (remoteCommandParameters.Find(p => p.CPNAME == "PPID") == null) - { - Kxware.Common.Log.Warn("GEM", $"Cannot perform 'PP-SELECT' command. PPID is not specified."); - result = enumRemoteCommandAckCode.AtLeastOneParameterIsInvalid; - } - else if (remoteCommandParameters.Find(p => p.CPNAME == "LotID") == null) - { - Kxware.Common.Log.Warn("GEM", $"Cannot perform 'PP-SELECT' command. LotID is not specified."); - result = enumRemoteCommandAckCode.AtLeastOneParameterIsInvalid; - } else { - string PPID = remoteCommandParameters.Find(p => p.CPNAME == "PPID").CPVAL.GetValueAsString(); - PPIDNoExtension = PPID.Replace(@"Sequence\", "").Replace(".seq", ""); - LotID = remoteCommandParameters.Find(p => p.CPNAME == "LotID").CPVAL.GetValueAsString(); - Kxware.Common.Log.Info("GEM", $"Received 'PP-SELECT' command. PPID={PPID}, LotID={LotID}"); + Kxware.Common.Log.Info("GEM", $"Received 'CREATE-JOB' command."); + result = enumRemoteCommandAckCode.AcknowledgeCommandPerformed; - //Check if rcpID is exist. if not exist, returen enumRemoteCommandAckCode.AtLeastOneParameterIsInvalid - - result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; - } - } - catch (Exception) - { - result = enumRemoteCommandAckCode.AtLeastOneParameterIsInvalid; - } - } - break; - - //CREATE-JOB指令没有附加参数 - case "CREATE-JOB": - { - if (RtStatus != "AutoIdle") - { - Kxware.Common.Log.Warn("GEM", $"Cannot perform 'CREATE-JOB' command. Equipment State is not in AutoIdle."); - result = enumRemoteCommandAckCode.CannotPerformNow; - } - else - { - Kxware.Common.Log.Info("GEM", $"Received 'CREATE-JOB' command."); - result = enumRemoteCommandAckCode.AcknowledgeCommandPerformed; - - //具体操作 - JobID = "CJ_Local_Load_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - Dictionary dictionary = new Dictionary + //具体操作 + JobID = "CJ_Local_Load_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + Dictionary dictionary = new Dictionary { { "JobId", JobID}, { "Module", "LoadLock" }, @@ -648,129 +671,134 @@ namespace MECF.Framework.Common.Gem { "AutoStart", true } }; - OP.DoOperation("System.CreateJob", dictionary); + OP.DoOperation("System.CreateJob", dictionary); + } } - } - break; + break; - //START指令没有附加参数 - case "START": - { - if (RtStatus != "AutoIdle" && RtStatus != "AutoRunning") + //START指令没有附加参数 + case "START": { - Kxware.Common.Log.Warn("GEM", $"Cannot perform 'STRAT' command. Equipment State is not in AutoIdle or AutoRunning."); - result = enumRemoteCommandAckCode.CannotPerformNow; + if (RtStatus != "AutoIdle" && RtStatus != "AutoRunning") + { + Kxware.Common.Log.Warn("GEM", $"Cannot perform 'STRAT' command. Equipment State is not in AutoIdle or AutoRunning."); + result = enumRemoteCommandAckCode.CannotPerformNow; + } + else + { + Kxware.Common.Log.Info("GEM", $"Received 'STRAT' command."); + result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; + + //具体操作 + OP.DoOperation("System.StartJob", JobID); + } } - else + break; + + //ABORT指令没有附加参数 + case "ABORT": + case "STOP": { - Kxware.Common.Log.Info("GEM", $"Received 'STRAT' command."); + if (RtStatus != "AutoRunning") + { + Kxware.Common.Log.Warn("GEM", $"Cannot perform 'ABORT' command. Equipment State is not in AutoRunning."); + result = enumRemoteCommandAckCode.CannotPerformNow; + } + else + { + Kxware.Common.Log.Info("GEM", $"Received 'ABORT' command."); + result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; + + //具体操作 + OP.DoOperation("System.Abort"); + } + } + break; + + //Online指令附加参数(ModuleID) + case "Online": + { + Kxware.Common.Log.Info("GEM", $"Received 'Online' command."); result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; - //具体操作 - OP.DoOperation("System.StartJob", JobID); + string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); + OP.DoOperation($"{module}.SetOnline"); } - } - break; + break; - //ABORT指令没有附加参数 - case "ABORT": - case "STOP": - { - if (RtStatus != "AutoRunning") + //Offline指令附加参数(ModuleID) + case "Offline": { - Kxware.Common.Log.Warn("GEM", $"Cannot perform 'ABORT' command. Equipment State is not in AutoRunning."); - result = enumRemoteCommandAckCode.CannotPerformNow; - } - else - { - Kxware.Common.Log.Info("GEM", $"Received 'ABORT' command."); + Kxware.Common.Log.Info("GEM", $"Received 'Offline' command."); result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; - //具体操作 - OP.DoOperation("System.Abort"); + string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); + OP.DoOperation($"{module}.SetOffline"); } - } - break; + break; - //Online指令附加参数(ModuleID) - case "Online": - { - Kxware.Common.Log.Info("GEM", $"Received 'Online' command."); - result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; + //CreateWafer指令附加参数(ModuleID,SlotID) + case "CreateWafer": + { + Kxware.Common.Log.Info("GEM", $"Received 'CreateWafer' command."); + result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; - string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); - OP.DoOperation($"{module}.SetOnline"); - } - break; + string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); + int slot = remoteCommandParameters.Find(p => p.CPNAME == "SlotID").CPVAL.GetValueAsInt(0); + OP.DoOperation($"CreateWafer", module, slot); + } + break; - //Offline指令附加参数(ModuleID) - case "Offline": - { - Kxware.Common.Log.Info("GEM", $"Received 'Offline' command."); - result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; + //CreateTray指令附加参数(ModuleID,SlotID) + case "CreateTray": + { + Kxware.Common.Log.Info("GEM", $"Received 'CreateTray' command."); + result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; - string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); - OP.DoOperation($"{module}.SetOffline"); - } - break; + string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); + int slot = remoteCommandParameters.Find(p => p.CPNAME == "SlotID").CPVAL.GetValueAsInt(0); + OP.DoOperation($"CreateTray", module, slot); + } + break; - //CreateWafer指令附加参数(ModuleID,SlotID) - case "CreateWafer": - { - Kxware.Common.Log.Info("GEM", $"Received 'CreateWafer' command."); - result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; + //DeleteWafer指令附加参数(ModuleID,SlotID) + case "DeleteWafer": + { + Kxware.Common.Log.Info("GEM", $"Received 'DeleteWafer' command."); + result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; - string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); - int slot = remoteCommandParameters.Find(p => p.CPNAME == "SlotID").CPVAL.GetValueAsInt(0); - OP.DoOperation($"CreateWafer", module, slot); - } - break; + string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); + int slot = remoteCommandParameters.Find(p => p.CPNAME == "SlotID").CPVAL.GetValueAsInt(0); + OP.DoOperation($"DeleteWafer", module, slot); + } + break; - //CreateTray指令附加参数(ModuleID,SlotID) - case "CreateTray": - { - Kxware.Common.Log.Info("GEM", $"Received 'CreateTray' command."); - result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; + //DeleteTray指令附加参数(ModuleID) + case "DeleteTray": + { + Kxware.Common.Log.Info("GEM", $"Received 'DeleteTray' command."); + result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; - string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); - int slot = remoteCommandParameters.Find(p => p.CPNAME == "SlotID").CPVAL.GetValueAsInt(0); - OP.DoOperation($"CreateTray",module,slot); - } - break; + string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); + int slot = remoteCommandParameters.Find(p => p.CPNAME == "SlotID").CPVAL.GetValueAsInt(0); + OP.DoOperation($"DeleteTray", module, slot); + } + break; - //DeleteWafer指令附加参数(ModuleID,SlotID) - case "DeleteWafer": - { - Kxware.Common.Log.Info("GEM", $"Received 'DeleteWafer' command."); - result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; + default: + { + Kxware.Common.Log.Error("GEM", $"Un-handled remote command: {remoteCommand}"); + } - string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); - int slot = remoteCommandParameters.Find(p => p.CPNAME == "SlotID").CPVAL.GetValueAsInt(0); - OP.DoOperation($"DeleteWafer", module, slot); - } - break; + break; + } - //DeleteTray指令附加参数(ModuleID) - case "DeleteTray": - { - Kxware.Common.Log.Info("GEM", $"Received 'DeleteTray' command."); - result = enumRemoteCommandAckCode.AcknowledgeCommandWillBePerformed; - - string module = remoteCommandParameters.Find(p => p.CPNAME == "ModuleID").CPVAL.GetValueAsString(); - int slot = remoteCommandParameters.Find(p => p.CPNAME == "SlotID").CPVAL.GetValueAsInt(0); - OP.DoOperation($"DeleteTray", module, slot); - } - break; - - default: - { - Kxware.Common.Log.Error("GEM", $"Un-handled remote command: {remoteCommand}"); - } - - break; + return result; + } + catch (Exception) + { + return enumRemoteCommandAckCode.CannotPerformNow; } - - return result; } private bool SetSoftwareVersion(string softwareVersion)