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
53 changes: 42 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Build and Test

on:
workflow_dispatch:
inputs:
opendaq_ref:
description: "openDAQ SDK commit, branch or tag"
required: false
default: ""
pull_request:
types: [opened, reopened, synchronize, ready_for_review]

Expand All @@ -12,8 +18,16 @@ jobs:
include:
- os: ubuntu-latest
generator: Ninja
build_type: Debug
- os: windows-latest
generator: "Visual Studio 17 2022"
build_type: Debug
- os: ubuntu-latest
generator: Ninja
build_type: Release
- os: windows-latest
generator: "Visual Studio 17 2022"
build_type: Release

runs-on: ${{ matrix.os }}

Expand All @@ -28,11 +42,15 @@ jobs:
with:
ref: ${{ github.event.inputs.branch || github.event.client_payload.branch || github.ref }}

- name: Overwrite opendaq_ref
if: ${{ github.event.inputs.opendaq_ref != '' }}
run: echo "${{ github.event.inputs.opendaq_ref }}" > opendaq_ref

- name: Configure project with CMake
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DOPENDAQ_MQTT_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DDAQMODULES_MQTT_ENABLE_TESTS=ON -DDAQMODULES_MQTT_DEBUG_WARNINGS_AS_ERRORS=ON -DOPENDAQ_DEBUG_WARNINGS_AS_ERRORS=ON -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}"

- name: Build project with CMake
run: cmake --build build/output --config Debug
run: cmake --build build/output --config "${{ matrix.build_type }}"

- name: Install and run mosquitto Linux
if: matrix.os == 'ubuntu-latest'
Expand All @@ -41,17 +59,25 @@ jobs:

- name: Run project tests with CMake
if: matrix.os == 'ubuntu-latest'
run: ctest --test-dir build/output --output-on-failure -C Debug
run: ctest --test-dir build/output --output-on-failure -C "${{ matrix.build_type }}"

install-build-and-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
generator: Ninja
build_type: Debug
- os: windows-latest
generator: "Visual Studio 17 2022"
build_type: Debug
- os: ubuntu-latest
generator: Ninja
build_type: Release
- os: windows-latest
generator: "Visual Studio 17 2022"
build_type: Release

runs-on: ${{ matrix.os }}
env:
Expand All @@ -69,6 +95,11 @@ jobs:
ref: ${{ github.event.inputs.branch || github.event.client_payload.branch || github.ref }}
path: module

- name: Overwrite opendaq_ref
if: ${{ github.event.inputs.opendaq_ref != '' }}
working-directory: module
run: echo "${{ github.event.inputs.opendaq_ref }}" > opendaq_ref

- name: Read openDAQ version
shell: bash
working-directory: module
Expand All @@ -86,28 +117,28 @@ jobs:
- name: Configure, build and install openDAQ
working-directory: opendaq
run: |
cmake -B build/output -S . -G "${{ matrix.generator }}" -DOPENDAQ_ENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_PREFIX }}"
cmake --build build/output --config Release
cmake --install build/output --config Release
cmake -B build/output -S . -G "${{ matrix.generator }}" -DOPENDAQ_ENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}" -DCMAKE_INSTALL_PREFIX="${{ env.INSTALL_PREFIX }}"
cmake --build build/output --config "${{ matrix.build_type }}"
cmake --install build/output --config "${{ matrix.build_type }}"

- name: Add DLL path (Windows only)
if: matrix.os == 'windows-latest'
run: echo "${{ env.INSTALL_PREFIX }}/lib" >> $env:GITHUB_PATH

- name: Configure project with CMake
working-directory: module
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DDAQMODULES_MQTT_ENABLE_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DopenDAQ_DIR="${{ env.INSTALL_PREFIX }}/lib/cmake/opendaq/"
run: cmake -B build/output -S . -G "${{ matrix.generator }}" -DDAQMODULES_MQTT_ENABLE_TESTS=ON -DDAQMODULES_MQTT_DEBUG_WARNINGS_AS_ERRORS=ON -DCMAKE_BUILD_TYPE="${{ matrix.build_type }}" -DopenDAQ_DIR="${{ env.INSTALL_PREFIX }}/lib/cmake/opendaq/"

- name: Build project with CMake
working-directory: module
run: cmake --build build/output --config Release
run: cmake --build build/output --config "${{ matrix.build_type }}"

- name: Install and run mosquitto Linux
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install -y --no-install-recommends mosquitto

- name: Run project tests with CMake
if: matrix.os == 'ubuntu-latest'
working-directory: module
run: ctest --test-dir build/output --output-on-failure -C Release
run: ctest --test-dir build/output --output-on-failure -C "${{ matrix.build_type }}"
4 changes: 4 additions & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
cmake_minimum_required(VERSION 3.25)
opendaq_set_cmake_folder_context(TARGET_FOLDER_NAME)

if (MSVC)
add_compile_options(/wd4100)
endif()

add_subdirectory(mqtt_streaming_module)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <opendaq/function_block_ptr.h>
#include <mqtt_streaming_module/handler_base.h>
#include <set>

BEGIN_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE

Expand All @@ -41,6 +42,18 @@ class AtomicSignalAtomicSampleHandler : public HandlerBase
MqttDataSample processDataPacket(SignalContext& signalContext, const DataPacketPtr& dataPacket, size_t offset);
std::string toString(const std::string valueFieldName, daq::DataPacketPtr packet, size_t offset);
std::string buildTopicName(const SignalContext& signalContext);


inline static const std::set<SampleType> allowedSampleTypes{SampleType::Float64,
SampleType::Float32,
SampleType::UInt8,
SampleType::Int8,
SampleType::UInt16,
SampleType::Int16,
SampleType::UInt32,
SampleType::Int32,
SampleType::UInt64,
SampleType::Int64};
};

END_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <opendaq/function_block_ptr.h>
#include <mqtt_streaming_module/handler_base.h>
#include <opendaq/multi_reader_ptr.h>
#include <set>

BEGIN_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE

Expand Down Expand Up @@ -70,6 +71,18 @@ class GroupSignalSharedTsHandler : public HandlerBase
static std::string messageFromFields(const std::vector<std::string>& fields);
static TimestampTickStruct domainToTs(const MultiReaderStatusPtr status);
bool processEvents(const daq::MultiReaderStatusPtr& status); // true if descriptor changed or invalid reader


inline static const std::set<SampleType> allowedSampleTypes{SampleType::Float64,
SampleType::Float32,
SampleType::UInt8,
SampleType::Int8,
SampleType::UInt16,
SampleType::Int16,
SampleType::UInt32,
SampleType::Int32,
SampleType::UInt64,
SampleType::Int64};
};

END_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <opendaq/function_block_ptr.h>
#include <mqtt_streaming_module/handler_base.h>
#include <opendaq/multi_reader_ptr.h>
#include <set>

BEGIN_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE

Expand All @@ -39,6 +40,18 @@ class SignalArrayAtomicSampleHandler : public HandlerBase
std::string toString(const std::string valueFieldName, daq::DataPacketPtr packet);
std::string buildTopicName();
static std::string messageFromArray(const std::vector<std::string>& array);


inline static const std::set<SampleType> allowedSampleTypes{SampleType::Float64,
SampleType::Float32,
SampleType::UInt8,
SampleType::Int8,
SampleType::UInt16,
SampleType::Int16,
SampleType::UInt32,
SampleType::Int32,
SampleType::UInt64,
SampleType::Int64};
};

END_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <opendaq/event_packet_params.h>
#include <opendaq/event_packet_ptr.h>
#include <opendaq/sample_type_traits.h>
#include <set>

BEGIN_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE

Expand All @@ -26,16 +25,6 @@ MqttData AtomicSignalAtomicSampleHandler::processSignalContexts(std::vector<Sign

ProcedureStatus AtomicSignalAtomicSampleHandler::validateSignalContexts(const std::vector<SignalContext>& signalContexts) const
{
static const std::set<SampleType> allowedSampleTypes{SampleType::Float64,
SampleType::Float32,
SampleType::UInt8,
SampleType::Int8,
SampleType::UInt16,
SampleType::Int16,
SampleType::UInt32,
SampleType::Int32,
SampleType::UInt64,
SampleType::Int64};
ProcedureStatus status{true, {}};
for (const auto& sigCtx : signalContexts)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <opendaq/reader_utils.h>
#include <opendaq/sample_type_traits.h>
#include <optional>
#include <set>

BEGIN_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE

Expand Down Expand Up @@ -64,17 +63,6 @@ MqttData GroupSignalSharedTsHandler::processSignalContexts(std::vector<SignalCon

ProcedureStatus GroupSignalSharedTsHandler::validateSignalContexts(const std::vector<SignalContext>& signalContexts) const
{

static const std::set<SampleType> allowedSampleTypes{SampleType::Float64,
SampleType::Float32,
SampleType::UInt8,
SampleType::Int8,
SampleType::UInt16,
SampleType::Int16,
SampleType::UInt32,
SampleType::Int32,
SampleType::UInt64,
SampleType::Int64};
ProcedureStatus status{true, {}};
for (const auto& sigCtx : signalContexts)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <opendaq/reader_factory.h>
#include <opendaq/reader_utils.h>
#include <opendaq/sample_type_traits.h>
#include <set>

BEGIN_NAMESPACE_OPENDAQ_MQTT_STREAMING_MODULE

Expand Down Expand Up @@ -57,17 +56,6 @@ MqttData SignalArrayAtomicSampleHandler::processSignalContexts(std::vector<Signa

ProcedureStatus SignalArrayAtomicSampleHandler::validateSignalContexts(const std::vector<SignalContext>& signalContexts) const
{

static const std::set<SampleType> allowedSampleTypes{SampleType::Float64,
SampleType::Float32,
SampleType::UInt8,
SampleType::Int8,
SampleType::UInt16,
SampleType::Int16,
SampleType::UInt32,
SampleType::Int32,
SampleType::UInt64,
SampleType::Int64};
ProcedureStatus status{true, {}};
for (const auto& sigCtx : signalContexts)
{
Expand Down