Skip to content

Latest commit

 

History

History

EventSystem

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

About the "EventSystem" sample

The "EventSystem" extension is an extension that showcases various features of the event system. It uses the "RequestListener" interface to provide the function symbols "SendAnotherMessage," "SendDynamicallyLocalizedMessage", and "RaiseAdditionalAlarm". The "EventLocalizationListener" interface is used to localize the messages with the name "DYNAMICALLY_LOCALIZED_MESSAGE," that are created/sent when the "SendDynamicallyLocalizedMessage" function symbol is called, dynamically at runtime (as opposed to static localizations defined in the "EventSystem.Language.en.json" file). It uses the "AlarmProviderListener" to handle confirmations of the provided alarms, as well as to make use of temporary events, not just persistent events.

First steps:

Example requests

  1. Check whether the "FIRST_MESSAGE" was successfully sent during initialization of the sample extension.

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "ListEvents",
                "filter": [
                    {
                        "comparator": "==",
                        "path": "domain",
                        "value": "EventSystem"
                    },
                    {
                        "logic": "AND"
                    },
                    {
                        "comparator": "==",
                        "path": "name",
                        "value": "FIRST_MESSAGE"
                    }
                ],
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }

    Response:

    {
        "commands": [
            {
                "symbol": "ListEvents",
                "readValue": [
                    {
                        "domain": "EventSystem",
                        "localizedString": "First message. Sent upon initialization of this sample extension.",
                        "name": "FIRST_MESSAGE",
                        "payload": {
                            "name": "FIRST_MESSAGE",
                            "domain": "EventSystem",
                            "params": {},
                            "severity": 1,
                            "timeRaised": "2020-12-28T09:40:03.8830387Z"
                        },
                        "payloadType": 0,
                        "timeReceived": "2020-12-28T09:40:03.8950405Z"
                    }
                ]
            }
        ]
    }
  2. List all events (alarms and messages) of the sample extension

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "ListEvents",
                "filter": [
                    {
                        "comparator": "==",
                        "path": "domain",
                        "value": "EventSystem"
                    }
                ],
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }

    Response:

    {
        "commands": [
            {
                "symbol": "ListEvents",
                "readValue": [
                    {
                        "domain": "EventSystem",
                        "localizedString": "An alarm. If not already confirmed, it can be confirmed by calling the 'ConfirmAlarm' function symbol.",
                        "name": "ALARM_TO_CONFIRM",
                        "payload": {
                            "name": "ALARM_TO_CONFIRM",
                            "domain": "EventSystem",
                            "params": {},
                            "severity": 1,
                            "id": 3,
                            "timeRaised": "2020-12-28T10:32:23.2066268Z",
                            "timeCleared": "2020-12-28T10:32:23.2066268Z",
                            "timeConfirmed": null,
                            "alarmState": 2,
                            "confirmationState": 2
                        },
                        "payloadType": 1,
                        "timeReceived": "2020-12-28T10:32:23.2066268Z"
                    },
                    {
                        "domain": "EventSystem",
                        "localizedString": "First message. Sent upon initialization of this sample extension.",
                        "name": "FIRST_MESSAGE",
                        "payload": {
                            "name": "FIRST_MESSAGE",
                            "domain": "EventSystem",
                            "params": {},
                            "severity": 1,
                            "timeRaised": "2020-12-28T09:40:03.8830387Z"
                        },
                        "payloadType": 0,
                        "timeReceived": "2020-12-28T09:40:03.8950405Z"
                    }
                ]
            }
        ]
    }
  3. Send a message with name "ANOTHER_MESSAGE".

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "EventSystem.SendAnotherMessage",
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }
  4. Send an additional alarm with a new alarm ID.

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "EventSystem.RaiseAdditionalAlarm",
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }
  5. Send a message with name "DYNAMICALLY_LOCALIZED_MESSAGE".

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "EventSystem.SendDynamicallyLocalizedMessage",
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }
  6. Raise a new alarm with a new unique alarm id and name "ALARM_TO_CONFIRM".

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "EventSystem.SendDynamicallyLocalizedMessage",
                "commandOptions": [ "SendErrorMessage" ]
            }
        ]
    }
  7. Confirm a specific alarm instance.

    Request:

    {
        "requestType": "ReadWrite",
        "commands": [
            {
                "symbol": "ConfirmAlarm",
                "writeValue": {
                    "name": "ALARM_TO_CONFIRM",
                    "domain": "EventSystem",
                    "params": {},
                    "severity": 1,
                    "id": 3,
                    "timeRaised": "2020-12-28T10:32:23.2066268Z",
                    "timeCleared": "2020-12-28T10:32:23.2066268Z",
                    "timeConfirmed": null,
                    "alarmState": 2,
                    "confirmationState": 2
                },
                "commandOptions": [ "SendErrorMessage", "SendWriteValue" ]
            }
        ]
    }