DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
SignalDesigner.h
Go to the documentation of this file.
1// This file is part of DynExp.
2
9#pragma once
10
11#include "stdafx.h"
12#include "DynExpCore.h"
13#include "../MetaInstruments/FunctionGenerator.h"
14
15#include <QWidget>
16
17namespace Ui
18{
19 class SignalDesigner;
20}
21
22namespace DynExpModule
23{
24 class SignalDesigner;
25 class SignalDesignerData;
26
28 {
29 Q_OBJECT
30
31 public:
34
35 bool AllowResize() const noexcept override final { return true; }
36
37 const auto GetUI() const noexcept { return ui.get(); }
38 bool HavePulsesChanged() noexcept;
39 auto GetPulses() const { return Pulses; }
40
42
43 private:
44 std::unique_ptr<Ui::SignalDesigner> ui;
45
50
52 bool PulsesChanged = false;
53
54 private slots:
55 void OnPulsesContextMenuRequested(const QPoint& Position);
56 void OnAddPulse(bool);
57 void OnRemovePulse(bool);
58 void OnClearPulses(bool);
59 void OnPulsesChanged(QTableWidgetItem*);
60 };
61
63 {
64 public:
66 virtual ~SignalDesignerData() = default;
67
70
71 void SetCurrentFuncGenIndex(int Index);
73 const auto& GetFuncGenLabels() const noexcept { return FunctionGenerator.GetLabels(); }
74 std::string_view GetFuncGenIconPath() const { return FunctionGenerator.GetIconPath(); }
75
76 bool IsUIInitialized() const noexcept { return UIInitialized; }
77 void SetUIInitialized() noexcept { UIInitialized = true; }
78
84
96
98
99 private:
100 void ResetImpl(dispatch_tag<QModuleDataBase>) override final;
102
103 void Init();
104
107
109 };
110
112 {
113 public:
115 virtual ~SignalDesignerParams() = default;
116
117 virtual const char* GetParamClassTag() const noexcept override { return "SignalDesignerParams"; }
118
120 "FunctionGenerator", "Function generator(s)", "Underlying function generator instrument(s) to be used to generate the designed waveform(s)", DynExpUI::Icons::Instrument };
121
122 private:
124 };
125
127 {
128 public:
131
133 virtual ~SignalDesignerConfigurator() = default;
134
135 private:
136 virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override final { return DynExp::MakeParams<SignalDesignerConfigurator>(ID, Core); }
137 };
138
140 {
141 public:
145
146 constexpr static auto Name() noexcept { return "Signal Designer"; }
147 constexpr static auto Category() noexcept { return "I/O"; }
148
151 virtual ~SignalDesigner() = default;
152
153 virtual std::string GetName() const override { return Name(); }
154 virtual std::string GetCategory() const override { return Category(); }
155
156 private:
158
159 void ResetImpl(dispatch_tag<QModuleBase>) override final;
160
161 std::unique_ptr<DynExp::QModuleWidget> MakeUIWidget() override final;
162 void UpdateUIChild(const ModuleBase::ModuleDataGetterType& ModuleDataGetter) override final;
163
164 void UpdateWaveform(Util::SynchronizedPointer<SignalDesignerData>& ModuleData, bool Autostart = false) const;
165
166 // Events, run in module thread
167 void OnInit(DynExp::ModuleInstance* Instance) const override final;
168 void OnExit(DynExp::ModuleInstance* Instance) const override final;
169 void OnSourceChanged(DynExp::ModuleInstance* Instance, int Index) const;
170 void OnSignalTypeChanged(DynExp::ModuleInstance* Instance, QString Text) const;
171 void OnStreamSizeChanged(DynExp::ModuleInstance* Instance, int Value) const;
172 void OnResetStreamSize(DynExp::ModuleInstance* Instance, bool) const;
173 void OnFrequencyChanged(DynExp::ModuleInstance* Instance, double Value) const;
174 void OnPhaseChanged(DynExp::ModuleInstance* Instance, double Value) const;
175 void OnAmplitudeChanged(DynExp::ModuleInstance* Instance, double Value) const;
176 void OnOffsetChanged(DynExp::ModuleInstance* Instance, double Value) const;
177 void OnDutyCycleChanged(DynExp::ModuleInstance* Instance, double Value) const;
178 void OnPulsesChanged(DynExp::ModuleInstance* Instance) const;
179 void OnTriggerModeChanged(DynExp::ModuleInstance* Instance, QString Text) const;
180 void OnTriggerEdgeChanged(DynExp::ModuleInstance* Instance, QString Text) const;
181 void OnAutostartChanged(DynExp::ModuleInstance* Instance, Qt::CheckState State) const;
182 void OnPersistParametersClicked(DynExp::ModuleInstance* Instance, bool Value) const;
183 void OnStart(DynExp::ModuleInstance* Instance, bool) const;
184 void OnStop(DynExp::ModuleInstance* Instance, bool) const;
185 void OnForceTrigger(DynExp::ModuleInstance* Instance, bool) const;
186 };
187}
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...
DynExpInstr::FunctionGeneratorDefs::PulsesDescType CurrentPulses
DynExpInstr::FunctionGeneratorDefs::FunctionDescType MaxFuncDesc
DynExpInstr::FunctionGeneratorDefs::TriggerDescType::TriggerEdgeType CurrentTriggerEdge
DynExpInstr::FunctionGeneratorDefs::TriggerDescType::TriggerModeType CurrentTriggerMode
Util::FeatureTester< DynExpInstr::FunctionGenerator::TriggerCapsType > TriggerCaps
void LockFunctionGenerators(DynExp::ModuleInstance *Instance, const DynExp::ParamsBase::ListParam< DynExp::ObjectLink< DynExpInstr::FunctionGenerator > > &FuncGenParam)
DynExpInstr::FunctionGeneratorDefs::WaveformTypes CurrentWaveform
bool IsUIInitialized() const noexcept
virtual ~SignalDesignerData()=default
std::string_view GetFuncGenIconPath() const
const auto & GetFuncGenLabels() const noexcept
DynExpInstr::FunctionGeneratorDefs::FunctionDescType MinFuncDesc
virtual void ResetImpl(dispatch_tag< SignalDesignerData >)
DynExpInstr::FunctionGeneratorDefs::FunctionDescType DefaultFuncDesc
void UnlockFunctionGenerators(DynExp::ModuleInstance *Instance)
Util::FeatureTester< DynExpInstr::FunctionGenerator::WaveformCapsType > WaveformCaps
DynExp::LinkedObjectWrapperContainerList< DynExpInstr::FunctionGenerator > FunctionGenerator
void ResetImpl(dispatch_tag< QModuleDataBase >) override final
ListParam< DynExp::ObjectLink< DynExpInstr::FunctionGenerator > > FunctionGenerator
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...
virtual ~SignalDesignerParams()=default
void ConfigureParamsImpl(dispatch_tag< QModuleParamsBase >) override final
SignalDesignerParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
DynExpInstr::FunctionGeneratorDefs::PulsesDescType Pulses
const auto GetUI() const noexcept
void OnPulsesContextMenuRequested(const QPoint &Position)
bool AllowResize() const noexcept override final
Indicates the resizing behavior of the user interface window. Override to adjust.
void InitializeUI(Util::SynchronizedPointer< SignalDesignerData > &ModuleData)
Layout changes not involving ModuleData->CurrentWaveform come here.
std::unique_ptr< Ui::SignalDesigner > ui
void OnPulsesChanged(QTableWidgetItem *)
void OnPhaseChanged(DynExp::ModuleInstance *Instance, double Value) const
static constexpr auto Category() noexcept
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
void OnForceTrigger(DynExp::ModuleInstance *Instance, bool) const
void OnTriggerModeChanged(DynExp::ModuleInstance *Instance, QString Text) const
void OnSourceChanged(DynExp::ModuleInstance *Instance, int Index) const
void OnSignalTypeChanged(DynExp::ModuleInstance *Instance, QString Text) const
void OnAutostartChanged(DynExp::ModuleInstance *Instance, Qt::CheckState State) const
void OnOffsetChanged(DynExp::ModuleInstance *Instance, double Value) const
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...
void OnTriggerEdgeChanged(DynExp::ModuleInstance *Instance, QString Text) const
void OnExit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread terminates (not due to an exception,...
virtual std::string GetName() const override
Returns the name of this Object type.
void ResetImpl(dispatch_tag< QModuleBase >) override final
void OnResetStreamSize(DynExp::ModuleInstance *Instance, bool) const
std::unique_ptr< DynExp::QModuleWidget > MakeUIWidget() override final
Used by InitUI() as a factory function for the module's user interface widget. Create the widget here...
SignalDesigner(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
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 OnAmplitudeChanged(DynExp::ModuleInstance *Instance, double Value) const
void OnPersistParametersClicked(DynExp::ModuleInstance *Instance, bool Value) const
virtual ~SignalDesigner()=default
void OnStreamSizeChanged(DynExp::ModuleInstance *Instance, int Value) const
void OnDutyCycleChanged(DynExp::ModuleInstance *Instance, double Value) const
void OnStop(DynExp::ModuleInstance *Instance, bool) const
void OnStart(DynExp::ModuleInstance *Instance, bool) const
void OnFrequencyChanged(DynExp::ModuleInstance *Instance, double Value) const
void OnPulsesChanged(DynExp::ModuleInstance *Instance) const
void UpdateWaveform(Util::SynchronizedPointer< SignalDesignerData > &ModuleData, bool Autostart=false) const
virtual std::string GetCategory() const override
Returns the category of this Object type.
static constexpr auto Name() noexcept
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:3311
const auto & GetLabels() const noexcept
Returns ObjectLabels.
Definition Object.h:3324
std::string_view GetIconPath() const
Returns IconPath.
Definition Object.h:3325
Util::CallableMemberWrapper< ModuleBase, ModuleDataTypeSyncPtrType(ModuleBase::*)(const std::chrono::milliseconds)> ModuleDataGetterType
Invoking an instance of this alias is supposed to call ModuleBase::GetModuleData() of the instance th...
Definition Module.h:624
const std::unique_ptr< ModuleDataType > ModuleData
Module data belonging to this ModuleBase instance.
Definition Module.h:788
ModuleBase(const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
Constructs a ModuleBase instance.
Definition Module.cpp:206
Refer to ParamsBase::dispatch_tag.
Definition Module.h:191
Defines data for a thread belonging to a ModuleBase instance. Refer to RunnableInstance.
Definition Module.h:840
const std::thread::id OwnerThreadID
Thread id of the thread which has constructed (and owns) this Object instance.
Definition Object.h:2302
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
Definition Object.h:2303
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 Qt-based user interface. Derive from this class to implement modules wi...
Definition Module.h:1660
QModuleBase(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs a QModuleBase instance.
Definition Module.cpp:591
Configurator class for QModuleBase.
Definition Module.h:1646
Data class for QModuleBase.
Definition Module.h:1536
Parameter class for QModuleBase.
Definition Module.h:1622
QModuleParamsBase(ItemIDType ID, const DynExpCore &Core)
Constructs the parameters for a QModuleBase instance.
Definition Module.h:1628
Window class for Qt-based user interfaces belonging to DynExp modules. User interface Qt window class...
Definition Module.h:1395
QModuleBase & Owner
Module owning this user interface window (reference, because it should never change nor be nullptr).
Definition Module.h:1478
QModuleWidget(QModuleBase &Owner, QWidget *Parent=nullptr)
Constructs a QModuleWidget instance.
Definition Module.cpp:451
void UnlockObject(LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer)
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer....
Definition Object.h:3609
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:3593
Holds a bitset containing flags to indicate which features a certain instrument/ module etc....
Definition Util.h:1293
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Definition Util.h:170
WaveformTypes
Type to determine the waveform type.
DynExp's module namespace contains the implementation of DynExp modules which extend DynExp's core fu...
constexpr auto Instrument
DynExp's main namespace contains the implementation of DynExp including classes to manage resources (...
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
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt an...
Accumulates include statements to provide a precompiled header.
Type describing a generic periodic function.
Type describing function consisting of a series of pulses.
TriggerEdgeType
Type to determine at which edge of a trigger signal to trigger. Not a strongly-typed enum to allow us...
TriggerModeType
Type to determine the trigger mode. Not a strongly-typed enum to allow using the enumeration in a Dyn...