i4connected Knowledgebase

Events script list

Abstract

Learn how to set up Events triggered on basis of a Script, in your i4connected project, by reading this article.

The scope of present article is to describe the Events script list. This panel is accessed by clicking the Alarms tile, from the Vied Device panel.

Event_script_list.jpg

The Event Script List panel

The Event Script List panel allows the user to organise the following operations:

Viewing and refreshing the Event scripts list

The Event script list panel allows the user to see the device's alarms conditions (events scripts), listed in the main area of the panel, in a card-based scrollable list.

Each event script card display information upon the Event and the used formula.

Event_script_card.jpg

The Event Script card

By clicking the Refresh toolbar button, the user can manually reload / update the Event script list.

refresh_script_list.jpg

The Refresh button

Adding a new Event Script

The list of Event scripts of a Device can be updated by adding new Event scripts. By clicking the Add toolbar button, the Add alarm condition panel is opened.

Add_alarm_condition.jpg

The Add alarm condition panel

The user must provide the required (and optional) alarm condition settings and click Save to add the alarm condition to the device's event scripts list. The alarm condition settings are the following:

  • Event - The actual event that will be triggered when the current condition is satisfied. Clicking on the Event button will open the Events panel, which allows the user to select an existing event or add a new one.

  • Parameters - Input signals that can be used in the formula to calculate the expected values. A new parameter can be added by clicking the Add parameter button which opens the Signal List panel. In this view, all the Signals assigned to the current Device are listed. The user can select a signal to act as input for the formula. The parameters can be either a standard signal or a virtual signal. Multiple parameters of mixed types (standard signals and virtual signals) are supported.

    Once a parameter is defined, it will be displayed in the table below the Add parameter button. Here the user is able to set the name of the parameter (which will be used inside the formula) and input a test value, allowing the user to test the alarm condition formula.

    Parameters_area.jpg

    The Parameters area

  • Formula - The expression that defines the alarm condition. The expression can use input parameters defined in the Parameters options. The expression can be a simple on line calculation or can be a complex, multi-line C# function enclosed in curly brackets {}, in which case a return function is required. The advantage of using complex C# expressions is the availability of variables, loops, etc.

    The value returned by the expression must always be boolean! The alarm condition is satisfied only when the formula's result is True.

    Simple expression example:

    in1 > 10

    Multi-line expression example:

    var calculatedValue = in1 + 10;
    if (calculatedValue > 20) {
        return true;
    } else {
        return false;
    }

    When using parameters in your expression, you are not limited only to the value of that parameter. Several properties of the signal used as input parameter can also be used inside the expression:

    • Delta (double), ex: in1.Double

    • Interpolated (bool), ex: in1.Interpolated

    • Plausible (bool), ex: in1.Plausible

    • Timestamp (DateTime), ex: in1.Timestamp

    • Value (object), ex: in1.Value

    • Counter (double), ex: in1.Counter

    For example:

    var signalDelta = in1.Delta;
    if (signalDelta > 20) {
        return true;
    } else {
        return false;
    }

    The value returned by the expression must always be boolean! The alarm condition is satisfied only when the formula's result is True.

    The formula can be tested using the Calculate test result button. This will use the parameter's test value as input value and the result will be listed below.

    Formula_area.jpg

    The Formula area

  • Computation Mode - The method of using the parameter values.

    • Historical script - uses the values already existing in the database. The alarm condition is evaluated whenever a timestamp match is found in the database and uses the corresponding value for the input parameter. The maximum alarm condition evaluation rate is limited to 15 minutes.

    • Online script - uses the online values of the input parameters. The alarm condition is evaluated whenever the input parameter signal is updated, and the new value of the input parameter is used in the alarm condition 's formula.

Editing an Event scripts

Clicking on an alarm condition in the Event script list opens the Edit alarm condition panel, allowing the user to change the alarm condition settings.

Edit_script_list.jpg

The Edit Alarm condition panel

Deleting an Event script

The Edit alarm condition panel provides the user with the possibility to remove the entity, by clicking the Delete toolbar button. In the Delete event script panel the user is requested to manually fill in the deletion confirmation code. To proceed with the deletion operation the user can click the Delete button.

Delete_script_list.jpg

The Delete event script panel