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#/definitions/master.

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

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

Todo

  • reconnect procedure when device is enabled (reconnect delay)

  • iec104 messages are sent to device only as reaction to system events

  • only “automatic” driver action is reconnect loop

  • new gateway events are generated only as reaction to:
    • receiving iec104 asdu messages

    • change of connection state

  • messages with test flag are ignored

  • time sync loop when device is enabled

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#/definitions/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#/definitions/events/master/gateway/data.

  • …, ‘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#/definitions/events/master/gateway/command.

  • …, ‘interrogation’, <asdu_address>

    Represents received IEC104 interrogation message.

    Source timestamp is None.

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

  • …, ‘counter_interrogation’, <asdu_address>

    Represents received IEC104 counter interrogation message.

    Source timestamp is None.

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

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#/definitions/events/master/system/command.

  • …, ‘interrogation’, <asdu_address>

    Represents request for interrogation (interrogation activation).

    Source timestamp is None.

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

  • …, ‘counter_interrogation’, <asdu_address>

    Represents request for counter interrogation (interrogation activation).

    Source timestamp is None.

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

Slave device#

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

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

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

Todo

  • all events are mapped to/from iec104 messages (only connections is exception)

  • messages with test flag are ignored

  • interrogation deactivation is rejected with UNKNOWN_CAUSE

Buffering#

Todo

  • data buffering
    • indication - single, double

    • measurement - normalized, scaled, floating

  • 2 buffers (one for indications, one for measurements)

  • size of each buffer defined by configuration

  • cyclic buffering

  • data changes with timestamp are added to buffer if master connection is not available

  • immediately after interrogation activation confirmation is sent, buffers are emptied - according to asdu address, data changes are notified with INTERROGATED_STATION cause

  • only one connection receives buffer content

  • buffers are not persisted

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#/definitions/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#/definitions/events/slave/gateway/command.

  • …, ‘interrogation’, <asdu_address>

    Represents received IEC104 interrogation activation message.

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/definitions/events/slave/gateway/interrogation.

  • …, ‘counter_interrogation’, <asdu_address>

    Represents received IEC104 counter interrogation activation message.

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/definitions/events/slave/gateway/counter_interrogation.

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#/definitions/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#/definitions/events/slave/system/command.

  • …, ‘interrogation’, <asdu_address>

    Represents interrogation response message.

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/definitions/events/slave/system/interrogation.

  • …, ‘counter_interrogation’, <asdu_address>

    Represents counter interrogation response message.

    Source timestamp is None.

    Payload is specified by hat-gateway://iec104.yaml#/definitions/events/slave/system/counter_interrogation.

Configurations and event payloads#

