|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# Integration test for Multicast Routed GOOSE messages. |
| 4 | +# |
| 5 | +# Author: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de> |
| 6 | +# SPDX-FileCopyrightText: 2025 Institute for Automation of Complex Power Systems, RWTH Aachen University |
| 7 | +# SPDX-License-Identifier: Apache-2.0 |
| 8 | + |
| 9 | +set -e |
| 10 | + |
| 11 | +# Check if user is superuser. |
| 12 | +if [[ "${EUID}" -ne 0 ]]; then |
| 13 | + echo "Please run as root" |
| 14 | + exit 99 |
| 15 | +fi |
| 16 | + |
| 17 | +DIR=$(mktemp -d) |
| 18 | +pushd ${DIR} |
| 19 | + |
| 20 | +function finish { |
| 21 | + popd |
| 22 | + rm -rf ${DIR} |
| 23 | +} |
| 24 | +trap finish EXIT |
| 25 | + |
| 26 | +NUM_SAMPLES=${NUM_SAMPLES:-10} |
| 27 | + |
| 28 | +cat > config.json << EOF |
| 29 | +{ |
| 30 | + "nodes": { |
| 31 | + "infile": { |
| 32 | + "type": "file", |
| 33 | + "uri": "input.dat", |
| 34 | + "signals": [{ "name": "counter" }] |
| 35 | + }, |
| 36 | +
|
| 37 | + "outfile": { |
| 38 | + "type": "file", |
| 39 | + "uri": "output.dat" |
| 40 | + }, |
| 41 | +
|
| 42 | + "goose": { |
| 43 | + "type": "iec61850-8-1", |
| 44 | +
|
| 45 | + "keys": [ |
| 46 | + { |
| 47 | + "id": 1, |
| 48 | + "security": "aes_128_gcm", |
| 49 | + "signature": "none", |
| 50 | + "string": "0123456789ABCDEF" |
| 51 | + } |
| 52 | + ], |
| 53 | +
|
| 54 | + "out": { |
| 55 | + "routed": true, |
| 56 | + "publishers": [ |
| 57 | + { |
| 58 | + "go_cb_ref": "simpleIOGenericIO/LLN0$GO$gcbAnalogValues", |
| 59 | + "data_set_ref": "simpleIOGenericIO/LLN0$AnalogValues", |
| 60 | + "conf_rev": 1, |
| 61 | + "time_allowed_to_live": 500, |
| 62 | + "app_id": 16385, |
| 63 | + "data": [ |
| 64 | + { |
| 65 | + "mms_type": "int32", |
| 66 | + "signal": "counter" |
| 67 | + } |
| 68 | + ] |
| 69 | + } |
| 70 | + ], |
| 71 | + "signals": [ |
| 72 | + { |
| 73 | + "name": "counter", |
| 74 | + "type": "integer" |
| 75 | + } |
| 76 | + ] |
| 77 | + }, |
| 78 | +
|
| 79 | + "in": { |
| 80 | + "routed": true, |
| 81 | + "subscribers": { |
| 82 | + "sub": { |
| 83 | + "go_cb_ref": "simpleIOGenericIO/LLN0$GO$gcbAnalogValues", |
| 84 | + "app_id": 1000, |
| 85 | + "trigger": "change" |
| 86 | + } |
| 87 | + }, |
| 88 | + "signals": [ |
| 89 | + { |
| 90 | + "name": "counter", |
| 91 | + "type": "integer", |
| 92 | + "mms_type": "int32", |
| 93 | + "subscriber": "sub", |
| 94 | + "index": 0 |
| 95 | + } |
| 96 | + ] |
| 97 | + } |
| 98 | + } |
| 99 | + }, |
| 100 | +
|
| 101 | + "paths": [ |
| 102 | + { |
| 103 | + "in": "infile", |
| 104 | + "hooks": [{ |
| 105 | + "type": "cast", |
| 106 | + "new_type": "integer", |
| 107 | + "signals": ["counter"] |
| 108 | + }], |
| 109 | + "out": "goose" |
| 110 | + }, |
| 111 | + { |
| 112 | + "in": "goose", |
| 113 | + "hooks": [{ |
| 114 | + "type": "cast", |
| 115 | + "new_type": "float", |
| 116 | + "signals": ["counter"] |
| 117 | + }], |
| 118 | + "out": "outfile" |
| 119 | + } |
| 120 | + ] |
| 121 | +} |
| 122 | +EOF |
| 123 | + |
| 124 | +villas signal -l ${NUM_SAMPLES} -n counter -r 10 > input.dat |
| 125 | + |
| 126 | +VILLAS_LOG_PREFIX="[node] " \ |
| 127 | +villas node config.json & |
| 128 | + |
| 129 | +# Wait for node to complete |
| 130 | +sleep $((NUM_SAMPLES / 10 + 2)) |
| 131 | + |
| 132 | +kill %% |
| 133 | +wait %% |
| 134 | + |
| 135 | +# Send / Receive data to node |
| 136 | +VILLAS_LOG_PREFIX="[compare] " \ |
| 137 | +villas compare -T input.dat output.dat |
0 commit comments