Skip to content
Open
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 .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
# SPDX-License-Identifier: Apache-2.0

[submodule "fpga/thirdparty/libxil"]
path = fpga/thirdparty/libxil
[submodule "thirdparty/libxil"]
path = thirdparty/libxil
url = https://github.com/VILLASframework/libxil.git
[submodule "fpga/thirdparty/udmabuf"]
path = fpga/thirdparty/udmabuf
[submodule "thirdparty/udmabuf"]
path = thirdparty/udmabuf
url = https://github.com/ikwzm/udmabuf
30 changes: 22 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,18 @@ find_package(Lua)
find_package(LibDataChannel)
find_package(re)
find_package(OpenDSSC)
find_package(OpalAsyncApi)

# Check for tools
find_program(PROTOBUFC_COMPILER NAMES protoc-c)
find_program(PROTOBUF_COMPILER NAMES protoc)
find_program(PASTE NAMES paste)
if(NOT PASTE)
message(SEND_ERROR "GNU paste is missing. Please install coreutils")
endif()

# Check programs
find_program(PROTOBUFC_COMPILER NAMES protoc-c)
find_program(PROTOBUF_COMPILER NAMES protoc)

# Build without any GPL-code
option(WITHOUT_GPL "Build VILLASnode without any GPL code" OFF)
# Check for libraries
find_library(STDCXX_FS NAMES stdc++fs)

set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/share/pkgconfig:/usr/lib64/pkgconfig")

Expand Down Expand Up @@ -151,13 +150,21 @@ endif()
FindSymbol(${LWS_LOCATION} lws_extension_callback_pm_deflate LWS_DEFLATE_FOUND)

# Check if submodules for VILLASfpga are present
if(EXISTS "${PROJECT_SOURCE_DIR}/fpga/thirdparty/libxil/CMakeLists.txt")
if(EXISTS "${PROJECT_SOURCE_DIR}/thirdparty/libxil/CMakeLists.txt")
set(FOUND_FPGA_SUBMODULES ON)
else()
set(FOUND_FPGA_SUBMODULES OFF)
endif()

if(STDCXX_FS)
set(STDCXX_FS_NOT_FOUND OFF)
else()
set(STDCXX_FS_NOT_FOUND ON)
endif()

# Build options
cmake_dependent_option(WITHOUT_GPL "Build VILLASnode without any GPL code" OFF "" ON)
cmake_dependent_option(WITH_GHC_FS "Build using ghc::filesystem, a drop in replacement for std::filesystem" ON "STDCXX_FS_NOT_FOUND" OFF)
cmake_dependent_option(WITH_DEFAULTS "Defaults for non required build options" ON "" OFF)

cmake_dependent_option(WITH_API "Build with remote control API" "${WITH_DEFAULTS}" "" OFF)
Expand Down Expand Up @@ -192,6 +199,7 @@ 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_ASYNC "Build with opal.async node-type" "${WITH_DEFAULTS}" "OpalAsyncApi_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 @@ -206,7 +214,7 @@ cmake_dependent_option(WITH_NODE_WEBSOCKET "Build with websocket node-type"
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
# Set a default for the build type
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Debug")
endif()
Expand All @@ -227,6 +235,11 @@ else()
add_compile_options(-Wno-error)
endif()

if(WITH_GHC_FS)
find_package(ghc_filesystem 1.5.14 REQUIRED)
include_directories($<TARGET_PROPERTY:ghcFilesystem::ghc_filesystem,INTERFACE_INCLUDE_DIRECTORIES>)
endif()

# Get version info and buildid from Git
GetVersion(${PROJECT_SOURCE_DIR} "CMAKE_PROJECT")