---
"$schema": "http://json-schema.org/schema#"
id: "hat-gateway://iec104.yaml#"
definitions:
    master:
        type: object
        required:
            - remote_addresses
            - response_timeout
            - supervisory_timeout
            - test_timeout
            - send_window_size
            - receive_window_size
            - reconnect_delay
            - time_sync_delay
        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:
                "$ref": "hat-gateway://iec104.yaml#/definitions/security"
    slave:
        type: object
        required:
            - local_host
            - local_port
            - remote_hosts
            - response_timeout
            - supervisory_timeout
            - test_timeout
            - send_window_size
            - receive_window_size
        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
            response_timeout:
                type: number
            supervisory_timeout:
                type: number
            test_timeout:
                type: number
            send_window_size:
                type: integer
            receive_window_size:
                type: integer
            buffer:
                type:
                    - integer
                    - "null"
            security:
                "$ref": "hat-gateway://iec104.yaml#/definitions/security"
    events:
        master:
            gateway:
                status:
                    enum:
                        - CONNECTING
                        - CONNECTED
                        - DISCONNECTED
                data:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/data/res"
                command:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/command/res"
                interrogation:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/interrogation/res"
                counter_interrogation:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/counter_interrogation/res"
            system:
                command:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/command/req"
                interrogation:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/interrogation/req"
                counter_interrogation:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/counter_interrogation/req"
        slave:
            gateway:
                connections:
                    type: array
                    items:
                        type: object
                        required:
                            - local
                            - remote
                        properties:
                            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
                command:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/command/req"
                interrogation:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/interrogation/req"
                counter_interrogation:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/counter_interrogation/req"
            system:
                data:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/data/res"
                command:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/command/res"
                interrogation:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/interrogation/res"
                counter_interrogation:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/messages/counter_interrogation/res"
    messages:
        data:
            res:
                type: object
                required:
                    - cause
                    - test
                properties:
                    cause:
                        oneOf:
                          - enum:
                                - PERIODIC
                                - BACKGROUND_SCAN
                                - SPONTANEOUS
                                - REQUEST
                                - REMOTE_COMMAND
                                - LOCAL_COMMAND
                                - INTERROGATED
                          - type: integer
                            description: |
                                other cause in range [0, 63]
                    test:
                        type: boolean
                oneOf:
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/single"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/double"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/step_position"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/bitstring"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/normalized"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/scaled"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/floating"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/binary_counter"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/protection"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/protection_start"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/protection_command"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/data_types/status"
        command:
            req:
                type: object
                required:
                    - cause
                properties:
                    cause:
                        oneOf:
                          - enum:
                                - ACTIVATION
                                - DEACTIVATION
                          - type: integer
                            description: |
                                other cause in range [0, 63]
                oneOf:
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/single"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/double"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/regulating"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/normalized"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/scaled"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/floating"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/bitstring"
            res:
                type: object
                required:
                    - cause
                    - success
                properties:
                    cause:
                        oneOf:
                          - enum:
                                - ACTIVATION_CONFIRMATION
                                - DEACTIVATION_CONFIRMATION
                                - ACTIVATION_TERMINATION
                                - UNKNOWN_TYPE
                                - UNKNOWN_CAUSE
                                - UNKNOWN_ASDU_ADDRESS
                                - UNKNOWN_IO_ADDRESS
                          - type: integer
                            description: |
                                other cause in range [0, 63]
                    success:
                        type: boolean
                oneOf:
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/single"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/double"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/regulating"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/normalized"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/scaled"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/floating"
                    - "$ref": "hat-gateway://iec104.yaml#/definitions/command_types/bitstring"
        interrogation:
            req:
                type: object
                required:
                    - request
                properties:
                    request:
                        type: integer
                        description: |
                            request in range [0, 255]
            res:
                type: object
                required:
                    - status
                    - request
                properties:
                    status:
                        enum:
                            - START
                            - STOP
                            - ERROR
                    request:
                        type: integer
                        description: |
                            request in range [0, 255]
        counter_interrogation:
            req:
                type: object
                required:
                    - request
                    - freeze
                properties:
                    request:
                        type: integer
                        description: |
                            request in range [0, 255]
                    freeze:
                        enum:
                            - READ
                            - FREEZE
                            - FREEZE_AND_RESET
                            - RESET
            res:
                type: object
                required:
                    - status
                    - request
                    - freeze
                properties:
                    status:
                        enum:
                            - START
                            - STOP
                            - ERROR
                    request:
                        type: integer
                        description: |
                            request in range [0, 255]
                    freeze:
                        enum:
                            - READ
                            - FREEZE
                            - FREEZE_AND_RESET
                            - RESET
    data_types:
        single:
            type: object
            required:
                - value
                - quality
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/single"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/indication"
        double:
            type: object
            required:
                - value
                - quality
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/double"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/indication"
        step_position:
            type: object
            required:
                - value
                - quality
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/step_position"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/measurement"
        bitstring:
            type: object
            required:
                - value
                - quality
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/bitstring"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/measurement"
        normalized:
            type: object
            required:
                - value
                - quality
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/normalized"
                quality:
                    oneOf:
                      - type: "null"
                      - "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/measurement"
        scaled:
            type: object
            required:
                - value
                - quality
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/scaled"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/measurement"
        floating:
            type: object
            required:
                - value
                - quality
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/floating"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/measurement"
        binary_counter:
            type: object
            required:
                - value
                - quality
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/binary_counter"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/counter"
        protection:
            type: object
            required:
                - value
                - quality
                - elapsed_time
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/protection"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/protection"
                elapsed_time:
                    type: integer
                    description: |
                        elapsed_time in range [0, 65535]
        protection_start:
            type: object
            required:
                - value
                - quality
                - duration_time
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/protection_start"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/protection"
                duration_time:
                    type: integer
                    description: |
                        duration_time in range [0, 65535]
        protection_command:
            type: object
            required:
                - value
                - quality
                - operating_time
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/protection_command"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/protection"
                operating_time:
                    type: integer
                    description: |
                        operating_time in range [0, 65535]
        status:
            type: object
            required:
                - value
                - quality
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/status"
                quality:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/qualities/measurement"
    command_types:
        single:
            type: object
            required:
                - value
                - select
                - qualifier
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/single"
                select:
                    type: boolean
                qualifier:
                    type: integer
                    description: |
                        qualifier in range [0, 31]
        double:
            type: object
            required:
                - value
                - select
                - qualifier
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/double"
                select:
                    type: boolean
                qualifier:
                    type: integer
                    description: |
                        qualifier in range [0, 31]
        regulating:
            type: object
            required:
                - value
                - select
                - qualifier
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/regulating"
                select:
                    type: boolean
                qualifier:
                    type: integer
                    description: |
                        qualifier in range [0, 31]
        normalized:
            type: object
            required:
                - value
                - select
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/normalized"
                select:
                    type: boolean
        scaled:
            type: object
            required:
                - value
                - select
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/scaled"
                select:
                    type: boolean
        floating:
            type: object
            required:
                - value
                - select
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/floating"
                select:
                    type: boolean
        bitstring:
            type: object
            required:
                - value
            properties:
                value:
                    "$ref": "hat-gateway://iec104.yaml#/definitions/values/bitstring"
    values:
        single:
            enum:
                - "OFF"
                - "ON"
        double:
            enum:
                - "INTERMEDIATE"
                - "OFF"
                - "ON"
                - "FAULT"
        regulating:
            enum:
                - LOWER
                - HIGHER
        step_position:
            type: object
            required:
                - value
                - transient
            properties:
                value:
                    type: integer
                    description: |
                        value in range [-64, 63]
                transient:
                    type: boolean
        bitstring:
            type: array
            description: |
                bitstring encoded as 4 bytes
            items:
                type: integer
        normalized:
            type: number
            description: |
                value in range [-1.0, 1.0)
        scaled:
            type: integer
            description: |
                value in range [-2^15, 2^15-1]
        floating:
            type: number
        binary_counter:
            type: integer
            description: |
                value in range [-2^31, 2^31-1]
        protection:
            enum:
                - "OFF"
                - "ON"
        protection_start:
            type: object
            required:
                - general
                - l1
                - l2
                - l3
                - ie
                - reverse
            properties:
                general:
                    type: boolean
                l1:
                    type: boolean
                l2:
                    type: boolean
                l3:
                    type: boolean
                ie:
                    type: boolean
                reverse:
                    type: boolean
        protection_command:
            type: object
            required:
                - general
                - l1
                - l2
                - l3
            properties:
                general:
                    type: boolean
                l1:
                    type: boolean
                l2:
                    type: boolean
                l3:
                    type: boolean
        status:
            type: object
            required:
                - value
                - change
            properties:
                value:
                    type: array
                    description: |
                        value length is 16
                    items:
                        type: boolean
                change:
                    type: array
                    description: |
                        change length is 16
                    items:
                        type: boolean
    qualities:
        indication:
            type: object
            required:
                - invalid
                - not_topical
                - substituted
                - blocked
            properties:
                invalid:
                    type: boolean
                not_topical:
                    type: boolean
                substituted:
                    type: boolean
                blocked:
                    type: boolean
        measurement:
            type: object
            required:
                - invalid
                - not_topical
                - substituted
                - blocked
                - overflow
            properties:
                invalid:
                    type: boolean
                not_topical:
                    type: boolean
                substituted:
                    type: boolean
                blocked:
                    type: boolean
                overflow:
                    type: boolean
        counter:
            type: object
            required:
                - invalid
                - adjusted
                - overflow
                - sequence
            properties:
                invalid:
                    type: boolean
                adjusted:
                    type: boolean
                overflow:
                    type: boolean
                sequence:
                    type: boolean
        protection:
            type: object
            required:
                - invalid
                - not_topical
                - substituted
                - blocked
                - time_invalid
            properties:
                invalid:
                    type: boolean
                not_topical:
                    type: boolean
                substituted:
                    type: boolean
                blocked:
                    type: boolean
                time_invalid:
                    type: boolean
    security:
        type: object
        required:
            - cert_path
            - key_path
            - verify_cert
            - ca_path
        properties:
            cert_path:
                type: string
            key_path:
                oneOf:
                  - type: "null"
                  - type: string
            verify_cert:
                type: boolean
            ca_path:
                type:
                    - "null"
                    - number

...