mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Remove broken opal node-type
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
This commit is contained in:
parent
9a9c890c09
commit
60b397dc29
13 changed files with 0 additions and 596 deletions
|
@ -69,7 +69,6 @@ endif()
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
find_package(OpenMP)
|
find_package(OpenMP)
|
||||||
find_package(Opal)
|
|
||||||
find_package(IBVerbs)
|
find_package(IBVerbs)
|
||||||
find_package(RDMACM)
|
find_package(RDMACM)
|
||||||
find_package(Etherlab)
|
find_package(Etherlab)
|
||||||
|
@ -192,7 +191,6 @@ cmake_dependent_option(WITH_NODE_MODBUS "Build with modbus node-type"
|
||||||
cmake_dependent_option(WITH_NODE_MQTT "Build with mqtt node-type" "${WITH_DEFAULTS}" "MOSQUITTO_FOUND" OFF)
|
cmake_dependent_option(WITH_NODE_MQTT "Build with mqtt node-type" "${WITH_DEFAULTS}" "MOSQUITTO_FOUND" OFF)
|
||||||
cmake_dependent_option(WITH_NODE_NANOMSG "Build with nanomsg node-type" "${WITH_DEFAULTS}" "NANOMSG_FOUND" OFF)
|
cmake_dependent_option(WITH_NODE_NANOMSG "Build with nanomsg node-type" "${WITH_DEFAULTS}" "NANOMSG_FOUND" OFF)
|
||||||
cmake_dependent_option(WITH_NODE_NGSI "Build with ngsi node-type" "${WITH_DEFAULTS}" "" OFF)
|
cmake_dependent_option(WITH_NODE_NGSI "Build with ngsi node-type" "${WITH_DEFAULTS}" "" OFF)
|
||||||
cmake_dependent_option(WITH_NODE_OPAL "Build with opal node-type" "${WITH_DEFAULTS}" "Opal_FOUND" OFF)
|
|
||||||
cmake_dependent_option(WITH_NODE_REDIS "Build with redis node-type" "${WITH_DEFAULTS}" "HIREDIS_FOUND; REDISPP_FOUND" OFF)
|
cmake_dependent_option(WITH_NODE_REDIS "Build with redis node-type" "${WITH_DEFAULTS}" "HIREDIS_FOUND; REDISPP_FOUND" OFF)
|
||||||
cmake_dependent_option(WITH_NODE_RTP "Build with rtp node-type" "${WITH_DEFAULTS}" "re_FOUND" OFF)
|
cmake_dependent_option(WITH_NODE_RTP "Build with rtp node-type" "${WITH_DEFAULTS}" "re_FOUND" OFF)
|
||||||
cmake_dependent_option(WITH_NODE_SHMEM "Build with shmem node-type" "${WITH_DEFAULTS}" "HAS_SEMAPHORE; HAS_MMAN" OFF)
|
cmake_dependent_option(WITH_NODE_SHMEM "Build with shmem node-type" "${WITH_DEFAULTS}" "HAS_SEMAPHORE; HAS_MMAN" OFF)
|
||||||
|
@ -298,7 +296,6 @@ add_feature_info(NODE_MODBUS WITH_NODE_MODBUS "Build with
|
||||||
add_feature_info(NODE_MQTT WITH_NODE_MQTT "Build with mqtt node-type")
|
add_feature_info(NODE_MQTT WITH_NODE_MQTT "Build with mqtt node-type")
|
||||||
add_feature_info(NODE_NANOMSG WITH_NODE_NANOMSG "Build with nanomsg node-type")
|
add_feature_info(NODE_NANOMSG WITH_NODE_NANOMSG "Build with nanomsg node-type")
|
||||||
add_feature_info(NODE_NGSI WITH_NODE_NGSI "Build with ngsi node-type")
|
add_feature_info(NODE_NGSI WITH_NODE_NGSI "Build with ngsi node-type")
|
||||||
add_feature_info(NODE_OPAL WITH_NODE_OPAL "Build with opal node-type")
|
|
||||||
add_feature_info(NODE_REDIS WITH_NODE_REDIS "Build with redis node-type")
|
add_feature_info(NODE_REDIS WITH_NODE_REDIS "Build with redis node-type")
|
||||||
add_feature_info(NODE_RTP WITH_NODE_RTP "Build with rtp node-type")
|
add_feature_info(NODE_RTP WITH_NODE_RTP "Build with rtp node-type")
|
||||||
add_feature_info(NODE_SHMEM WITH_NODE_SHMEM "Build with shmem node-type")
|
add_feature_info(NODE_SHMEM WITH_NODE_SHMEM "Build with shmem node-type")
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
# CMakeLists.txt.
|
|
||||||
#
|
|
||||||
# Author: Steffen Vogel <post@steffenvogel.de>
|
|
||||||
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
set(OPAL_PREFIX /usr/opalrt/common)
|
|
||||||
|
|
||||||
find_path(OPAL_INCLUDE_DIR
|
|
||||||
NAMES AsyncApi.h
|
|
||||||
HINTS
|
|
||||||
${OPAL_PREFIX}/include_target/
|
|
||||||
${PROJECT_SOURCE_DIR}/libopal/include/opal/
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(OPAL_LIBRARY
|
|
||||||
NAMES OpalAsyncApiCore
|
|
||||||
HINTS
|
|
||||||
${OPAL_PREFIX}/lib/
|
|
||||||
${PROJECT_SOURCE_DIR}/libopal/
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(OPAL_LIBRARY_IRC
|
|
||||||
NAMES irc
|
|
||||||
HINTS
|
|
||||||
${OPAL_PREFIX}/lib/
|
|
||||||
${PROJECT_SOURCE_DIR}/libopal/
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(OPAL_LIBRARY_UTILS
|
|
||||||
NAMES OpalUtils
|
|
||||||
HINTS
|
|
||||||
${OPAL_PREFIX}/lib/redhawk/
|
|
||||||
${OPAL_PREFIX}/lib/redhawk64/
|
|
||||||
${PROJECT_SOURCE_DIR}/libopal/
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(OPAL_LIBRARY_CORE
|
|
||||||
NAMES OpalCore
|
|
||||||
HINTS
|
|
||||||
${OPAL_PREFIX}/lib/redhawk/
|
|
||||||
${OPAL_PREFIX}/lib/redhawk64/
|
|
||||||
${PROJECT_SOURCE_DIR}/libopal/
|
|
||||||
)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(Opal DEFAULT_MSG OPAL_LIBRARY OPAL_LIBRARY_UTILS OPAL_LIBRARY_CORE OPAL_LIBRARY_IRC OPAL_INCLUDE_DIR)
|
|
||||||
|
|
||||||
mark_as_advanced(OPAL_INCLUDE_DIR OPAL_LIBRARY)
|
|
||||||
|
|
||||||
set(OPAL_LIBRARIES ${OPAL_LIBRARY} ${OPAL_LIBRARY_UTILS} ${OPAL_LIBRARY_CORE} ${OPAL_LIBRARY_IRC} $ENV{OPAL_LIBPATH} $ENV{OPAL_LIBS})
|
|
||||||
set(OPAL_INCLUDE_DIRS ${OPAL_INCLUDE_DIR})
|
|
|
@ -39,7 +39,6 @@ discriminator:
|
||||||
mqtt: nodes/_mqtt.yaml
|
mqtt: nodes/_mqtt.yaml
|
||||||
nanomsg: nodes/_nanomsg.yaml
|
nanomsg: nodes/_nanomsg.yaml
|
||||||
ngsi: nodes/_ngsi.yaml
|
ngsi: nodes/_ngsi.yaml
|
||||||
opal: nodes/_opal.yaml
|
|
||||||
redis: nodes/_redis.yaml
|
redis: nodes/_redis.yaml
|
||||||
rtp: nodes/_rtp.yaml
|
rtp: nodes/_rtp.yaml
|
||||||
shmem: nodes/_shmem.yaml
|
shmem: nodes/_shmem.yaml
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
# yaml-language-server: $schema=http://json-schema.org/draft-07/schema
|
|
||||||
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
---
|
|
||||||
allOf:
|
|
||||||
- $ref: ../node_obj.yaml
|
|
||||||
- $ref: opal.yaml
|
|
|
@ -1,18 +0,0 @@
|
||||||
# yaml-language-server: $schema=http://json-schema.org/draft-07/schema
|
|
||||||
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
---
|
|
||||||
allOf:
|
|
||||||
- type: object
|
|
||||||
properties:
|
|
||||||
send_id:
|
|
||||||
type: integer
|
|
||||||
|
|
||||||
recv_id:
|
|
||||||
type: integer
|
|
||||||
|
|
||||||
reply:
|
|
||||||
type: boolean
|
|
||||||
|
|
||||||
- $ref: ../node_signals.yaml
|
|
||||||
- $ref: ../node.yaml
|
|
|
@ -1,18 +0,0 @@
|
||||||
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
nodes = {
|
|
||||||
# The server can be started as an Asynchronous process
|
|
||||||
# from within an OPAL-RT model
|
|
||||||
opal_node = {
|
|
||||||
type = "opal",
|
|
||||||
|
|
||||||
# It's possible to have multiple send / recv Icons per model
|
|
||||||
send_id = 1,
|
|
||||||
|
|
||||||
# Specify the ID here
|
|
||||||
recv_id = 1,
|
|
||||||
|
|
||||||
reply = true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
/* Log sink for OPAL-RTs OpalPrint().
|
|
||||||
*
|
|
||||||
* Author: Steffen Vogel <post@steffenvogel.de>
|
|
||||||
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include <villas/config.hpp>
|
|
||||||
#include <villas/log.hpp>
|
|
||||||
|
|
||||||
#include <spdlog/details/null_mutex.h>
|
|
||||||
#include <spdlog/sinks/base_sink.h>
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
/* Define RTLAB before including OpalPrint.h for messages to be sent
|
|
||||||
* to the OpalDisplay. Otherwise stdout will be used. */
|
|
||||||
#define RTLAB
|
|
||||||
#include <OpalPrint.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace villas {
|
|
||||||
namespace node {
|
|
||||||
|
|
||||||
template <typename Mutex>
|
|
||||||
class OpalSink : public spdlog::sinks::base_sink<Mutex> {
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void sink_it_(const spdlog::details::log_msg &msg) override {
|
|
||||||
#ifdef WITH_NODE_OPAL
|
|
||||||
fmt::memory_buffer formatted;
|
|
||||||
|
|
||||||
sink::formatter_->format(msg, formatted);
|
|
||||||
|
|
||||||
auto str = fmt::to_string(formatted).c_str();
|
|
||||||
|
|
||||||
OpalPrint(PROJECT_NAME ": %s\n", str);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void flush_() override {
|
|
||||||
// nothing to do
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using OpalSink_mt = OpalSink<std::mutex>;
|
|
||||||
using OpalSink_st = OpalSink<spdlog::details::null_mutex>;
|
|
||||||
|
|
||||||
} // namespace node
|
|
||||||
} // namespace villas
|
|
|
@ -37,7 +37,6 @@
|
||||||
#cmakedefine WITH_WEB
|
#cmakedefine WITH_WEB
|
||||||
#cmakedefine WITH_NODE_WEBSOCKET
|
#cmakedefine WITH_NODE_WEBSOCKET
|
||||||
#cmakedefine WITH_NODE_WEBRTC
|
#cmakedefine WITH_NODE_WEBRTC
|
||||||
#cmakedefine WITH_NODE_OPAL
|
|
||||||
#cmakedefine WITH_API
|
#cmakedefine WITH_API
|
||||||
#cmakedefine WITH_HOOKS
|
#cmakedefine WITH_HOOKS
|
||||||
#cmakedefine WITH_CONFIG
|
#cmakedefine WITH_CONFIG
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
/* Node type: OPAL (libOpalAsync API).
|
|
||||||
*
|
|
||||||
* Author: Steffen Vogel <post@steffenvogel.de>
|
|
||||||
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
#include <villas/sample.hpp>
|
|
||||||
|
|
||||||
namespace villas {
|
|
||||||
namespace node {
|
|
||||||
|
|
||||||
// Forward declarations
|
|
||||||
class NodeCompat;
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include <OpalGenAsyncParamCtrl.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
struct opal {
|
|
||||||
int reply;
|
|
||||||
int mode;
|
|
||||||
int sequenceNo;
|
|
||||||
|
|
||||||
unsigned sendID;
|
|
||||||
unsigned recvID;
|
|
||||||
|
|
||||||
Opal_SendAsyncParam sendParams;
|
|
||||||
Opal_RecvAsyncParam recvParams;
|
|
||||||
};
|
|
||||||
|
|
||||||
int opal_type_start(SuperNode *sn);
|
|
||||||
|
|
||||||
int opal_register_region(int argc, char *argv[]);
|
|
||||||
|
|
||||||
int opal_type_stop();
|
|
||||||
|
|
||||||
int opal_parse(NodeCompat *n, json_t *json);
|
|
||||||
|
|
||||||
char *opal_print(NodeCompat *n);
|
|
||||||
|
|
||||||
int opal_start(NodeCompat *n);
|
|
||||||
|
|
||||||
int opal_stop(NodeCompat *n);
|
|
||||||
|
|
||||||
int opal_read(NodeCompat *n, struct Sample *const smps[], unsigned cnt);
|
|
||||||
|
|
||||||
int opal_write(NodeCompat *n, struct Sample *const smps[], unsigned cnt);
|
|
||||||
|
|
||||||
} // namespace node
|
|
||||||
} // namespace villas
|
|
|
@ -71,13 +71,6 @@ if(WITH_NODE_IEC61850)
|
||||||
list(APPEND LIBRARIES PkgConfig::LIBIEC61850)
|
list(APPEND LIBRARIES PkgConfig::LIBIEC61850)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!)
|
|
||||||
if(WITH_NODE_OPAL)
|
|
||||||
list(APPEND NODE_SRC opal.cpp)
|
|
||||||
list(APPEND INCLUDE_DIRS ${OPAL_INCLUDE_DIRS})
|
|
||||||
list(APPEND LIBRARIES ${OPAL_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WITH_NODE_MODBUS)
|
if(WITH_NODE_MODBUS)
|
||||||
list(APPEND NODE_SRC modbus.cpp)
|
list(APPEND NODE_SRC modbus.cpp)
|
||||||
list(APPEND LIBRARIES PkgConfig::MODBUS)
|
list(APPEND LIBRARIES PkgConfig::MODBUS)
|
||||||
|
|
|
@ -1,348 +0,0 @@
|
||||||
/* Node type: OPAL (AsyncApi).
|
|
||||||
*
|
|
||||||
* This file implements the opal subtype for nodes.
|
|
||||||
*
|
|
||||||
* Author: Steffen Vogel <post@steffenvogel.de>
|
|
||||||
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <villas/exceptions.hpp>
|
|
||||||
#include <villas/node_compat.hpp>
|
|
||||||
#include <villas/nodes/opal.hpp>
|
|
||||||
#include <villas/utils.hpp>
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
/* Define RTLAB before including OpalPrint.h for messages to be sent
|
|
||||||
* to the OpalDisplay. Otherwise stdout will be used. */
|
|
||||||
#define RTLAB
|
|
||||||
#include <AsyncApi.h>
|
|
||||||
#include <OpalGenAsyncParamCtrl.h>
|
|
||||||
#include <OpalPrint.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
// Private static storage
|
|
||||||
static std::string
|
|
||||||
asyncShmemName; // Shared Memory identifiers and size, provided via argv.
|
|
||||||
static std::string
|
|
||||||
printShmemName; // Shared Memory identifiers and size, provided via argv.
|
|
||||||
static size_t
|
|
||||||
asyncShmemSize; // Shared Memory identifiers and size, provided via argv.
|
|
||||||
|
|
||||||
static std::vector<unsigned> sendIDs,
|
|
||||||
recvIDs; // A dynamically allocated array of SendIDs.
|
|
||||||
|
|
||||||
static Opal_GenAsyncParam_Ctrl
|
|
||||||
params; // String and Float parameters, provided by the OPAL AsyncProcess block.
|
|
||||||
|
|
||||||
static pthread_mutex_t lock; // Big Global Lock for libOpalAsync API
|
|
||||||
|
|
||||||
using namespace villas;
|
|
||||||
using namespace villas::utils;
|
|
||||||
|
|
||||||
/* A bunch of symbols which are used by the libOpal libraries
|
|
||||||
* and undefined by GCC. We replace them by GCC variants here.
|
|
||||||
*/
|
|
||||||
extern "C" {
|
|
||||||
int __xstat(int ver, const char *path, struct stat *stat_buf) {
|
|
||||||
return stat(path, stat_buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
int backtrace(void **buffer, int size) { return 0; }
|
|
||||||
|
|
||||||
char **backtrace_symbols(void *const *buffer, int size) { return nullptr; }
|
|
||||||
|
|
||||||
void backtrace_symbols_fd(void *const *buffer, int size, int fd) {}
|
|
||||||
|
|
||||||
void *_intel_fast_memset(void *b, int c, size_t len) {
|
|
||||||
return memset(b, c, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *_intel_fast_memcpy(void *dst, const void *src, size_t n) {
|
|
||||||
return memcpy(dst, src, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
int _intel_fast_memcmp(const void *s1, const void *s2, size_t n) {
|
|
||||||
return memcmp(s1, s2, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *_intel_fast_memmove(void *s1, const void *s2, size_t n) {
|
|
||||||
return memmove(s1, s2, n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opal_register_region(int argc, char *argv[]) {
|
|
||||||
if (argc != 4)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
asyncShmemName = argv[1];
|
|
||||||
asyncShmemSize = atoi(argv[2]);
|
|
||||||
printShmemName = argv[3];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int villas::node::opal_type_start(villas::node::SuperNode *sn) {
|
|
||||||
int err, noRecvIcons, noSendIcons;
|
|
||||||
|
|
||||||
pthread_mutex_init(&lock, nullptr);
|
|
||||||
|
|
||||||
// Enable the OpalPrint function. This prints to the OpalDisplay.
|
|
||||||
err = OpalSystemCtrl_Register((char *)printShmemName.c_str());
|
|
||||||
if (err != EOK)
|
|
||||||
throw RuntimeError("OpalPrint() access not available ({})", err);
|
|
||||||
|
|
||||||
// Open Share Memory created by the model.
|
|
||||||
err = OpalOpenAsyncMem(asyncShmemSize, asyncShmemName.c_str());
|
|
||||||
if (err != EOK)
|
|
||||||
throw RuntimeError("Model shared memory not available ({})", err);
|
|
||||||
|
|
||||||
err = OpalGetAsyncCtrlParameters(¶ms, sizeof(Opal_GenAsyncParam_Ctrl));
|
|
||||||
if (err != EOK)
|
|
||||||
throw RuntimeError("Could not get OPAL controller parameters ({})", err);
|
|
||||||
|
|
||||||
// Get list of Send and RecvIDs
|
|
||||||
err = OpalGetNbAsyncSendIcon(&noSendIcons);
|
|
||||||
if (err != EOK)
|
|
||||||
throw RuntimeError("Failed to get number of send blocks ({})", err);
|
|
||||||
err = OpalGetNbAsyncRecvIcon(&noRecvIcons);
|
|
||||||
if (err != EOK)
|
|
||||||
throw RuntimeError("Failed to get number of recv blocks ({})", err);
|
|
||||||
|
|
||||||
sendIDs.resize(noSendIcons);
|
|
||||||
recvIDs.resize(noRecvIcons);
|
|
||||||
|
|
||||||
err = OpalGetAsyncSendIDList(sendIDs.data(), noSendIcons * sizeof(int));
|
|
||||||
if (err != EOK)
|
|
||||||
throw RuntimeError("Failed to get list of send ids ({})", err);
|
|
||||||
err = OpalGetAsyncRecvIDList(recvIDs.data(), noRecvIcons * sizeof(int));
|
|
||||||
if (err != EOK)
|
|
||||||
throw RuntimeError("Failed to get list of recv ids ({})", err);
|
|
||||||
|
|
||||||
auto logger = Log::get("node:opal");
|
|
||||||
logger->info("Started as OPAL Asynchronous process");
|
|
||||||
logger->info("This is VILLASnode %s (built on %s, %s)", PROJECT_BUILD_ID,
|
|
||||||
__DATE__, __TIME__);
|
|
||||||
|
|
||||||
opal_print_global();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int villas::node::opal_type_stop() {
|
|
||||||
int err;
|
|
||||||
|
|
||||||
err = OpalCloseAsyncMem(asyncShmemSize, asyncShmemName.c_str());
|
|
||||||
if (err != EOK)
|
|
||||||
throw RuntimeError("Failed to close shared memory area ({})", err);
|
|
||||||
|
|
||||||
auto logger = Log::get("node:opal");
|
|
||||||
logger->debug("Closing OPAL shared memory mapping");
|
|
||||||
|
|
||||||
err = OpalSystemCtrl_UnRegister((char *)printShmemName.c_str());
|
|
||||||
if (err != EOK)
|
|
||||||
throw RuntimeError("Failed to close shared memory for system control ({})",
|
|
||||||
err);
|
|
||||||
|
|
||||||
pthread_mutex_destroy(&lock);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opal_print_global() {
|
|
||||||
auto logger = Log::get("node:opal");
|
|
||||||
logger->debug("Controller ID: {}", params.controllerID);
|
|
||||||
|
|
||||||
std::stringstream sss, rss;
|
|
||||||
|
|
||||||
for (auto i : sendIDs)
|
|
||||||
sss << i << " ";
|
|
||||||
for (auto i : recvIDs)
|
|
||||||
rss << i << " ";
|
|
||||||
|
|
||||||
logger->debug("Send Blocks: {}", sss.str());
|
|
||||||
logger->debug("Receive Blocks: {}", rss.str());
|
|
||||||
|
|
||||||
logger->debug("Control Block Parameters:");
|
|
||||||
for (int i = 0; i < GENASYNC_NB_FLOAT_PARAM; i++)
|
|
||||||
logger->debug("FloatParam[{}] = {}", i, (double)params.FloatParam[i]);
|
|
||||||
for (int i = 0; i < GENASYNC_NB_STRING_PARAM; i++)
|
|
||||||
logger->debug("StringParam[{}] = {}", i, params.StringParam[i]);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int villas::node::opal_parse(NodeCompat *n, json_t *json) {
|
|
||||||
auto *o = n->getData<struct opal>();
|
|
||||||
|
|
||||||
int ret;
|
|
||||||
json_error_t err;
|
|
||||||
|
|
||||||
ret = json_unpack_ex(json, &err, 0, "{ s: i, s: i, s: b }", "send_id",
|
|
||||||
&o->sendID, "recv_id", &o->sendID, "reply", &o->reply);
|
|
||||||
if (ret)
|
|
||||||
throw ConfigError(json, err, "node-config-node-opal");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *villas::node::opal_print(NodeCompat *n) {
|
|
||||||
auto *o = n->getData<struct opal>();
|
|
||||||
|
|
||||||
// TODO: Print send_params, recv_params
|
|
||||||
|
|
||||||
return strf("sendID=%u, recvID=%u, reply=%u", o->sendID, o->recvID, o->reply);
|
|
||||||
}
|
|
||||||
|
|
||||||
int villas::node::opal_start(NodeCompat *n) {
|
|
||||||
auto *o = n->getData<struct opal>();
|
|
||||||
|
|
||||||
// Search for valid send and recv ids
|
|
||||||
int sfound = 0, rfound = 0;
|
|
||||||
for (auto i : sendIDs)
|
|
||||||
sfound += i == o->sendID;
|
|
||||||
for (auto i : recvIDs)
|
|
||||||
rfound += i == o->sendID;
|
|
||||||
|
|
||||||
if (!sfound)
|
|
||||||
throw RuntimeError("Invalid send_id '{}'", o->sendID);
|
|
||||||
if (!rfound)
|
|
||||||
throw RuntimeError("Invalid recv_id '{}'", o->recvID);
|
|
||||||
|
|
||||||
// Get some more informations and paramters from OPAL-RT
|
|
||||||
OpalGetAsyncSendIconMode(&o->mode, o->sendID);
|
|
||||||
OpalGetAsyncSendParameters(&o->sendParams, sizeof(Opal_SendAsyncParam),
|
|
||||||
o->sendID);
|
|
||||||
OpalGetAsyncRecvParameters(&o->recvParams, sizeof(Opal_RecvAsyncParam),
|
|
||||||
o->recvID);
|
|
||||||
|
|
||||||
o->sequenceNo = 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int villas::node::opal_read(NodeCompat *n, struct Sample *const smps[],
|
|
||||||
unsigned cnt) {
|
|
||||||
auto *o = n->getData<struct opal>();
|
|
||||||
|
|
||||||
int state, ret, len;
|
|
||||||
unsigned id;
|
|
||||||
|
|
||||||
struct Sample *s = smps[0];
|
|
||||||
|
|
||||||
double data[s->capacity];
|
|
||||||
|
|
||||||
if (cnt != 1)
|
|
||||||
throw RuntimeError("The OPAL-RT node type does not support combining!");
|
|
||||||
|
|
||||||
// This call unblocks when the 'Data Ready' line of a send icon is asserted.
|
|
||||||
do {
|
|
||||||
ret = OpalWaitForAsyncSendRequest(&id);
|
|
||||||
if (ret != EOK) {
|
|
||||||
state = OpalGetAsyncModelState();
|
|
||||||
if ((state == STATE_RESET) || (state == STATE_STOP))
|
|
||||||
throw RuntimeError(
|
|
||||||
"OpalGetAsyncModelState(): Model stopped or resetted!");
|
|
||||||
|
|
||||||
return -1; // TODO: correct return value
|
|
||||||
}
|
|
||||||
} while (id != o->sendID);
|
|
||||||
|
|
||||||
// No errors encountered yet
|
|
||||||
OpalSetAsyncSendIconError(0, o->sendID);
|
|
||||||
|
|
||||||
// Get the size of the data being sent by the unblocking SendID
|
|
||||||
OpalGetAsyncSendIconDataLength(&len, o->sendID);
|
|
||||||
if ((unsigned)len > s->capacity * sizeof(s->data[0])) {
|
|
||||||
n->logger->warn("Ignoring the last {} of {} values for OPAL (send_id={}).",
|
|
||||||
len / sizeof(double) - s->capacity, len / sizeof(double),
|
|
||||||
o->sendID);
|
|
||||||
|
|
||||||
len = sizeof(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read data from the model
|
|
||||||
OpalGetAsyncSendIconData(data, len, o->sendID);
|
|
||||||
|
|
||||||
s->sequence = htons(o->sequenceNo++);
|
|
||||||
s->length = (unsigned)len / sizeof(double);
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < s->length; i++)
|
|
||||||
s->data[i].f = (float)data[i]; // OPAL provides double precission
|
|
||||||
|
|
||||||
/* This next call allows the execution of the "asynchronous" process
|
|
||||||
* to actually be synchronous with the model. To achieve this, you
|
|
||||||
* should set the "Sending Mode" in the Async_Send block to
|
|
||||||
* NEED_REPLY_BEFORE_NEXT_SEND or NEED_REPLY_NOW. This will force
|
|
||||||
* the model to wait for this process to call this
|
|
||||||
* OpalAsyncSendRequestDone function before continuing. */
|
|
||||||
if (o->reply)
|
|
||||||
OpalAsyncSendRequestDone(o->sendID);
|
|
||||||
|
|
||||||
/* Before continuing, we make sure that the real-time model
|
|
||||||
* has not been stopped. If it has, we quit. */
|
|
||||||
state = OpalGetAsyncModelState();
|
|
||||||
if ((state == STATE_RESET) || (state == STATE_STOP))
|
|
||||||
throw RuntimeError("OpalGetAsyncModelState(): Model stopped or resetted!");
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int villas::node::opal_write(NodeCompat *n, struct Sample *const smps[],
|
|
||||||
unsigned cnt) {
|
|
||||||
auto *o = n->getData<struct opal>();
|
|
||||||
|
|
||||||
struct Sample *s = smps[0];
|
|
||||||
|
|
||||||
int state;
|
|
||||||
int len;
|
|
||||||
double data[s->length];
|
|
||||||
|
|
||||||
if (cnt != 1)
|
|
||||||
throw RuntimeError("The OPAL-RT node type does not support combining!");
|
|
||||||
|
|
||||||
state = OpalGetAsyncModelState();
|
|
||||||
if ((state == STATE_RESET) || (state == STATE_STOP))
|
|
||||||
throw RuntimeError("OpalGetAsyncModelState(): Model stopped or resetted!");
|
|
||||||
|
|
||||||
OpalSetAsyncRecvIconStatus(s->sequence,
|
|
||||||
o->recvID); // Set the Status to the message ID
|
|
||||||
OpalSetAsyncRecvIconError(0, o->recvID); // Set the Error to 0
|
|
||||||
|
|
||||||
// Get the number of signals to send back to the model
|
|
||||||
OpalGetAsyncRecvIconDataLength(&len, o->recvID);
|
|
||||||
if (len > (int)sizeof(data))
|
|
||||||
n->logger->warn(
|
|
||||||
"Node expecting more signals ({}) than values in message ({})",
|
|
||||||
len / sizeof(double), s->length);
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < s->length; i++)
|
|
||||||
data[i] = (double)s->data[i].f; // OPAL expects double precission
|
|
||||||
|
|
||||||
OpalSetAsyncRecvIconData(data, s->length * sizeof(double), o->recvID);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static NodeCompatType p;
|
|
||||||
|
|
||||||
__attribute__((constructor(110))) static void register_plugin() {
|
|
||||||
p.name = "opal";
|
|
||||||
p.description = "run as OPAL Asynchronous Process (libOpalAsyncApi)";
|
|
||||||
p.vectorize = 1;
|
|
||||||
p.size = sizeof(struct opal);
|
|
||||||
p.type.start = opal_type_start;
|
|
||||||
p.type.stop = opal_type_stop;
|
|
||||||
p.parse = opal_parse;
|
|
||||||
p.print = opal_print;
|
|
||||||
p.start = opal_start;
|
|
||||||
p.read = opal_read;
|
|
||||||
p.write = opal_write;
|
|
||||||
|
|
||||||
static NodeCompatFactory ncp(&p);
|
|
||||||
}
|
|
|
@ -31,11 +31,6 @@ target_link_libraries(villas-pipe PUBLIC villas Threads::Threads)
|
||||||
add_executable(villas-signal villas-signal.cpp)
|
add_executable(villas-signal villas-signal.cpp)
|
||||||
target_link_libraries(villas-signal PUBLIC villas)
|
target_link_libraries(villas-signal PUBLIC villas)
|
||||||
|
|
||||||
if(WITH_NODE_OPAL)
|
|
||||||
target_include_directories(villas-node PRIVATE ${OPAL_INCLUDE_DIRS})
|
|
||||||
target_link_libraries(villas-node PRIVATE ${OPAL_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WITH_GRAPHVIZ)
|
if(WITH_GRAPHVIZ)
|
||||||
add_executable(villas-graph villas-graph.cpp)
|
add_executable(villas-graph villas-graph.cpp)
|
||||||
target_link_libraries(villas-graph PUBLIC villas)
|
target_link_libraries(villas-graph PUBLIC villas)
|
||||||
|
|
|
@ -32,10 +32,6 @@
|
||||||
#include <villas/version.hpp>
|
#include <villas/version.hpp>
|
||||||
#include <villas/web.hpp>
|
#include <villas/web.hpp>
|
||||||
|
|
||||||
#ifdef WITH_NODE_OPAL
|
|
||||||
#include <villas/nodes/opal.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace villas;
|
using namespace villas;
|
||||||
using namespace villas::node;
|
using namespace villas::node;
|
||||||
using namespace villas::plugin;
|
using namespace villas::plugin;
|
||||||
|
@ -83,16 +79,6 @@ protected:
|
||||||
<< " and wait for provisioning over the web interface."
|
<< " and wait for provisioning over the web interface."
|
||||||
<< std::endl
|
<< std::endl
|
||||||
<< std::endl
|
<< std::endl
|
||||||
#ifdef WITH_NODE_OPAL
|
|
||||||
<< "Usage: villas-node OPAL_ASYNC_SHMEM_NAME OPAL_ASYNC_SHMEM_SIZE "
|
|
||||||
"OPAL_PRINT_SHMEM_NAME"
|
|
||||||
<< std::endl
|
|
||||||
<< " This type of invocation is used by OPAL-RT Asynchronous "
|
|
||||||
"processes."
|
|
||||||
<< std::endl
|
|
||||||
<< " See in the RT-LAB User Guide for more information." << std::endl
|
|
||||||
<< std::endl
|
|
||||||
#endif // WITH_NODE_OPAL
|
|
||||||
|
|
||||||
<< "Supported node-types:" << std::endl;
|
<< "Supported node-types:" << std::endl;
|
||||||
for (auto p : registry->lookup<NodeFactory>()) {
|
for (auto p : registry->lookup<NodeFactory>()) {
|
||||||
|
@ -134,18 +120,6 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse() {
|
void parse() {
|
||||||
// Check arguments
|
|
||||||
#ifdef WITH_NODE_OPAL
|
|
||||||
if (argc != 4) {
|
|
||||||
usage();
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
opal_register_region(argc, argv);
|
|
||||||
|
|
||||||
uri = "villas-node.conf";
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Parse optional command line arguments
|
// Parse optional command line arguments
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt(argc, argv, "hCVd:")) != -1) {
|
while ((c = getopt(argc, argv, "hCVd:")) != -1) {
|
||||||
|
@ -177,7 +151,6 @@ protected:
|
||||||
usage();
|
usage();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#endif // ENABLE_OPAL_ASYNC
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() { return showCapabilities ? capabilities() : daemon(); }
|
int main() { return showCapabilities ? capabilities() : daemon(); }
|
||||||
|
|
Loading…
Add table
Reference in a new issue