Auto: twincat-5.1 — IAlarmSource via TC3 EventLogger (gated, scaffold)
Closes #316
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
|
||||
<GVL Name="GVL_Alarms" Id="{00000000-0000-0000-0000-000000000505}">
|
||||
<Declaration><![CDATA[// PR 5.1 / #316 — TC3 EventLogger fixture for TwinCATAlarmIntegrationTests.
|
||||
// bTriggerEvent rises FALSE -> TRUE to fire one EventLogger event via FB_AlarmHarness.
|
||||
// bAcked is operator-side ACK toggle the alarm-source bridge writes back when the
|
||||
// driver's AcknowledgeAsync runs. nLastEventClass / nLastSeverity track the last
|
||||
// event the harness raised so the integration test can sanity-check the values it
|
||||
// expects to surface through IAlarmSource.
|
||||
VAR_GLOBAL
|
||||
bTriggerEvent : BOOL := FALSE;
|
||||
bAcked : BOOL := FALSE;
|
||||
nLastEventClass : DINT := 0;
|
||||
nLastSeverity : USINT := 0;
|
||||
fbAlarmHarness : FB_AlarmHarness;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
</GVL>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
|
||||
<POU Name="FB_AlarmHarness" Id="{00000000-0000-0000-0000-000000000303}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[// PR 5.1 / #316 — drives the TC3 EventLogger so TwinCATAlarmIntegrationTests
|
||||
// can observe an event surfacing through the driver's IAlarmSource bridge.
|
||||
//
|
||||
// On a rising edge of GVL_Alarms.bTriggerEvent the harness calls FB_TcLogEvent
|
||||
// with a fixed event class GUID + severity from GVL_Alarms.nLastSeverity and a
|
||||
// short message string. The wire side of the EventLogger then dispatches a
|
||||
// notification on AMS port 110 (AMSPORT_EVENTLOG); the driver's secondary
|
||||
// AdsClient receives the event + projects it onto OnAlarmEvent.
|
||||
//
|
||||
// The harness intentionally targets a single event class GUID per fixture cycle;
|
||||
// the test asserts shape + presence rather than per-event-class decoding because
|
||||
// the binary protocol is undocumented in managed code (see
|
||||
// docs/v3/twincat-eventlogger-spike.md).
|
||||
FUNCTION_BLOCK FB_AlarmHarness
|
||||
VAR
|
||||
fbTrigger : R_TRIG;
|
||||
fbLogEvent : FB_TcLogEvent; // declared in Tc3_EventLogger
|
||||
sMessage : STRING(255) := 'Integration-fixture EventLogger trigger';
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[fbTrigger(CLK := GVL_Alarms.bTriggerEvent);
|
||||
IF fbTrigger.Q THEN
|
||||
// Fixed event-class GUID for the integration fixture; replace with whatever
|
||||
// class the operator wires into the TC3 EventLogger configuration GUI.
|
||||
fbLogEvent.ipMessage := 0; // placeholder — TwinCAT 3 ships richer
|
||||
// overloads; the integration test only
|
||||
// asserts an event surfaces, not the
|
||||
// specific payload bytes.
|
||||
fbLogEvent.eSeverity := TcEventSeverity.Warning;
|
||||
fbLogEvent.bConfirmable := TRUE;
|
||||
fbLogEvent.Execute(bExecute := TRUE);
|
||||
|
||||
GVL_Alarms.nLastEventClass := 1; // fixture-side echo so a watch window can
|
||||
// confirm the harness fired.
|
||||
GVL_Alarms.nLastSeverity := 100;
|
||||
END_IF
|
||||
fbLogEvent.Execute(bExecute := FALSE);
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
Reference in New Issue
Block a user