Files
lmxopcua/tests/ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.IntegrationTests/TwinCatProject/PLC/POUs/FB_AlarmHarness.TcPOU

46 lines
2.2 KiB
XML

<?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>