mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
remove old super_node C wrapper code
This commit is contained in:
parent
4a4a7d1280
commit
14434d093f
25 changed files with 48 additions and 166 deletions
|
@ -28,12 +28,12 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#include <villas/super_node.hpp>
|
||||
#include <villas/list.h>
|
||||
#include <villas/common.h>
|
||||
#include <villas/memory.h>
|
||||
|
||||
/* Forward declarations */
|
||||
struct super_node;
|
||||
struct node;
|
||||
struct sample;
|
||||
|
||||
|
@ -62,7 +62,7 @@ struct node_type {
|
|||
* @retval 0 Success. Everything went well.
|
||||
* @retval <0 Error. Something went wrong.
|
||||
*/
|
||||
int (*start)(struct super_node *sn);
|
||||
int (*start)(villas::node::SuperNode *sn);
|
||||
|
||||
/** Global de-initialization per node type.
|
||||
*
|
||||
|
@ -228,7 +228,7 @@ struct node_type {
|
|||
*
|
||||
* @see node_type::init
|
||||
*/
|
||||
int node_type_start(struct node_type *vt, struct super_node *sn);
|
||||
int node_type_start(struct node_type *vt, villas::node::SuperNode *sn);
|
||||
|
||||
/** De-initialize node type subsystems.
|
||||
*
|
||||
|
|
|
@ -97,7 +97,7 @@ struct iec61850_receiver {
|
|||
};
|
||||
|
||||
/** @see node_type::type_start */
|
||||
int iec61850_type_start(struct super_node *sn);
|
||||
int iec61850_type_start(villas::node::SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int iec61850_type_stop();
|
||||
|
|
|
@ -85,7 +85,7 @@ int mqtt_destroy(struct node *n);
|
|||
int mqtt_stop(struct node *n);
|
||||
|
||||
/** @see node_type::type_start */
|
||||
int mqtt_type_start(struct super_node *sn);
|
||||
int mqtt_type_start(villas::node::SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int mqtt_type_stop();
|
||||
|
|
|
@ -68,7 +68,7 @@ struct ngsi {
|
|||
*
|
||||
* @see node_type::type_start
|
||||
*/
|
||||
int ngsi_type_start(struct super_node *sn);
|
||||
int ngsi_type_start(villas::node::SuperNode *sn);
|
||||
|
||||
/** Free global NGSI settings and unmaps shared memory regions.
|
||||
*
|
||||
|
|
|
@ -56,7 +56,7 @@ struct opal {
|
|||
*
|
||||
* @see node_type::type_start
|
||||
*/
|
||||
int opal_type_start(struct super_node *sn);
|
||||
int opal_type_start(villas::node::SuperNode *sn);
|
||||
|
||||
/** Free global OPAL settings and unmaps shared memory regions.
|
||||
*
|
||||
|
|
|
@ -66,7 +66,7 @@ struct socket {
|
|||
|
||||
|
||||
/** @see node_vtable::type_start */
|
||||
int socket_type_start(struct super_node *sn);
|
||||
int socket_type_start(villas::node::SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int socket_type_stop();
|
||||
|
|
|
@ -31,15 +31,11 @@
|
|||
|
||||
#include <jansson.h>
|
||||
|
||||
#include <villas/node.h>
|
||||
#include <villas/stats.h>
|
||||
#include <villas/task.h>
|
||||
#include <villas/list.h>
|
||||
|
||||
/* Forward declarations */
|
||||
struct node;
|
||||
struct sample;
|
||||
struct super_node;
|
||||
|
||||
struct stats_node_signal {
|
||||
struct node *node;
|
||||
char *node_str;
|
||||
|
@ -57,7 +53,7 @@ struct stats_node {
|
|||
};
|
||||
|
||||
/** @see node_type::print */
|
||||
int stats_node_type_start(struct super_node *sn);
|
||||
int stats_node_type_start(villas::node::SuperNode *sn);
|
||||
|
||||
/** @see node_type::print */
|
||||
char *stats_node_print(struct node *n);
|
||||
|
|
|
@ -92,7 +92,7 @@ struct websocket_destination {
|
|||
int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len);
|
||||
|
||||
/** @see node_type::type_start */
|
||||
int websocket_type_start(struct super_node *sn);
|
||||
int websocket_type_start(villas::node::SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int websocket_type_stop();
|
||||
|
|
|
@ -87,7 +87,7 @@ char * zeromq_print(struct node *n);
|
|||
int zeromq_parse(struct node *n, json_t *cfg);
|
||||
|
||||
/** @see node_type::type_start */
|
||||
int zeromq_type_start(struct super_node *sn);
|
||||
int zeromq_type_start(villas::node::SuperNode *sn);
|
||||
|
||||
/** @see node_type::type_stop */
|
||||
int zeromq_type_stop();
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/** The super node object holding the state of the application (C-compatability header).
|
||||
*
|
||||
* @file
|
||||
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
* @copyright 2014-2019, 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 <villas/node/config.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Forward declarations */
|
||||
struct vlist;
|
||||
struct web;
|
||||
struct super_node;
|
||||
struct lws;
|
||||
|
||||
struct vlist * super_node_get_nodes(struct super_node *sn);
|
||||
|
||||
struct vlist * super_node_get_paths(struct super_node *sn);
|
||||
|
||||
struct vlist * super_node_get_interfaces(struct super_node *sn);
|
||||
|
||||
int super_node_get_cli_argc(struct super_node *sn);
|
||||
|
||||
struct web * super_node_get_web(struct super_node *sn);
|
||||
|
||||
struct lws_context * web_get_context(struct web *w);
|
||||
|
||||
struct lws_vhost * web_get_vhost(struct web *w);
|
||||
|
||||
enum state web_get_state(struct web *w);
|
||||
|
||||
#ifdef WITH_WEB
|
||||
int web_callback_on_writable(struct web *w, struct lws *wsi);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -32,6 +32,9 @@
|
|||
#include <villas/task.h>
|
||||
#include <villas/common.h>
|
||||
|
||||
/* Forward declarations */
|
||||
struct node;
|
||||
|
||||
namespace villas {
|
||||
namespace node {
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <villas/node/config.h>
|
||||
#include <villas/plugin.h>
|
||||
|
||||
int node_type_start(struct node_type *vt, struct super_node *sn)
|
||||
int node_type_start(struct node_type *vt, villas::node::SuperNode *sn)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ int iec61850_parse_signals(json_t *json_signals, struct vlist *signals, struct v
|
|||
return total_size;
|
||||
}
|
||||
|
||||
int iec61850_type_start(struct super_node *sn)
|
||||
int iec61850_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@ mosquitto_error:
|
|||
return ret;
|
||||
}
|
||||
|
||||
int mqtt_type_start(struct super_node *sn)
|
||||
int mqtt_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ out: json_decref(request);
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ngsi_type_start(struct super_node *sn)
|
||||
int ngsi_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
return curl_global_init(CURL_GLOBAL_ALL);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ int opal_register_region(int argc, char *argv[])
|
|||
print_shmem_name = argv[3];
|
||||
}
|
||||
|
||||
int opal_type_start(struct super_node *sn)
|
||||
int opal_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ extern "C" {
|
|||
#include <villas/stats.h>
|
||||
#include <villas/hook.h>
|
||||
#include <villas/format_type.h>
|
||||
#include <villas/super_node.h>
|
||||
#include <villas/super_node.hpp>
|
||||
|
||||
#ifdef WITH_NETEM
|
||||
#include <villas/kernel/if.h>
|
||||
|
@ -457,7 +457,7 @@ static void stop_handler(int sig, siginfo_t *si, void *ctx)
|
|||
|
||||
typedef void *(*pthread_start_routine)(void *);
|
||||
|
||||
int rtp_type_start(struct super_node *sn)
|
||||
int rtp_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -484,7 +484,7 @@ int rtp_type_start(struct super_node *sn)
|
|||
return ret;
|
||||
|
||||
#ifdef WITH_NETEM
|
||||
struct vlist *interfaces = super_node_get_interfaces(sn);
|
||||
struct vlist *interfaces = sn->getInterfaces();
|
||||
|
||||
/* Gather list of used network interfaces */
|
||||
for (size_t i = 0; i < vlist_length(&p.node.instances); i++) {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <villas/queue.h>
|
||||
#include <villas/plugin.h>
|
||||
#include <villas/compat.h>
|
||||
#include <villas/super_node.h>
|
||||
#include <villas/super_node.hpp>
|
||||
|
||||
#ifdef WITH_SOCKET_LAYER_ETH
|
||||
#include <netinet/ether.h>
|
||||
|
@ -47,10 +47,12 @@
|
|||
/* Forward declartions */
|
||||
static struct plugin p;
|
||||
|
||||
int socket_type_start(struct super_node *sn)
|
||||
using namespace villas::node;
|
||||
|
||||
int socket_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
#ifdef WITH_NETEM
|
||||
struct vlist *interfaces = super_node_get_interfaces(sn);
|
||||
struct vlist *interfaces = sn->getInterfaces();
|
||||
|
||||
/* Gather list of used network interfaces */
|
||||
for (size_t i = 0; i < vlist_length(&p.node.instances); i++) {
|
||||
|
|
|
@ -26,12 +26,14 @@
|
|||
#include <villas/hook.h>
|
||||
#include <villas/plugin.h>
|
||||
#include <villas/stats.h>
|
||||
#include <villas/super_node.h>
|
||||
#include <villas/super_node.hpp>
|
||||
#include <villas/sample.h>
|
||||
#include <villas/node.h>
|
||||
|
||||
#define STATS_METRICS 6
|
||||
|
||||
using namespace villas::node;
|
||||
|
||||
static struct vlist *nodes; /** The global list of nodes */
|
||||
|
||||
int stats_node_signal_destroy(struct stats_node_signal *s)
|
||||
|
@ -87,9 +89,9 @@ invalid_format:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int stats_node_type_start(struct super_node *sn)
|
||||
int stats_node_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
nodes = super_node_get_nodes(sn);
|
||||
nodes = sn->getNodes();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ static int uldaq_connect(struct node *n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int uldaq_type_start(struct super_node *sn)
|
||||
int uldaq_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
UlError err;
|
||||
|
||||
|
@ -665,4 +665,4 @@ __attribute__((destructor(110)))
|
|||
static void deregister_plugin() {
|
||||
if (plugins.state != STATE_DESTROYED)
|
||||
vlist_remove_all(&plugins, &p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,14 +35,14 @@
|
|||
#include <villas/nodes/websocket.hpp>
|
||||
#include <villas/format_type.h>
|
||||
#include <villas/formats/msg_format.h>
|
||||
#include <villas/super_node.h>
|
||||
#include <villas/super_node.hpp>
|
||||
|
||||
#define DEFAULT_WEBSOCKET_BUFFER_SIZE (1 << 12)
|
||||
|
||||
/* Private static storage */
|
||||
static struct vlist connections = { .state = STATE_DESTROYED }; /**< List of active libwebsocket connections which receive samples from all nodes (catch all) */
|
||||
|
||||
static struct web *web;
|
||||
static villas::node::Web *web;
|
||||
|
||||
/* Forward declarations */
|
||||
static struct plugin p;
|
||||
|
@ -165,7 +165,7 @@ static int websocket_connection_write(struct websocket_connection *c, struct sam
|
|||
|
||||
/* Client connections which are currently conecting don't have an associate c->wsi yet */
|
||||
if (c->wsi)
|
||||
web_callback_on_writable(web, c->wsi);
|
||||
web->callbackOnWritable(c->wsi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -373,12 +373,12 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
|
|||
return 0;
|
||||
}
|
||||
|
||||
int websocket_type_start(struct super_node *sn)
|
||||
int websocket_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
vlist_init(&connections);
|
||||
|
||||
web = super_node_get_web(sn);
|
||||
if (web_get_state(web) != STATE_STARTED)
|
||||
web = sn->getWeb();
|
||||
if (web->getState() != STATE_STARTED)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
@ -417,8 +417,8 @@ int websocket_start(struct node *n)
|
|||
c->node = n;
|
||||
c->destination = d;
|
||||
|
||||
d->info.context = web_get_context(web);
|
||||
d->info.vhost = web_get_vhost(web);
|
||||
d->info.context = web->getContext();
|
||||
d->info.vhost = web->getVHost();
|
||||
d->info.userdata = c;
|
||||
|
||||
lws_client_connect_via_info(&d->info);
|
||||
|
|
|
@ -245,7 +245,7 @@ char * zeromq_print(struct node *n)
|
|||
return buf;
|
||||
}
|
||||
|
||||
int zeromq_type_start(struct super_node *sn)
|
||||
int zeromq_type_start(villas::node::SuperNode *sn)
|
||||
{
|
||||
context = zmq_ctx_new();
|
||||
|
||||
|
@ -598,4 +598,4 @@ __attribute__((destructor(110)))
|
|||
static void deregister_plugin() {
|
||||
if (plugins.state != STATE_DESTROYED)
|
||||
vlist_remove_all(&plugins, &p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ void SuperNode::startNodeTypes()
|
|||
for (size_t i = 0; i < vlist_length(&nodes); i++) {
|
||||
auto *n = (struct node *) vlist_at(&nodes, i);
|
||||
|
||||
ret = node_type_start(n->_vt, reinterpret_cast<super_node *>(this));
|
||||
ret = node_type_start(n->_vt, this);
|
||||
if (ret)
|
||||
throw RuntimeError("Failed to start node-type: {}", node_type_name(n->_vt));
|
||||
}
|
||||
|
@ -523,64 +523,3 @@ int SuperNode::periodic()
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* C-compatability */
|
||||
extern "C" {
|
||||
struct vlist * super_node_get_nodes(struct super_node *sn)
|
||||
{
|
||||
SuperNode *ssn = reinterpret_cast<SuperNode *>(sn);
|
||||
|
||||
return ssn->getNodes();
|
||||
}
|
||||
|
||||
struct vlist * super_node_get_paths(struct super_node *sn)
|
||||
{
|
||||
SuperNode *ssn = reinterpret_cast<SuperNode *>(sn);
|
||||
|
||||
return ssn->getPaths();
|
||||
}
|
||||
|
||||
struct vlist * super_node_get_interfaces(struct super_node *sn)
|
||||
{
|
||||
SuperNode *ssn = reinterpret_cast<SuperNode *>(sn);
|
||||
|
||||
return ssn->getInterfaces();
|
||||
}
|
||||
#ifdef WITH_WEB
|
||||
struct web * super_node_get_web(struct super_node *sn)
|
||||
{
|
||||
SuperNode *ssn = reinterpret_cast<SuperNode *>(sn);
|
||||
Web *w = ssn->getWeb();
|
||||
|
||||
return reinterpret_cast<web *>(w);
|
||||
}
|
||||
#endif
|
||||
struct lws_context * web_get_context(struct web *w)
|
||||
{
|
||||
Web *ws = reinterpret_cast<Web *>(w);
|
||||
|
||||
return ws->getContext();
|
||||
}
|
||||
|
||||
struct lws_vhost * web_get_vhost(struct web *w)
|
||||
{
|
||||
Web *ws = reinterpret_cast<Web *>(w);
|
||||
|
||||
return ws->getVHost();
|
||||
}
|
||||
|
||||
enum state web_get_state(struct web *w)
|
||||
{
|
||||
Web *ws = reinterpret_cast<Web *>(w);
|
||||
|
||||
return ws->getState();
|
||||
}
|
||||
|
||||
#ifdef WITH_WEB
|
||||
int web_callback_on_writable(struct web *w, struct lws *wsi)
|
||||
{
|
||||
return lws_callback_on_writable(wsi);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -388,7 +388,7 @@ check: if (optarg == endptr)
|
|||
if (reverse)
|
||||
node_reverse(node);
|
||||
|
||||
ret = node_type_start(node_type(node), reinterpret_cast<super_node *>(&sn));
|
||||
ret = node_type_start(node_type(node), &sn);
|
||||
if (ret)
|
||||
throw RuntimeError("Failed to intialize node type {}: reason={}", node_type_name(node_type(node)), ret);
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ check: if (optarg == endptr)
|
|||
if (!node)
|
||||
throw RuntimeError("There's no node with the name '{}'", nodestr);
|
||||
|
||||
ret = node_type_start(node->_vt, reinterpret_cast<super_node *>(&sn));
|
||||
ret = node_type_start(node->_vt, &sn);
|
||||
if (ret)
|
||||
throw RuntimeError("Failed to start node-type {}: reason={}", node_type_name(node->_vt), ret);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue