IEC 60870-5-104 devices

Together with IEC104 specific events, generic enable and running events are also supported.

Supported data types (<data_type>):

  • ‘single’

  • ‘double’

  • ‘step_position’

  • ‘bitstring’

  • ‘normalized’

  • ‘scaled’

  • ‘floating’

  • ‘binary_counter’

  • ‘protection’

  • ‘protection_start’

  • ‘protection_command’

  • ‘status’

Supported command types (<command_type>):

  • ‘single’

  • ‘double’

  • ‘regulating’

  • ‘normalized’

  • ‘scaled’

  • ‘floating’

  • ‘bitstring’

Master device

IEC104 master device configuration is specified by hat-gateway://iec104.yaml#/$defs/master.

According to gateway specification, all IEC104 master device event types have prefix:

'gateway', <gateway_name>, 'iec104_master', <device_name>, <source>, ...

When IEC104 master device is enabled, connection establishment loop is started. Device will try to connect to one of configured remote slave devices in order defined by configuration. Once connection to remote slave is established, connection loop is temporary paused and new connection’s status is monitored. If connection is broken, connection loop is resumed. Changes in connection status are notified as gateway ‘status’ events.

Implementation of IEC104 master device is based on transparent mapping of IEC104 request/response messages to system/gateway events. Supported IEC104 messages:

  • Data response

    When master receives IEC104 data response message, it will generate gateway ‘data’ event.

  • Command request

    When master receives system ‘command’ event, it will send IEC104 command request message.

  • Command response

    When master receives IEC104 command response message, it will generate gateway ‘command’ event.

  • Interrogate request

    When master receives system ‘interrogate’ event, it will send IEC104 interrogate request message.

  • Interrogate response

    When master receives IEC104 interrogate response message, it will generate gateway ‘interrogate’ event.

  • Counter interrogate request

    When master receives system ‘counter_interrogate’ event, it will send IEC104 counter interrogate request message.

  • Counter interrogate response

    When master receives IEC104 counter interrogate response message, it will generate gateway ‘counter_interrogate’ event.

In addition to bidirectional mapping of messages/events, IEC104 master device provides possibility of time synchronization. If configured, once connection to remote slave is established, master will periodically send IEC104 clock sync messages with current system time.

Gateway events

Events registered by gateway have event type starting with:

'gateway', <gateway_name>, 'iec104_master', <device_name>, 'gateway', ...

Available gateway events are:

  • …, ‘status’

    Represents change in connection status. Upon enabling device, new CONNECTING status should be registered. Once device is disabled, DISCONNECTED status should be assumed regardless of last registered status event (registration of DISCONNECTED status event during device disabling is mandatory but should not be relied upon).

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/master/gateway/status.

  • …, ‘data’, <data_type>, <asdu_address>, <io_address>

    Represents received IEC104 data message.

    Source timestamp is dependent on existence of IEC104 time. If IEC104 time is not available, source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/master/gateway/data/res.

  • …, ‘command’, <command_type>, <asdu_address>, <io_address>

    Represents received IEC104 command message.

    Source timestamp is dependent on existence of IEC104 time. If IEC104 time is not available, source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/master/gateway/command/res.

  • …, ‘interrogation’, <asdu_address>

    Represents received IEC104 interrogation message.

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/master/gateway/interrogation/res.

  • …, ‘counter_interrogation’, <asdu_address>

    Represents received IEC104 counter interrogation message.

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/master/gateway/counter_interrogation/res.

System events

Events registered by other Hat components, which are consumed by gateway, have event type starting with:

'gateway', <gateway_name>, 'iec104_master', <device_name>, 'system', ...

Available system events are:

  • …, ‘command’, <command_type>, <asdu_address>, <io_address>

    Represents request for command execution.

    Source timestamp is dependent on existence of IEC104 time. If IEC104 time is not available, source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/master/system/command/req.

  • …, ‘interrogation’, <asdu_address>

    Represents request for interrogation (interrogation activation).

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/master/system/interrogation/req.

  • …, ‘counter_interrogation’, <asdu_address>

    Represents request for counter interrogation (interrogation activation).

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/master/system/counter_interrogation/req.

Slave device

IEC104 slave device configuration is specified by hat-gateway://iec104.yaml#/$defs/slave.

According to gateway specification, all IEC104 slave device event types have prefix:

'gateway', <gateway_name>, 'iec104_slave', <device_name>, <source>, ...

IEC104 slave device provides implementation of IEC104 slave which accepts multiple parallel remote master connections. If configured, allowed master connections can be filtered based on remote master IP address. Change of active master connections list is trigger for registration of new gateway ‘connection’ event containing current list’s state.

IEC104 slave device is configured with list of available data. Once device is enabled, device will query last system ‘data’ events corresponding to configured data. This local cache is continuously updated with latest data states based on received system ‘data’ events. All remote masters are notified with IEC104 data messages each time locally cached data state is changed. When slave receives IEC104 interrogation or counter interrogation message, it will immediately respond with IEC104 interrogation/data messages based on current state of local data cache. Interrogation deactivation is not supported (slave responds with negative confirmation).

In addition to local cache of last data states, IEC104 slave device can be configured with arbitrary number of circular data buffers, each configured with limited size. Each data can be associated with single buffer. When system ‘data’ event, associated with configured data, is received, together with local cache update, data change is appended to the end of configured data buffer. Once buffer is full, new changes will overwrite oldest changes. Data change is removed from buffer when at least one remote master acknowledges delivery of IEC104 data message associated with data change (delivery confirmation is based on IEC104 APCI sequence numbers). When remote master connect to slave and new connection is established, slave will immediately send IEC104 data messages for each buffered data change. Slave’s initial query of system ‘data’ events is not buffered.

In addition to sending IEC104 data messages and processing IEC104 interrogation and counter interrogation requests, slave supports IEC104 command messages. Command messages are transparently bidirectionally mapped to ‘command’ events. Each time slave receives IEC104 command request, it will register new gateway ‘command’ event which contains unique identification of master connection which sent command request. When new system ‘command’ event is received, it must contain identification of master connection which will be used for sending associated IEC104 command response.

Gateway events

Events registered by gateway have event type starting with:

'gateway', <gateway_name>, 'iec104_slave', <device_name>, 'gateway', ...

Available gateway events are:

  • …, ‘connections’

    Represents change in list of all active connections. When device is disabled, empty list of connections is assumed (when device is disabled, new connections event should be registered but user should not depend on this behaviour).

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/slave/gateway/connections.

  • …, ‘command’, <command_type>, <asdu_address>, <io_address>

    Represents received IEC104 command message.

    Source timestamp is dependent on existence of IEC104 time. If IEC104 time is not available, source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/slave/gateway/command.

System events

Events registered by other Hat components, which are consumed by gateway, have event type starting with:

'gateway', <gateway_name>, 'iec104_slave', <device_name>, 'system', ...

Available system events are:

  • …, ‘data’, <data_type>, <asdu_address>, <io_address>

    Represents data change.

    Source timestamp is dependent on existence of IEC104 time. If IEC104 time is not available, source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/slave/system/data.

  • …, ‘command’, <command_type>, <asdu_address>, <io_address>

    Represents command response.

    Source timestamp is dependent on existence of IEC104 time. If IEC104 time is not available, source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/$defs/events/slave/system/command.

Configurations and event payloads

$schema: "https://json-schema.org/draft/2020-12/schema"
$id: "hat-gateway://iec104.yaml"
$defs:
    master:
        type: object
        required:
            - remote_addresses
            - response_timeout
            - supervisory_timeout
            - test_timeout
            - send_window_size
            - receive_window_size
            - reconnect_delay
            - time_sync_delay
            - security
        properties:
            remote_addresses:
                type: array
                items:
                    type: object
                    required:
                        - host
                        - port
                    properties:
                        host:
                            type: string
                        port:
                            type: integer
            response_timeout:
                type: number
            supervisory_timeout:
                type: number
            test_timeout:
                type: number
            send_window_size:
                type: integer
            receive_window_size:
                type: integer
            reconnect_delay:
                type: number
            time_sync_delay:
                type:
                    - "null"
                    - number
            security:
                oneOf:
                  - type: "null"
                  - $ref: "hat-gateway://iec104.yaml#/$defs/security"
    slave:
        type: object
        required:
            - local_host
            - local_port
            - remote_hosts
            - max_connections
            - response_timeout
            - supervisory_timeout
            - test_timeout
            - send_window_size
            - receive_window_size
            - security
            - buffers
            - data
        properties:
            local_host:
                type: string
            local_port:
                type: integer
            remote_hosts:
                type:
                    - array
                    - "null"
                description: |
                    if null, all remote hosts are allowed
                items:
                    type: string
            max_connections:
                type:
                    - "null"
                    - integer
            response_timeout:
                type: number
            supervisory_timeout:
                type: number
            test_timeout:
                type: number
            send_window_size:
                type: integer
            receive_window_size:
                type: integer
            security:
                oneOf:
                  - type: "null"
                  - $ref: "hat-gateway://iec104.yaml#/$defs/security"
            buffers:
                type: array
                items:
                    type: object
                    required:
                        - name
                        - size
                    properties:
                        name:
                            type: string
                        size:
                            type: integer
            data:
                type: array
                items:
                    type: object
                    required:
                        - data_type
                        - asdu_address
                        - io_address
                        - buffer
                    properties:
                        data_type:
                            enum:
                                - SINGLE
                                - DOUBLE
                                - STEP_POSITION
                                - BITSTRING
                                - NORMALIZED
                                - SCALED
                                - FLOATING
                                - BINARY_COUNTER
                                - PROTECTION
                                - PROTECTION_START
                                - PROTECTION_COMMAND
                                - STATUS
                        asdu_address:
                            type: integer
                        io_address:
                            type: integer
                        buffer:
                            type:
                                - "null"
                                - string
    events:
        master:
            gateway:
                status:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/master/gateway/status"
                data:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/master/gateway/data"
                command:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/master/gateway/command"
                interrogation:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/master/gateway/interrogation"
                counter_interrogation:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/master/gateway/counter_interrogation"
            system:
                command:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/master/system/command"
                interrogation:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/master/system/interrogation"
                counter_interrogation:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/master/system/counter_interrogation"
        slave:
            gateway:
                connections:
                    $ref: "hat-gateway://iec104.yaml#/$defs/messages/connections"
                command:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/slave/gateway/command"
            system:
                data:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/slave/system/data"
                command:
                    $ref: "hat-gateway://iec101.yaml#/$defs/events/slave/system/command"
    messages:
        connections:
            type: array
            items:
                type: object
                required:
                    - connection_id
                    - local
                    - remote
                properties:
                    connection_id:
                        type: integer
                    local:
                        type: object
                        required:
                            - host
                            - port
                        properties:
                            host:
                                type: string
                            port:
                                type: integer
                    remote:
                        type: object
                        required:
                            - host
                            - port
                        properties:
                            host:
                                type: string
                            port:
                                type: integer
    security:
        type: object
        required:
            - cert_path
            - key_path
            - verify_cert
            - ca_path
        properties:
            cert_path:
                type: string
            key_path:
                type:
                    - "null"
                    - string
            verify_cert:
                type: boolean
            ca_path:
                type:
                    - "null"
                    - string
            strict_mode:
                type: boolean
            renegotiate_delay:
                type:
                    - "null"
                    - number