14#include "../Instruments/InterModuleCommunicator.h"
20 class StreamManipulator;
118 void ResetImpl(dispatch_tag<ModuleDataBase>)
override final;
161 virtual const char*
GetParamClassTag() const noexcept
override {
return "StreamManipulatorParams"; }
168 "InputDataStreams",
"Input data stream instrument(s)",
"Data stream instruments to be used as data sources",
DynExpUI::Icons::Instrument,
true };
175 "OutputDataStreams",
"Output data stream instrument(s)",
"Data stream instruments to be used as data sinks",
DynExpUI::Icons::Instrument,
true };
204 "Path to a Python file containing the function which writes samples to the output streams based on the input streams' data",
true,
"",
DynExp::TextUsageType::Code };
212 "InterModuleCommunicator",
"Inter-module communicator",
"Inter-module communicator to control this module with",
DynExpUI::Icons::Instrument,
true };
259 constexpr static auto Name() noexcept {
return "Stream Manipulator"; }
260 constexpr static auto Category() noexcept {
return "I/O"; }
279 std::chrono::milliseconds
GetMainLoopDelay() const override final {
return std::chrono::milliseconds(1); }
287 void ResetImpl(dispatch_tag<ModuleBase>)
override final;
Provides common events for inter-module communication. Also refer to DynExp::InterModuleEventBase.
Defines DynExp's core module as an interface between the UI and DynExp objects.
Implementation of mappings between DynExp instruments and corresponding embedded Python modules makin...
Base class for all circular data streams based on Util::circularbuf.
Configurator class for StreamManipulator.
virtual ~StreamManipulatorConfigurator()=default
StreamManipulatorConfigurator()=default
virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core) const override final
Override to make derived classes call DynExp::MakeParams with the correct configurator type derived f...
Data class for StreamManipulator.
auto & GetInputDataStreams() const noexcept
Getter for InputDataStreams.
virtual void ResetImpl(dispatch_tag< StreamManipulatorData >)
Refer to DynExp::ModuleDataBase::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of ...
auto & GetInputDataStreams() noexcept
Getter for InputDataStreams.
virtual ~StreamManipulatorData()=default
auto & GetOutputDataStreams() noexcept
Getter for OutputDataStreams.
DynExp::LinkedObjectWrapperContainerList< DynExpInstr::DataStreamInstrument > InputDataStreams
Linked input data stream instruments whose samples are going to be used for calculations.
auto & GetOutputDataStreams() const noexcept
Getter for OutputDataStreams.
void Init()
Called by ResetImpl(dispatch_tag<DynExp::ModuleDataBase>) overridden by this class to initialize the ...
DynExp::LinkedObjectWrapperContainerList< DynExpInstr::DataStreamInstrument > OutputDataStreams
Linked output data stream instruments to write the computed new samples to.
void ResetImpl(dispatch_tag< ModuleDataBase >) override final
Refer to DynExp::ModuleDataBase::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of ...
DynExp::LinkedObjectWrapperContainer< DynExpInstr::InterModuleCommunicator > Communicator
Inter-module communicator instrument to receive events from that are translated to calls to respectiv...
auto & GetCommunicator() noexcept
Getter for Communicator.
Parameter class for StreamManipulator.
ListParam< DynExp::ObjectLink< DynExpInstr::DataStreamInstrument > > InputDataStreams
Parameter for data stream instruments containing input samples. Refer to StreamManipulatorData::Input...
Param< ParamsConfigDialog::TextType > PythonCodePath
Path to the Python file containing the code, which performs the stream manipulation.
StreamManipulatorParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Constructs the parameters for a StreamManipulator instance.
virtual const char * GetParamClassTag() const noexcept override
This function is intended to be overridden once in each derived class returning the name of the respe...
Param< DynExp::ObjectLink< DynExpInstr::InterModuleCommunicator > > Communicator
This module listens to the DynExpModule::StartEvent, DynExpModule::StopEvent, and DynExpModule::Trigg...
void ConfigureParamsImpl(dispatch_tag< ModuleParamsBase >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
ListParam< DynExp::ObjectLink< DynExpInstr::DataStreamInstrument > > OutputDataStreams
Parameter for data stream instruments containing output samples. Refer to StreamManipulatorData::Outp...
virtual ~StreamManipulatorParams()=default
Module to process data stored in data stream instrument(s) with a Python script and to write the resu...
void OnStart(DynExp::ModuleInstance *Instance) const
Called when receiving DynExpModule::StartEvent.
void Step(Util::SynchronizedPointer< ModuleDataType > &ModuleData, const PyFuncType &StepFunction, bool UpdateLastExecutionTime=true) const
Performs a single manipulation step by preparing input data for a call to the Python function on_step...
void OnInit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread starts. Override it to lock instruments this m...
size_t NumFailedUpdateAttempts
Counts how often StreamManipulator::ModuleMainLoop() contiguously failed due to an exception of type ...
std::chrono::time_point< std::chrono::system_clock > LastManipulatorPyFuncExecution
Time point when the on_step() Python function was invoked last.
std::atomic< bool > IsInitialized
Indicates whether the module has been fully initialized by finishing OnInit(). The variable is atomic...
void OnTrigger(DynExp::ModuleInstance *Instance) const
Called when receiving DynExpModule::TriggerEvent.
PyFuncType ManipulatorPyFuncStep
Handle to a Python function called for each manipulation step.
PyFuncType ManipulatorPyFuncFinished
Handle to a Python function called for DynExpModule::FinishedEvent.
virtual std::string GetCategory() const override
Returns the category of this Object type.
PyStreamManipulatorOutputData ManipulatorPyFuncOutput
Output data returned from the on_step() and event handler Python functions.
Util::DynExpErrorCodes::DynExpErrorCodes ModuleMainLoop(DynExp::ModuleInstance &Instance) override final
Module main loop. The function is executed periodically by the module thread. Also refer to GetMainLo...
StreamManipulator(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs a ModuleBase instance.
PyFuncType ManipulatorPyFuncExit
Handle to a Python function called on module termination.
virtual std::string GetName() const override
Returns the name of this Object type.
virtual ~StreamManipulator()=default
void OnFinished(DynExp::ModuleInstance *Instance) const
Called when receiving DynExpModule::FinishedEvent.
static constexpr auto Name() noexcept
Every derived class has to redefine this function.
void ResetImpl(dispatch_tag< ModuleBase >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
PyFuncType ManipulatorPyFuncStart
Handle to a Python function called for DynExpModule::StartEvent.
static constexpr auto Category() noexcept
Every derived class has to redefine this function.
void OnStop(DynExp::ModuleInstance *Instance) const
Called when receiving DynExpModule::StopEvent.
PyFuncType ManipulatorPyFuncInit
Handle to a Python function called on module initialization.
void OnExit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread terminates (not due to an exception,...
PyFuncType ManipulatorPyFuncStop
Handle to a Python function called for DynExpModule::StopEvent.
std::string ManipulatorPyFuncName
Unique name of the Python function all the code of this StreamManipulator instance is declared in....
PyStreamManipulatorInputData ManipulatorPyFuncInput
Input data passed to the on_step() and event handler Python functions.
std::chrono::milliseconds GetMainLoopDelay() const override final
Specifies in which time intervals the module's event queue runs to handle pending events.
void OnSetFilename(DynExp::ModuleInstance *Instance, const std::string &Filename) const
Called when receiving DynExpModule::SetFilenameEvent.
bool TreatModuleExceptionsAsWarnings() const override
Determines whether this module should be terminated if an exception leaves the module's main loop or ...
PyFuncType ManipulatorPyFuncTrigger
Handle to a Python function called for DynExpModule::TriggerEvent.
Util::PyObject< py::object > PyFuncType
Type of a pointer to a Python function bound by pybind11.
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
This class defines a list of LinkedObjectWrapperContainer instances. The list owns the contained Link...
This class holds a pointer (LinkedObjectWrapperPointer) to a LinkedObjectWrapper. Intances of this cl...
Base class for modules. Modules implement programs on their own (e.g. measurement protocols or server...
const std::unique_ptr< ModuleDataType > ModuleData
Module data belonging to this ModuleBase instance.
ModuleBase(const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
Constructs a ModuleBase instance.
Configurator class for ModuleBase.
Data structure to contain data which is synchronized in between different threads....
Refer to ParamsBase::dispatch_tag.
Defines data for a thread belonging to a ModuleBase instance. Refer to RunnableInstance.
Parameter class for ModuleBase.
ModuleParamsBase(ItemIDType ID, const DynExpCore &Core)
Constructs the parameters for a ModuleBase instance.
const std::thread::id OwnerThreadID
Thread id of the thread which has constructed (and owns) this Object instance.
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
const auto & GetCore() const noexcept
Returns a reference to DynExp's core.
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
const DynExpCore & Core
Reference to DynExp's core.
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
DynExp's module namespace contains the implementation of DynExp modules which extend DynExp's core fu...
std::vector< DynExpInstr::PyDataStreamInstrument > PyStreamListType
Type of a list of data stream instruments made available to Python.
constexpr auto Instrument
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
size_t ItemIDType
ID type of objects/items managed by DynExp.
DynExpErrorCodes
DynExp's error codes
Accumulates include statements to provide a precompiled header.
Output data type returned from on_step() or event handler Python functions.
void Reset()
Resets all member variables of this PyStreamManipulatorOutputData instance back to their default valu...
std::chrono::milliseconds MinNextExecutionDelay
Time wo wait minimally before the on_step() Python function is called again when each input data stre...
std::chrono::milliseconds MaxNextExecutionDelay
Time to wait maximally before the on_step() Python function is called again when the input data strea...
std::vector< size_t > LastConsumedSampleIDsPerInputStream
Maintaining the order of input data streams in PyStreamManipulatorInputData::InputStreams as passed t...