Expand Down Expand Up @@ -299,6 +312,7 @@ add_feature_info(NODE_MQTT WITH_NODE_MQTT "Build with
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_OPENDSS WITH_NODE_OPENDSS "Build with opendss node-type")
add_feature_info(NODE_OPAL_ASYNC WITH_NODE_OPAL_ASYNC "Build with opal.async 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_SHMEM WITH_NODE_SHMEM "Build with shmem node-type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static void *RecvFromIPPort(void *arg) {
for (int i = 0; i < msg->length; i++)
mdldata[i] = (double)msg->data[i].f;

// Update OPAL model
// Update OPAL-RT model
OpalSetAsyncRecvIconStatus(msg->sequence,
RecvID); // Set the Status to the message ID
#elif PROTOCOL == GTNET_SKT
Expand Down Expand Up @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) {
// Check for the proper arguments to the program
if (argc < 4) {
printf("Invalid Arguments: 1-AsyncShmemName 2-AsyncShmemSize "
"3-PrintShmemName\n");
"3-SystemCtrlShmemName\n");
exit(0);
}

Expand Down
34 changes: 34 additions & 0 deletions cmake/FindOpalAsyncApi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# CMakeLists.txt
#
# Author: Steffen Vogel <[email protected]>
# SPDX-FileCopyrightText: 2023-2025 OPAL-RT Germany GmbH
# SPDX-License-Identifier: Apache-2.0

set(TARGET_RTLAB_ROOT "/usr/opalrt" CACHE STRING "RT-LAB Root directory")

if(EXISTS "${TARGET_RTLAB_ROOT}/common/bin/opalmodelmk")
set(ENV{TARGET_RTLAB_ROOT} ${TARGET_RTLAB_ROOT})

file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/get_vars.mk"
"all:\n\techo $(OPAL_LIBS) $(OPAL_LIBPATH)\n")

execute_process(
COMMAND make -sf ${TARGET_RTLAB_ROOT}/common/bin/opalmodelmk
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
OUTPUT_VARIABLE OPAL_VARS
)

string(STRIP ${OPAL_VARS} OPAL_VARS)
string(REPLACE " " ";" OPAL_VARS ${OPAL_VARS})

set(OPAL_LIBRARIES -lOpalCore -lOpalUtils ${OPAL_VARS} -lirc -ldl -pthread -lrt)
set(OPAL_INCLUDE_DIR ${TARGET_RTLAB_ROOT}/common/include_target)

add_library(OpalAsyncApi INTERFACE)
target_include_directories(OpalAsyncApi INTERFACE ${OPAL_INCLUDE_DIR})
target_link_libraries(OpalAsyncApi INTERFACE ${OPAL_LIBRARIES})
endif()

find_package_handle_standard_args(OpalAsyncApi DEFAULT_MSG OPAL_LIBRARIES OPAL_INCLUDE_DIR)

mark_as_advanced(OPAL_LIBRARIES OPAL_INCLUDE_DIR)
1 change: 1 addition & 0 deletions common/include/villas/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@

// Library features
#cmakedefine FMT_LEGACY_OSTREAM_FORMATTER
#cmakedefine WITH_GHC_FS

// clang-format on
15 changes: 15 additions & 0 deletions common/include/villas/fs.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* std::filesystem compatability
*
* SPDX-FileCopyrightText: 2025, ghc::filesystem Authors
* SPDX-License-Identifier: MIT
*/

#include <villas/config.hpp>

#ifdef WITH_GHC_FS
#include <ghc/filesystem.hpp>
namespace fs = ghc::filesystem;
#else
#include <filesystem>
namespace fs = std::filesystem;
#endif
6 changes: 3 additions & 3 deletions common/include/villas/kernel/devices/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#pragma once

#include <filesystem>
#include <optional>

#include <villas/fs.hpp>
#include <villas/kernel/devices/driver.hpp>

