From 6cf5e1eec36705417b137ca0322cb71ab1aa0d0c Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Sun, 22 Oct 2023 21:36:20 +0200 Subject: [PATCH] Move acquisition interface to own lib --- CMakeLists.txt | 1 + src/service/acquisition/CMakeLists.txt | 8 +- src/service/acquisition/acqWorker.hpp | 2 +- src/service/acquisition/daq_api.hpp | 81 --------------------- src/service/acquisition/test/CMakeLists.txt | 2 +- src/service/gnuradio/CMakeLists.txt | 7 +- src/service/gnuradio/GnuRadioWorker.hpp | 3 +- src/service/gnuradio/daq_api.hpp | 81 --------------------- src/service/gnuradio/test/CMakeLists.txt | 2 +- src/ui/CMakeLists.txt | 9 ++- src/ui/flowgraph/remotedatasource.cpp | 2 + 11 files changed, 22 insertions(+), 176 deletions(-) delete mode 100644 src/service/acquisition/daq_api.hpp delete mode 100644 src/service/gnuradio/daq_api.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 811b5cd7..075db99f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ set(BUILD_DIR ${CMAKE_BINARY_DIR}/CMakeExternals/Build) set(INSTALL_DIR ${CMAKE_BINARY_DIR}/CMakeExternals/Install) +add_subdirectory(src/acquisition) add_subdirectory(src/ui) ExternalProject_Add( ui-wasm diff --git a/src/service/acquisition/CMakeLists.txt b/src/service/acquisition/CMakeLists.txt index 208c04b4..508b9209 100644 --- a/src/service/acquisition/CMakeLists.txt +++ b/src/service/acquisition/CMakeLists.txt @@ -1,5 +1,5 @@ -add_library(od_acquisition INTERFACE acqWorker.hpp daq_api.hpp) -target_include_directories(od_acquisition INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/.) -target_link_libraries(od_acquisition INTERFACE majordomo disruptor project_options project_warnings) +add_library(od_acquisition_worker INTERFACE acqWorker.hpp) +target_include_directories(od_acquisition_worker INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/.) +target_link_libraries(od_acquisition_worker INTERFACE od_acquisition majordomo disruptor project_options project_warnings) -add_subdirectory(test) \ No newline at end of file +add_subdirectory(test) diff --git a/src/service/acquisition/acqWorker.hpp b/src/service/acquisition/acqWorker.hpp index 083bae2b..2981a55b 100644 --- a/src/service/acquisition/acqWorker.hpp +++ b/src/service/acquisition/acqWorker.hpp @@ -1,7 +1,7 @@ #ifndef OPENDIGITIZER_SERVICE_ACQWORKER_H #define OPENDIGITIZER_SERVICE_ACQWORKER_H -#include "daq_api.hpp" +#include #include #include #include diff --git a/src/service/acquisition/daq_api.hpp b/src/service/acquisition/daq_api.hpp deleted file mode 100644 index 61886b7f..00000000 --- a/src/service/acquisition/daq_api.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -using opencmw::Annotated; -using namespace units::isq; -using namespace units::isq::si; -using namespace std::literals; - -/** - * Generic time domain data object. - * Specified in: https://edms.cern.ch/document/1823376/1 EDMS: 1823376 v.1 Section 4.3.1 - */ -// clang-format: OFF -struct Acquisition { - Annotated selectedFilter; // specified as Enum + String - Annotated acqTriggerName = { "STREAMING" }; // specified as ENUM - Annotated, "UTC timestamp on which the timing event occurred"> acqTriggerTimeStamp = 0; // specified as type WR timestamp - Annotated, "time-stamp w.r.t. beam-in trigger"> acqLocalTimeStamp = 0; - Annotated, si::time, "time scale"> channelTimeBase; // todo either nanosecond or float - Annotated, "user-defined delay"> channelUserDelay = 0.0f; - Annotated, "actual trigger delay"> channelActualDelay = 0.0f; - Annotated channelName; - Annotated, opencmw::NoUnit, "value of the channel/signal"> channelValue; - Annotated, opencmw::NoUnit, "r.m.s. error of of the channel/signal"> channelError; - Annotated channelUnit; - Annotated status; - Annotated channelRangeMin; - Annotated channelRangeMax; - Annotated temperature; -}; -ENABLE_REFLECTION_FOR(Acquisition, selectedFilter, acqTriggerName, acqTriggerTimeStamp, acqLocalTimeStamp, channelTimeBase, channelUserDelay, channelActualDelay, channelName, channelValue, channelError, channelUnit, status, channelRangeMin, channelRangeMax, temperature) - -/** - * Generic frequency domain data object. - * Specified in: https://edms.cern.ch/document/1823376/1 EDMS: 1823376 v.1 Section 4.3.2 - */ -// clang-format: OFF -struct AcquisitionSpectra { - Annotated selectedFilter; // specified as Enum + String - Annotated acqTriggerName = { "STREAMING" }; // specified as ENUM - Annotated, "UTC timestamp on which the timing event occurred"> acqTriggerTimeStamp = 0; // specified as type WR timestamp - Annotated, "time-stamp w.r.t. beam-in trigger"> acqLocalTimeStamp = 0; - Annotated channelName; - Annotated, opencmw::NoUnit, "magnitude spectra of signals"> channelMagnitude; - Annotated, opencmw::NoUnit, "{N_meas, N_binning}"> channelMagnitude_dimensions; - Annotated, opencmw::NoUnit, "{'time', 'frequency'}"> channelMagnitude_labels; - Annotated, si::time, "timestamps of samples"> channelMagnitude_dim1_labels; // todo: either nanosecond or float - Annotated, opencmw::NoUnit, "freqency scale"> channelMagnitude_dim2_labels; // unit: Hz or f_rev - Annotated, opencmw::NoUnit, "phase spectra of signals"> channelPhase; - Annotated, opencmw::NoUnit, "{'time', 'frequency'}"> channelPhase_labels; - Annotated, si::time, "timestamps of samples"> channelPhase_dim1_labels; // todo: either nanosecond or float - Annotated, opencmw::NoUnit, "freqency scale"> channelPhase_dim2_labels; // unit: Hz or f_rev -}; -ENABLE_REFLECTION_FOR(AcquisitionSpectra, selectedFilter, acqTriggerName, acqTriggerTimeStamp, acqLocalTimeStamp, channelName, channelMagnitude, channelMagnitude_dimensions, channelMagnitude_labels, channelMagnitude_dim1_labels, channelMagnitude_dim2_labels, channelPhase, channelPhase_labels, channelPhase_dim1_labels, channelPhase_dim2_labels) -// clang-format: ON - -struct TimeDomainContext { - std::string channelNameFilter; - int32_t acquisitionModeFilter = 0; // STREAMING - std::string triggerNameFilter; - int32_t maxClientUpdateFrequencyFilter = 25; - opencmw::MIME::MimeType contentType = opencmw::MIME::JSON; -}; - -ENABLE_REFLECTION_FOR(TimeDomainContext, channelNameFilter, acquisitionModeFilter, triggerNameFilter, maxClientUpdateFrequencyFilter, contentType) - -struct FreqDomainContext { - std::string channelNameFilter; - int32_t acquisitionModeFilter = 0; // STREAMING - std::string triggerNameFilter; - int32_t maxClientUpdateFrequencyFilter = 25; - opencmw::MIME::MimeType contentType = opencmw::MIME::JSON; -}; - -ENABLE_REFLECTION_FOR(FreqDomainContext, channelNameFilter, acquisitionModeFilter, triggerNameFilter, maxClientUpdateFrequencyFilter, contentType) diff --git a/src/service/acquisition/test/CMakeLists.txt b/src/service/acquisition/test/CMakeLists.txt index d0748cf2..3d9d43f0 100644 --- a/src/service/acquisition/test/CMakeLists.txt +++ b/src/service/acquisition/test/CMakeLists.txt @@ -1,3 +1,3 @@ add_executable(acqWorkerTest acqWorker_test.cpp) target_include_directories(acqWorkerTest INTERFACE ../include) -target_link_libraries(acqWorkerTest PRIVATE fmt ut od_acquisition client zmq) +target_link_libraries(acqWorkerTest PRIVATE fmt ut od_acquisition_worker client zmq) diff --git a/src/service/gnuradio/CMakeLists.txt b/src/service/gnuradio/CMakeLists.txt index 2cfddc6f..fc158a44 100644 --- a/src/service/gnuradio/CMakeLists.txt +++ b/src/service/gnuradio/CMakeLists.txt @@ -1,6 +1,5 @@ - -add_library(od_gnuradio INTERFACE GnuRadioWorker.hpp) -target_include_directories(od_gnuradio INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/.) -target_link_libraries(od_gnuradio INTERFACE majordomo disruptor gr-basic yaml-cpp::yaml-cpp project_options project_warnings) +add_library(od_gnuradio_worker INTERFACE GnuRadioWorker.hpp) +target_include_directories(od_gnuradio_worker INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/.) +target_link_libraries(od_gnuradio_worker INTERFACE od_acquisition majordomo disruptor gr-basic yaml-cpp::yaml-cpp project_options project_warnings) add_subdirectory(test) diff --git a/src/service/gnuradio/GnuRadioWorker.hpp b/src/service/gnuradio/GnuRadioWorker.hpp index 89133b64..c247e0ce 100644 --- a/src/service/gnuradio/GnuRadioWorker.hpp +++ b/src/service/gnuradio/GnuRadioWorker.hpp @@ -1,7 +1,8 @@ #ifndef OPENDIGITIZER_SERVICE_GNURADIOWORKER_H #define OPENDIGITIZER_SERVICE_GNURADIOWORKER_H -#include "daq_api.hpp" +#include + #include #include diff --git a/src/service/gnuradio/daq_api.hpp b/src/service/gnuradio/daq_api.hpp deleted file mode 100644 index 61886b7f..00000000 --- a/src/service/gnuradio/daq_api.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include - -using opencmw::Annotated; -using namespace units::isq; -using namespace units::isq::si; -using namespace std::literals; - -/** - * Generic time domain data object. - * Specified in: https://edms.cern.ch/document/1823376/1 EDMS: 1823376 v.1 Section 4.3.1 - */ -// clang-format: OFF -struct Acquisition { - Annotated selectedFilter; // specified as Enum + String - Annotated acqTriggerName = { "STREAMING" }; // specified as ENUM - Annotated, "UTC timestamp on which the timing event occurred"> acqTriggerTimeStamp = 0; // specified as type WR timestamp - Annotated, "time-stamp w.r.t. beam-in trigger"> acqLocalTimeStamp = 0; - Annotated, si::time, "time scale"> channelTimeBase; // todo either nanosecond or float - Annotated, "user-defined delay"> channelUserDelay = 0.0f; - Annotated, "actual trigger delay"> channelActualDelay = 0.0f; - Annotated channelName; - Annotated, opencmw::NoUnit, "value of the channel/signal"> channelValue; - Annotated, opencmw::NoUnit, "r.m.s. error of of the channel/signal"> channelError; - Annotated channelUnit; - Annotated status; - Annotated channelRangeMin; - Annotated channelRangeMax; - Annotated temperature; -}; -ENABLE_REFLECTION_FOR(Acquisition, selectedFilter, acqTriggerName, acqTriggerTimeStamp, acqLocalTimeStamp, channelTimeBase, channelUserDelay, channelActualDelay, channelName, channelValue, channelError, channelUnit, status, channelRangeMin, channelRangeMax, temperature) - -/** - * Generic frequency domain data object. - * Specified in: https://edms.cern.ch/document/1823376/1 EDMS: 1823376 v.1 Section 4.3.2 - */ -// clang-format: OFF -struct AcquisitionSpectra { - Annotated selectedFilter; // specified as Enum + String - Annotated acqTriggerName = { "STREAMING" }; // specified as ENUM - Annotated, "UTC timestamp on which the timing event occurred"> acqTriggerTimeStamp = 0; // specified as type WR timestamp - Annotated, "time-stamp w.r.t. beam-in trigger"> acqLocalTimeStamp = 0; - Annotated channelName; - Annotated, opencmw::NoUnit, "magnitude spectra of signals"> channelMagnitude; - Annotated, opencmw::NoUnit, "{N_meas, N_binning}"> channelMagnitude_dimensions; - Annotated, opencmw::NoUnit, "{'time', 'frequency'}"> channelMagnitude_labels; - Annotated, si::time, "timestamps of samples"> channelMagnitude_dim1_labels; // todo: either nanosecond or float - Annotated, opencmw::NoUnit, "freqency scale"> channelMagnitude_dim2_labels; // unit: Hz or f_rev - Annotated, opencmw::NoUnit, "phase spectra of signals"> channelPhase; - Annotated, opencmw::NoUnit, "{'time', 'frequency'}"> channelPhase_labels; - Annotated, si::time, "timestamps of samples"> channelPhase_dim1_labels; // todo: either nanosecond or float - Annotated, opencmw::NoUnit, "freqency scale"> channelPhase_dim2_labels; // unit: Hz or f_rev -}; -ENABLE_REFLECTION_FOR(AcquisitionSpectra, selectedFilter, acqTriggerName, acqTriggerTimeStamp, acqLocalTimeStamp, channelName, channelMagnitude, channelMagnitude_dimensions, channelMagnitude_labels, channelMagnitude_dim1_labels, channelMagnitude_dim2_labels, channelPhase, channelPhase_labels, channelPhase_dim1_labels, channelPhase_dim2_labels) -// clang-format: ON - -struct TimeDomainContext { - std::string channelNameFilter; - int32_t acquisitionModeFilter = 0; // STREAMING - std::string triggerNameFilter; - int32_t maxClientUpdateFrequencyFilter = 25; - opencmw::MIME::MimeType contentType = opencmw::MIME::JSON; -}; - -ENABLE_REFLECTION_FOR(TimeDomainContext, channelNameFilter, acquisitionModeFilter, triggerNameFilter, maxClientUpdateFrequencyFilter, contentType) - -struct FreqDomainContext { - std::string channelNameFilter; - int32_t acquisitionModeFilter = 0; // STREAMING - std::string triggerNameFilter; - int32_t maxClientUpdateFrequencyFilter = 25; - opencmw::MIME::MimeType contentType = opencmw::MIME::JSON; -}; - -ENABLE_REFLECTION_FOR(FreqDomainContext, channelNameFilter, acquisitionModeFilter, triggerNameFilter, maxClientUpdateFrequencyFilter, contentType) diff --git a/src/service/gnuradio/test/CMakeLists.txt b/src/service/gnuradio/test/CMakeLists.txt index ffd18c16..c1ce2acf 100644 --- a/src/service/gnuradio/test/CMakeLists.txt +++ b/src/service/gnuradio/test/CMakeLists.txt @@ -1,4 +1,4 @@ cmrc_add_resource_library(GNURADIO_WORKER_TEST_ASSETS ALIAS assets::grc NAMESPACE gnuradioWorkerTestFilesystem simple-counter.grc) add_executable(GnuRadioWorkerTest GnuRadioWorker_test.cpp) -target_link_libraries(GnuRadioWorkerTest PRIVATE fmt ut od_gnuradio client zmq assets::grc) +target_link_libraries(GnuRadioWorkerTest PRIVATE fmt ut od_gnuradio_worker client zmq assets::grc) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 6381a59c..02752baa 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -88,6 +88,7 @@ if (EMSCRIPTEN) target_link_libraries( ${outputFileName} PRIVATE + function2::function2 implot plf_colony app_header @@ -106,6 +107,10 @@ if (EMSCRIPTEN) COMMENT start a python server serving the webassembly app DEPENDS ${outputFileName} ) + + # TODO should be pulled via linking od_acquisition, but that's outside the source folder (src/ui) for the ui-wasm build + target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../acquisition) #for daq_api.hpp + else () # native build set(target_name "opendigitizer-ui") @@ -118,6 +123,8 @@ else () # native build target_link_libraries( ${target_name} PRIVATE + od_acquisition + function2::function2 SDL2 implot imgui-node-editor @@ -134,5 +141,3 @@ else () # native build target_compile_definitions(${target_name} PRIVATE BLOCKS_DIR="${GNURADIO_PREFIX}/share/gnuradio/grc/blocks/") endif() -target_link_libraries(${target_name} PRIVATE function2::function2) -target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../service/acquisition) #for daq_api.hpp diff --git a/src/ui/flowgraph/remotedatasource.cpp b/src/ui/flowgraph/remotedatasource.cpp index f51cea87..cd103da4 100644 --- a/src/ui/flowgraph/remotedatasource.cpp +++ b/src/ui/flowgraph/remotedatasource.cpp @@ -9,6 +9,8 @@ #include "../app.h" +using namespace opendigitizer::acq; + namespace DigitizerUi { class RemoteBlockType : public BlockType {