1.调整位置,防止未安装GEM许可证机台有报错信息

This commit is contained in:
HCL 2024-05-09 10:20:32 +08:00
parent f5a77f2817
commit c28796560e
1 changed files with 99 additions and 93 deletions

View File

@ -111,105 +111,111 @@ namespace MECF.Framework.Common.Gem
public void Initialize()
{
string equipmentName = SC.GetStringValue("System.EquipmentName");
int equipmentNo = SC.GetValue<int>("System.EquipmentNo");
_equipment = new Kxware.ToolAutomation.Equipment(equipmentName);
//_equipment.RegisteringVariables += new RegisterVariableDelegate(RegisteringVariables);
//_equipment.RegisteringAlarms += new RegisterAlarmDelegate(RegisteringAlarms);
//initialize SECS/ GEM service from configruation file
_equipment.Initialize(PathManager.GetCfgDir() + "Gem.exml");
#region
//设置内置名称,软件版本等SV
_equipment.SetValue("MDLN", "Sic");
_equipment.SetValue("Manufacturer", equipmentName);
_equipment.SetValue("EqpSerialNum", equipmentNo.ToString());
//设置Recipes路径
_equipment.SetValue("PPDirectory", "./Recipes");
_equipment.SetValue("PPFileExtension", "seq,rcp");
//设置PPFormat
_equipment.SetValue("PPFormat", 1);
//设置Log路径
//Log.SetLoggingDirectory("");
#endregion
#region
_equipment.AlarmSET += new OnAlarmSET(AlarmSET);
_equipment.AlarmCLEAR += new OnAlarmCLEAR(AlarmCLEAR);
Kxware.Common.Log.NewMessage += Log_NewMessage;
_equipment.DataMessageReceived += DataMessageReceived;
_equipment.DataMessageSent += DataMessageSent;
_equipment.TerminalMessageReceived += TerminalMessageReceived;
//注册远程操作指令
_equipment.RegisterRemoteCommandHandler("GO-LOCAL", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("GO-REMOTE", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("PP-SELECT", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("CREATE-JOB", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("START", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("ABORT", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("STOP", OnReceivedRemoteCommand);
_equipment.EventTriggered += EventTriggered;
//register custom SECS message
_equipment.RegisterMessageHandler(7, 7, HandleS7F7);
//Variable value change callback
var allHostECs = _equipment.GetVariables().FindAll(p => p.HostVisible && p.VariableType == VariableType.EC);
allHostECs.ForEach(v =>
try
{
v.AdvancedValueChanged += Variable_AdvancedValueChanged;
});
//注册
DATA.Subscribe("GEM.CommunicationState", () => CommunicationState);
DATA.Subscribe("GEM.ControlMode", () => ControlMode);
DATA.Subscribe("GEM.VariableList", () => VariableList);
DATA.Subscribe("GEM.EventList", () => EventList);
DATA.Subscribe("GEM.EventInfoList", () => EventInfoList);
DATA.Subscribe("GEM.AlarmList", () => AlarmList);
DATA.Subscribe("GEM.AlarmInfoList", () => AlarmInfoList);
DATA.Subscribe("GEM.SequenceRecipeNameList", () => SequenceRecipeNameList);
DATA.Subscribe("GEM.SequenceRecipeContent", () => SequenceRecipeContent);
DATA.Subscribe("GEM.RecvMsgFromHost", () => RecvMsgFromHost);
DATA.Subscribe("GEM.ProgramLog", () => ProgramLog);
DATA.Subscribe("GEM.SecsLog", () => SecsLog);
DATA.Subscribe("GEM.PPID", () => PPIDNoExtension);
DATA.Subscribe("GEM.LotID", () => LotID);
#endregion
OP.Subscribe($"GEM_SetSoftwareVersion", (string cmd, object[] args) => SetSoftwareVersion((string)args[0]));
OP.Subscribe($"GEM_SetEnable", (string cmd, object[] args) => SetEnable((bool)args[0]));
OP.Subscribe($"GEM_SetControlMode", (string cmd, object[] args) => SetControlMode(args[0].ToString()));
OP.Subscribe($"GEM_SelectSequenceRecipeChanged", (string cmd, object[] args) => SelectSequenceRecipeChanged(args[0].ToString()));
OP.Subscribe($"GEM_TerminalMessageConfirm", (string cmd, object[] args) => TerminalMessageConfirm());
OP.Subscribe($"GEM_SendMessageToHost", (string cmd, object[] args) => SendMessageToHost(args[0].ToString()));
OP.Subscribe($"GEM_ClearProgramLog", (string cmd, object[] args) => ClearProgramLog());
OP.Subscribe($"GEM_ClearSecsLog", (string cmd, object[] args) => ClearSecsLog());
OP.Subscribe($"GEM_ClearAllAlarm", (string cmd, object[] args) => ClearAllAlarm());
OP.Subscribe($"GEM_ClearModuleAlarm", (string cmd, object[] args) => ClearModuleAlarm(args[0].ToString()));
OP.Subscribe($"GEM_PPChange", (string cmd, object[] args) => PPChange(args));
//enable GEM
_equipment.GemEnable();
_equipment.OnlineLocal(_equipment.MasterConnectionName);
string equipmentName = SC.GetStringValue("System.EquipmentName");
int equipmentNo = SC.GetValue<int>("System.EquipmentNo");
_equipment = new Kxware.ToolAutomation.Equipment(equipmentName);
//注册
DATA.Subscribe("GEM.CommunicationState", () => CommunicationState);
DATA.Subscribe("GEM.ControlMode", () => ControlMode);
DATA.Subscribe("GEM.VariableList", () => VariableList);
DATA.Subscribe("GEM.EventList", () => EventList);
DATA.Subscribe("GEM.EventInfoList", () => EventInfoList);
DATA.Subscribe("GEM.AlarmList", () => AlarmList);
DATA.Subscribe("GEM.AlarmInfoList", () => AlarmInfoList);
DATA.Subscribe("GEM.SequenceRecipeNameList", () => SequenceRecipeNameList);
DATA.Subscribe("GEM.SequenceRecipeContent", () => SequenceRecipeContent);
DATA.Subscribe("GEM.RecvMsgFromHost", () => RecvMsgFromHost);
DATA.Subscribe("GEM.ProgramLog", () => ProgramLog);
DATA.Subscribe("GEM.SecsLog", () => SecsLog);
DATA.Subscribe("GEM.PPID", () => PPIDNoExtension);
DATA.Subscribe("GEM.LotID", () => LotID);
//_equipment.RegisteringVariables += new RegisterVariableDelegate(RegisteringVariables);
OP.Subscribe($"GEM_SetSoftwareVersion", (string cmd, object[] args) => SetSoftwareVersion((string)args[0]));
OP.Subscribe($"GEM_SetEnable", (string cmd, object[] args) => SetEnable((bool)args[0]));
OP.Subscribe($"GEM_SetControlMode", (string cmd, object[] args) => SetControlMode(args[0].ToString()));
OP.Subscribe($"GEM_SelectSequenceRecipeChanged", (string cmd, object[] args) => SelectSequenceRecipeChanged(args[0].ToString()));
OP.Subscribe($"GEM_TerminalMessageConfirm", (string cmd, object[] args) => TerminalMessageConfirm());
OP.Subscribe($"GEM_SendMessageToHost", (string cmd, object[] args) => SendMessageToHost(args[0].ToString()));
OP.Subscribe($"GEM_ClearProgramLog", (string cmd, object[] args) => ClearProgramLog());
OP.Subscribe($"GEM_ClearSecsLog", (string cmd, object[] args) => ClearSecsLog());
OP.Subscribe($"GEM_ClearAllAlarm", (string cmd, object[] args) => ClearAllAlarm());
OP.Subscribe($"GEM_ClearModuleAlarm", (string cmd, object[] args) => ClearModuleAlarm(args[0].ToString()));
OP.Subscribe($"GEM_PPChange", (string cmd, object[] args) => PPChange(args));
//_equipment.RegisteringAlarms += new RegisterAlarmDelegate(RegisteringAlarms);
_monitorJob = new PeriodicJob(1000, Monitor, "GEM_Monitor", true);
//initialize SECS/ GEM service from configruation file
_equipment.Initialize(PathManager.GetCfgDir() + "Gem.exml");
#region
//设置内置名称,软件版本等SV
_equipment.SetValue("MDLN", "Sic");
_equipment.SetValue("Manufacturer", "Sicentury");
_equipment.SetValue("EqpSerialNum", equipmentNo.ToString());
//设置Recipes路径
_equipment.SetValue("PPDirectory", "./Recipes");
_equipment.SetValue("PPFileExtension", "seq,rcp");
//设置PPFormat
_equipment.SetValue("PPFormat", 1);
//设置Log路径
//Log.SetLoggingDirectory("");
#endregion
#region
_equipment.AlarmSET += new OnAlarmSET(AlarmSET);
_equipment.AlarmCLEAR += new OnAlarmCLEAR(AlarmCLEAR);
Kxware.Common.Log.NewMessage += Log_NewMessage;
_equipment.DataMessageReceived += DataMessageReceived;
_equipment.DataMessageSent += DataMessageSent;
_equipment.TerminalMessageReceived += TerminalMessageReceived;
//注册远程操作指令
_equipment.RegisterRemoteCommandHandler("GO-LOCAL", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("GO-REMOTE", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("PP-SELECT", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("CREATE-JOB", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("START", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("ABORT", OnReceivedRemoteCommand);
_equipment.RegisterRemoteCommandHandler("STOP", OnReceivedRemoteCommand);
_equipment.EventTriggered += EventTriggered;
//register custom SECS message
_equipment.RegisterMessageHandler(7, 7, HandleS7F7);
//Variable value change callback
var allHostECs = _equipment.GetVariables().FindAll(p => p.HostVisible && p.VariableType == VariableType.EC);
allHostECs.ForEach(v =>
{
v.AdvancedValueChanged += Variable_AdvancedValueChanged;
});
#endregion
//enable GEM
_equipment.GemEnable();
_equipment.OnlineLocal(_equipment.MasterConnectionName);
_monitorJob = new PeriodicJob(1000, Monitor, "GEM_Monitor", true);
}
catch (Exception ex)
{
//LOG.Error(ex.Message,ex);
}
}
private void Variable_AdvancedValueChanged(Variable variable, SecsValue oldValue, SecsValue newValue, enumSource source)