mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
port large parts of VILLASnode to C++ and fix tests alongside
This commit is contained in:
parent
6adcd8cf92
commit
784e970bfe
440 changed files with 14581 additions and 9425 deletions
|
@ -101,9 +101,13 @@ test:cppcheck:
|
|||
--error-exitcode=1
|
||||
--quiet
|
||||
--inline-suppr
|
||||
--enable=warning,performance,portability,information,missingInclude
|
||||
--enable=warning,performance,portability,missingInclude
|
||||
--std=c++11
|
||||
--suppress=noValidConfiguration
|
||||
-U '_MSC_VER;_WIN32;_M_ARM'
|
||||
-U '_MSC_VER;_WIN32;_M_AMD64;_M_X64'
|
||||
-U '_MSC_FULL_VER;_MSC_VER'
|
||||
-U '_MSC_BUILD;_MSC_VER'
|
||||
-I include
|
||||
-I common/include
|
||||
src/ lib/ tests/unit/ | tee cppcheck.log
|
||||
|
@ -147,9 +151,13 @@ test:integration:
|
|||
paths:
|
||||
- build/tests/integration/
|
||||
services:
|
||||
- eclipse-mosquitto
|
||||
- rabbitmq:3.8
|
||||
- redis
|
||||
- name: eclipse-mosquitto:2.0
|
||||
alias: mosquitto
|
||||
command: [ mosquitto, -c, /mosquitto-no-auth.conf ]
|
||||
- name: rwthacs/rabbitmq
|
||||
alias: rabbitmq
|
||||
- name: redis:6.2
|
||||
alias: redis
|
||||
tags:
|
||||
- docker
|
||||
needs:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Main CMakeLists.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
@ -28,7 +28,7 @@ project(villas-node
|
|||
|
||||
# Some more project settings
|
||||
set(PROJECT_AUTHOR "Steffen Vogel")
|
||||
set(PROJECT_COPYRIGHT "2014-2020, Institute for Automation of Complex Power Systems, RWTH Aachen University")
|
||||
set(PROJECT_COPYRIGHT "2014-2021, Institute for Automation of Complex Power Systems, RWTH Aachen University")
|
||||
set(PROJECT_HOMEPAGE_URL "https://www.fein-aachen.org/projects/villas-node/")
|
||||
|
||||
# Several CMake settings/defaults
|
||||
|
@ -243,8 +243,8 @@ if(WITH_TESTS)
|
|||
endif()
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/villas/node/config.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/villas/node/config.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/villas/node/config.hpp.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/villas/node/config.hpp
|
||||
)
|
||||
|
||||
# Show feature summary
|
||||
|
|
|
@ -34,7 +34,7 @@ User documentation is available here: <https://villas.fein-aachen.org/doc/node.h
|
|||
|
||||
## Copyright
|
||||
|
||||
2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
#include <iostream>
|
||||
#include <atomic>
|
||||
|
||||
#include <villas/node/config.h>
|
||||
#include <villas/node.h>
|
||||
#include <villas/pool.h>
|
||||
#include <villas/sample.h>
|
||||
#include <villas/shmem.h>
|
||||
#include <villas/node/config.hpp>
|
||||
#include <villas/node.hpp>
|
||||
#include <villas/pool.hpp>
|
||||
#include <villas/sample.hpp>
|
||||
#include <villas/shmem.hpp>
|
||||
#include <villas/colors.hpp>
|
||||
#include <villas/tool.hpp>
|
||||
#include <villas/log.hpp>
|
||||
|
@ -71,8 +71,8 @@ protected:
|
|||
{
|
||||
int ret, readcnt, writecnt, avail;
|
||||
|
||||
struct shmem_int shm;
|
||||
struct shmem_conf conf = {
|
||||
struct ShmemInterface shm;
|
||||
struct ShmemConfig conf = {
|
||||
.polling = 0,
|
||||
.queuelen = DEFAULT_SHMEM_QUEUELEN,
|
||||
.samplelen = DEFAULT_SHMEM_SAMPLELEN
|
||||
|
@ -91,7 +91,7 @@ protected:
|
|||
if (ret < 0)
|
||||
throw RuntimeError("Failed to open shared-memory interface");
|
||||
|
||||
struct sample *insmps[vectorize], *outsmps[vectorize];
|
||||
struct Sample *insmps[vectorize], *outsmps[vectorize];
|
||||
|
||||
while (!stop) {
|
||||
readcnt = shmem_int_read(&shm, insmps, vectorize);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
|||
Subproject commit 06bd16a965a494ccfd4d69ab74a5737c8cb1328c
|
||||
Subproject commit 851b7a454021711af55f253cc05feb972067da74
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# CMakeLists.txt.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"hugepages": 0,
|
||||
"http": {
|
||||
"htdocs": "/usr/share/villas/node/web"
|
||||
"port": 80
|
||||
},
|
||||
"nodes": {
|
||||
"sig": {
|
||||
|
|
|
@ -21,7 +21,6 @@ logging = {
|
|||
}
|
||||
|
||||
http = {
|
||||
htdocs = "/villas/web/" # Root directory of internal webserver
|
||||
port = 80 # Port for HTTP connections
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -33,7 +33,7 @@
|
|||
@include "global.conf"
|
||||
|
||||
# An example node. Define multiple nodes in the "nodes" dictionary
|
||||
@include "nodes/signal_generator.conf"
|
||||
@include "nodes/socket.conf"
|
||||
|
||||
# A list of example paths. Define multiple paths by appending them to the "paths" list.
|
||||
#@include "paths.conf"
|
||||
@include "paths.conf"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -53,6 +53,5 @@ logging = {
|
|||
http = {
|
||||
enabled = true, # Do not listen on port if true
|
||||
|
||||
htdocs = "/villas/web/socket/", # Root directory of internal webserver
|
||||
port = 80 # Port for HTTP connections
|
||||
}
|
||||
|
|
19
etc/examples/hooks/limit_value.conf
Normal file
19
etc/examples/hooks/limit_value.conf
Normal file
|
@ -0,0 +1,19 @@
|
|||
@include "hook-nodes.conf"
|
||||
|
||||
paths = (
|
||||
{
|
||||
in = "signal_node"
|
||||
out = "file_node"
|
||||
|
||||
hooks = (
|
||||
{
|
||||
type = "limit_value"
|
||||
|
||||
min = -0.5
|
||||
max = 0.5
|
||||
|
||||
signals = [ "sine" ]
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
|
@ -11,7 +11,7 @@ paths = (
|
|||
|
||||
output = "print_output_file.log"
|
||||
format = "villas.human"
|
||||
prefix = "[file_node] "
|
||||
# prefix = "[file_node] " # prefix and output are exclusive settings!
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
30
etc/examples/nodes/signal.v2.conf
Normal file
30
etc/examples/nodes/signal.v2.conf
Normal file
|
@ -0,0 +1,30 @@
|
|||
nodes = {
|
||||
signal_node = {
|
||||
type = "signal.v2",
|
||||
|
||||
rate = 10.0
|
||||
realtime = true, # Wait between emitting each sample
|
||||
limit = 1000, # Only emit 1000 samples, then stop
|
||||
monitor_missed = true # Count and warn about missed steps
|
||||
|
||||
in = {
|
||||
signals = (
|
||||
{ name = "sine1", signal = "sine", amplitude = 123.456, frequency = 10, offset = 1.0 },
|
||||
{ name = "sine2", signal = "sine", amplitude = 12.456, frequency = 20, offset = 10.0 },
|
||||
{ name = "sine3", signal = "sine", amplitude = 2, frequency = 1, offset = 100.0 },
|
||||
{ name = "random1", signal = "random", amplitude = 2, stddev = 2, offset = 13.0 },
|
||||
{ name = "pulse1", signal = "pulse", frequency = 1.0, pulse_width = 1, pulse_high = 100, pulse_low = 50 }
|
||||
)
|
||||
}
|
||||
},
|
||||
signal_node2 = {
|
||||
type = "signal.v2",
|
||||
|
||||
in = {
|
||||
signals = {
|
||||
count = 8,
|
||||
signal = "mixed"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ nodes = {
|
|||
|
||||
http = {
|
||||
port = 8080
|
||||
htdocs = "/villas/contrib/websocket/"
|
||||
ssl_cert = "/etc/ssl/certs/mycert.pem"
|
||||
ssl_private_key= "/etc/ssl/private/mykey.pem"
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ paths = (
|
|||
enabled = true, # Enable this path (default: true)
|
||||
reverse = true, # Setup a path in the reverse direction as well (default: false)
|
||||
|
||||
in = "acs", # Name of the node we receive messages from (see node dictionary)
|
||||
out = "sintef", # Name of the node we send messages to.
|
||||
in = "udp_node", # Name of the node we receive messages from (see node dictionary)
|
||||
out = "ethernet_node", # Name of the node we send messages to.
|
||||
|
||||
rate = 10.0 # A rate at which this path will be triggered if no input node receives new data
|
||||
|
||||
|
@ -13,26 +13,6 @@ paths = (
|
|||
mode = "all", # When this path should be triggered
|
||||
# - "all": After all masked input nodes received new data
|
||||
# - "any": After any of the masked input nodes received new data
|
||||
mask = [ "acs" ], # A list of input nodes which will trigger the path
|
||||
},
|
||||
{
|
||||
enabled = false,
|
||||
reverse = false,
|
||||
|
||||
in = [ # Multiple source nodes are multiplexed
|
||||
"opal_node.data[0-4]",
|
||||
"signal_node.data[0-4]"
|
||||
],
|
||||
out = [ # Multiple destination nodes are supported too.
|
||||
"udp_node", # All destination nodes receive the same sample
|
||||
"zeromq_node" # Which gets constructed by the 'in' mapping.
|
||||
]
|
||||
},
|
||||
{
|
||||
in = "socket_node",
|
||||
out = "file_node", # This path includes all available example hooks.
|
||||
|
||||
builtin = false, # By default, all paths will have a few builtin hooks attached to them.
|
||||
# When collecting statistics or measurements these are undesired.
|
||||
mask = [ "udp_node" ], # A list of input nodes which will trigger the path
|
||||
}
|
||||
)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* villas node <(node /etc/villas/node/js/config.js)
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html//Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -59,7 +59,6 @@ module.exports = {
|
|||
http : {
|
||||
enabled : true, // Do not listen on port if true
|
||||
|
||||
htdocs : "/villas/web/socket/", // Root directory of internal webserver
|
||||
port : 80 // Port for HTTP connections
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
103
etc/sim-hes-off/rwth.conf
Normal file
103
etc/sim-hes-off/rwth.conf
Normal file
|
@ -0,0 +1,103 @@
|
|||
|
||||
nodes = {
|
||||
rwth-opal = {
|
||||
type = "socket"
|
||||
layer = "udp"
|
||||
|
||||
in = {
|
||||
address = "0.0.0.0:12008"
|
||||
|
||||
# signals = (
|
||||
# { name = "Idc1_meas", type = "float", unit = "A" },
|
||||
# { name = "Idc2_meas", type = "float", unit = "A" }
|
||||
# )
|
||||
|
||||
hooks = (
|
||||
"stats"
|
||||
)
|
||||
}
|
||||
|
||||
out = {
|
||||
address = "134.130.169.81:12008"
|
||||
}
|
||||
}
|
||||
|
||||
ntnu-villas = {
|
||||
type = "socket"
|
||||
layer = "udp"
|
||||
|
||||
in = {
|
||||
address = "0.0.0.0:12001"
|
||||
|
||||
# signals = (
|
||||
# { name = "P1_ref", type = "float", unit = "W" },
|
||||
# { name = "P2_ref", type = "float", unit = "W" },
|
||||
# { name = "Udc_meas", type = "float", unit = "V" }
|
||||
#
|
||||
# )
|
||||
|
||||
hooks = (
|
||||
"stats"
|
||||
)
|
||||
}
|
||||
|
||||
out = {
|
||||
address = "10.101.8.4:12001" # todo: update with real IP
|
||||
}
|
||||
}
|
||||
|
||||
web-rwth = {
|
||||
type = "websocket"
|
||||
|
||||
destinations = [
|
||||
"https://villas.k8s.eonerc.rwth-aachen.de/ws/relay/sim-hes-off-rwth"
|
||||
]
|
||||
},
|
||||
|
||||
web-ntnu = {
|
||||
type = "websocket"
|
||||
|
||||
destinations = [
|
||||
"https://villas.k8s.eonerc.rwth-aachen.de/ws/relay/sim-hes-off-ntnu"
|
||||
]
|
||||
},
|
||||
|
||||
logger = {
|
||||
type = "file"
|
||||
format = "csv"
|
||||
|
||||
uri = "opal-rwth.csv"
|
||||
}
|
||||
}
|
||||
|
||||
paths = (
|
||||
{
|
||||
in = "rwth-opal",
|
||||
out = [
|
||||
# "ntnu-villas",
|
||||
"web-rwth"
|
||||
],
|
||||
hooks = (
|
||||
{
|
||||
type = "decimate"
|
||||
ratio = 100
|
||||
},
|
||||
{
|
||||
type = "print"
|
||||
}
|
||||
)
|
||||
},
|
||||
{
|
||||
enabled = false
|
||||
|
||||
in = [
|
||||
"ntnu-villas"
|
||||
]
|
||||
out = [
|
||||
"rwth-opal"
|
||||
# "web-ntnu"
|
||||
# "logger"
|
||||
]
|
||||
}
|
||||
)
|
||||
|
19
etc/test.conf
Normal file
19
etc/test.conf
Normal file
|
@ -0,0 +1,19 @@
|
|||
nodes = {
|
||||
signal = {
|
||||
type = "signal"
|
||||
|
||||
signal = "mixed"
|
||||
values = 5
|
||||
}
|
||||
}
|
||||
|
||||
paths = (
|
||||
{
|
||||
in = "signal"
|
||||
hooks = (
|
||||
{
|
||||
type = "print"
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
2
fpga
2
fpga
|
@ -1 +1 @@
|
|||
Subproject commit f1b5554752353ee044e6139f20ba92bfeaf12c70
|
||||
Subproject commit 47a7c0f30ffb6e21422e3a45fd81d86a33716e9f
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -25,11 +25,12 @@
|
|||
|
||||
#include <villas/api/request.hpp>
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
class Node;
|
||||
|
||||
namespace api {
|
||||
|
||||
class NodeRequest : public Request {
|
||||
|
@ -37,7 +38,7 @@ class NodeRequest : public Request {
|
|||
public:
|
||||
using Request::Request;
|
||||
|
||||
struct vnode *node;
|
||||
Node *node;
|
||||
|
||||
virtual void
|
||||
prepare();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -25,11 +25,12 @@
|
|||
|
||||
#include <villas/api/request.hpp>
|
||||
|
||||
/* Forward declarations */
|
||||
struct vpath;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
class Path;
|
||||
|
||||
namespace api {
|
||||
|
||||
class PathRequest : public Request {
|
||||
|
@ -37,7 +38,7 @@ class PathRequest : public Request {
|
|||
public:
|
||||
using Request::Request;
|
||||
|
||||
struct vpath *path;
|
||||
class Path *path;
|
||||
|
||||
virtual void
|
||||
prepare();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -115,9 +115,6 @@ public:
|
|||
|
||||
virtual
|
||||
std::string toString();
|
||||
|
||||
void setLogger(Logger log)
|
||||
{ logger = log; }
|
||||
};
|
||||
|
||||
class RequestFactory : public plugin::Plugin {
|
||||
|
@ -134,10 +131,18 @@ public:
|
|||
static
|
||||
Request * create(Session *s, const std::string &uri, Session::Method meth, unsigned long ct);
|
||||
|
||||
virtual
|
||||
void init(Request *r)
|
||||
{
|
||||
r->logger = getLogger();
|
||||
}
|
||||
|
||||
virtual
|
||||
std::string
|
||||
getType() const
|
||||
{ return "api:request"; }
|
||||
{
|
||||
return "api:request";
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, const char *name, const char *re, const char *desc>
|
||||
|
@ -157,7 +162,7 @@ public:
|
|||
{
|
||||
auto *r = new T(s);
|
||||
|
||||
r->setLogger(getLogger());
|
||||
init(r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -115,7 +115,6 @@ public:
|
|||
|
||||
static std::string
|
||||
methodToString(Method meth);
|
||||
|
||||
};
|
||||
|
||||
} /* namespace api */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -30,7 +30,7 @@
|
|||
#include <functional>
|
||||
#include <regex>
|
||||
|
||||
#include <villas/node/config.h>
|
||||
#include <villas/node/config.hpp>
|
||||
#include <villas/log.hpp>
|
||||
|
||||
#ifdef WITH_CONFIG
|
|
@ -1,7 +1,7 @@
|
|||
/** Helpers for configuration parsers.
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -22,19 +22,26 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#include <villas/node/config.h>
|
||||
#include <villas/sample.h>
|
||||
|
||||
#ifdef WITH_CONFIG
|
||||
#include <libconfig.h>
|
||||
#endif
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#include <villas/node/config.hpp>
|
||||
#include <villas/sample.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
#ifdef WITH_CONFIG
|
||||
|
||||
/** Convert a libconfig object to a jansson object */
|
||||
json_t *config_to_json(config_setting_t *json);
|
||||
json_t * config_to_json(struct config_setting_t *cfg);
|
||||
|
||||
/** Convert a jansson object into a libconfig object. */
|
||||
int json_to_config(json_t *json, config_setting_t *parent);
|
||||
int json_to_config(json_t *json, struct config_setting_t *parent);
|
||||
|
||||
#endif /* WITH_CONFIG */
|
||||
|
||||
int json_object_extend_str(json_t *orig, const char *str);
|
||||
|
@ -47,3 +54,6 @@ void json_object_extend_key_value_token(json_t *obj, const char *key, const char
|
|||
int json_object_extend(json_t *orig, json_t *merge);
|
||||
|
||||
json_t * json_load_cli(int argc, const char *argv[]);
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Manuel Pitz <manuel.pitz@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -23,20 +23,31 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <villas/list.h>
|
||||
#include <memory>
|
||||
|
||||
#include <villas/list.hpp>
|
||||
#include <villas/plugin.hpp>
|
||||
#include <villas/sample.h>
|
||||
#include <villas/sample.hpp>
|
||||
#include <villas/signal_list.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
class FormatFactory;
|
||||
|
||||
class Format {
|
||||
|
||||
friend FormatFactory;
|
||||
|
||||
|
||||
public:
|
||||
using Ptr = std::unique_ptr<Format>;
|
||||
|
||||
protected:
|
||||
|
||||
int flags; /**< A set of flags which is automatically used. */
|
||||
int real_precision; /**< Number of digits used for floatint point numbers */
|
||||
bool destroy_signals;
|
||||
int flags; /**< A set of flags which is automatically used. */
|
||||
int real_precision; /**< Number of digits used for floatint point numbers */
|
||||
|
||||
Logger logger;
|
||||
|
||||
|
@ -45,7 +56,7 @@ protected:
|
|||
size_t buflen;
|
||||
} in, out;
|
||||
|
||||
struct vlist *signals; /**< Signal meta data for parsed samples by Format::scan() */
|
||||
SignalList::Ptr signals; /**< Signal meta data for parsed samples by Format::scan() */
|
||||
|
||||
public:
|
||||
Format(int fl);
|
||||
|
@ -55,18 +66,21 @@ public:
|
|||
|
||||
virtual
|
||||
bool isBinaryPayload()
|
||||
{ return false; }
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
struct vlist * getSignals() const
|
||||
{ return signals; }
|
||||
const SignalList::Ptr getSignals() const
|
||||
{
|
||||
return signals;
|
||||
}
|
||||
|
||||
int getFlags() const
|
||||
{ return flags; }
|
||||
{
|
||||
return flags;
|
||||
}
|
||||
|
||||
void setLogger(Logger log)
|
||||
{ logger = log; }
|
||||
|
||||
void start(struct vlist *sigs, int fl = (int) SampleFlags::HAS_ALL);
|
||||
void start(const SignalList::Ptr sigs, int fl = (int) SampleFlags::HAS_ALL);
|
||||
void start(const std::string &dtypes, int fl = (int) SampleFlags::HAS_ALL);
|
||||
|
||||
virtual
|
||||
|
@ -77,10 +91,10 @@ public:
|
|||
void parse(json_t *json);
|
||||
|
||||
virtual
|
||||
int print(FILE *f, const struct sample * const smps[], unsigned cnt);
|
||||
int print(FILE *f, const struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
int scan(FILE *f, struct sample * const smps[], unsigned cnt);
|
||||
int scan(FILE *f, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** Print \p cnt samples from \p smps into buffer \p buf of length \p len.
|
||||
*
|
||||
|
@ -94,7 +108,7 @@ public:
|
|||
* @retval <0 Something went wrong.
|
||||
*/
|
||||
virtual
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt) = 0;
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample * const smps[], unsigned cnt) = 0;
|
||||
|
||||
/** Parse samples from the buffer \p buf with a length of \p len bytes.
|
||||
*
|
||||
|
@ -108,26 +122,26 @@ public:
|
|||
* @retval <0 Something went wrong.
|
||||
*/
|
||||
virtual
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt) = 0;
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample * const smps[], unsigned cnt) = 0;
|
||||
|
||||
/* Wrappers for sending a (un)parsing single samples */
|
||||
|
||||
int print(FILE *f, const struct sample *smp)
|
||||
int print(FILE *f, const struct Sample *smp)
|
||||
{
|
||||
return print(f, &smp, 1);
|
||||
}
|
||||
|
||||
int scan(FILE *f, struct sample *smp)
|
||||
int scan(FILE *f, struct Sample *smp)
|
||||
{
|
||||
return scan(f, &smp, 1);
|
||||
}
|
||||
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct sample *smp)
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample *smp)
|
||||
{
|
||||
return sprint(buf, len, wbytes, &smp, 1);
|
||||
}
|
||||
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct sample *smp)
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample *smp)
|
||||
{
|
||||
return sscan(buf, len, rbytes, &smp, 1);
|
||||
}
|
||||
|
@ -156,9 +170,17 @@ public:
|
|||
static
|
||||
Format * make(const std::string &format);
|
||||
|
||||
virtual
|
||||
void init(Format *f)
|
||||
{
|
||||
f->logger = getLogger();
|
||||
}
|
||||
|
||||
virtual
|
||||
std::string getType() const
|
||||
{ return "format"; }
|
||||
{
|
||||
return "format";
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, const char *name, const char *desc, int flags = 0>
|
||||
|
@ -171,20 +193,22 @@ public:
|
|||
{
|
||||
auto *f = new T(flags);
|
||||
|
||||
f->setLogger(getLogger());
|
||||
init(f);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
/// Get plugin name
|
||||
virtual std::string
|
||||
getName() const
|
||||
{ return name; }
|
||||
virtual
|
||||
std::string getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/// Get plugin description
|
||||
virtual std::string
|
||||
getDescription() const
|
||||
{ return desc; }
|
||||
virtual
|
||||
std::string getDescription() const
|
||||
{
|
||||
return desc;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -27,17 +27,17 @@
|
|||
|
||||
#include <villas/formats/line.hpp>
|
||||
|
||||
/* Forward declarations. */
|
||||
struct sample;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations. */
|
||||
struct Sample;
|
||||
|
||||
class ColumnLineFormat : public LineFormat {
|
||||
|
||||
protected:
|
||||
virtual size_t sprintLine(char *buf, size_t len, const struct sample *smp);
|
||||
virtual size_t sscanLine(const char *buf, size_t len, struct sample *smp);
|
||||
virtual size_t sprintLine(char *buf, size_t len, const struct Sample *smp);
|
||||
virtual size_t sscanLine(const char *buf, size_t len, struct Sample *smp);
|
||||
|
||||
char separator; /**< Column separator */
|
||||
|
||||
|
@ -48,7 +48,7 @@ public:
|
|||
{ }
|
||||
|
||||
virtual
|
||||
void header(FILE *f, const struct vlist *sigs);
|
||||
void header(FILE *f, const SignalList::Ptr sigs);
|
||||
|
||||
virtual
|
||||
void parse(json_t *json);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** UltraLight format for FISMEP project.
|
||||
*
|
||||
* @author Iris Koester <ikoester@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -24,19 +24,20 @@
|
|||
|
||||
#include <villas/format.hpp>
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct Sample;
|
||||
|
||||
class IotAgentUltraLightFormat : public Format {
|
||||
|
||||
protected:
|
||||
virtual
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt);
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt);
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
public:
|
||||
using Format::Format;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** JSON serializtion sample data.
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -26,28 +26,28 @@
|
|||
|
||||
#include <villas/format.hpp>
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct Sample;
|
||||
|
||||
class JsonFormat : public Format {
|
||||
|
||||
protected:
|
||||
static enum SignalType detect(const json_t *val);
|
||||
|
||||
json_t * packTimestamps(const struct sample *smp);
|
||||
int unpackTimestamps(json_t *json_ts, struct sample *smp);
|
||||
json_t * packTimestamps(const struct Sample *smp);
|
||||
int unpackTimestamps(json_t *json_ts, struct Sample *smp);
|
||||
|
||||
virtual
|
||||
int packSample(json_t **j, const struct sample *smp);
|
||||
int packSample(json_t **j, const struct Sample *smp);
|
||||
virtual
|
||||
int packSamples(json_t **j, const struct sample * const smps[], unsigned cnt);
|
||||
int packSamples(json_t **j, const struct Sample * const smps[], unsigned cnt);
|
||||
virtual
|
||||
int unpackSample(json_t *json_smp, struct sample *smp);
|
||||
int unpackSample(json_t *json_smp, struct Sample *smp);
|
||||
virtual
|
||||
int unpackSamples(json_t *json_smps, struct sample * const smps[], unsigned cnt);
|
||||
int unpackSamples(json_t *json_smps, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
int dump_flags;
|
||||
|
||||
|
@ -58,14 +58,14 @@ public:
|
|||
{ }
|
||||
|
||||
virtual
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt);
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample * const smps[], unsigned cnt);
|
||||
virtual
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt);
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
int print(FILE *f, const struct sample * const smps[], unsigned cnt);
|
||||
int print(FILE *f, const struct Sample * const smps[], unsigned cnt);
|
||||
virtual
|
||||
int scan(FILE *f, struct sample * const smps[], unsigned cnt);
|
||||
int scan(FILE *f, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
void parse(json_t *json);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** JSON serializtion for edgeFlex project.
|
||||
*
|
||||
* @author Manuel Pitz <manuel.pitz@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -31,9 +31,9 @@ class JsonEdgeflexFormat : public JsonFormat {
|
|||
|
||||
protected:
|
||||
virtual
|
||||
int packSample(json_t **j, const struct sample *smp);
|
||||
int packSample(json_t **j, const struct Sample *smp);
|
||||
virtual
|
||||
int unpackSample(json_t *json_smp, struct sample *smp);
|
||||
int unpackSample(json_t *json_smp, struct Sample *smp);
|
||||
|
||||
public:
|
||||
using JsonFormat::JsonFormat;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** JSON serializtion for Kafka schema/payloads.
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <villas/signal_type.h>
|
||||
#include <villas/signal_type.hpp>
|
||||
#include <villas/formats/json.hpp>
|
||||
|
||||
namespace villas {
|
||||
|
@ -32,9 +32,9 @@ class JsonKafkaFormat : public JsonFormat {
|
|||
|
||||
protected:
|
||||
virtual
|
||||
int packSample(json_t **j, const struct sample *smp);
|
||||
int packSample(json_t **j, const struct Sample *smp);
|
||||
virtual
|
||||
int unpackSample(json_t *json_smp, struct sample *smp);
|
||||
int unpackSample(json_t *json_smp, struct Sample *smp);
|
||||
|
||||
const char * villasToKafkaType(enum SignalType vt);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** JSON serializtion for RESERVE project.
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -31,9 +31,9 @@ class JsonReserveFormat : public JsonFormat {
|
|||
|
||||
protected:
|
||||
virtual
|
||||
int packSample(json_t **j, const struct sample *smp);
|
||||
int packSample(json_t **j, const struct Sample *smp);
|
||||
virtual
|
||||
int unpackSample(json_t *json_smp, struct sample *smp);
|
||||
int unpackSample(json_t *json_smp, struct Sample *smp);
|
||||
|
||||
public:
|
||||
using JsonFormat::JsonFormat;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -31,8 +31,8 @@ namespace node {
|
|||
class LineFormat : public Format {
|
||||
|
||||
protected:
|
||||
virtual size_t sprintLine(char *buf, size_t len, const struct sample *smp) = 0;
|
||||
virtual size_t sscanLine(const char *buf, size_t len, struct sample *smp) = 0;
|
||||
virtual size_t sprintLine(char *buf, size_t len, const struct Sample *smp) = 0;
|
||||
virtual size_t sscanLine(const char *buf, size_t len, struct Sample *smp) = 0;
|
||||
|
||||
char delimiter; /**< Newline delimiter. */
|
||||
char comment; /**< Prefix for comment lines. */
|
||||
|
@ -56,20 +56,20 @@ public:
|
|||
|
||||
/** Print a header. */
|
||||
virtual
|
||||
void header(FILE *f, const struct vlist *sigs)
|
||||
void header(FILE *f, const SignalList::Ptr sigs)
|
||||
{
|
||||
header_printed = true;
|
||||
}
|
||||
|
||||
virtual
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt);
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample * const smps[], unsigned cnt);
|
||||
virtual
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt);
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
int scan(FILE *f, struct sample * const smps[], unsigned cnt);
|
||||
int scan(FILE *f, struct Sample * const smps[], unsigned cnt);
|
||||
virtual
|
||||
int print(FILE *f, const struct sample * const smps[], unsigned cnt);
|
||||
int print(FILE *f, const struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
void parse(json_t *json);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** Message related functions.
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -22,22 +22,30 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include<villas/signal_list.hpp>
|
||||
|
||||
namespace villas {
|
||||
|
||||
/* Forward declarataions */
|
||||
struct List;
|
||||
|
||||
namespace node {
|
||||
|
||||
/* Forward declaration */
|
||||
struct msg;
|
||||
struct sample;
|
||||
struct vlist;
|
||||
struct Message;
|
||||
struct Sample;
|
||||
|
||||
/** Convert msg from network to host byteorder */
|
||||
void msg_ntoh(struct msg *m);
|
||||
void msg_ntoh(struct Message *m);
|
||||
|
||||
/** Convert msg from host to network byteorder */
|
||||
void msg_hton(struct msg *m);
|
||||
void msg_hton(struct Message *m);
|
||||
|
||||
/** Convert msg header from network to host byteorder */
|
||||
void msg_hdr_hton(struct msg *m);
|
||||
void msg_hdr_hton(struct Message *m);
|
||||
|
||||
/** Convert msg header from host to network byteorder */
|
||||
void msg_hdr_ntoh(struct msg *m);
|
||||
void msg_hdr_ntoh(struct Message *m);
|
||||
|
||||
/** Check the consistency of a message.
|
||||
*
|
||||
|
@ -47,10 +55,13 @@ void msg_hdr_ntoh(struct msg *m);
|
|||
* @retval 0 The message header is valid.
|
||||
* @retval <0 The message header is invalid.
|
||||
*/
|
||||
int msg_verify(const struct msg *m);
|
||||
int msg_verify(const struct Message *m);
|
||||
|
||||
/** Copy fields from \p msg into \p smp. */
|
||||
int msg_to_sample(const struct msg *msg, struct sample *smp, const struct vlist *sigs, uint8_t *source_index);
|
||||
int msg_to_sample(const struct Message *msg, struct Sample *smp, const SignalList::Ptr sigs, uint8_t *source_index);
|
||||
|
||||
/** Copy fields form \p smp into \p msg. */
|
||||
int msg_from_sample(struct msg *msg, const struct sample *smp, const struct vlist *sigs, uint8_t source_index);
|
||||
int msg_from_sample(struct Message *msg, const struct Sample *smp, const SignalList::Ptr sigs, uint8_t source_index);
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -34,24 +34,27 @@
|
|||
#define MSG_TYPE_STOP 2 /**< Message marks the end of a simulation case */
|
||||
|
||||
/** The total size in bytes of a message */
|
||||
#define MSG_LEN(values) (sizeof(struct msg) + MSG_DATA_LEN(values))
|
||||
#define MSG_LEN(values) (sizeof(struct Message) + MSG_DATA_LEN(values))
|
||||
|
||||
/** The length of \p values values in bytes. */
|
||||
#define MSG_DATA_LEN(values) (sizeof(float) * (values))
|
||||
|
||||
/** The offset to the first data value in a message. */
|
||||
#define MSG_DATA_OFFSET(msg) ((char *) (msg) + offsetof(struct msg, data))
|
||||
#define MSG_DATA_OFFSET(msg) ((char *) (msg) + offsetof(struct Message, data))
|
||||
|
||||
/** The timestamp of a message in struct timespec format */
|
||||
#define MSG_TS(msg, i) \
|
||||
i.tv_sec = (msg)->ts.sec; \
|
||||
i.tv_nsec = (msg)->ts.nsec;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/** This message format is used by all clients
|
||||
*
|
||||
* @diafile msg_format.dia
|
||||
**/
|
||||
struct msg
|
||||
struct Message
|
||||
{
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
unsigned version: 4; /**< Specifies the format of the remaining message (see MGS_VERSION) */
|
||||
|
@ -81,3 +84,6 @@ struct msg
|
|||
uint32_t i; /**< Integer values. */
|
||||
} data[];
|
||||
} __attribute__((packed));
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -30,12 +30,12 @@
|
|||
/* Generated message descriptors by protoc */
|
||||
#include <villas.pb-c.h>
|
||||
|
||||
/* Forward declarations. */
|
||||
struct sample;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations. */
|
||||
struct Sample;
|
||||
|
||||
class ProtobufFormat : public BinaryFormat {
|
||||
|
||||
protected:
|
||||
|
@ -45,9 +45,9 @@ public:
|
|||
using BinaryFormat::BinaryFormat;
|
||||
|
||||
virtual
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt);
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample * const smps[], unsigned cnt);
|
||||
virtual
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt);
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample * const smps[], unsigned cnt);
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -33,12 +33,12 @@
|
|||
#define HAS_128BIT
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct sample;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct Sample;
|
||||
|
||||
class RawFormat : public BinaryFormat {
|
||||
|
||||
public:
|
||||
|
@ -65,9 +65,9 @@ public:
|
|||
}
|
||||
|
||||
virtual
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt);
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample * const smps[], unsigned cnt);
|
||||
virtual
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt);
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
void parse(json_t *json);
|
||||
|
|
|
@ -36,9 +36,9 @@ public:
|
|||
using Format::Format;
|
||||
|
||||
virtual
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt);
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample * const smps[], unsigned cnt);
|
||||
virtual
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt);
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample * const smps[], unsigned cnt);
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -27,13 +27,12 @@
|
|||
|
||||
#include <villas/format.hpp>
|
||||
|
||||
/* Forward declarations. */
|
||||
struct sample;
|
||||
struct msg;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations. */
|
||||
struct Sample;
|
||||
|
||||
class VillasBinaryFormat : public BinaryFormat {
|
||||
|
||||
protected:
|
||||
|
@ -50,9 +49,9 @@ public:
|
|||
{ }
|
||||
|
||||
virtual
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt);
|
||||
int sscan(const char *buf, size_t len, size_t *rbytes, struct Sample * const smps[], unsigned cnt);
|
||||
virtual
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt);
|
||||
int sprint(char *buf, size_t len, size_t *wbytes, const struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
void parse(json_t *json);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -34,15 +34,15 @@ class VILLASHumanFormat : public LineFormat {
|
|||
|
||||
protected:
|
||||
virtual
|
||||
size_t sprintLine(char *buf, size_t len, const struct sample *smp);
|
||||
size_t sprintLine(char *buf, size_t len, const struct Sample *smp);
|
||||
virtual
|
||||
size_t sscanLine(const char *buf, size_t len, struct sample *smp);
|
||||
size_t sscanLine(const char *buf, size_t len, struct Sample *smp);
|
||||
|
||||
public:
|
||||
using LineFormat::LineFormat;
|
||||
|
||||
virtual
|
||||
void header(FILE *f, const struct vlist *sigs);
|
||||
void header(FILE *f, const SignalList::Ptr sigs);
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -27,23 +27,29 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <villas/list.h>
|
||||
#include <villas/signal.h>
|
||||
#include <villas/list.hpp>
|
||||
#include <villas/signal.hpp>
|
||||
#include <villas/signal_list.hpp>
|
||||
#include <villas/log.hpp>
|
||||
#include <villas/plugin.hpp>
|
||||
#include <villas/exceptions.hpp>
|
||||
|
||||
/* Forward declarations */
|
||||
struct vpath;
|
||||
struct vnode;
|
||||
struct sample;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
class Node;
|
||||
class Path;
|
||||
struct Sample;
|
||||
class HookFactory;
|
||||
|
||||
class Hook {
|
||||
|
||||
friend HookFactory;
|
||||
|
||||
public:
|
||||
using Ptr = std::shared_ptr<Hook>;
|
||||
|
||||
enum class Flags {
|
||||
BUILTIN = (1 << 0), /**< Should we add this hook by default to every path?. */
|
||||
PATH = (1 << 1), /**< This hook type is used by paths. */
|
||||
|
@ -61,34 +67,32 @@ public:
|
|||
protected:
|
||||
Logger logger;
|
||||
|
||||
HookFactory *factory;
|
||||
|
||||
enum State state;
|
||||
|
||||
int flags;
|
||||
unsigned priority; /**< A priority to change the order of execution within one type of hook. */
|
||||
bool enabled; /**< Is this hook active? */
|
||||
|
||||
struct vpath *path;
|
||||
struct vnode *node;
|
||||
Path *path;
|
||||
Node *node;
|
||||
|
||||
struct vlist signals;
|
||||
SignalList::Ptr signals;
|
||||
|
||||
json_t *config; /**< A JSON object containing the configuration of the hook. */
|
||||
|
||||
public:
|
||||
Hook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true);
|
||||
Hook(Path *p, Node *n, int fl, int prio, bool en = true);
|
||||
|
||||
virtual
|
||||
~Hook();
|
||||
~Hook()
|
||||
{ }
|
||||
|
||||
virtual
|
||||
void parse(json_t *json);
|
||||
|
||||
void prepare(struct vlist *sigs);
|
||||
|
||||
void setLogger(Logger log)
|
||||
{
|
||||
logger = log;
|
||||
}
|
||||
void prepare(SignalList::Ptr sigs);
|
||||
|
||||
Logger getLogger()
|
||||
{
|
||||
|
@ -123,7 +127,11 @@ public:
|
|||
|
||||
virtual
|
||||
void prepare()
|
||||
{ }
|
||||
{
|
||||
assert(state == State::CHECKED);
|
||||
|
||||
state = State::PREPARED;
|
||||
}
|
||||
|
||||
/** Called periodically. Period is set by global 'stats' option in the configuration file. */
|
||||
virtual
|
||||
|
@ -141,7 +149,7 @@ public:
|
|||
|
||||
/** Called whenever a sample is processed. */
|
||||
virtual
|
||||
Reason process(struct sample *smp)
|
||||
Reason process(struct Sample *smp)
|
||||
{
|
||||
return Reason::OK;
|
||||
};
|
||||
|
@ -157,9 +165,9 @@ public:
|
|||
}
|
||||
|
||||
virtual
|
||||
struct vlist * getSignals()
|
||||
SignalList::Ptr getSignals() const
|
||||
{
|
||||
return &signals;
|
||||
return signals;
|
||||
}
|
||||
|
||||
json_t * getConfig() const
|
||||
|
@ -167,6 +175,11 @@ public:
|
|||
return config;
|
||||
}
|
||||
|
||||
HookFactory * getFactory() const
|
||||
{
|
||||
return factory;
|
||||
}
|
||||
|
||||
bool isEnabled() const
|
||||
{
|
||||
return enabled;
|
||||
|
@ -180,7 +193,7 @@ protected:
|
|||
std::string signalName;
|
||||
|
||||
public:
|
||||
SingleSignalHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
SingleSignalHook(Path *p, Node *n, int fl, int prio, bool en = true) :
|
||||
Hook(p, n, fl, prio, en),
|
||||
signalIndex(0)
|
||||
{ }
|
||||
|
@ -214,6 +227,7 @@ public:
|
|||
class LimitHook : public Hook {
|
||||
|
||||
public:
|
||||
using Ptr = std::shared_ptr<LimitHook>;
|
||||
using Hook::Hook;
|
||||
|
||||
virtual void setRate(double rate, double maxRate = -1) = 0;
|
||||
|
@ -236,18 +250,30 @@ public:
|
|||
|
||||
class HookFactory : public plugin::Plugin {
|
||||
|
||||
protected:
|
||||
virtual
|
||||
void init(Hook::Ptr h)
|
||||
{
|
||||
h->logger = getLogger();
|
||||
h->factory = this;
|
||||
}
|
||||
|
||||
public:
|
||||
using plugin::Plugin::Plugin;
|
||||
|
||||
virtual Hook * make(struct vpath *p, struct vnode *n) = 0;
|
||||
|
||||
virtual int getFlags() const = 0;
|
||||
virtual unsigned getPriority() const = 0;
|
||||
virtual Hook::Ptr make(Path *p, Node *n) = 0;
|
||||
|
||||
virtual
|
||||
std::string
|
||||
getType() const
|
||||
{ return "hook"; }
|
||||
int getFlags() const = 0;
|
||||
|
||||
virtual
|
||||
unsigned getPriority() const = 0;
|
||||
|
||||
virtual
|
||||
std::string getType() const
|
||||
{
|
||||
return "hook";
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, const char *name, const char *desc, int flags = 0, unsigned prio = 99>
|
||||
|
@ -256,30 +282,38 @@ class HookPlugin : public HookFactory {
|
|||
public:
|
||||
using HookFactory::HookFactory;
|
||||
|
||||
virtual Hook * make(struct vpath *p, struct vnode *n)
|
||||
virtual Hook::Ptr make(Path *p, Node *n)
|
||||
{
|
||||
auto *h = new T(p, n, getFlags(), getPriority());
|
||||
auto h = std::make_shared<T>(p, n, getFlags(), getPriority());
|
||||
|
||||
h->setLogger(getLogger());
|
||||
init(h);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
virtual std::string
|
||||
getName() const
|
||||
{ return name; }
|
||||
virtual
|
||||
std::string getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
virtual std::string
|
||||
getDescription() const
|
||||
{ return desc; }
|
||||
virtual
|
||||
std::string getDescription() const
|
||||
{
|
||||
return desc;
|
||||
}
|
||||
|
||||
virtual int
|
||||
getFlags() const
|
||||
{ return flags; }
|
||||
virtual
|
||||
int getFlags() const
|
||||
{
|
||||
return flags;
|
||||
}
|
||||
|
||||
virtual unsigned
|
||||
getPriority() const
|
||||
{ return prio; }
|
||||
virtual
|
||||
unsigned getPriority() const
|
||||
{
|
||||
return prio;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -23,61 +23,60 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hooks User-defined hook functions
|
||||
* @ingroup path
|
||||
* @{
|
||||
*********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#include <villas/hook.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vlist;
|
||||
struct sample;
|
||||
struct vpath;
|
||||
struct vnode;
|
||||
class Node;
|
||||
class Path;
|
||||
struct Sample;
|
||||
|
||||
int hook_list_init(struct vlist *hs) __attribute__ ((warn_unused_result));
|
||||
class HookList : public std::list<Hook::Ptr> {
|
||||
|
||||
int hook_list_destroy(struct vlist *hs) __attribute__ ((warn_unused_result));
|
||||
public:
|
||||
HookList()
|
||||
{ }
|
||||
|
||||
/** Parses an object of hooks
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* {
|
||||
* stats = {
|
||||
* output = "stdout"
|
||||
* },
|
||||
* skip_first = {
|
||||
* seconds = 10
|
||||
* },
|
||||
* hooks = [ "print" ]
|
||||
* }
|
||||
*/
|
||||
void hook_list_parse(struct vlist *hs, json_t *json, int mask, struct vpath *p, struct vnode *n);
|
||||
/** Parses an object of hooks
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* {
|
||||
* stats = {
|
||||
* output = "stdout"
|
||||
* },
|
||||
* skip_first = {
|
||||
* seconds = 10
|
||||
* },
|
||||
* hooks = [ "print" ]
|
||||
* }
|
||||
*/
|
||||
void parse(json_t *json, int mask, Path *p, Node *n);
|
||||
|
||||
void hook_list_check(struct vlist *hs);
|
||||
void check();
|
||||
|
||||
void hook_list_prepare(struct vlist *hs, struct vlist *sigs, int mask, struct vpath *p, struct vnode *n);
|
||||
void prepare(SignalList::Ptr sigs, int mask, Path *p, Node *n);
|
||||
|
||||
int hook_list_prepare_signals(struct vlist *hs, struct vlist *signals);
|
||||
int process(struct Sample *smps[], unsigned cnt);
|
||||
void periodic();
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
int hook_list_add(struct vlist *hs, int mask, struct vpath *p, struct vnode *n);
|
||||
void dump(villas::Logger logger, std::string subject) const;
|
||||
|
||||
int hook_list_process(struct vlist *hs, struct sample * smps[], unsigned cnt);
|
||||
SignalList::Ptr getSignals() const;
|
||||
|
||||
void hook_list_periodic(struct vlist *hs);
|
||||
/** Get the maximum number of signals which is used by any of the hooks in the list. */
|
||||
unsigned getSignalsMaxCount() const;
|
||||
|
||||
void hook_list_start(struct vlist *hs);
|
||||
json_t * toJson() const;
|
||||
};
|
||||
|
||||
void hook_list_stop(struct vlist *hs);
|
||||
|
||||
struct vlist * hook_list_get_signals(struct vlist *hs);
|
||||
|
||||
/** Get the maximum number of signals which is used by any of the hooks in the list. */
|
||||
unsigned hook_list_get_signals_max_cnt(struct vlist *hs);
|
||||
|
||||
json_t * hook_list_to_json(struct vlist *hs);
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** Decimate hook.
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -24,10 +24,6 @@
|
|||
|
||||
#include <villas/hook.hpp>
|
||||
|
||||
/** @addtogroup hooks Hook functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
|
@ -40,7 +36,8 @@ protected:
|
|||
public:
|
||||
using LimitHook::LimitHook;
|
||||
|
||||
virtual void setRate(double rate, double maxRate = -1)
|
||||
virtual
|
||||
void setRate(double rate, double maxRate = -1)
|
||||
{
|
||||
assert(maxRate > 0);
|
||||
|
||||
|
@ -56,16 +53,16 @@ public:
|
|||
ratio = r;
|
||||
}
|
||||
|
||||
virtual void start();
|
||||
virtual
|
||||
void start();
|
||||
|
||||
virtual void parse(json_t *json);
|
||||
virtual
|
||||
void parse(json_t *json);
|
||||
|
||||
virtual Hook::Reason process(sample *smp);
|
||||
virtual
|
||||
Hook::Reason process(struct Sample *smp);
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/** Rate-limiting hook.
|
||||
*
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -24,10 +24,6 @@
|
|||
|
||||
#include <villas/hook.hpp>
|
||||
|
||||
/** @addtogroup hooks Hook functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
|
@ -44,7 +40,7 @@ protected:
|
|||
timespec last;
|
||||
|
||||
public:
|
||||
LimitRateHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true) :
|
||||
LimitRateHook(Path *p, Node *n, int fl, int prio, bool en = true) :
|
||||
LimitHook(p, n, fl, prio, en),
|
||||
mode(LIMIT_RATE_LOCAL),
|
||||
deadtime(0),
|
||||
|
@ -58,13 +54,8 @@ public:
|
|||
|
||||
virtual void parse(json_t *json);
|
||||
|
||||
virtual Hook::Reason process(sample *smp);
|
||||
virtual Hook::Reason process(struct Sample *smp);
|
||||
};
|
||||
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace node {
|
|||
|
||||
/* Forward declarations */
|
||||
class LuaHook;
|
||||
enum SignalType;
|
||||
|
||||
class LuaSignalExpression {
|
||||
|
||||
|
@ -54,7 +55,7 @@ public:
|
|||
|
||||
void parseExpression(const std::string &expr);
|
||||
|
||||
void evaluate(union signal_data *data, enum SignalType type);
|
||||
void evaluate(union SignalData *data, enum SignalType type);
|
||||
};
|
||||
|
||||
class LuaHook : public Hook {
|
||||
|
@ -68,8 +69,8 @@ protected:
|
|||
std::string script;
|
||||
std::vector<LuaSignalExpression> expressions;
|
||||
|
||||
struct vlist signalsProcessed; /**> Signals as emited by Lua process() function */
|
||||
struct vlist signalsExpressions; /**> Signals as emited by Lua expressions */
|
||||
SignalList::Ptr signalsProcessed; /**> Signals as emited by Lua process() function */
|
||||
SignalList::Ptr signalsExpressions; /**> Signals as emited by Lua expressions */
|
||||
|
||||
lua_State *L;
|
||||
std::mutex mutex;
|
||||
|
@ -118,7 +119,7 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
LuaHook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true);
|
||||
LuaHook(Path *p, Node *n, int fl, int prio, bool en = true);
|
||||
|
||||
virtual ~LuaHook();
|
||||
|
||||
|
@ -139,11 +140,9 @@ public:
|
|||
virtual void restart();
|
||||
|
||||
/** Called whenever a sample is processed. */
|
||||
virtual Reason process(sample *smp);
|
||||
virtual Reason process(struct Sample *smp);
|
||||
};
|
||||
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -24,10 +24,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/** @addtogroup kernel Kernel
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
|
@ -42,16 +38,15 @@
|
|||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
struct nl_addr;
|
||||
struct rtnl_link;
|
||||
struct rtnl_qdisc;
|
||||
|
||||
namespace villas {
|
||||
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
class Node;
|
||||
class SuperNode;
|
||||
|
||||
}
|
||||
|
@ -69,7 +64,7 @@ protected:
|
|||
int affinity; /**< IRQ / Core Affinity of this interface. */
|
||||
|
||||
std::list<int> irqs; /**< List of IRQs of the NIC. */
|
||||
std::list<struct vnode *> nodes; /**< List of nodes which use this interface. */
|
||||
std::list<node::Node *> nodes; /**< List of nodes which use this interface. */
|
||||
|
||||
Logger logger;
|
||||
|
||||
|
@ -105,7 +100,7 @@ public:
|
|||
*/
|
||||
static
|
||||
Interface *
|
||||
getEgress(struct sockaddr *sa, villas::node::SuperNode *sn);
|
||||
getEgress(struct sockaddr *sa, node::SuperNode *sn);
|
||||
|
||||
/** Get all IRQs for this interface.
|
||||
*
|
||||
|
@ -129,7 +124,7 @@ public:
|
|||
|
||||
std::string getName() const;
|
||||
|
||||
void addNode(struct vnode *n)
|
||||
void addNode(node::Node *n)
|
||||
{
|
||||
nodes.push_back(n);
|
||||
}
|
||||
|
@ -137,5 +132,3 @@ public:
|
|||
|
||||
} /* namespace kernel */
|
||||
} /* namespace villas */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,10 +21,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/** @addtogroup kernel Kernel
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
@ -63,5 +59,3 @@ void shutdown();
|
|||
} /* namespace nl */
|
||||
} /* namespace kernel */
|
||||
} /* namespace villas */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -26,10 +26,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/** @addtogroup kernel Kernel
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -83,5 +79,3 @@ int mark(Interface *i, struct rtnl_cls **cls, tc_hdl_t flowid, uint32_t mark);
|
|||
} /* namespace tc */
|
||||
} /* namespace kernel */
|
||||
} /* namespace villas */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -26,10 +26,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/** @addtogroup kernel Kernel
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -81,5 +77,3 @@ int netem_set_delay_distribution(struct rtnl_qdisc *qdisc, json_t *json);
|
|||
} /* namespace tc */
|
||||
} /* namespace kernel */
|
||||
} /* namespace villas */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLAScommon
|
||||
|
@ -26,7 +26,7 @@
|
|||
#include <mutex>
|
||||
|
||||
#include <villas/log.hpp>
|
||||
#include <villas/config.h>
|
||||
#include <villas/config.hpp>
|
||||
|
||||
#include <spdlog/sinks/base_sink.h>
|
||||
#include <spdlog/details/null_mutex.h>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/** Sample value remapping for mux.
|
||||
/** Sample value remapping for path source muxing.
|
||||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -24,9 +24,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <jansson.h>
|
||||
#include <memory>
|
||||
|
||||
#include <villas/stats.hpp>
|
||||
#include <villas/common.hpp>
|
||||
#include <villas/stats.hpp>
|
||||
#include <villas/node_list.hpp>
|
||||
|
||||
#define RE_MAPPING_INDEX "[a-zA-Z0-9_]+"
|
||||
|
@ -39,35 +40,39 @@
|
|||
#define RE_MAPPING_DATA2 "(?:data\\.)?(" RE_MAPPING_INDEX ")"
|
||||
#define RE_MAPPING "(?:(" RE_NODE_NAME ")\\.(?:" RE_MAPPING_STATS "|" RE_MAPPING_HDR "|" RE_MAPPING_TS "|" RE_MAPPING_DATA1 "|" RE_MAPPING_DATA2 ")|(" RE_NODE_NAME ")(?:\\[" RE_MAPPING_RANGE "\\])?)"
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
struct sample;
|
||||
struct signal;
|
||||
struct vlist;
|
||||
class Node;
|
||||
struct Sample;
|
||||
class Signal;
|
||||
|
||||
enum class MappingType {
|
||||
UNKNOWN,
|
||||
DATA,
|
||||
STATS,
|
||||
HEADER,
|
||||
TIMESTAMP
|
||||
};
|
||||
class MappingEntry {
|
||||
|
||||
enum class MappingHeaderType {
|
||||
LENGTH,
|
||||
SEQUENCE
|
||||
};
|
||||
public:
|
||||
using Ptr = std::shared_ptr<MappingEntry>;
|
||||
|
||||
enum class MappingTimestampType {
|
||||
ORIGIN,
|
||||
RECEIVED
|
||||
};
|
||||
enum class Type {
|
||||
UNKNOWN,
|
||||
DATA,
|
||||
STATS,
|
||||
HEADER,
|
||||
TIMESTAMP
|
||||
};
|
||||
|
||||
struct mapping_entry {
|
||||
char *node_name;
|
||||
struct vnode *node; /**< The node to which this mapping refers. */
|
||||
enum class HeaderType {
|
||||
LENGTH,
|
||||
SEQUENCE
|
||||
};
|
||||
|
||||
enum MappingType type; /**< The mapping type. Selects one of the union fields below. */
|
||||
enum class TimestampType {
|
||||
ORIGIN,
|
||||
RECEIVED
|
||||
};
|
||||
|
||||
Node *node; /**< The node to which this mapping refers. */
|
||||
enum Type type; /**< The mapping type. Selects one of the union fields below. */
|
||||
|
||||
/** The number of values which is covered by this mapping entry.
|
||||
*
|
||||
|
@ -79,43 +84,42 @@ struct mapping_entry {
|
|||
union {
|
||||
struct {
|
||||
int offset;
|
||||
struct signal *signal;
|
||||
Signal *signal;
|
||||
|
||||
char *first;
|
||||
char *last;
|
||||
} data;
|
||||
|
||||
struct {
|
||||
enum villas::Stats::Metric metric;
|
||||
enum villas::Stats::Type type;
|
||||
enum Stats::Metric metric;
|
||||
enum Stats::Type type;
|
||||
} stats;
|
||||
|
||||
struct {
|
||||
enum MappingHeaderType type;
|
||||
enum HeaderType type;
|
||||
} header;
|
||||
|
||||
struct {
|
||||
enum MappingTimestampType type;
|
||||
enum TimestampType type;
|
||||
} timestamp;
|
||||
};
|
||||
|
||||
std::string nodeName; /**< Used for between parse and prepare only. */
|
||||
|
||||
MappingEntry();
|
||||
|
||||
int prepare(NodeList &nodes);
|
||||
|
||||
int update(struct Sample *remapped, const struct Sample *original) const;
|
||||
|
||||
int parse(json_t *json);
|
||||
|
||||
int parseString(const std::string &str);
|
||||
|
||||
std::string toString(unsigned index) const;
|
||||
|
||||
Signal::Ptr toSignal(unsigned index) const;
|
||||
};
|
||||
|
||||
int mapping_entry_prepare(struct mapping_entry *me, villas::node::NodeList &nodes);
|
||||
|
||||
int mapping_entry_update(const struct mapping_entry *me, struct sample *remapped, const struct sample *original);
|
||||
|
||||
int mapping_entry_init(struct mapping_entry *me);
|
||||
|
||||
int mapping_entry_destroy(struct mapping_entry *me);
|
||||
|
||||
int mapping_entry_parse(struct mapping_entry *me, json_t *json);
|
||||
|
||||
int mapping_entry_parse_str(struct mapping_entry *e, const std::string &str);
|
||||
|
||||
int mapping_entry_to_str(const struct mapping_entry *me, unsigned index, char **str);
|
||||
|
||||
int mapping_list_parse(struct vlist *ml, json_t *json);
|
||||
|
||||
int mapping_list_prepare(struct vlist *ml, villas::node::NodeList &nodes);
|
||||
|
||||
int mapping_list_remap(const struct vlist *ml, struct sample *remapped, const struct sample *original);
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
47
include/villas/mapping_list.hpp
Normal file
47
include/villas/mapping_list.hpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#pragma once
|
||||
|
||||
/** Sample value remapping for path source muxing.
|
||||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <villas/mapping.hpp>
|
||||
#include <villas/node_list.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
class MappingList : public std::list<MappingEntry::Ptr> {
|
||||
|
||||
public:
|
||||
int parse(json_t *json);
|
||||
|
||||
int prepare(NodeList &nodes);
|
||||
|
||||
int remap(struct Sample *remapped, const struct Sample *original) const;
|
||||
|
||||
int update(const MappingEntry::Ptr me, struct Sample *remapped, const struct Sample *original);
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Dennis Potter <dennis@dennispotter.eu>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -23,11 +23,19 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <villas/node.h>
|
||||
#include <villas/node.hpp>
|
||||
|
||||
struct memory_ib {
|
||||
namespace villas {
|
||||
namespace node {
|
||||
namespace memory {
|
||||
|
||||
struct IB {
|
||||
struct ibv_pd *pd;
|
||||
struct memory_type *parent;
|
||||
struct Type *parent;
|
||||
};
|
||||
|
||||
struct ibv_mr * memory_ib_get_mr(void *ptr);
|
||||
struct ibv_mr * ib_get_mr(void *ptr);
|
||||
|
||||
} /* namespace memory */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -1,242 +0,0 @@
|
|||
/** Nodes
|
||||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup node Node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <jansson.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <spdlog/fmt/ostr.h>
|
||||
|
||||
#include <villas/node_type.h>
|
||||
#include <villas/node_list.hpp>
|
||||
#include <villas/node_direction.h>
|
||||
#include <villas/sample.h>
|
||||
#include <villas/list.h>
|
||||
#include <villas/queue.h>
|
||||
#include <villas/common.hpp>
|
||||
#include <villas/stats.hpp>
|
||||
#include <villas/log.hpp>
|
||||
#include <villas/node_type.h>
|
||||
|
||||
#if defined(LIBNL3_ROUTE_FOUND) && defined(__linux__)
|
||||
#define WITH_NETEM
|
||||
#endif /* LIBNL3_ROUTE_FOUND */
|
||||
|
||||
/* Forward declarations */
|
||||
#ifdef WITH_NETEM
|
||||
struct rtnl_qdisc;
|
||||
struct rtnl_cls;
|
||||
#endif /* WITH_NETEM */
|
||||
|
||||
#define RE_NODE_NAME "[a-z0-9_-]{2,32}"
|
||||
|
||||
/* Forward declaration */
|
||||
static inline
|
||||
struct vnode_type * node_type(const struct vnode *n);
|
||||
|
||||
/** The data structure for a node.
|
||||
*
|
||||
* Every entity which exchanges messages is represented by a node.
|
||||
* Nodes can be remote machines and simulators or locally running processes.
|
||||
*/
|
||||
struct vnode {
|
||||
char *name; /**< A short identifier of the node, only used for configuration and logging */
|
||||
bool enabled;
|
||||
|
||||
enum State state;
|
||||
villas::Logger logger;
|
||||
|
||||
char *_name; /**< Singleton: A string used to print to screen. */
|
||||
char *_name_long; /**< Singleton: A string used to print to screen. */
|
||||
|
||||
uuid_t uuid;
|
||||
|
||||
int affinity; /**< CPU Affinity of this node */
|
||||
|
||||
uint64_t sequence; /**< This is a counter of received samples, in case the node-type does not generate sequence numbers itself. */
|
||||
|
||||
std::shared_ptr<villas::Stats> stats; /**< Statistic counters. This is a pointer to the statistic hooks private data. */
|
||||
|
||||
struct vnode_direction in, out;
|
||||
|
||||
#ifdef __linux__
|
||||
int fwmark; /**< Socket mark for netem, routing and filtering */
|
||||
|
||||
#ifdef WITH_NETEM
|
||||
struct rtnl_qdisc *tc_qdisc; /**< libnl3: Network emulator queuing discipline */
|
||||
struct rtnl_cls *tc_classifier; /**< libnl3: Firewall mark classifier */
|
||||
#endif /* WITH_NETEM */
|
||||
#endif /* __linux__ */
|
||||
|
||||
struct vlist sources; /**< A list of path sources which reference this node (struct vpath_sources). */
|
||||
struct vlist destinations; /**< A list of path destinations which reference this node (struct vpath_destinations). */
|
||||
|
||||
struct vnode_type *_vt; /**< Virtual functions (C++ OOP style) */
|
||||
void *_vd; /**< Virtual data (used by struct vnode::_vt functions) */
|
||||
|
||||
json_t *config; /**< A JSON object containing the configuration of the node. */
|
||||
|
||||
/** Custom formatter for spdlog */
|
||||
template<typename OStream>
|
||||
friend OStream &operator<<(OStream &os, const struct vnode &n)
|
||||
{
|
||||
os << n.name << "(" << *node_type(&n) << ")";
|
||||
|
||||
return os;
|
||||
}
|
||||
};
|
||||
|
||||
/** Initialize node with default values */
|
||||
int node_init(struct vnode *n, struct vnode_type *vt) __attribute__ ((warn_unused_result));
|
||||
|
||||
/** Do initialization after parsing the configuration */
|
||||
int node_prepare(struct vnode *n);
|
||||
|
||||
/** Parse settings of a node.
|
||||
*
|
||||
* @param json A JSON object containing the configuration of the node.
|
||||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int node_parse(struct vnode *n, json_t *json, const uuid_t sn_uuid);
|
||||
|
||||
/** Parse an array or single node and checks if they exist in the "nodes" section.
|
||||
*
|
||||
* Examples:
|
||||
* out = [ "sintef", "scedu" ]
|
||||
* out = "acs"
|
||||
*
|
||||
* @param json A JSON array or string. See examples above.
|
||||
* @param nodes The nodes will be added to this list.
|
||||
* @param all This list contains all valid nodes.
|
||||
*/
|
||||
int node_list_parse(struct vlist *list, json_t *json, villas::node::NodeList &all);
|
||||
|
||||
/** Parse the list of signal definitions. */
|
||||
int node_parse_signals(struct vlist *list, json_t *json);
|
||||
|
||||
/** Validate node configuration. */
|
||||
int node_check(struct vnode *n);
|
||||
|
||||
/** Start operation of a node.
|
||||
*
|
||||
* @see node_type::start
|
||||
*/
|
||||
int node_start(struct vnode *n);
|
||||
|
||||
/** Stops operation of a node.
|
||||
*
|
||||
* @see node_type::stop
|
||||
*/
|
||||
int node_stop(struct vnode *n);
|
||||
|
||||
/** Pauses operation of a node.
|
||||
*
|
||||
* @see node_type::stop
|
||||
*/
|
||||
int node_pause(struct vnode *n);
|
||||
|
||||
/** Resumes operation of a node.
|
||||
*
|
||||
* @see node_type::stop
|
||||
*/
|
||||
int node_resume(struct vnode *n);
|
||||
|
||||
/** Restarts operation of a node.
|
||||
*
|
||||
* @see node_type::stop
|
||||
*/
|
||||
int node_restart(struct vnode *n);
|
||||
|
||||
/** Destroy node by freeing dynamically allocated memory.
|
||||
*
|
||||
* @see node_type::destroy
|
||||
*/
|
||||
int node_destroy(struct vnode *n) __attribute__ ((warn_unused_result));
|
||||
|
||||
/** Return a pointer to a string which should be used to print this node.
|
||||
*
|
||||
* @see node::_name‚
|
||||
* @param n A pointer to the node structure.
|
||||
*/
|
||||
const char * node_name_short(struct vnode *n);
|
||||
|
||||
/** Return a pointer to a string which should be used to print this node. */
|
||||
char * node_name(struct vnode *n);
|
||||
|
||||
/** Return a pointer to a string which should be used to print this node.
|
||||
*
|
||||
* @see node::_name_short
|
||||
* @see node_type::print
|
||||
* @param n A pointer to the node structure.
|
||||
*/
|
||||
char * node_name_long(struct vnode *n);
|
||||
|
||||
/** Return a list of signals which are sent to this node.
|
||||
*
|
||||
* This list is derived from the path which uses the node as destination.
|
||||
*/
|
||||
struct vlist * node_output_signals(struct vnode *n);
|
||||
|
||||
struct vlist * node_input_signals(struct vnode *n);
|
||||
|
||||
unsigned node_input_signals_max_cnt(struct vnode *n);
|
||||
|
||||
unsigned node_output_signals_max_cnt(struct vnode *n);
|
||||
|
||||
/** Reverse local and remote socket address.
|
||||
*
|
||||
* @see node_type::reverse
|
||||
*/
|
||||
int node_reverse(struct vnode *n);
|
||||
|
||||
int node_read(struct vnode *n, struct sample * smps[], unsigned cnt);
|
||||
|
||||
int node_write(struct vnode *n, struct sample * smps[], unsigned cnt);
|
||||
|
||||
int node_poll_fds(struct vnode *n, int fds[]);
|
||||
|
||||
int node_netem_fds(struct vnode *n, int fds[]);
|
||||
|
||||
static inline
|
||||
struct vnode_type * node_type(const struct vnode *n)
|
||||
{
|
||||
return n->_vt;
|
||||
}
|
||||
|
||||
struct memory_type * node_memory_type(struct vnode *n);
|
||||
|
||||
bool node_is_valid_name(const char *name);
|
||||
|
||||
bool node_is_enabled(const struct vnode *n);
|
||||
|
||||
json_t * node_to_json(struct vnode *);
|
||||
|
||||
/** @} */
|
484
include/villas/node.hpp
Normal file
484
include/villas/node.hpp
Normal file
|
@ -0,0 +1,484 @@
|
|||
/** Nodes
|
||||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jansson.h>
|
||||
#include <uuid/uuid.h>
|
||||
#include <spdlog/fmt/ostr.h>
|
||||
|
||||
#include <villas/node_list.hpp>
|
||||
#include <villas/node_direction.hpp>
|
||||
#include <villas/node/memory.hpp>
|
||||
#include <villas/sample.hpp>
|
||||
#include <villas/list.hpp>
|
||||
#include <villas/queue.h>
|
||||
#include <villas/common.hpp>
|
||||
#include <villas/stats.hpp>
|
||||
#include <villas/log.hpp>
|
||||
#include <villas/plugin.hpp>
|
||||
#include <villas/path_source.hpp>
|
||||
#include <villas/path_destination.hpp>
|
||||
|
||||
#if defined(LIBNL3_ROUTE_FOUND) && defined(__linux__)
|
||||
#define WITH_NETEM
|
||||
#endif /* LIBNL3_ROUTE_FOUND */
|
||||
|
||||
/* Forward declarations */
|
||||
#ifdef WITH_NETEM
|
||||
struct rtnl_qdisc;
|
||||
struct rtnl_cls;
|
||||
#endif /* WITH_NETEM */
|
||||
|
||||
#define RE_NODE_NAME "[a-z0-9_-]{2,32}"
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
class NodeFactory;
|
||||
class SuperNode;
|
||||
|
||||
/** The class for a node.
|
||||
*
|
||||
* Every entity which exchanges messages is represented by a node.
|
||||
* Nodes can be remote machines and simulators or locally running processes.
|
||||
*/
|
||||
class Node {
|
||||
|
||||
friend NodeFactory;
|
||||
|
||||
public:
|
||||
Logger logger;
|
||||
|
||||
uint64_t sequence_init;
|
||||
uint64_t sequence; /**< This is a counter of received samples, in case the node-type does not generate sequence numbers itself. */
|
||||
|
||||
NodeDirection in, out;
|
||||
|
||||
PathSourceList sources; /**< A list of path sources which reference this node. */
|
||||
PathDestinationList destinations; /**< A list of path destinations which reference this node. */
|
||||
|
||||
#ifdef __linux__
|
||||
int fwmark; /**< Socket mark for netem, routing and filtering */
|
||||
|
||||
#ifdef WITH_NETEM
|
||||
struct rtnl_qdisc *tc_qdisc; /**< libnl3: Network emulator queuing discipline */
|
||||
struct rtnl_cls *tc_classifier; /**< libnl3: Firewall mark classifier */
|
||||
#endif /* WITH_NETEM */
|
||||
#endif /* __linux__ */
|
||||
|
||||
protected:
|
||||
enum State state;
|
||||
|
||||
uuid_t uuid;
|
||||
|
||||
bool enabled;
|
||||
|
||||
Stats::Ptr stats; /**< Statistic counters. This is a pointer to the statistic hooks private data. */
|
||||
|
||||
json_t *config; /**< A JSON object containing the configuration of the node. */
|
||||
|
||||
std::string name_short; /**< A short identifier of the node, only used for configuration and logging */
|
||||
std::string name_long; /**< Singleton: A string used to print to screen. */
|
||||
std::string name_full; /**< Singleton: A string used to print to screen. */
|
||||
std::string details;
|
||||
|
||||
int affinity; /**< CPU Affinity of this node */
|
||||
|
||||
NodeFactory *factory; /**< The factory which created this instance */
|
||||
|
||||
virtual
|
||||
int _read(struct Sample * smps[], unsigned cnt)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
virtual
|
||||
int _write(struct Sample * smps[], unsigned cnt)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public:
|
||||
/** Initialize node with default values */
|
||||
Node(const std::string &name = "");
|
||||
|
||||
/** Destroy node by freeing dynamically allocated memory.
|
||||
*
|
||||
* @see node_type::destroy
|
||||
*/
|
||||
virtual
|
||||
~Node();
|
||||
|
||||
/** Do initialization after parsing the configuration */
|
||||
virtual
|
||||
int prepare();
|
||||
|
||||
/** Parse settings of a node.
|
||||
*
|
||||
* @param json A JSON object containing the configuration of the node.
|
||||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
virtual
|
||||
int parse(json_t *json, const uuid_t sn_uuid);
|
||||
|
||||
/** Validate node configuration. */
|
||||
virtual
|
||||
int check();
|
||||
|
||||
/** Start operation of a node.
|
||||
*
|
||||
* @see node_type::start
|
||||
*/
|
||||
virtual
|
||||
int start();
|
||||
|
||||
/** Stops operation of a node.
|
||||
*
|
||||
* @see node_type::stop
|
||||
*/
|
||||
virtual
|
||||
int stop();
|
||||
|
||||
/** Pauses operation of a node.
|
||||
*
|
||||
* @see node_type::stop
|
||||
*/
|
||||
virtual
|
||||
int pause()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Resumes operation of a node.
|
||||
*
|
||||
* @see node_type::stop
|
||||
*/
|
||||
virtual
|
||||
int resume()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Restarts operation of a node.
|
||||
*
|
||||
* @see node_type::stop
|
||||
*/
|
||||
virtual
|
||||
int restart();
|
||||
|
||||
/** Receive multiple messages at once.
|
||||
*
|
||||
* This callback is optional. It will only be called if non-null.
|
||||
*
|
||||
* Messages are received with a single recvmsg() syscall by
|
||||
* using gathering techniques (struct iovec).
|
||||
* The messages will be stored in a circular buffer / array @p m.
|
||||
* Indexes used to address @p m will wrap around after len messages.
|
||||
* Some node-types might only support to receive one message at a time.
|
||||
*
|
||||
* @param smps An array of pointers to memory blocks where the function should store received samples.
|
||||
* @param cnt The number of samples that are allocated by the calling function.
|
||||
* @return The number of messages actually received.
|
||||
*/
|
||||
int read(struct Sample * smps[], unsigned cnt);
|
||||
|
||||
/** Send multiple messages in a single datagram / packet.
|
||||
*
|
||||
* This callback is optional. It will only be called if non-null.
|
||||
*
|
||||
* Messages are sent with a single sendmsg() syscall by
|
||||
* using gathering techniques (struct iovec).
|
||||
* The messages have to be stored in a circular buffer / array m.
|
||||
* So the indexes will wrap around after len.
|
||||
*
|
||||
* @param smps An array of pointers to memory blocks where samples read from.
|
||||
* @param cnt The number of samples that are allocated by the calling function.
|
||||
* @return The number of messages actually sent.
|
||||
*/
|
||||
int write(struct Sample * smps[], unsigned cnt);
|
||||
|
||||
/** Reverse local and remote socket address.
|
||||
*
|
||||
* @see node_type::reverse
|
||||
*/
|
||||
virtual
|
||||
int reverse()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
virtual
|
||||
std::vector<int> getPollFDs()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
virtual
|
||||
int getNetemFDs(int fds[])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual
|
||||
struct villas::node::memory::Type * getMemoryType()
|
||||
{
|
||||
return villas::node::memory::default_type;
|
||||
}
|
||||
|
||||
villas::node::NodeFactory * getFactory() const
|
||||
{
|
||||
return factory;
|
||||
}
|
||||
|
||||
/** Return a pointer to a string which should be used to print this node.
|
||||
*
|
||||
* @see Node::name_short
|
||||
* @param n A pointer to the node structure.
|
||||
*/
|
||||
std::string getNameShort() const
|
||||
{
|
||||
return name_short;
|
||||
}
|
||||
|
||||
/** Return a pointer to a string which should be used to print this node. */
|
||||
const std::string & getName() const
|
||||
{
|
||||
return name_long;
|
||||
}
|
||||
|
||||
const std::string & getNameFull();
|
||||
|
||||
virtual
|
||||
const std::string & getDetails()
|
||||
{
|
||||
static std::string empty;
|
||||
return empty;
|
||||
}
|
||||
|
||||
/** Return a pointer to a string which should be used to print this node.
|
||||
*
|
||||
* @see Node::name_long
|
||||
* @see node_type::print
|
||||
* @param n A pointer to the node structure.
|
||||
*/
|
||||
const std::string & getNameLong();
|
||||
|
||||
/** Return a list of signals which are sent to this node.
|
||||
*
|
||||
* This list is derived from the path which uses the node as destination.
|
||||
*/
|
||||
SignalList::Ptr getOutputSignals(bool after_hooks = true) const;
|
||||
SignalList::Ptr getInputSignals(bool after_hooks = true) const;
|
||||
|
||||
unsigned getInputSignalsMaxCount() const;
|
||||
unsigned getOutputSignalsMaxCount() const;
|
||||
|
||||
void swapSignals();
|
||||
|
||||
json_t * getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
enum State getState() const
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
void setState(enum State s)
|
||||
{
|
||||
state = s;
|
||||
}
|
||||
|
||||
const uuid_t & getUuid() const
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
||||
std::shared_ptr<Stats> getStats()
|
||||
{
|
||||
return stats;
|
||||
}
|
||||
|
||||
void setStats(std::shared_ptr<Stats> sts)
|
||||
{
|
||||
stats = sts;
|
||||
}
|
||||
|
||||
void setEnabled(bool en)
|
||||
{
|
||||
enabled = en;
|
||||
}
|
||||
|
||||
/** Custom formatter for spdlog */
|
||||
template<typename OStream>
|
||||
friend OStream &operator<<(OStream &os, const Node &n)
|
||||
{
|
||||
os << n.getName();
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
json_t * toJson() const;
|
||||
|
||||
static
|
||||
bool isValidName(const std::string &name);
|
||||
|
||||
bool isEnabled() const
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
};
|
||||
|
||||
class NodeFactory : public villas::plugin::Plugin {
|
||||
|
||||
friend Node;
|
||||
|
||||
protected:
|
||||
virtual
|
||||
void init(Node *n)
|
||||
{
|
||||
n->logger = getLogger();
|
||||
n->factory = this;
|
||||
|
||||
instances.push_back(n);
|
||||
}
|
||||
|
||||
State state;
|
||||
|
||||
public:
|
||||
enum class Flags {
|
||||
SUPPORTS_POLL = (1 << 0),
|
||||
SUPPORTS_READ = (1 << 1),
|
||||
SUPPORTS_WRITE = (1 << 2),
|
||||
REQUIRES_WEB = (1 << 3),
|
||||
PROVIDES_SIGNALS = (1 << 4),
|
||||
INTERNAL = (1 << 5)
|
||||
};
|
||||
|
||||
NodeList instances;
|
||||
|
||||
NodeFactory() :
|
||||
Plugin()
|
||||
{
|
||||
state = State::INITIALIZED;
|
||||
}
|
||||
|
||||
virtual
|
||||
Node * make() = 0;
|
||||
|
||||
static
|
||||
Node * make(json_t *json, uuid_t uuid);
|
||||
|
||||
static
|
||||
Node * make(const std::string &type);
|
||||
|
||||
virtual
|
||||
std::string getType() const
|
||||
{
|
||||
return "node";
|
||||
}
|
||||
|
||||
/** Custom formatter for spdlog */
|
||||
template<typename OStream>
|
||||
friend OStream &operator<<(OStream &os, const NodeFactory &f)
|
||||
{
|
||||
os << f.getName();
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
virtual
|
||||
int getFlags() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual
|
||||
int getVectorize() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
isInternal() const
|
||||
{
|
||||
return getFlags() & (int) Flags::INTERNAL;
|
||||
}
|
||||
|
||||
virtual
|
||||
int start(SuperNode *sn);
|
||||
|
||||
virtual
|
||||
int stop();
|
||||
|
||||
State getState() const
|
||||
{
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, const char *name, const char *desc, int flags = 0, int vectorize = 0>
|
||||
class NodePlugin : public NodeFactory {
|
||||
|
||||
public:
|
||||
virtual
|
||||
Node * make()
|
||||
{
|
||||
T* n = new T();
|
||||
|
||||
init(n);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
virtual
|
||||
int getFlags() const
|
||||
{
|
||||
return flags;
|
||||
}
|
||||
|
||||
virtual
|
||||
int getVectorize() const
|
||||
{
|
||||
return vectorize;
|
||||
}
|
||||
|
||||
virtual std::string
|
||||
getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
virtual std::string
|
||||
getDescription() const
|
||||
{
|
||||
return desc;
|
||||
}
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
|
@ -5,7 +5,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -26,7 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <villas/config.h>
|
||||
#include <villas/config.hpp>
|
||||
|
||||
/** Default number of values in a sample */
|
||||
#define DEFAULT_SAMPLE_LENGTH 64u
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <villas/node/config.h>
|
||||
#include <villas/node/config.hpp>
|
||||
#include <villas/exceptions.hpp>
|
||||
|
||||
#ifdef WITH_CONFIG
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -23,29 +23,34 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef IBVERBS_FOUND
|
||||
#include <infiniband/verbs.h>
|
||||
#endif /* IBVERBS_FOUND */
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include <villas/node/config.h>
|
||||
#include <villas/memory_type.h>
|
||||
#include <villas/node/config.hpp>
|
||||
#include <villas/node/memory_type.hpp>
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
namespace villas {
|
||||
namespace node {
|
||||
namespace memory {
|
||||
|
||||
/** Descriptor of a memory block. Associated block always starts at
|
||||
* &m + sizeof(struct memory_block). */
|
||||
struct memory_block {
|
||||
struct memory_block *prev;
|
||||
struct memory_block *next;
|
||||
* &m + sizeof(struct Block). */
|
||||
struct Block {
|
||||
struct Block *prev;
|
||||
struct Block *next;
|
||||
size_t length; /**< Length of the block; doesn't include the descriptor itself */
|
||||
bool used;
|
||||
};
|
||||
|
||||
/** @todo Unused for now */
|
||||
struct memory_allocation {
|
||||
struct memory_type *type;
|
||||
struct Allocation {
|
||||
struct Type *type;
|
||||
|
||||
struct memory_allocation *parent;
|
||||
struct Allocation *parent;
|
||||
|
||||
void *address;
|
||||
size_t alignment;
|
||||
|
@ -58,25 +63,29 @@ struct memory_allocation {
|
|||
} ib;
|
||||
#endif
|
||||
struct {
|
||||
struct memory_block *block;
|
||||
struct Block *block;
|
||||
} managed;
|
||||
};
|
||||
};
|
||||
|
||||
/** Initilialize memory subsystem */
|
||||
int memory_init(int hugepages) __attribute__ ((warn_unused_result));
|
||||
int init(int hugepages) __attribute__ ((warn_unused_result));
|
||||
|
||||
int memory_lock(size_t lock);
|
||||
int lock(size_t lock);
|
||||
|
||||
/** Allocate \p len bytes memory of type \p m.
|
||||
*
|
||||
* @retval nullptr If allocation failed.
|
||||
* @retval <>0 If allocation was successful.
|
||||
*/
|
||||
void * memory_alloc(size_t len, struct memory_type *m = memory_default);
|
||||
void * alloc(size_t len, struct Type *m = default_type);
|
||||
|
||||
void * memory_alloc_aligned(size_t len, size_t alignment, struct memory_type *m = memory_default);
|
||||
void * alloc_aligned(size_t len, size_t alignment, struct Type *m = default_type);
|
||||
|
||||
int memory_free(void *ptr);
|
||||
int free(void *ptr);
|
||||
|
||||
struct memory_allocation * memory_get_allocation(void *ptr);
|
||||
struct Allocation * get_allocation(void *ptr);
|
||||
|
||||
} /* namespace memory */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -26,38 +26,48 @@
|
|||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct memory_type;
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
typedef struct memory_allocation * (*memory_allocator_t)(size_t len, size_t alignment, struct memory_type *mem);
|
||||
typedef int (*memory_deallocator_t)(struct memory_allocation * ma, struct memory_type *mem);
|
||||
namespace memory {
|
||||
|
||||
enum class MemoryFlags {
|
||||
struct Type;
|
||||
|
||||
typedef struct Allocation * (*allocator_t)(size_t len, size_t alignment, struct Type *mem);
|
||||
typedef int (*deallocator_t)(struct Allocation * ma, struct Type *mem);
|
||||
|
||||
enum class Flags {
|
||||
MMAP = (1 << 0),
|
||||
DMA = (1 << 1),
|
||||
HUGEPAGE = (1 << 2),
|
||||
HEAP = (1 << 3)
|
||||
};
|
||||
|
||||
struct memory_type {
|
||||
struct Type {
|
||||
const char *name;
|
||||
int flags;
|
||||
|
||||
size_t alignment;
|
||||
|
||||
memory_allocator_t alloc;
|
||||
memory_deallocator_t free;
|
||||
allocator_t alloc;
|
||||
deallocator_t free;
|
||||
|
||||
void *_vd; /**< Virtual data for internal state */
|
||||
};
|
||||
|
||||
extern struct memory_type memory_heap;
|
||||
extern struct memory_type memory_mmap;
|
||||
extern struct memory_type memory_mmap_hugetlb;
|
||||
extern struct memory_type *memory_default;
|
||||
extern struct Type heap;
|
||||
extern struct Type mmap;
|
||||
extern struct Type mmap_hugetlb;
|
||||
extern struct Type *default_type;
|
||||
|
||||
struct memory_type * memory_ib(struct vnode *n, struct memory_type *parent);
|
||||
struct memory_type * memory_managed(void *ptr, size_t len);
|
||||
struct Type * ib(NodeCompat *n, struct Type *parent);
|
||||
struct Type * managed(void *ptr, size_t len);
|
||||
|
||||
int memory_mmap_init(int hugepages) __attribute__ ((warn_unused_result));
|
||||
int mmap_init(int hugepages) __attribute__ ((warn_unused_result));
|
||||
|
||||
} /* namespace memory */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
221
include/villas/node_compat.hpp
Normal file
221
include/villas/node_compat.hpp
Normal file
|
@ -0,0 +1,221 @@
|
|||
/** Node compatability layer for C++
|
||||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup node Node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#include <villas/sample.hpp>
|
||||
#include <villas/node.hpp>
|
||||
#include <villas/node_compat_type.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
class NodeCompatFactory;
|
||||
|
||||
class NodeCompat : public Node {
|
||||
|
||||
protected:
|
||||
struct NodeCompatType *_vt; /**< Virtual functions (C++ OOP style) */
|
||||
void *_vd; /**< Virtual data (used by struct vnode::_vt functions) */
|
||||
|
||||
std::string _details;
|
||||
|
||||
virtual
|
||||
int _read(struct Sample *smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
int _write(struct Sample *smps[], unsigned cnt);
|
||||
|
||||
public:
|
||||
NodeCompat *node;
|
||||
json_t *cfg;
|
||||
|
||||
NodeCompat(struct NodeCompatType *vt);
|
||||
NodeCompat(const NodeCompat& n);
|
||||
|
||||
NodeCompat& operator=(const NodeCompat& other);
|
||||
|
||||
virtual
|
||||
~NodeCompat();
|
||||
|
||||
template<typename T>
|
||||
T * getData()
|
||||
{
|
||||
return static_cast<T *>(_vd);
|
||||
}
|
||||
|
||||
virtual
|
||||
NodeCompatType * getType() const
|
||||
{
|
||||
return _vt;
|
||||
}
|
||||
|
||||
/** Parse node connection details.
|
||||
|
||||
*
|
||||
* @param cfg A JSON object containing the configuration of the node.
|
||||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
virtual
|
||||
int parse(json_t *cfg, const uuid_t sn_uuid);
|
||||
|
||||
/** Returns a string with a textual represenation of this node. */
|
||||
virtual
|
||||
const std::string & getDetails();
|
||||
|
||||
/** Check the current node configuration for plausability and errors.
|
||||
|
||||
*
|
||||
* @retval 0 Success. Node configuration is good.
|
||||
* @retval <0 Error. The node configuration is bogus.
|
||||
*/
|
||||
virtual
|
||||
int check();
|
||||
|
||||
virtual
|
||||
int prepare();
|
||||
|
||||
/** Start this node.
|
||||
|
||||
*
|
||||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
virtual
|
||||
int start();
|
||||
|
||||
/** Stop this node.
|
||||
|
||||
*
|
||||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
virtual
|
||||
int stop();
|
||||
|
||||
/** Restart this node.
|
||||
|
||||
*
|
||||
* @param n A pointer to the node object.
|
||||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
virtual
|
||||
int restart();
|
||||
|
||||
/** Pause this node.
|
||||
|
||||
*
|
||||
* @param n A pointer to the node object.
|
||||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
virtual
|
||||
int pause();
|
||||
|
||||
/** Resume this node.
|
||||
|
||||
*
|
||||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
virtual
|
||||
int resume();
|
||||
|
||||
/** Reverse source and destination of a node.
|
||||
|
||||
*/
|
||||
virtual
|
||||
int reverse();
|
||||
|
||||
virtual
|
||||
std::vector<int> getPollFDs();
|
||||
|
||||
/** Get list of socket file descriptors for configuring network emulation.
|
||||
|
||||
*
|
||||
* @return The number of file descriptors which have been put into \p sds.
|
||||
*/
|
||||
virtual
|
||||
int getNetemFDs(int fds[]);
|
||||
|
||||
/** Return a memory allocator which should be used for sample pools passed to this node. */
|
||||
virtual
|
||||
struct memory::Type * getMemoryType();
|
||||
};
|
||||
|
||||
class NodeCompatFactory : public NodeFactory {
|
||||
|
||||
protected:
|
||||
struct NodeCompatType *_vt;
|
||||
|
||||
public:
|
||||
NodeCompatFactory(struct NodeCompatType *vt) :
|
||||
NodeFactory(),
|
||||
_vt(vt)
|
||||
{ }
|
||||
|
||||
virtual
|
||||
Node * make();
|
||||
|
||||
/// Get plugin name
|
||||
virtual
|
||||
std::string getName() const
|
||||
{
|
||||
return _vt->name;
|
||||
}
|
||||
|
||||
/// Get plugin description
|
||||
virtual
|
||||
std::string getDescription() const
|
||||
{
|
||||
return _vt->description;
|
||||
}
|
||||
|
||||
virtual
|
||||
int getFlags() const;
|
||||
|
||||
virtual
|
||||
int getVectorize() const
|
||||
{
|
||||
return _vt->vectorize;
|
||||
}
|
||||
|
||||
virtual
|
||||
int start(SuperNode *sn);
|
||||
|
||||
virtual
|
||||
int stop();
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -19,9 +19,6 @@
|
|||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @addtogroup node Node
|
||||
* @{
|
||||
*********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
@ -29,28 +26,21 @@
|
|||
#include <jansson.h>
|
||||
#include <spdlog/fmt/ostr.h>
|
||||
|
||||
#include <villas/node_list.hpp>
|
||||
#include <villas/common.hpp>
|
||||
#include <villas/memory.h>
|
||||
#include <villas/node/memory.hpp>
|
||||
#include <villas/log.hpp>
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
struct sample;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct Sample;
|
||||
class Node;
|
||||
class SuperNode;
|
||||
}
|
||||
}
|
||||
|
||||
enum class NodeFlags {
|
||||
PROVIDES_SIGNALS = (1 << 0),
|
||||
INTERNAL = (1 << 1)
|
||||
};
|
||||
class NodeCompatType {
|
||||
|
||||
/** C++ like vtable construct for node_types */
|
||||
struct vnode_type {
|
||||
public:
|
||||
const char *name;
|
||||
const char *description;
|
||||
|
||||
|
@ -59,8 +49,6 @@ struct vnode_type {
|
|||
|
||||
enum State state; /**< State of this node-type. */
|
||||
|
||||
villas::node::NodeList instances; /**< A list of all existing nodes of this type. */
|
||||
|
||||
size_t size; /**< Size of private data bock. @see node::_vd */
|
||||
|
||||
struct {
|
||||
|
@ -72,7 +60,7 @@ struct vnode_type {
|
|||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int (*start)(villas::node::SuperNode *sn);
|
||||
int (*start)(SuperNode *sn);
|
||||
|
||||
/** Global de-initialization per node type.
|
||||
*
|
||||
|
@ -92,7 +80,7 @@ struct vnode_type {
|
|||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int (*init)(struct vnode *n);
|
||||
int (*init)(NodeCompat *n);
|
||||
|
||||
/** Free memory of an instance of this type.
|
||||
*
|
||||
|
@ -100,7 +88,7 @@ struct vnode_type {
|
|||
*
|
||||
* @param n A pointer to the node object.
|
||||
*/
|
||||
int (*destroy)(struct vnode *n);
|
||||
int (*destroy)(NodeCompat *n);
|
||||
|
||||
/** Parse node connection details.
|
||||
*
|
||||
|
@ -111,7 +99,7 @@ struct vnode_type {
|
|||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int (*parse)(struct vnode *n, json_t *json);
|
||||
int (*parse)(NodeCompat *n, json_t *json);
|
||||
|
||||
/** Check the current node configuration for plausability and errors.
|
||||
*
|
||||
|
@ -121,9 +109,9 @@ struct vnode_type {
|
|||
* @retval 0 Success. Node configuration is good.
|
||||
* @retval <0 Error. The node configuration is bogus.
|
||||
*/
|
||||
int (*check)(struct vnode *n);
|
||||
int (*check)(NodeCompat *n);
|
||||
|
||||
int (*prepare)(struct vnode *);
|
||||
int (*prepare)(NodeCompat *n);
|
||||
|
||||
/** Returns a string with a textual represenation of this node.
|
||||
*
|
||||
|
@ -132,7 +120,7 @@ struct vnode_type {
|
|||
* @param n A pointer to the node object.
|
||||
* @return A pointer to a dynamically allocated string. Must be freed().
|
||||
*/
|
||||
char * (*print)(struct vnode *n);
|
||||
char * (*print)(NodeCompat *n);
|
||||
|
||||
/** Start this node.
|
||||
*
|
||||
|
@ -142,7 +130,7 @@ struct vnode_type {
|
|||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int (*start)(struct vnode *n);
|
||||
int (*start)(NodeCompat *n);
|
||||
|
||||
/** Restart this node.
|
||||
*
|
||||
|
@ -152,7 +140,7 @@ struct vnode_type {
|
|||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int (*restart)(struct vnode *n);
|
||||
int (*restart)(NodeCompat *n);
|
||||
|
||||
/** Stop this node.
|
||||
*
|
||||
|
@ -162,7 +150,7 @@ struct vnode_type {
|
|||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int (*stop)(struct vnode *n);
|
||||
int (*stop)(NodeCompat *n);
|
||||
|
||||
/** Pause this node.
|
||||
*
|
||||
|
@ -172,7 +160,7 @@ struct vnode_type {
|
|||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int (*pause)(struct vnode *n);
|
||||
int (*pause)(NodeCompat *n);
|
||||
|
||||
/** Resume this node.
|
||||
*
|
||||
|
@ -182,7 +170,7 @@ struct vnode_type {
|
|||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int (*resume)(struct vnode *n);
|
||||
int (*resume)(NodeCompat *n);
|
||||
|
||||
/** Receive multiple messages at once.
|
||||
*
|
||||
|
@ -200,7 +188,7 @@ struct vnode_type {
|
|||
* @param release The number of samples that should be released after read is called.
|
||||
* @return The number of messages actually received.
|
||||
*/
|
||||
int (*read)(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int (*read)(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** Send multiple messages in a single datagram / packet.
|
||||
*
|
||||
|
@ -217,7 +205,7 @@ struct vnode_type {
|
|||
* @param release The number of samples that should be released after write is called
|
||||
* @return The number of messages actually sent.
|
||||
*/
|
||||
int (*write)(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int (*write)(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** Reverse source and destination of a node.
|
||||
*
|
||||
|
@ -225,7 +213,7 @@ struct vnode_type {
|
|||
*
|
||||
* @param n A pointer to the node object.
|
||||
*/
|
||||
int (*reverse)(struct vnode *n);
|
||||
int (*reverse)(NodeCompat *n);
|
||||
|
||||
/** Get list of file descriptors which can be used by poll/select to detect the availability of new data.
|
||||
*
|
||||
|
@ -233,7 +221,7 @@ struct vnode_type {
|
|||
*
|
||||
* @return The number of file descriptors which have been put into \p fds.
|
||||
*/
|
||||
int (*poll_fds)(struct vnode *n, int fds[]);
|
||||
int (*poll_fds)(NodeCompat *n, int fds[]);
|
||||
|
||||
/** Get list of socket file descriptors for configuring network emulation.
|
||||
*
|
||||
|
@ -241,38 +229,11 @@ struct vnode_type {
|
|||
*
|
||||
* @return The number of file descriptors which have been put into \p sds.
|
||||
*/
|
||||
int (*netem_fds)(struct vnode *n, int sds[]);
|
||||
int (*netem_fds)(NodeCompat *n, int sds[]);
|
||||
|
||||
/** Return a memory allocator which should be used for sample pools passed to this node. */
|
||||
struct memory_type * (*memory_type)(struct vnode *n, struct memory_type *parent);
|
||||
|
||||
/** Custom formatter for spdlog */
|
||||
template<typename OStream>
|
||||
friend OStream &operator<<(OStream &os, const struct vnode_type &vt)
|
||||
{
|
||||
return os << vt.name;
|
||||
}
|
||||
struct memory::Type * (*memory_type)(NodeCompat *n, struct memory::Type *parent);
|
||||
};
|
||||
|
||||
/** Initialize all registered node type subsystems.
|
||||
*
|
||||
* @see node_type::init
|
||||
*/
|
||||
int node_type_start(struct vnode_type *vt, villas::node::SuperNode *sn);
|
||||
|
||||
/** De-initialize node type subsystems.
|
||||
*
|
||||
* @see node_type::deinit
|
||||
*/
|
||||
int node_type_stop(struct vnode_type *vt);
|
||||
|
||||
/** Return a printable representation of the node-type. */
|
||||
const char * node_type_name(struct vnode_type *vt);
|
||||
|
||||
struct vnode_type * node_type_lookup(const std::string &name);
|
||||
|
||||
using NodeTypeList = std::list<struct vnode_type *>;
|
||||
|
||||
extern NodeTypeList *node_types;
|
||||
|
||||
/** @} */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
|
@ -1,84 +0,0 @@
|
|||
/** Node direction
|
||||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup node Node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#include <villas/common.hpp>
|
||||
#include <villas/list.h>
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
struct vpath;
|
||||
|
||||
enum class NodeDir {
|
||||
IN, /**< VILLASnode is receiving/reading */
|
||||
OUT /**< VILLASnode is sending/writing */
|
||||
};
|
||||
|
||||
struct vnode_direction {
|
||||
enum State state;
|
||||
enum NodeDir direction;
|
||||
|
||||
/** The path which uses this node as a source/destination.
|
||||
*
|
||||
* Usually every node should be used only by a single path as destination.
|
||||
* Otherwise samples from different paths would be interleaved.
|
||||
*/
|
||||
struct vpath *path;
|
||||
|
||||
int enabled;
|
||||
int builtin; /**< This node should use built-in hooks by default. */
|
||||
unsigned vectorize; /**< Number of messages to send / recv at once (scatter / gather) */
|
||||
|
||||
struct vlist hooks; /**< List of read / write hooks (struct hook). */
|
||||
struct vlist signals; /**< Signal description. */
|
||||
|
||||
json_t *config; /**< A JSON object containing the configuration of the node. */
|
||||
};
|
||||
|
||||
int node_direction_init(struct vnode_direction *nd, enum NodeDir dir, struct vnode *n) __attribute__ ((warn_unused_result));
|
||||
|
||||
int node_direction_destroy(struct vnode_direction *nd, struct vnode *n) __attribute__ ((warn_unused_result));
|
||||
|
||||
int node_direction_parse(struct vnode_direction *nd, struct vnode *n, json_t *json);
|
||||
|
||||
void node_direction_check(struct vnode_direction *nd, struct vnode *n);
|
||||
|
||||
int node_direction_prepare(struct vnode_direction *nd, struct vnode *n);
|
||||
|
||||
int node_direction_start(struct vnode_direction *nd, struct vnode *n);
|
||||
|
||||
int node_direction_stop(struct vnode_direction *nd, struct vnode *n);
|
||||
|
||||
struct vlist * node_direction_get_signals(struct vnode_direction *nd);
|
||||
|
||||
unsigned node_direction_get_signals_max_cnt(struct vnode_direction *nd);
|
||||
|
||||
/** @} */
|
80
include/villas/node_direction.hpp
Normal file
80
include/villas/node_direction.hpp
Normal file
|
@ -0,0 +1,80 @@
|
|||
/** Node direction
|
||||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#include <villas/common.hpp>
|
||||
#include <villas/list.hpp>
|
||||
#include <villas/signal_list.hpp>
|
||||
#include <villas/hook_list.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
class Node;
|
||||
class Path;
|
||||
|
||||
class NodeDirection {
|
||||
friend Node;
|
||||
|
||||
public:
|
||||
enum class Direction {
|
||||
IN, /**< VILLASnode is receiving/reading */
|
||||
OUT /**< VILLASnode is sending/writing */
|
||||
} direction;
|
||||
|
||||
/** The path which uses this node as a source/destination.
|
||||
*
|
||||
* Usually every node should be used only by a single path as destination.
|
||||
* Otherwise samples from different paths would be interleaved.
|
||||
*/
|
||||
Path *path;
|
||||
Node *node;
|
||||
|
||||
int enabled;
|
||||
int builtin; /**< This node should use built-in hooks by default. */
|
||||
unsigned vectorize; /**< Number of messages to send / recv at once (scatter / gather) */
|
||||
|
||||
HookList hooks; /**< List of read / write hooks (struct hook). */
|
||||
SignalList::Ptr signals; /**< Signal description. */
|
||||
|
||||
json_t *config; /**< A JSON object containing the configuration of the node. */
|
||||
|
||||
NodeDirection(enum NodeDirection::Direction dir, Node *n);
|
||||
|
||||
int parse(json_t *json);
|
||||
void check();
|
||||
int prepare();
|
||||
int start();
|
||||
int stop();
|
||||
|
||||
SignalList::Ptr getSignals(int after_hooks = true) const;
|
||||
|
||||
unsigned getSignalsMaxCount() const;
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
|
@ -24,24 +24,39 @@
|
|||
#pragma once
|
||||
|
||||
#include <uuid/uuid.h>
|
||||
#include <jansson.h>
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
class NodeList : public std::list<struct vnode *> {
|
||||
/* Forward declarations */
|
||||
class Node;
|
||||
|
||||
class NodeList : public std::list<Node *> {
|
||||
|
||||
public:
|
||||
/** Lookup a node from the list based on its name */
|
||||
struct vnode * lookup(const std::string &name);
|
||||
Node * lookup(const std::string &name);
|
||||
|
||||
/** Lookup a node from the list based on its UUID */
|
||||
struct vnode * lookup(const uuid_t &uuid);
|
||||
Node * lookup(const uuid_t &uuid);
|
||||
|
||||
/** Parse an array or single node and checks if they exist in the "nodes" section.
|
||||
*
|
||||
* Examples:
|
||||
* out = [ "sintef", "scedu" ]
|
||||
* out = "acs"
|
||||
*
|
||||
* @param json A JSON array or string. See examples above.
|
||||
* @param nodes The nodes will be added to this list.
|
||||
* @param all This list contains all valid nodes.
|
||||
*/
|
||||
int parse(json_t *json, NodeList &all);
|
||||
|
||||
json_t * toJson() const;
|
||||
};
|
||||
|
||||
} /* namespace node */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,21 +21,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup amqp amqp node type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <amqp.h>
|
||||
|
||||
#include <villas/list.h>
|
||||
#include <villas/list.hpp>
|
||||
#include <villas/format.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
struct amqp_ssl_info {
|
||||
int verify_peer;
|
||||
|
@ -58,25 +55,26 @@ struct amqp {
|
|||
amqp_connection_state_t producer;
|
||||
amqp_connection_state_t consumer;
|
||||
|
||||
villas::node::Format *formatter;
|
||||
Format *formatter;
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * amqp_print(struct vnode *n);
|
||||
char * amqp_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int amqp_parse(struct vnode *n, json_t *json);
|
||||
int amqp_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::start */
|
||||
int amqp_start(struct vnode *n);
|
||||
int amqp_start(NodeCompat *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int amqp_stop(struct vnode *n);
|
||||
int amqp_init(NodeCompat *n);
|
||||
|
||||
/** @see node_type::read */
|
||||
int amqp_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int amqp_destroy(NodeCompat *n);
|
||||
|
||||
/** @see node_type::write */
|
||||
int amqp_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int amqp_poll_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
/** @} */
|
||||
int amqp_stop(NodeCompat *n);
|
||||
|
||||
int amqp_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
int amqp_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Niklas Eiling <niklas.eiling@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,21 +21,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup can CAN bus Node Type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
#include <villas/timing.h>
|
||||
#include <villas/timing.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
union signal_data;
|
||||
class NodeCompat;
|
||||
union SignalData;
|
||||
|
||||
struct can_signal {
|
||||
uint32_t id;
|
||||
|
@ -52,42 +49,32 @@ struct can {
|
|||
|
||||
/* States */
|
||||
int socket;
|
||||
union signal_data *sample_buf;
|
||||
union SignalData *sample_buf;
|
||||
size_t sample_buf_num;
|
||||
struct timespec start_time;
|
||||
};
|
||||
|
||||
/** @see node_type::init */
|
||||
int can_init(struct vnode *n);
|
||||
int can_init(NodeCompat *n);
|
||||
|
||||
/** @see node_type::destroy */
|
||||
int can_destroy(struct vnode *n);
|
||||
int can_destroy(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int can_parse(struct vnode *n, json_t *json);
|
||||
int can_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * can_print(struct vnode *n);
|
||||
char * can_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::check */
|
||||
int can_check();
|
||||
int can_check(NodeCompat *n);
|
||||
|
||||
/** @see node_type::prepare */
|
||||
int can_prepare();
|
||||
int can_prepare(NodeCompat *n);
|
||||
|
||||
/** @see node_type::start */
|
||||
int can_start(struct vnode *n);
|
||||
int can_start(NodeCompat *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int can_stop(struct vnode *n);
|
||||
int can_stop(NodeCompat *n);
|
||||
|
||||
/** @see node_type::write */
|
||||
int can_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int can_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::read */
|
||||
int can_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int can_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::poll_fds */
|
||||
int can_poll_fds(struct vnode *n, int fds[]);
|
||||
int can_poll_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
/** @} */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,21 +21,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup comedi Comedi node type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <comedilib.h>
|
||||
|
||||
#include <villas/list.h>
|
||||
#include <villas/timing.h>
|
||||
#include <villas/list.hpp>
|
||||
#include <villas/timing.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
// whether to use read() or mmap() kernel interface
|
||||
#define COMEDI_USE_READ (1)
|
||||
|
@ -82,22 +79,19 @@ struct comedi {
|
|||
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * comedi_print(struct vnode *n);
|
||||
char * comedi_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int comedi_parse(struct vnode *n, json_t *json);
|
||||
int comedi_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::start */
|
||||
int comedi_start(struct vnode *n);
|
||||
int comedi_start(NodeCompat *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int comedi_stop(struct vnode *n);
|
||||
int comedi_stop(NodeCompat *n);
|
||||
|
||||
/** @see node_type::read */
|
||||
int comedi_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int comedi_poll_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
/** @see node_type::write */
|
||||
int comedi_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int comedi_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @} */
|
||||
int comedi_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -23,25 +23,23 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup ethercats WebSockets node type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include <villas/pool.h>
|
||||
#include <villas/pool.hpp>
|
||||
#include <villas/task.hpp>
|
||||
#include <villas/queue_signalled.h>
|
||||
#include <villas/common.hpp>
|
||||
#include <villas/format.hpp>
|
||||
#include <villas/config.h>
|
||||
#include <villas/config.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
class SuperNode;
|
||||
|
||||
/* Include hard-coded Ethercat Bus configuration */
|
||||
#include <villas/nodes/ethercat_config.hpp>
|
||||
|
@ -74,45 +72,39 @@ struct ethercat {
|
|||
|
||||
std::thread thread; /**< Cyclic task thread */
|
||||
struct Task task; /**< Periodic timer */
|
||||
struct pool pool;
|
||||
struct queue_signalled queue; /**< For samples which are received from WebSockets */
|
||||
struct Pool pool;
|
||||
struct CQueueSignalled queue; /**< For samples which are received from WebSockets */
|
||||
|
||||
std::atomic<struct sample *> send; /**< Last sample to be sent via EtherCAT */
|
||||
std::atomic<struct Sample *> send; /**< Last sample to be sent via EtherCAT */
|
||||
};
|
||||
|
||||
/* Internal datastructures */
|
||||
|
||||
/** @see node_type::type_start */
|
||||
int ethercat_type_start(struct super_node *sn);
|
||||
int ethercat_type_start(SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int ethercat_type_stop();
|
||||
|
||||
/** @see node_type::init */
|
||||
int ethercat_init(struct vnode *n);
|
||||
int ethercat_init(NodeCompat *n);
|
||||
|
||||
/** @see node_type::destroy */
|
||||
int ethercat_destroy(struct vnode *n);
|
||||
int ethercat_destroy(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int ethercat_parse(struct vnode *n, json_t *json);
|
||||
int ethercat_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::check */
|
||||
int ethercat_check(struct vnode *n);
|
||||
int ethercat_check(NodeCompat *n);
|
||||
|
||||
/** @see node_type::prepare */
|
||||
int ethercat_prepare(struct vnode *n);
|
||||
int ethercat_prepare(NodeCompat *n);
|
||||
|
||||
/** @see node_type::open */
|
||||
int ethercat_start(struct vnode *n);
|
||||
int ethercat_start(NodeCompat *n);
|
||||
|
||||
/** @see node_type::close */
|
||||
int ethercat_stop(struct vnode *n);
|
||||
int ethercat_stop(NodeCompat *n);
|
||||
|
||||
/** @see node_type::read */
|
||||
int ethercat_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int ethercat_poll_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
/** @see node_type::write */
|
||||
int ethercat_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
char * ethercat_print(NodeCompat *n);
|
||||
|
||||
/** @} */
|
||||
int ethercat_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
int ethercat_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,20 +21,17 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup example Example node-type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <villas/node/config.h>
|
||||
#include <villas/node/config.hpp>
|
||||
#include <villas/format.hpp>
|
||||
#include <villas/timing.h>
|
||||
#include <villas/timing.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
struct example {
|
||||
/* Settings */
|
||||
|
@ -47,55 +44,39 @@ struct example {
|
|||
struct timespec start_time;
|
||||
};
|
||||
|
||||
/** @see node_vtable::type_start */
|
||||
int example_type_start(villas::node::SuperNode *sn);
|
||||
int example_type_start(SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int example_type_stop();
|
||||
|
||||
/** @see node_type::init */
|
||||
int example_init(struct vnode *n);
|
||||
int example_init(NodeCompat *n);
|
||||
|
||||
/** @see node_type::destroy */
|
||||
int example_destroy(struct vnode *n);
|
||||
int example_destroy(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int example_parse(struct vnode *n, json_t *json);
|
||||
int example_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * example_print(struct vnode *n);
|
||||
char * example_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::check */
|
||||
int example_check();
|
||||
int example_check(NodeCompat *n);
|
||||
|
||||
/** @see node_type::prepare */
|
||||
int example_prepare();
|
||||
int example_prepare(NodeCompat *n);
|
||||
|
||||
/** @see node_type::start */
|
||||
int example_start(struct vnode *n);
|
||||
int example_start(NodeCompat *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int example_stop(struct vnode *n);
|
||||
int example_stop(NodeCompat *n);
|
||||
|
||||
/** @see node_type::pause */
|
||||
int example_pause(struct vnode *n);
|
||||
int example_pause(NodeCompat *n);
|
||||
|
||||
/** @see node_type::resume */
|
||||
int example_resume(struct vnode *n);
|
||||
int example_resume(NodeCompat *n);
|
||||
|
||||
/** @see node_type::write */
|
||||
int example_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int example_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::read */
|
||||
int example_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int example_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::reverse */
|
||||
int example_reverse(struct vnode *n);
|
||||
int example_reverse(NodeCompat *n);
|
||||
|
||||
/** @see node_type::poll_fds */
|
||||
int example_poll_fds(struct vnode *n, int fds[]);
|
||||
int example_poll_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
/** @see node_type::netem_fds */
|
||||
int example_netem_fds(struct vnode *n, int fds[]);
|
||||
int example_netem_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
/** @} */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,53 +21,71 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @ingroup node
|
||||
* @addtogroup exec Execute node-type as a sub-process
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <villas/node.hpp>
|
||||
#include <villas/popen.hpp>
|
||||
#include <villas/format.hpp>
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
struct sample;
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/** Node-type for signal generation.
|
||||
* @see node_type
|
||||
*/
|
||||
struct exec {
|
||||
/* Forward declarations */
|
||||
struct Sample;
|
||||
|
||||
class ExecNode : public Node {
|
||||
|
||||
protected:
|
||||
std::unique_ptr<villas::utils::Popen> proc;
|
||||
std::unique_ptr<Format> formatter;
|
||||
|
||||
FILE *stream_in, *stream_out;
|
||||
|
||||
bool flush;
|
||||
bool shell;
|
||||
|
||||
std::string working_dir;
|
||||
std::string command;
|
||||
|
||||
villas::utils::Popen::arg_list arguments;
|
||||
villas::utils::Popen::env_map environment;
|
||||
|
||||
villas::node::Format *formatter;
|
||||
virtual
|
||||
int _read(struct Sample * smps[], unsigned cnt);
|
||||
|
||||
virtual
|
||||
int _write(struct Sample * smps[], unsigned cnt);
|
||||
|
||||
public:
|
||||
ExecNode(const std::string &name = "") :
|
||||
Node(name),
|
||||
stream_in(nullptr),
|
||||
stream_out(nullptr),
|
||||
flush(true),
|
||||
shell(false)
|
||||
{ }
|
||||
|
||||
virtual
|
||||
~ExecNode();
|
||||
|
||||
virtual
|
||||
const std::string & getDetails();
|
||||
|
||||
virtual
|
||||
int start();
|
||||
|
||||
virtual
|
||||
int stop();
|
||||
|
||||
virtual
|
||||
int prepare();
|
||||
|
||||
virtual
|
||||
int parse(json_t *json, const uuid_t sn_uuid);
|
||||
|
||||
virtual
|
||||
std::vector<int> getPollFDs();
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * exec_print(struct vnode *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int exec_parse(struct vnode *n, json_t *json);
|
||||
|
||||
/** @see node_type::start */
|
||||
int exec_open(struct vnode *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int exec_close(struct vnode *n);
|
||||
|
||||
/** @see node_type::read */
|
||||
int exec_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::write */
|
||||
int exec_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @} */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,12 +21,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup file File-IO node type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
|
@ -34,19 +28,21 @@
|
|||
#include <villas/format.hpp>
|
||||
#include <villas/task.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
#define FILE_MAX_PATHLEN 512
|
||||
|
||||
struct file {
|
||||
villas::node::Format *formatter;
|
||||
Format *formatter;
|
||||
FILE *stream_in;
|
||||
FILE *stream_out;
|
||||
|
||||
char *uri_tmpl; /**< Format string for file name. */
|
||||
char *uri; /**< Real file name. */
|
||||
char *mode; /**< File access mode. */
|
||||
|
||||
unsigned skip_lines; /**< Skip the first n-th lines/samples of the file. */
|
||||
int flush; /**< Flush / upload file contents after each write. */
|
||||
|
@ -74,22 +70,23 @@ struct file {
|
|||
struct timespec offset; /**< An offset between the timestamp in the input file and the current time */
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * file_print(struct vnode *n);
|
||||
char * file_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int file_parse(struct vnode *n, json_t *json);
|
||||
int file_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::start */
|
||||
int file_start(struct vnode *n);
|
||||
int file_start(NodeCompat *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int file_stop(struct vnode *n);
|
||||
int file_stop(NodeCompat *n);
|
||||
|
||||
/** @see node_type::read */
|
||||
int file_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int file_init(NodeCompat *n);
|
||||
|
||||
/** @see node_type::write */
|
||||
int file_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int file_destroy(NodeCompat *n);
|
||||
|
||||
/** @} */
|
||||
int file_poll_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
int file_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
int file_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,43 +21,43 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup fpga BSD fpga Node Type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <villas/node/config.h>
|
||||
#include <villas/node/config.hpp>
|
||||
#include <villas/format.hpp>
|
||||
#include <villas/timing.h>
|
||||
#include <villas/timing.hpp>
|
||||
|
||||
#include <villas/fpga/card.hpp>
|
||||
#include <villas/fpga/node.hpp>
|
||||
#include <villas/fpga/ips/dma.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
using namespace villas;
|
||||
|
||||
#define FPGA_DMA_VLNV
|
||||
#define FPGA_AURORA_VLNV "acs.eonerc.rwth-aachen.de:user:aurora_axis:"
|
||||
|
||||
struct fpga {
|
||||
struct fpga_node {
|
||||
int irqFd;
|
||||
int coalesce;
|
||||
bool polling;
|
||||
|
||||
std::shared_ptr<villas::fpga::PCIeCard> card;
|
||||
std::shared_ptr<fpga::PCIeCard> card;
|
||||
|
||||
std::shared_ptr<villas::fpga::ip::Dma> dma;
|
||||
std::shared_ptr<villas::fpga::ip::Node> intf;
|
||||
std::shared_ptr<fpga::ip::Dma> dma;
|
||||
std::shared_ptr<fpga::ip::Node> intf;
|
||||
|
||||
struct {
|
||||
villas::MemoryAccessor<uint32_t> mem;
|
||||
villas::MemoryBlock block;
|
||||
struct {
|
||||
MemoryAccessor<int32_t> i;
|
||||
MemoryAccessor<float> f;
|
||||
} accessor;
|
||||
MemoryBlock::Ptr block;
|
||||
} in, out;
|
||||
|
||||
// Config only
|
||||
|
@ -66,43 +66,27 @@ struct fpga {
|
|||
std::string dmaName;
|
||||
};
|
||||
|
||||
/** @see node_vtable::type_start */
|
||||
int fpga_type_start(villas::node::SuperNode *sn);
|
||||
int fpga_type_start(SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int fpga_type_stop();
|
||||
|
||||
/** @see node_type::init */
|
||||
int fpga_init(struct vnode *n);
|
||||
int fpga_init(NodeCompat *n);
|
||||
|
||||
/** @see node_type::destroy */
|
||||
int fpga_destroy(struct vnode *n);
|
||||
int fpga_destroy(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int fpga_parse(struct vnode *n, json_t *json);
|
||||
int fpga_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * fpga_print(struct vnode *n);
|
||||
char * fpga_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::check */
|
||||
int fpga_check();
|
||||
int fpga_check(NodeCompat *n);
|
||||
|
||||
/** @see node_type::prepare */
|
||||
int fpga_prepare();
|
||||
int fpga_prepare(NodeCompat *n);
|
||||
|
||||
/** @see node_type::start */
|
||||
int fpga_start(struct vnode *n);
|
||||
int fpga_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int fpga_stop(struct vnode *n);
|
||||
int fpga_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::write */
|
||||
int fpga_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int fpga_poll_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
/** @see node_type::read */
|
||||
int fpga_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::poll_fds */
|
||||
int fpga_poll_fds(struct vnode *n, int fds[]);
|
||||
|
||||
/** @} */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,12 +21,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup iec61850_sv IEC 61850-9-2 (Sampled Values) node type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -41,16 +35,19 @@
|
|||
#include <libiec61850/goose_receiver.h>
|
||||
#include <libiec61850/sv_subscriber.h>
|
||||
|
||||
#include <villas/list.h>
|
||||
#include <villas/signal.h>
|
||||
#include <villas/super_node.hpp>
|
||||
#include <villas/list.hpp>
|
||||
#include <villas/signal.hpp>
|
||||
#include <villas/signal_list.hpp>
|
||||
|
||||
#ifndef CONFIG_GOOSE_DEFAULT_DST_ADDRESS
|
||||
#define CONFIG_GOOSE_DEFAULT_DST_ADDRESS {0x01, 0x0c, 0xcd, 0x01, 0x00, 0x01}
|
||||
#endif
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
enum class IEC61850Type {
|
||||
/* According to IEC 61850-7-2 */
|
||||
|
@ -103,15 +100,13 @@ struct iec61850_receiver {
|
|||
};
|
||||
};
|
||||
|
||||
/** @see node_type::type_start */
|
||||
int iec61850_type_start(villas::node::SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int iec61850_type_stop();
|
||||
|
||||
const struct iec61850_type_descriptor * iec61850_lookup_type(const char *name);
|
||||
|
||||
int iec61850_parse_signals(json_t *json_signals, struct vlist *signals, struct vlist *node_signals);
|
||||
int iec61850_parse_signals(json_t *json_signals, struct List *signals, SignalList::Ptr node_signals);
|
||||
|
||||
struct iec61850_receiver * iec61850_receiver_lookup(enum iec61850_receiver::Type t, const char *intf);
|
||||
|
||||
|
@ -123,4 +118,7 @@ int iec61850_receiver_stop(struct iec61850_receiver *r);
|
|||
|
||||
int iec61850_receiver_destroy(struct iec61850_receiver *r);
|
||||
|
||||
/** @} */
|
||||
const struct iec61850_type_descriptor * iec61850_lookup_type(const char *name);
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,12 +21,6 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup iec61850_sv IEC 61850-9-2 (Sampled Values) node type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
@ -35,12 +29,15 @@
|
|||
#include <libiec61850/sv_subscriber.h>
|
||||
|
||||
#include <villas/queue_signalled.h>
|
||||
#include <villas/pool.h>
|
||||
#include <villas/list.h>
|
||||
#include <villas/pool.hpp>
|
||||
#include <villas/list.hpp>
|
||||
#include <villas/nodes/iec61850.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
struct iec61850_sv {
|
||||
char *interface;
|
||||
|
@ -53,10 +50,10 @@ struct iec61850_sv {
|
|||
SVSubscriber subscriber;
|
||||
SVReceiver receiver;
|
||||
|
||||
struct queue_signalled queue;
|
||||
struct pool pool;
|
||||
struct CQueueSignalled queue;
|
||||
struct Pool pool;
|
||||
|
||||
struct vlist signals; /**< Mappings of type struct iec61850_type_descriptor */
|
||||
struct List signals; /**< Mappings of type struct iec61850_type_descriptor */
|
||||
int total_size;
|
||||
} in;
|
||||
|
||||
|
@ -74,36 +71,28 @@ struct iec61850_sv {
|
|||
int smprate;
|
||||
int confrev;
|
||||
|
||||
struct vlist signals; /**< Mappings of type struct iec61850_type_descriptor */
|
||||
struct List signals; /**< Mappings of type struct iec61850_type_descriptor */
|
||||
int total_size;
|
||||
} out;
|
||||
};
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int iec61850_sv_type_stop();
|
||||
|
||||
/** @see node_type::parse */
|
||||
int iec61850_sv_parse(struct vnode *n, json_t *json);
|
||||
int iec61850_sv_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * iec61850_sv_print(struct vnode *n);
|
||||
char * iec61850_sv_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::start */
|
||||
int iec61850_sv_start(struct vnode *n);
|
||||
int iec61850_sv_start(NodeCompat *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int iec61850_sv_stop(struct vnode *n);
|
||||
int iec61850_sv_stop(NodeCompat *n);
|
||||
|
||||
/** @see node_type::destroy */
|
||||
int iec61850_sv_destroy(struct vnode *n);
|
||||
int iec61850_sv_destroy(NodeCompat *n);
|
||||
|
||||
/** @see node_type::read */
|
||||
int iec61850_sv_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int iec61850_sv_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::write */
|
||||
int iec61850_sv_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int iec61850_sv_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @see node_type::fd */
|
||||
int iec61850_sv_fd(struct vnode *n);
|
||||
int iec61850_sv_poll_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
/** @} */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Dennis Potter <dennis@dennispotter.eu>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,21 +21,18 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup infiniband infiniband node type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <villas/pool.h>
|
||||
#include <villas/pool.hpp>
|
||||
#include <villas/format.hpp>
|
||||
#include <villas/queue_signalled.h>
|
||||
#include <rdma/rdma_cma.h>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
/* Constants */
|
||||
#define META_SIZE 24
|
||||
|
@ -111,28 +108,23 @@ struct infiniband {
|
|||
int is_source;
|
||||
};
|
||||
|
||||
/** @see node_type::reverse */
|
||||
int ib_reverse(struct vnode *n);
|
||||
int ib_reverse(NodeCompat *n);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * ib_print(struct vnode *n);
|
||||
char * ib_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int ib_parse(struct vnode *n, json_t *json);
|
||||
int ib_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::start */
|
||||
int ib_start(struct vnode *n);
|
||||
int ib_check(NodeCompat *n);
|
||||
|
||||
/** @see node_type::destroy */
|
||||
int ib_destroy(struct vnode *n);
|
||||
int ib_start(NodeCompat *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int ib_stop(struct vnode *n);
|
||||
int ib_destroy(NodeCompat *n);
|
||||
|
||||
/** @see node_type::read */
|
||||
int ib_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int ib_stop(NodeCompat *n);
|
||||
|
||||
/** @see node_type::write */
|
||||
int ib_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int ib_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @} */
|
||||
int ib_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @copyright 2014-2021, Institute for Automation of Complex Power Systems, EONERC
|
||||
* @license GNU General Public License (version 3)
|
||||
*
|
||||
* VILLASnode
|
||||
|
@ -21,46 +21,36 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @ingroup node
|
||||
* @addtogroup influxdb InfluxDB node-type
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <villas/list.h>
|
||||
#include <villas/list.hpp>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
struct sample;
|
||||
class NodeCompat;
|
||||
struct Sample;
|
||||
|
||||
/** Node-type for signal generation.
|
||||
* @see node_type
|
||||
*/
|
||||
struct influxdb {
|
||||
char *host;
|
||||
char *port;
|
||||
char *key;
|
||||
|
||||
struct vlist fields;
|
||||
struct List fields;
|
||||
|
||||
int sd;
|
||||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
char * influxdb_print(struct vnode *n);
|
||||
char * influxdb_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int influxdb_parse(struct vnode *n, json_t *json);
|
||||
int influxdb_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::start */
|
||||
int influxdb_open(struct vnode *n);
|
||||
int influxdb_open(NodeCompat *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int influxdb_close(struct vnode *n);
|
||||
int influxdb_close(NodeCompat *n);
|
||||
|
||||
/** @see node_type::write */
|
||||
int influxdb_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int influxdb_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @} */
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
|
@ -21,26 +21,23 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************************/
|
||||
|
||||
/**
|
||||
* @addtogroup kafka kafka node type
|
||||
* @ingroup node
|
||||
* @{
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <librdkafka/rdkafka.h>
|
||||
|
||||
#include <villas/pool.h>
|
||||
#include <villas/pool.hpp>
|
||||
#include <villas/format.hpp>
|
||||
#include <villas/queue_signalled.h>
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
/* Forward declarations */
|
||||
struct vnode;
|
||||
class NodeCompat;
|
||||
|
||||
struct kafka {
|
||||
struct queue_signalled queue;
|
||||
struct pool pool;
|
||||
struct CQueueSignalled queue;
|
||||
struct Pool pool;
|
||||
|
||||
double timeout; /**< Timeout in seconds. */
|
||||
char *server; /**< Hostname/IP:Port address of the bootstrap server. */
|
||||
|
@ -69,40 +66,34 @@ struct kafka {
|
|||
char *password; /**< SSL certificate. */
|
||||
} sasl;
|
||||
|
||||
villas::node::Format *formatter;
|
||||
Format *formatter;
|
||||
};
|
||||
|
||||
/** @see node_type::reverse */
|
||||
int kafka_reverse(struct vnode *n);
|
||||
int kafka_reverse(NodeCompat *n);
|
||||
|
||||
/** @see node_type::print */
|
||||
char * kafka_print(struct vnode *n);
|
||||
char * kafka_print(NodeCompat *n);
|
||||
|
||||
/** @see node_type::prepare */
|
||||
int kafka_prepare(struct vnode *n);
|
||||
int kafka_init(NodeCompat *n);
|
||||
|
||||
/** @see node_type::parse */
|
||||
int kafka_parse(struct vnode *n, json_t *json);
|
||||
int kafka_prepare(NodeCompat *n);
|
||||
|
||||
/** @see node_type::start */
|
||||
int kafka_start(struct vnode *n);
|
||||
int kafka_parse(NodeCompat *n, json_t *json);
|
||||
|
||||
/** @see node_type::destroy */
|
||||
int kafka_destroy(struct vnode *n);
|
||||
int kafka_start(NodeCompat *n);
|
||||
|
||||
/** @see node_type::stop */
|
||||
int kafka_stop(struct vnode *n);
|
||||
int kafka_destroy(NodeCompat *n);
|
||||
|
||||
/** @see node_type::type_start */
|
||||
int kafka_type_start(villas::node::SuperNode *sn);
|
||||
int kafka_stop(NodeCompat *n);
|
||||
|
||||
int kafka_type_start(SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int kafka_type_stop();
|
||||
|
||||
/** @see node_type::read */
|
||||
int kafka_read(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int kafka_poll_fds(NodeCompat *n, int fds[]);
|
||||
|
||||
/** @see node_type::write */
|
||||
int kafka_write(struct vnode *n, struct sample * const smps[], unsigned cnt);
|
||||
int kafka_read(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
/** @} */
|
||||
int kafka_write(NodeCompat *n, struct Sample * const smps[], unsigned cnt);
|
||||
|
||||
} /* namespace node */
|
||||
} /* namespace villas */
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue