Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ test:python:
stage: test
script:
- cd python
- /venv/bin/pytest --verbose .
- /venv/bin/black --extend-exclude=".*(\\.pyi|_pb2.py)$" --check .
- /venv/bin/flake8 --extend-exclude="*.pyi,*_pb2.py" .
- /venv/bin/mypy .
- pytest --verbose .
- black --extend-exclude=".*(\\.pyi|_pb2.py)$" --check .
- flake8 --extend-exclude="*.pyi,*_pb2.py" .
- mypy .
image: ${DOCKER_IMAGE_DEV}:${DOCKER_TAG}
needs:
- job: "build:source: [fedora]"
Expand Down
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ cmake_dependent_option(WITH_NODE_EXAMPLE "Build with example node-type"
cmake_dependent_option(WITH_NODE_EXEC "Build with exec node-type" "${WITH_DEFAULTS}" "" OFF)
cmake_dependent_option(WITH_NODE_FILE "Build with file node-type" "${WITH_DEFAULTS}" "" OFF)
cmake_dependent_option(WITH_NODE_FPGA "Build with fpga node-type" "${WITH_DEFAULTS}" "WITH_FPGA" OFF)
cmake_dependent_option(WITH_NODE_IEC61850 "Build with iec61850 node-types" "${WITH_DEFAULTS}" "LIBIEC61850_FOUND; NOT WITHOUT_GPL" OFF)
cmake_dependent_option(WITH_NODE_IEC60870 "Build with iec60870 node-types" "${WITH_DEFAULTS}" "LIB60870_FOUND; NOT WITHOUT_GPL" OFF)
cmake_dependent_option(WITH_NODE_IEC61850 "Build with iec61850 node-types" "${WITH_DEFAULTS}" "LIBIEC61850_FOUND; NOT WITHOUT_GPL" OFF)
cmake_dependent_option(WITH_NODE_INFINIBAND "Build with infiniband node-type" "${WITH_DEFAULTS}" "IBVerbs_FOUND; RDMACM_FOUND" OFF) # Infiniband node-type is currenly broken
cmake_dependent_option(WITH_NODE_INFLUXDB "Build with influxdb node-type" "${WITH_DEFAULTS}" "" OFF)
cmake_dependent_option(WITH_NODE_KAFKA "Build with kafka node-type" "${WITH_DEFAULTS}" "RDKAFKA_FOUND" OFF)
Expand All @@ -199,8 +199,9 @@ 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_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_OPAL_ORCHESTRA "Build with opal-orchestra node-type" "${WITH_DEFAULTS}" "OpalOrchestra_FOUND; LibXml2_FOUND" OFF)
cmake_dependent_option(WITH_NODE_OPAL_ASYNC "Build with opal.async node-type" "${WITH_DEFAULTS}" "OpalAsyncApi_FOUND" OFF)
cmake_dependent_option(WITH_NODE_OPAL_ORCHESTRA "Build with opal.orchestra node-type" "${WITH_DEFAULTS}" "OpalOrchestra_FOUND; LibXml2_FOUND" OFF)
cmake_dependent_option(WITH_NODE_OPENDSS "Build with opendss node-type" "${WITH_DEFAULTS}" "OpenDSSC_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_SHMEM "Build with shmem node-type" "${WITH_DEFAULTS}" "HAS_SEMAPHORE; HAS_MMAN" OFF)
Expand All @@ -213,7 +214,6 @@ cmake_dependent_option(WITH_NODE_ULDAQ "Build with uldaq node-type"
cmake_dependent_option(WITH_NODE_WEBRTC "Build with webrtc node-type" "${WITH_DEFAULTS}" "WITH_WEB; LibDataChannel_FOUND" OFF)
cmake_dependent_option(WITH_NODE_WEBSOCKET "Build with websocket node-type" "${WITH_DEFAULTS}" "WITH_WEB" OFF)
cmake_dependent_option(WITH_NODE_ZEROMQ "Build with zeromq node-type" "${WITH_DEFAULTS}" "LIBZMQ_FOUND; NOT WITHOUT_GPL" OFF)
cmake_dependent_option(WITH_NODE_OPENDSS "Build with opendss node-type" "${WITH_DEFAULTS}" "OpenDSSC_FOUND" OFF)

# Set a default for the build type
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
Expand Down Expand Up @@ -299,8 +299,8 @@ add_feature_info(NODE_EXAMPLE WITH_NODE_EXAMPLE "Build with
add_feature_info(NODE_EXEC WITH_NODE_EXEC "Build with exec node-type")
add_feature_info(NODE_FILE WITH_NODE_FILE "Build with file node-type")
add_feature_info(NODE_FPGA WITH_NODE_FPGA "Build with fpga node-type")
add_feature_info(NODE_IEC61850 WITH_NODE_IEC61850 "Build with iec61850 node-types")
add_feature_info(NODE_IEC60870 WITH_NODE_IEC60870 "Build with iec60870 node-types")
add_feature_info(NODE_IEC61850 WITH_NODE_IEC61850 "Build with iec61850 node-types")
add_feature_info(NODE_INFINIBAND WITH_NODE_INFINIBAND "Build with infiniband node-type")
add_feature_info(NODE_INFLUXDB WITH_NODE_INFLUXDB "Build with influxdb node-type")
add_feature_info(NODE_KAFKA WITH_NODE_KAFKA "Build with kafka node-type")
Expand All @@ -309,6 +309,8 @@ 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_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_OPAL_AYSNC WITH_NODE_OPAL_ASYNC "Build with opal.async node-type")
add_feature_info(NODE_OPAL_ORCHESTRA WITH_NODE_OPAL_ORCHESTRA "Build with opal.orchestra node-type")
add_feature_info(NODE_OPENDSS WITH_NODE_OPENDSS "Build with opendss 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")
Expand Down
4 changes: 2 additions & 2 deletions cmake/FindOpalOrchestra.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
find_path(OPAL_ORCHESTRA_INCLUDE_DIR
NAMES RTAPI.h
PATHS
/usr/opalrt/common/bin
/usr/opalrt/common/include_target
)

find_library(OPAL_ORCHESTRA_LIBRARY
NAMES OpalOrchestra
PATHS
/usr/opalrt/common/include
/usr/opalrt/common/bin
)

include(FindPackageHandleStandardArgs)
Expand Down
10 changes: 10 additions & 0 deletions common/include/villas/fs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once

#include <villas/config.hpp>

#ifdef WITH_GHC_FS

#include <fmt/ostream.h>
#include <ghc/filesystem.hpp>

namespace fs = ghc::filesystem;

template <> class fmt::formatter<fs::path> : public fmt::ostream_formatter {};

#else

#include <filesystem>
namespace fs = std::filesystem;

#endif
3 changes: 2 additions & 1 deletion include/villas/nodes/opal_orchestra/ddf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <libxml/tree.h>

#include <villas/fs.hpp>
#include <villas/nodes/opal_orchestra/signal.hpp>
#include <villas/sample.hpp>
#include <villas/signal.hpp>
Expand Down Expand Up @@ -148,7 +149,7 @@ class DataDefinitionFile {

xmlNode *toXml() const;

void writeToFile(const std::filesystem::path &filename) const;
void writeToFile(const fs::path &filename) const;
};

} // namespace orchestra
Expand Down
8 changes: 7 additions & 1 deletion lib/api/requests/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

extern "C" {
#include <graphviz/graphviz_version.h>
#include <graphviz/gvc.h>
}

Expand Down Expand Up @@ -46,7 +47,12 @@ class GraphRequest : public Request {
auto *graph = sn->getGraph();

char *data;
unsigned len;

#if GRAPHVIZ_VERSION_MAJOR >= 13
size_t len;
#else
unsigned int len;
#endif

std::list<std::string> supportedLayouts = {
"circo", "dot", "fdp", "neato", "nop", "nop1",
Expand Down
3 changes: 2 additions & 1 deletion lib/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ json_t *Config::expandIncludes(json_t *in) {
std::string text = json_string_value(str);
static const std::string kw = "@include ";

if (!text.starts_with(kw))
auto res = std::mismatch(kw.begin(), kw.end(), text.begin());
if (res.first != kw.end())
return json_incref(str);
else {
std::string pattern = text.substr(kw.size());
Expand Down
5 changes: 2 additions & 3 deletions lib/mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ int MappingEntry::parseString(const std::string &str) {
throw RuntimeError("Failed to parse mapping expression: {}", str);
}

MappingEntry::MappingEntry()
: node(nullptr), type(Type::UNKNOWN), length(0), offset(0), data(0),
nodeName() {}
MappingEntry::MappingEntry() // cppcheck-suppress uninitMemberVar
: node(nullptr), type(Type::UNKNOWN), length(0), offset(0), nodeName() {}

int MappingEntry::parse(json_t *json) {
const char *str;
Expand Down
17 changes: 8 additions & 9 deletions lib/nodes/opal_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <cstdlib>
#include <thread>
#include <unordered_map>
#include <vector>

#include <unistd.h>
Expand Down Expand Up @@ -51,15 +52,15 @@ static std::thread awaiter;

static std::mutex lock; // Protecting state and nodeMap
static int state;
static std::map<int, OpalAsyncNode *> nodeMap;
static std::unordered_map<int, OpalAsyncNode *> nodeMap;

static void waitForModelState(int state) {
while (OpalGetAsyncModelState() != state)
usleep(1000);
}

static void waitForAsyncSendRequests() {
auto logger = logging.get("node:opal");
auto logger = Log::get("node:opal");
int ret;
unsigned id;

Expand Down Expand Up @@ -88,7 +89,7 @@ static void waitForAsyncSendRequests() {
}

static int dumpGlobal() {
auto logger = logging.get("node:opal");
auto logger = Log::get("node:opal");

logger->debug("Controller ID: {}", params.controllerID);

Expand Down Expand Up @@ -131,9 +132,7 @@ void LogSink::sink_it_(const spdlog::details::log_msg &msg) {
buf.clear();
formatter_->format(msg, buf);

char *bufPtr;

bufPtr = bufPtr.data();
auto bufPtr = buf.data();
bufPtr[buf.size()] = '\0';

OpalPrint(bufPtr);
Expand Down Expand Up @@ -349,7 +348,7 @@ void OpalAsyncNode::waitReady() {
ready = false;
}

int OpalAsyncNode::start(SuperNode *sn) {
int OpalAsyncNodeFactory::start(SuperNode *sn) {
int ret, idsRecvLen, idsSendLen;

auto *shmemAsyncNamePtr = std::getenv("OPAL_ASYNC_SHMEM_NAME");
Expand All @@ -365,7 +364,7 @@ int OpalAsyncNode::start(SuperNode *sn) {

// Register OpalPrint sink for spdlog
sink = std::make_shared<LogSink>(shmemSystemCtrlName);
logging.replaceStdSink(sink);
Log::getInstance().replaceStdSink(sink);

// Open shared memory region created by the RT-LAB model.
ret = OpalOpenAsyncMem(shmemAsyncSize,
Expand Down Expand Up @@ -402,7 +401,7 @@ int OpalAsyncNode::start(SuperNode *sn) {
return NodeFactory::start(sn);
}

int OpalAsyncNode::stop() {
int OpalAsyncNodeFactory::stop() {
int ret;

logger->debug("Stopping waiter thread");
Expand Down
5 changes: 3 additions & 2 deletions lib/nodes/opal_orchestra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern "C" {

#include <villas/config_helper.hpp>
#include <villas/exceptions.hpp>
#include <villas/fs.hpp>
#include <villas/node_compat.hpp>
#include <villas/nodes/opal_orchestra/ddf.hpp>
#include <villas/nodes/opal_orchestra/error.hpp>
Expand Down Expand Up @@ -248,7 +249,7 @@ class OpalOrchestraNode : public Node {
publishMappings;

double rate;
std::optional<std::filesystem::path> dataDefinitionFilename;
std::optional<fs::path> dataDefinitionFilename;

std::chrono::seconds connectTimeout;
std::optional<std::chrono::microseconds>
Expand Down Expand Up @@ -499,7 +500,7 @@ class OpalOrchestraNode : public Node {

int check() override {
if (dataDefinitionFilename) {
if (!std::filesystem::exists(*dataDefinitionFilename) &&
if (!fs::exists(*dataDefinitionFilename) &&
!dataDefinitionFileOverwrite) {
throw RuntimeError("OPAL-RT Orchestra Data Definition file (DDF) at "
"'{}' does not exist",
Expand Down
4 changes: 2 additions & 2 deletions lib/nodes/opal_orchestra/ddf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ extern "C" {
#include <RTAPI.h>
}

#include <villas/fs.hpp>
#include <villas/nodes/opal_orchestra/ddf.hpp>
#include <villas/nodes/opal_orchestra/error.hpp>
#include <villas/nodes/opal_orchestra/signal.hpp>
Expand Down Expand Up @@ -367,8 +368,7 @@ xmlNode *DataDefinitionFile::toXml() const {
return rootNode;
}

void DataDefinitionFile::writeToFile(
const std::filesystem::path &filename) const {
void DataDefinitionFile::writeToFile(const fs::path &filename) const {
// Create a new XML document
auto *doc = xmlNewDoc(BAD_CAST "1.0");
auto *rootNode = toXml();
Expand Down
Loading