Das Visualisierungselement Alarmtabelle kann zur Laufzeit Informationen aus der Visualisierung in eine Applikationsvariable schreiben. Diese Variable kann programmatisch ausgewertet werden.
Die Informationen zu einem Alarm, wie beispielsweise Alarmgruppe, Alarm-ID, Zeitstempel von Statusübergängen, Latch-Variablen, Meldungstexte, erhalten Sie aus der Struktur AlarmSelectionInfo (Bibliothek VisuElemsAlarm) .
Tragen Sie dazu in der Eigenschaft Selektion - Variable für Information zum selektierten Alarm der Alarmtabelle eine Variable vom Typ AlarmSelectionInfo ein. Diese Variable verwenden Sie dann in der Applikation, beispielsweise wie folgt:
-
Fügen Sie eine neue POU PRG_VISU hinzu
-
Fügen Sie die POU PRG_VISU zur VISU_TASK hinzu
-
Öffnen Sie die POU PRG_VISU im Editor und fügen Sie nachfolgende Programmzeilen ein.
Deklaration
PROGRAM PRG_VISU VAR alarmSelectionInfoDefault : AlarmSelectionInfoDefault; sLastTimestampDate : STRING; sLastTimestampTime : STRING; sLatch1 : STRING; sLatch2 : STRING; wsMessage1 : WSTRING := "No selection"; wsMessage2 : WSTRING := "No selection"; pInt : POINTER TO INT; xInit: BOOL := TRUE; pString : POINTER TO STRING; cbsFormattedValueLatch1 : CharBufferString(uiBufferSize := 0, stringType := TYPE_CLASS.TYPE_STRING); cbsFormattedValueLatch2 : CharBufferString(uiBufferSize := 0, stringType := TYPE_CLASS.TYPE_STRING); abyLocalBufferLatch1 : ARRAY[0..LENGTH] OF BYTE; abyLocalBufferLatch2 : ARRAY[0..LENGTH] OF BYTE; iPrevSelectionChangedCounter: INT; END_VAR VAR CONSTANT // The length of the string of the local CharBufferString instance LENGTH : INT := 80 * 2; END_VARImplementierung
IF xInit THEN cbsFormattedValueLatch1.Init(pBuffer:=ADR(abyLocalBufferLatch1), uiBufferSize:=INT_TO_UINT(LENGTH + 1), stringType:=TYPE_CLASS.TYPE_STRING); cbsFormattedValueLatch2.Init(pBuffer:=ADR(abyLocalBufferLatch2), uiBufferSize:=INT_TO_UINT(LENGTH + 1), stringType:=TYPE_CLASS.TYPE_STRING); xInit := FALSE; END_IF IF alarmSelectionInfoDefault.AlarmSelectionInfo.iSelectionChangedCounter <> iPrevSelectionChangedCounter THEN // Format Date/Time as string sLastTimestampDate := AlarmManager.FormatDate(alarmSelectionInfoDefault.AlarmSelectionInfo.timeStampLast, AlarmManager.AlarmGlobals.g_sDateFormat); sLastTimestampTime := AlarmManager.FormatTime(alarmSelectionInfoDefault.AlarmSelectionInfo.timeStampLast, AlarmManager.AlarmGlobals.g_sTimeFormat); // Retrieve latch variables as string cbsFormattedValueLatch1.FromString(''); pString := FormatTypedValue(alarmSelectionInfoDefault.AlarmSelectionInfo.paLatchVariables^[0], cbsFormattedValueLatch1); STU.StrCpyA(ADR(sLatch1), SIZEOF(sLatch1), pString); cbsFormattedValueLatch2.FromString(''); pString := FormatTypedValue(alarmSelectionInfoDefault.AlarmSelectionInfo.paLatchVariables^[1], cbsFormattedValueLatch2); STU.StrCpyA(ADR(sLatch2), SIZEOF(sLatch2), pString); // Retrieve messages STU.StrCpyW(ADR(wsMessage1), SIZEOF(wsMessage1), alarmSelectionInfoDefault.AlarmSelectionInfo.papwsAlarmMessages^[0]); STU.StrCpyW(ADR(wsMessage2), SIZEOF(wsMessage2), alarmSelectionInfoDefault.AlarmSelectionInfo.papwsAlarmMessages^[1]); iPrevSelectionChangedCounter := alarmSelectionInfoDefault.AlarmSelectionInfo.iSelectionChangedCounter; END_IF