# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University # SPDX-License-Identifier: Apache-2.0 @include "hook-nodes.conf" stats = 1 paths = ( { in = "signal_node" out = "file_node" hooks = ( { type = "lua" # Enables or disables the use of signal names in the process() function # of the Lua script. If disabled, numeric indices will be used use_names = true # The Lua hook will pass the complete hook configuration to the prepare() # function. So you can add arbitrary settings here which are then # consumed by the Lua script some_setting = "Hello World" this = { is = { nested = 1234 bool_val = true } } # Script mode: we provide a Lua script containing functions # for the individual hook points # Define some or all of the following functions in your Lua script: # # prepare(cfg) Called during initialization with a Lua table which contains # the full hook configuration # start() Called when the node/path is started # # stop() Called when the node/path is stopped # # restart() Called when the node/path is restarted # Falls back to stop() + start() if absent # # process(smp) Called for each sample which is being processed # The sample is passed as a Lua table with the following # fields: # - sequence The sequence number of the sample # - flags The flags field of the sample # - ts_origin The origin timestamp as a Lua table containing # the following keys: # 0: seconds # 1: nanoseconds # - ts_received The receive timestamp a Lua table containing # the following keys: # 0: seconds # 1: nanoseconds # - data The sample data as a Lua table container either # numeric indices or the signal names depending # on the 'use_names' option of the hook # # periodic() Called periodically with the rate of the global 'stats' option script = "../lua/hooks/test.lua" # Expression mode: We provide a mangled signal list including Lua expressions signals = ( { name = "sum", type="float", unit = "V", expression = "smp.data.square * 10" }, # You can access any global variable set by the script { name = "sequence", type="float", unit = "V", expression = "global_var" }, # Here we set a global variable from the periodic handler { name = "temp_aachen", type="float", unit = "°C", expression = "temp_aachen" }, # We can refer to the current time the global Lua variable 't' { name = "sum", type="float", unit = "V", expression = "math.sin(2 * math.pi * f * t)" }, { name = "random", expression = "smp.data.random" } ) }, { type = "print" } ) } )