- FB_AlarmMessage now displays its parent source in the event source info instead of its own source
131 lines
4.3 KiB
XML
131 lines
4.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<TcPlcObject Version="1.1.0.1">
|
|
<POU Name="FB_AlarmMessage" Id="{00b96800-3427-0356-3ac6-5d6b32218bad}" SpecialFunc="None">
|
|
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_AlarmMessage
|
|
VAR_INPUT
|
|
xActive : BOOL;
|
|
xRelease : BOOL;
|
|
xAcknowledge : BOOL;
|
|
timOnDelay : TIME := T#0S;
|
|
timOffDelay : TIME := T#0S;
|
|
|
|
{attribute 'hide'}
|
|
xInUnitTestMode : BOOL := FALSE;
|
|
END_VAR
|
|
VAR_OUTPUT
|
|
END_VAR
|
|
VAR
|
|
_fbReleaseAlarm : FB_ReleaseSignal;
|
|
_fbAlarmMessage : FB_TcAlarm;
|
|
_fbSourceInfo : FB_TcSourceInfo;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[// Filter alarm signal
|
|
_fbReleaseAlarm(
|
|
xSignal:= xActive,
|
|
xRelease:= xRelease,
|
|
timOnDelay:= timOnDelay,
|
|
timOffDelay:= timOffDelay);
|
|
|
|
// Raise alarm
|
|
IF _fbReleaseAlarm.xReleaseSignal AND (NOT xInUnitTestMode) AND (NOT _fbAlarmMessage.bRaised) THEN
|
|
_fbAlarmMessage.Raise(0);
|
|
END_IF
|
|
|
|
// Clear alarm
|
|
IF ((NOT _fbReleaseAlarm.xReleaseSignal) OR (NOT xRelease)) AND (_fbAlarmMessage.bRaised) THEN
|
|
_fbAlarmMessage.Clear(0, FALSE);
|
|
END_IF
|
|
|
|
// Confirm alarm
|
|
IF _fbAlarmMessage.eConfirmationState = TcEventConfirmationState.WaitForConfirmation AND (xAcknowledge OR (NOT xRelease)) THEN
|
|
_fbAlarmMessage.Confirm(0);
|
|
END_IF]]></ST>
|
|
</Implementation>
|
|
<Property Name="Active" Id="{00a4408d-c0d1-0670-1ca5-9dcb270a2efc}">
|
|
<Declaration><![CDATA[PROPERTY Active : BOOL]]></Declaration>
|
|
<Get Name="Get" Id="{3e04f28e-d803-004a-19a2-eeac94c59afc}">
|
|
<Declaration><![CDATA[VAR
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[Active := _fbAlarmMessage.bActive;]]></ST>
|
|
</Implementation>
|
|
</Get>
|
|
</Property>
|
|
<Property Name="Arguments" Id="{bad76689-89ef-0a0e-34ee-f40fa5d6aac1}">
|
|
<Declaration><![CDATA[PROPERTY PUBLIC Arguments : I_TcArguments]]></Declaration>
|
|
<Get Name="Get" Id="{8f632d08-eff2-0cce-3562-f29db78cffa0}">
|
|
<Declaration><![CDATA[VAR
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[Arguments := _fbAlarmMessage.ipArguments;]]></ST>
|
|
</Implementation>
|
|
</Get>
|
|
</Property>
|
|
<Method Name="FB_init" Id="{173de1d9-a300-02b1-2769-f9766f992e18}">
|
|
<Declaration><![CDATA[//FB_Init ist immer implizit verfügbar und wird primär für die Initialisierung verwendet.
|
|
//Der Rückgabewert wird nicht ausgewertet. Für gezielte Einflussnahme können Sie
|
|
//die Methoden explizit deklarieren und darin mit dem Standard-Initialisierungscode
|
|
//zusätzlichen Code bereitstellen. Sie können den Rückgabewert auswerten.
|
|
METHOD FB_Init: BOOL
|
|
VAR_INPUT
|
|
bInitRetains: BOOL; // TRUE: Die Retain-Variablen werden initialisiert (Reset warm / Reset kalt)
|
|
bInCopyCode: BOOL; // TRUE: Die Instanz wird danach in den Kopiercode kopiert (Online-Change)
|
|
|
|
stEventEntry : TcEventEntry;
|
|
xWithConfirmation : BOOL;
|
|
END_VAR
|
|
VAR
|
|
_sTmp : STRING;
|
|
_sLeft : STRING;
|
|
_sRight : STRING;
|
|
_udiI : UDINT;
|
|
_udiPosition : UDINT;
|
|
END_VAR]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[// Edit source info name, so that we get the parent as a source
|
|
// and not this fb
|
|
_sTmp := _fbSourceInfo.sName;
|
|
FindAndSplitChar(
|
|
sSeparatorChar:= '.',
|
|
pSrcString:= ADR(_sTmp),
|
|
pLeftString:= ADR(_sLeft),
|
|
nLeftSize:= SIZEOF(_sLeft),
|
|
pRightString:= ADR(_sRight),
|
|
nRightSize:= SIZEOF(_sRight),
|
|
bSearchFromRight:= TRUE);
|
|
|
|
_fbSourceInfo.sName := _sLeft;
|
|
|
|
|
|
// Create alarm
|
|
_fbAlarmMessage.CreateEx(stEventEntry := stEventEntry, bWithConfirmation := xWithConfirmation);]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Property Name="Raised" Id="{2254f7ab-28c0-02ea-0e65-a373d9d5b007}">
|
|
<Declaration><![CDATA[PROPERTY Raised : BOOL]]></Declaration>
|
|
<Get Name="Get" Id="{402fa563-3cdd-092f-24cf-a227bf8b3ef3}">
|
|
<Declaration><![CDATA[VAR
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[Raised := _fbAlarmMessage.bRaised;]]></ST>
|
|
</Implementation>
|
|
</Get>
|
|
</Property>
|
|
<Property Name="Triggered" Id="{cafebd2a-d123-0563-2c59-c51cfbad3eb5}">
|
|
<Declaration><![CDATA[PROPERTY Triggered : BOOL]]></Declaration>
|
|
<Get Name="Get" Id="{532baece-3197-078f-07fe-70f16274ef68}">
|
|
<Declaration><![CDATA[VAR
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[Triggered := _fbReleaseAlarm.xReleaseSignal;]]></ST>
|
|
</Implementation>
|
|
</Get>
|
|
</Property>
|
|
</POU>
|
|
</TcPlcObject> |