namespace villas {
Expand All @@ -24,8 +24,8 @@ class Device {
virtual std::optional<std::unique_ptr<Driver>> driver() const = 0;
virtual std::optional<int> iommu_group() const = 0;
virtual std::string name() const = 0;
virtual std::filesystem::path override_path() const = 0;
virtual std::filesystem::path path() const = 0;
virtual fs::path override_path() const = 0;
virtual fs::path path() const = 0;
virtual void probe() const = 0;
};

Expand Down
10 changes: 5 additions & 5 deletions common/include/villas/kernel/devices/ip_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#pragma once

#include <filesystem>
#include <vector>

#include <villas/fs.hpp>
#include <villas/kernel/devices/platform_device.hpp>

namespace villas {
Expand All @@ -19,21 +19,21 @@ namespace devices {

class IpDevice : public PlatformDevice {
public:
static IpDevice from(const std::filesystem::path unsafe_path);
static bool is_path_valid(const std::filesystem::path unsafe_path);
static IpDevice from(const fs::path unsafe_path);
static bool is_path_valid(const fs::path unsafe_path);

private:
IpDevice() = delete;
IpDevice(
const std::filesystem::path valid_path) //! Dont allow unvalidated paths
const fs::path valid_path) //! Dont allow unvalidated paths
: PlatformDevice(valid_path){};

public:
size_t addr() const;
std::string ip_name() const;

static std::vector<villas::kernel::devices::IpDevice>
from_directory(std::filesystem::path devices_directory);
from_directory(fs::path devices_directory);
};

} // namespace devices
Expand Down
20 changes: 10 additions & 10 deletions common/include/villas/kernel/devices/linux_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#pragma once

#include <filesystem>
#include <fstream>
#include <iostream>

#include <villas/fs.hpp>
#include <villas/kernel/devices/driver.hpp>

namespace villas {
Expand All @@ -24,20 +24,20 @@ class LinuxDriver : public Driver {
static constexpr char UNBIND_DEFAULT[] = "unbind";

public:
const std::filesystem::path path;
const fs::path path;

private:
const std::filesystem::path bind_path;
const std::filesystem::path unbind_path;
const fs::path bind_path;
const fs::path unbind_path;

public:
LinuxDriver(const std::filesystem::path path)
: LinuxDriver(path, path / std::filesystem::path(BIND_DEFAULT),
path / std::filesystem::path(UNBIND_DEFAULT)){};
LinuxDriver(const fs::path path)
: LinuxDriver(path, path / fs::path(BIND_DEFAULT),
path / fs::path(UNBIND_DEFAULT)){};

LinuxDriver(const std::filesystem::path path,
const std::filesystem::path bind_path,
const std::filesystem::path unbind_path)
LinuxDriver(const fs::path path,
const fs::path bind_path,
const fs::path unbind_path)
: path(path), bind_path(bind_path), unbind_path(unbind_path){};

public:
Expand Down
25 changes: 12 additions & 13 deletions common/include/villas/kernel/devices/platform_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

#pragma once

#include <filesystem>

#include <villas/fs.hpp>
#include <villas/kernel/devices/device.hpp>
#include <villas/kernel/devices/driver.hpp>

Expand All @@ -23,27 +22,27 @@ class PlatformDevice : public Device {
static constexpr char OVERRIDE_DEFAULT[] = "driver_override";

private:
const std::filesystem::path m_path;
const std::filesystem::path m_probe_path;
const std::filesystem::path m_override_path;
const fs::path m_path;
const fs::path m_probe_path;
const fs::path m_override_path;

public:
PlatformDevice(const std::filesystem::path path)
: PlatformDevice(path, std::filesystem::path(PROBE_DEFAULT),
path / std::filesystem::path(OVERRIDE_DEFAULT)){};
PlatformDevice(const fs::path path)
: PlatformDevice(path, fs::path(PROBE_DEFAULT),
path / fs::path(OVERRIDE_DEFAULT)){};

PlatformDevice(const std::filesystem::path path,
const std::filesystem::path probe_path,
const std::filesystem::path override_path)
PlatformDevice(const fs::path path,
const fs::path probe_path,
const fs::path override_path)
: m_path(path), m_probe_path(probe_path),
m_override_path(override_path){};

// Implement device interface
std::optional<std::unique_ptr<Driver>> driver() const override;
std::optional<int> iommu_group() const override;
std::string name() const override;
std::filesystem::path override_path() const override;
std::filesystem::path path() const override;
fs::path override_path() const override;
fs::path path() const override;
void probe() const override;
};

Expand Down
6 changes: 3 additions & 3 deletions common/include/villas/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <cassert>
#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <list>
#include <string>
#include <vector>
Expand All @@ -21,6 +20,7 @@
#include <signal.h>
#include <sys/types.h>

#include <villas/fs.hpp>
#include <villas/config.hpp>

#ifdef __GNUC__
Expand Down Expand Up @@ -212,9 +212,9 @@ template <class... Ts> struct overloaded : Ts... {
// Explicit deduction guide (not needed as of C++20)
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;

void write_to_file(std::string data, const std::filesystem::path file);
void write_to_file(std::string data, const fs::path file);
std::vector<std::string>
read_names_in_directory(const std::filesystem::path &directory);
read_names_in_directory(const fs::path &directory);

namespace base64 {

Expand Down
2 changes: 1 addition & 1 deletion common/lib/kernel/devices/device_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DeviceConnection DeviceConnection::from(

// Bind the devicetree device to vfio driver
LinuxDriver driver(
std::filesystem::path("/sys/bus/platform/drivers/vfio-platform"));
fs::path("/sys/bus/platform/drivers/vfio-platform"));
driver.attach(device);

// Attach vfio container to the iommu group
Expand Down
Loading