Skip to main content

Creating a Visualization with an Alarm Table

In the following instructions, the Alarm Table visualization element is configured as an example.

For more information, see the following: Defining an Alarm Group and Alarms

Configuration

Requirement: The AG_PartsShortage alarm group and the AC_PartsShortage alarm class are defined in your project.

  1. Add a visualization below your application.

    1. Select the application and click the Add ObjectVisualization command.

    2. Specify the name as VIS_PartsShortage.

  2. Open the visualization editor.

  3. Drag the Alarm Table element from the Alarm Manager category into the visualization editor and open the properties view of the element.

  4. Configure the alarm table as follows.

    1. In the Element name property, in the Value column, specify the name AT_PartsShortage.

    2. Configuration of the Alarm groups visualization element property:

      1. In the Alarm configurationAlarm groups property, click in the corresponding value cell.

        The Selected Alarm Group dialog opens.

      2. Clear the All option and select the AG_PartsShortage alarm group.

      3. Click the _visu_img_add_selected_alarm_group.png button to add the group to the Selected Alarm Group list.

      4. Click OK to confirm the configuration.

    3. Configuration of the Alarm classes visualization element property:

      1. In the Alarm configurationAlarm classes property, define the alarm classes which you want to visualize. Click into the value field.

        In the Alarm configurationAlarm classes property, click in the corresponding value cell.

        The Select Alarm Class dialog opens.

      2. Clear the All option and select the AC_PartsShortage alarm class.

      3. Click the _visu_img_add_selected_alarm_group.png button to add the alarm class to the selected alarm classes.

      4. Click OK to confirm the configuration.

    4. Configuration of a column:

      1. In the Columns property, click the Create New button.

        Column [2] is available. The new column with the name Bitmap is listed in the visualization editor.

      2. In the Type of data property, select the State value for column [2].

        In the table, the column is given the new default heading State.

      3. In the Column header property, specify the name Parts Shortage State.

        Column [2] is renamed.

    5. Configuration of the Selection visualization element property:

      1. In the Selection color property, select the color Green in the Value column.

        At runtime, the table cells can be selected by the visualization user. These then turn green.

    6. Configuration of the Control variables visualization element property:

      1. In your application code, declare the bQuitAlarm control variable.

      2. In the Acknowledge selected property, specify the PLC_PRG.bQuitAlarm variable in the value cell.

    Configured properties

    _visu_img_alarm_table_porperties.png

Supplementing an alarm visualization with controls

The visualization user needs controls to operate the alarm visualization. When programming, you can get support from the Alarm Table Wizard. The command which calls the wizard is available only when you have selected an alarm table in the visualization.

  1. In the visualization editor, select the alarm table element.

  2. In the context menu, click the Insert Elements for Alarm Acknowledgement command.

    The Alarm Table Wizard dialog opens.

  3. Click OK to accept all settings.

    The Acknowledge selected, Acknowledge all visible, History, and Freeze scrolling position buttons are added. The elements have a complete input configuration.

    _visu_img_alarm_table_controls.png

Evaluating Alarm Information in the Program Code

The Alarm Table visualization element can write information from the visualization to an application variable at runtime. This variable can be evaluated programmatically.

You get information about an alarm (for example: alarm group, alarm ID, timestamp of state transitions, latch variables, message texts) from the structure AlarmSelectionInfo (VisuElemsAlarm library).

To do this, in the SelectionVariable for information about selected alarm property of the alarm table, specify a variable of type AlarmSelectionInfo. Then use the variable in the application as follows:

  1. Add a new PRG_VISU POU.

  2. Add the PRG_VISU POU to VISU_TASK.

  3. Open the PRG_VISU POU in the editor and insert the following program lines.

    Declaration

    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_VAR                        

    Implementation

    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