# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
# SPDX-License-Identifier: Apache-2.0


nodes = {
    goose = {
        type = "iec61850-8-1"

        out = {
            # Ethernet interface to publish on
            interface = "lo"

            # Array of goose publisher definitions
            publishers = (
                {
                    # Mandatory GOOSE publisher meta data
                    go_id = "AA1J1Q01A3LD0/LLN0.gcbdata"
                    go_cb_ref = "AA1J1Q01A3LD0/LLN0$GO$gcbdata"
                    data_set_ref = "AA1J1Q01A3LD0/LLN0$data"
                    dst_address = "01:0c:cd:01:00:00"
                    app_id = 2
                    conf_rev = 100
                    time_allowed_to_live = 11000

                    # Payload description with either constant data or values from a signal
                    data = (
                        {
                            # Mandatory MMS type
                            mms_type = "boolean"

                            # Name of the signal in the array below
                            signal = "ABB_cascade_state"
                        },
                        {
                            # Mandatory MMS type
                            mms_type = "bitstring"

                            # Type meta data
                            mms_bitstring_size = 13

                            # Constant value
                            value = 2048
                        }
                    )
                },
                {
                    go_id = "AA1J1Q01A3LD0/LLN0.gcbDataset_1"
                    go_cb_ref = "AA1J1Q01A3LD0/LLN0$GO$gcbDataset_1"
                    data_set_ref = "AA1J1Q01A3LD0/LLN0$Dataset_1"
                    dst_address = "01:0c:cd:01:00:01"
                    app_id = 1
                    conf_rev = 300
                    time_allowed_to_live = 22000
                    data = (
                        {
                            mms_type = "boolean"
                            signal = "ABB_cascade_state"
                        },
                        {
                            mms_type = "bitstring"
                            mms_bitstring_size = 13
                            value = 2048
                        },
                        {
                            mms_type = "bitstring"
                            mms_bitstring_size = 2
                            value = 0
                        },
                        {
                            mms_type = "bitstring"
                            mms_bitstring_size = 13
                            value = 2048
                        },
                        {
                            mms_type = "bitstring"
                            mms_bitstring_size = 13
                            value = 2048
                        },
                        {
                            mms_type = "bitstring"
                            mms_bitstring_size = 2
                            value = 0
                        }
                    )
                }
            )
            signals = (
                {
                    # The signal name used to identify the signal in a publishers data field
                    name = "ABB_cascade_state"
                    type = "boolean"
                }
            )
        }

        in = {
            # Ethernet interface to listen on
            interface = "lo"

            # Use the goose timestamp for a sample
            with_timestamp = true

            # List of named subscriber definitions
            subscribers = {
                relay = {
                    # Mandatory GoCbRef
                    go_cb_ref = "AA1J1Q01A3LD0/LLN0$GO$gcbdata"

                    # Optional filter by packet destination MAC address
                    dst_address = "01:0c:cd:01:00:00"

                    # Optional filter by AppID
                    app_id = 2

                    # Optional trigger specification (either "always" or "change")
                    #
                    # "always" = emit an updated sample for each incoming GOOSE message
                    # "change" = only emit an updated sample when SqNum is 0
                    trigger = "change"
                }
            }

            signals = (
                {
                    name = "ABB_relay_state"
                    type = "boolean"

                    # Mandatory MmsType specification
                    mms_type = "boolean"

                    # Mandatory subscriber name
                    subscriber = "relay"

                    # Mandatory index within the received vector of GOOSE values
                    index = 0
                },
                {
                    name = "ABB_relay_state_meta_bitset"
                    type = "integer"
                    mms_type = "bitstring"
                    subscriber = "relay"
                    index = 1
                }
            )
        }
    }
}
