DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
SignalPlotter.h
Go to the documentation of this file.
1// This file is part of DynExp.
2
8#pragma once
9
10#include "stdafx.h"
11#include "DynExpCore.h"
12#include "../GraphUtil.h"
13#include "../../MetaInstruments/DataStreamInstrument.h"
14
16{
17 class SignalPlotter;
18
20 {
21 public:
23 {
27 QList<QPointF> Samples;
28
32 bool Visible = true;
33 };
34
36 virtual ~SignalPlotterData() = default;
37
40
41 auto& GetDataStreamInstr(size_t Index) { return DataStreamInstr[Index]; }
42 auto GetDataStreamInstrCount() const noexcept { return DataStreamInstr.GetList().size(); }
43 const auto& GetDataStreamInstrLabels() const noexcept { return DataStreamInstr.GetLabels(); }
44 std::string_view GetDataStreamInstrIconPath() const { return DataStreamInstr.GetIconPath(); }
45
46 bool IsUIInitialized() const noexcept { return UIInitialized; }
47 void SetUIInitialized() noexcept { UIInitialized = true; }
48
49 bool Running;
52
54 std::vector<SampleDataType> SampleDataList;
55
56 private:
57 void ResetImpl(dispatch_tag<QMLModuleDataBase>) override final;
59
60 void Init();
61
63
65 };
66
68 {
69 public:
71 virtual ~SignalPlotterParams() = default;
72
73 virtual const char* GetParamClassTag() const noexcept override { return "SignalPlotterParams"; }
74
76 "DataStreamInstr", "Data stream instrument(s)", "Underlying data stream instrument(s) to be used as a data source(s)", DynExpUI::Icons::Instrument };
77
78 Param<bool> RollingView = { *this, "RollingView", false };
79 Param<bool> Autoscale = { *this, "Autoscale", true };
80
81 private:
83 };
84
86 {
87 public:
90
92 virtual ~SignalPlotterConfigurator() = default;
93
94 private:
95 virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override final { return DynExp::MakeParams<SignalPlotterConfigurator>(ID, Core); }
96 };
97
99 {
100 public:
104
105 constexpr static auto Name() noexcept { return "Signal Plotter"; }
106 constexpr static auto Category() noexcept { return "I/O"; }
107
110 virtual ~SignalPlotter() = default;
111
112 virtual std::string GetName() const override { return Name(); }
113 virtual std::string GetCategory() const override { return Category(); }
114
115 std::chrono::milliseconds GetMainLoopDelay() const override final { return std::chrono::milliseconds(50); }
116
117 private:
119
120 void ResetImpl(dispatch_tag<QMLModuleBase>) override final;
121
122 void MakeConnections(QObject* Backend) override final;
123 QAnyStringView GetModuleSourceUri() const noexcept override final { return "Modules.SignalPlotter"; }
124 QAnyStringView GetModuleSourceTypeName() const noexcept override final { return "SignalPlotter"; }
125 void UpdateUIChild(const ModuleBase::ModuleDataGetterType& ModuleDataGetter) override final;
126
127 // Events, run in module thread
128 void OnInit(DynExp::ModuleInstance* Instance) const override final;
129 void OnExit(DynExp::ModuleInstance* Instance) const override final;
130 void OnRunningChanged(DynExp::ModuleInstance* Instance, bool State) const;
131 void OnRollingViewChanged(DynExp::ModuleInstance* Instance, bool State) const;
132 void OnAutoscaleChanged(DynExp::ModuleInstance* Instance, bool State) const;
133 void OnClearStream(DynExp::ModuleInstance* Instance) const;
134
135 // Events, run in UI thread
136 void OnSaveData() const;
137
138 void FinishedSavingData() const noexcept { IsSavingData = false; }
140
144 mutable std::atomic_bool IsSavingData = false;
145
147
155 };
156}
Defines DynExp's core module as an interface between the UI and DynExp objects.
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...
void ResetImpl(dispatch_tag< QMLModuleDataBase >) override final
QList< QPointF > Samples
Data points of a single data series to plot.
DynExp::LinkedObjectWrapperContainerList< DynExpInstr::DataStreamInstrument > DataStreamInstr
bool Visible
Determines whether this series should be processed and plotted.
const auto & GetDataStreamInstrLabels() const noexcept
void UnlockInstruments(DynExp::ModuleInstance *Instance)
std::vector< SampleDataType > SampleDataList
virtual void ResetImpl(dispatch_tag< SignalPlotterData >)
std::string_view GetDataStreamInstrIconPath() const
void LockInstruments(DynExp::ModuleInstance *Instance, const DynExp::ParamsBase::ListParam< DynExp::ObjectLink< DynExpInstr::DataStreamInstrument > > &InstrParam)
void ConfigureParamsImpl(dispatch_tag< QMLModuleParamsBase >) override final
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...
ListParam< DynExp::ObjectLink< DynExpInstr::DataStreamInstrument > > DataStreamInstr
SignalPlotterParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
void OnRollingViewChanged(DynExp::ModuleInstance *Instance, bool State) const
static constexpr auto Name() noexcept
static constexpr auto Category() noexcept
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...
void OnExit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread terminates (not due to an exception,...
void OnAutoscaleChanged(DynExp::ModuleInstance *Instance, bool State) const
void OnRunningChanged(DynExp::ModuleInstance *Instance, bool State) const
std::atomic_bool IsSavingData
If data is currently being saved to file, do not update internal data.
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...
virtual std::string GetCategory() const override
Returns the category of this Object type.
void MakeConnections(QObject *Backend) override final
Use QModuleBase::Connect() to connect Qt QML signals to the module's event functions.
QAnyStringView GetModuleSourceUri() const noexcept override final
Used by QModuleBase::MakeUIWidget to construct the module's user interface QML widget.
virtual std::string GetName() const override
Returns the name of this Object type.
std::chrono::milliseconds GetMainLoopDelay() const override final
Specifies in which time intervals the module's event queue runs to handle pending events.
QAnyStringView GetModuleSourceTypeName() const noexcept override final
Used by QModuleBase::MakeUIWidget to construct the module's user interface QML widget.
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
SignalPlotter(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
void ResetImpl(dispatch_tag< QMLModuleBase >) override final
QObject SignalContext
Does nothing but ensures that this module's Qt connections are disconnected when SignalContext is des...
void OnClearStream(DynExp::ModuleInstance *Instance) const
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition DynExpCore.h:127
This class defines a list of LinkedObjectWrapperContainer instances. The list owns the contained Link...
Definition Object.h:3319
const auto & GetLabels() const noexcept
Returns ObjectLabels.
Definition Object.h:3332
std::string_view GetIconPath() const
Returns IconPath.
Definition Object.h:3333
const auto & GetList() const noexcept
Returns Containers.
Definition Object.h:3331
Refer to ParamsBase::dispatch_tag.
Definition Module.h:192
Defines data for a thread belonging to a ModuleBase instance. Refer to RunnableInstance.
Definition Module.h:841
const std::thread::id OwnerThreadID
Thread id of the thread which has constructed (and owns) this Object instance.
Definition Object.h:2310
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
Definition Object.h:2311
const auto & GetCore() const noexcept
Returns a reference to DynExp's core.
Definition Object.h:1677
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
Definition Object.h:1779
const DynExpCore & Core
Reference to DynExp's core.
Definition Object.h:1780
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Definition Object.h:349
Base class for modules with a QML-based user interface. Derive from this class to implement modules w...
Definition Module.h:1961
QMLModuleBase(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs a QMLModuleBase instance.
Definition Module.cpp:898
Configurator class for QMLModuleBase.
Definition Module.h:1947
Data class for QMLModuleBase.
Definition Module.h:1909
Parameter class for QMLModuleBase.
Definition Module.h:1923
QMLModuleParamsBase(ItemIDType ID, const DynExpCore &Core)
Constructs the parameters for a QMLModuleBase instance.
Definition Module.h:1929
void UnlockObject(LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer)
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer....
Definition Object.h:3617
void LockObject(const ParamsBase::Param< ObjectLink< ObjectT > > &LinkParam, LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault)
Locks an Object instance referenced by a parameter LinkParam of type ParamsBase::Param< ObjectLink< O...
Definition Object.h:3601
Holds a CallableMemberWrapper and invokes its callable when being destroyed.
Definition Util.h:495
constexpr auto Instrument
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
Definition Object.h:1807
size_t ItemIDType
ID type of objects/items managed by DynExp.
DynExpErrorCodes
DynExp's error codes
Definition Exception.h:22
Accumulates include statements to provide a precompiled header.