Reputation: 41
I am new to using the Tc3EventLogger functionality. I have created my EventClasses in the Type system. I have successfully created and raised single instances of different alarms based on an EventClass using CreateEx, IpArguments, Raise, etc.
Issue: My issue is that I have multiple pieces of equipment that need to raise the same Alarm Type, but I differentiate them to the operator (HMI EventGrid) by supplying arguments.
My approach to this has been to create arrays of FB_TcAlarm and iterate through them in a loop to CreateEx, verify creation by HRESULT, modify arguments for each FB_TcAlarm instance in the array, and then later raise them individually when process conditions should trigger the alarm.
// Bank Global Pressure Limit Alarms
FOR nLoopCtr := 1 TO nNumBanks BY 1 DO
arrFbBankPressHresult[nLoopCtr] := arrFbBankPressAlm[nLoopCtr].CreateEx(TC_Events.BankPressureAlarm.Trigger, FALSE, 0);
END_FOR
However when I do this, only a single alarm instance is created (verified by one index having an HRESULT = S_OK
), while the remaining FB_TcAlarm objects in the array have a HRESULT = 16#B7
which is "ERROR_ALREADY_EXISTS"
. Also, when I inspect the TcSourceInfo.nId
of the created alarm instances in the array, they are all the same.
I have read through the Beckhoff manual TC3 Event Logger.
Any feedback on why this is happening or how my understanding of the EventClass or FB_TcAlarm is incorrect would be greatly appreciated.
Thank you.
Upvotes: 3
Views: 1102
Reputation: 11
Some time ago I did a workaround so that you can use the same TcEventEntry multiple times.
When creating the Alarm instances you have to make sure that the tcEventEntry.nEventId are unique!
You can set that property before creating the instance, just adding by 1 is sufficient.
Example:
// Set the event text from tmc file
tcEventEntry := TC_Events.TcGeneralAdsEventClass.AddHash;
// Set event id to 1
tcEventEntry.nEventId := 1;
// Create instance 1 of event text 'AddHash'
nResult := fbTcAlarm[1].CreateEx( tcEventEntry, TRUE, _ipSourceInfo )
// Set event id to 2
tcEventEntry.nEventId := 2;
// Create instance 2 of event text 'AddHash'
nResult := fbTcAlarm[2].CreateEx( tcEventEntry, TRUE, _ipSourceInfo )
In your case:
Declaration:
VAR
tcEventEntry := TC_Events.BankPressureAlarm.Trigger;
END_VAR
Code:
// Bank Global Pressure Limit Alarms
FOR nLoopCtr := 1 TO nNumBanks BY 1 DO
tcEventEntry.nEventId := nLoopCtr;
arrFbBankPressHresult[nLoopCtr] := arrFbBankPressAlm[nLoopCtr].CreateEx(tcEventEntry, FALSE, 0);
END_FOR
Now when you raise your events, you should see all of them individually in the TcHmiEventGrid
Upvotes: 1
Reputation: 1018
Your issue appears to be related to the use of the same TcEventEntry
(Tc_Events.BankPressureAlarm.Trigger) in multiple alarm instances.
My understanding is that every Alarm, Message (any thing that extends TcEventBase) must be registered back to a an individual EventEntry. 'Create' appears to bundle this EventEntry generation as part of the method while 'CreateEx' puts this burden on you.
Result2, Result3 return 16#B7.
AdsErr_TO_TcEventEntry( ErrCode, Event1 );
Result1 := Alarm1.CreateEx( Event1, FALSE, 0 );
Result2 := Alarm2.CreateEx( Event1, FALSE, 0 );
Result3 := Alarm3.CreateEx( Event1, FALSE, 0 );
All alarms return S_OK
AdsErr_TO_TcEventEntry( ErrCode, Event1 );
AdsErr_TO_TcEventEntry( ErrCode, Event2 );
AdsErr_TO_TcEventEntry( ErrCode, Event3 );
Result1 := Alarm1.CreateEx( Event1, FALSE, 0 );
Result2 := Alarm2.CreateEx( Event2, FALSE, 0 );
Result3 := Alarm3.CreateEx( Event3, FALSE, 0 );
Upvotes: 0