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#include "ui_SignalDesigner.h"
17
18namespace DynExpModule
19{
20 class SignalDesigner;
21 class SignalDesignerData;
22
24 {
25 Q_OBJECT
26
27 public:
30
31 bool AllowResize() const noexcept override final { return true; }
32
33 const auto& GetUI() const noexcept { return ui; }
34 bool HavePulsesChanged() noexcept;
35 auto GetPulses() const { return Pulses; }
36
38
39 private:
40 Ui::SignalDesigner ui;
41
46
48 bool PulsesChanged = false;
49
50 private slots:
51 void OnPulsesContextMenuRequested(const QPoint& Position);
52 void OnAddPulse(bool);
53 void OnRemovePulse(bool);
54 void OnClearPulses(bool);
55 void OnPulsesChanged(QTableWidgetItem*);
56 };
57
59 {
60 public:
62 virtual ~SignalDesignerData() = default;
63
66
67 void SetCurrentFuncGenIndex(int Index);
69 const auto& GetFuncGenLabels() const noexcept { return FunctionGenerator.GetLabels(); }
70 std::string_view GetFuncGenIconPath() const { return FunctionGenerator.GetIconPath(); }
71
72 bool IsUIInitialized() const noexcept { return UIInitialized; }
73 void SetUIInitialized() noexcept { UIInitialized = true; }
74
80
92
94
95 private:
96 void ResetImpl(dispatch_tag<QModuleDataBase>) override final;
98
99 void Init();
100
103
105 };
106
108 {
109 public:
111 virtual ~SignalDesignerParams() = default;
112
113 virtual const char* GetParamClassTag() const noexcept override { return "SignalDesignerParams"; }
114
116 "FunctionGenerator", "Function generator(s)", "Underlying function generator instrument(s) to be used to generate the designed waveform(s)", DynExpUI::Icons::Instrument };
117
118 private:
120 };
121
123 {
124 public:
127
129 virtual ~SignalDesignerConfigurator() = default;
130
131 private:
132 virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override final { return DynExp::MakeParams<SignalDesignerConfigurator>(ID, Core); }
133 };
134
136 {
137 public:
141
142 constexpr static auto Name() noexcept { return "Signal Designer"; }
143 constexpr static auto Category() noexcept { return "I/O"; }
144
147 virtual ~SignalDesigner() = default;
148
149 virtual std::string GetName() const override { return Name(); }
150 virtual std::string GetCategory() const override { return Category(); }
151
152 private:
154
155 void ResetImpl(dispatch_tag<QModuleBase>) override final;
156
157 std::unique_ptr<DynExp::QModuleWidget> MakeUIWidget() override final;
158 void UpdateUIChild(const ModuleBase::ModuleDataGetterType& ModuleDataGetter) override final;
159
160 void UpdateWaveform(Util::SynchronizedPointer<SignalDesignerData>& ModuleData, bool Autostart = false) const;
161
162 // Events, run in module thread
163 void OnInit(DynExp::ModuleInstance* Instance) const override final;
164 void OnExit(DynExp::ModuleInstance* Instance) const override final;
165 void OnSourceChanged(DynExp::ModuleInstance* Instance, int Index) const;
166 void OnSignalTypeChanged(DynExp::ModuleInstance* Instance, QString Text) const;
167 void OnStreamSizeChanged(DynExp::ModuleInstance* Instance, int Value) const;
168 void OnResetStreamSize(DynExp::ModuleInstance* Instance, bool) const;
169 void OnFrequencyChanged(DynExp::ModuleInstance* Instance, double Value) const;
170 void OnPhaseChanged(DynExp::ModuleInstance* Instance, double Value) const;
171 void OnAmplitudeChanged(DynExp::ModuleInstance* Instance, double Value) const;
172 void OnOffsetChanged(DynExp::ModuleInstance* Instance, double Value) const;
173 void OnDutyCycleChanged(DynExp::ModuleInstance* Instance, double Value) const;
174 void OnPulsesChanged(DynExp::ModuleInstance* Instance) const;
175 void OnTriggerModeChanged(DynExp::ModuleInstance* Instance, QString Text) const;
176 void OnTriggerEdgeChanged(DynExp::ModuleInstance* Instance, QString Text) const;
177 void OnAutostartChanged(DynExp::ModuleInstance* Instance, int Value) const;
178 void OnPersistParametersClicked(DynExp::ModuleInstance* Instance, bool Value) const;
179 void OnStart(DynExp::ModuleInstance* Instance, bool) const;
180 void OnStop(DynExp::ModuleInstance* Instance, bool) const;
181 void OnForceTrigger(DynExp::ModuleInstance* Instance, bool) const;
182 };
183}
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
void OnPulsesContextMenuRequested(const QPoint &Position)
const auto & GetUI() const noexcept
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.
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 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
void OnAutostartChanged(DynExp::ModuleInstance *Instance, int 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:3303
const auto & GetLabels() const noexcept
Returns ObjectLabels.
Definition Object.h:3316
std::string_view GetIconPath() const
Returns IconPath.
Definition Object.h:3317
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:587
const std::unique_ptr< ModuleDataType > ModuleData
Module data belonging to this ModuleBase instance.
Definition Module.h:743
ModuleBase(const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
Constructs a ModuleBase instance.
Definition Module.cpp:189
Refer to ParamsBase::dispatch_tag.
Definition Module.h:189
Defines data for a thread belonging to a ModuleBase instance. Refer to RunnableInstance.
Definition Module.h:793
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:1344
QModuleBase(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs a QModuleBase instance.
Definition Module.cpp:557
Configurator class for QModuleBase.
Definition Module.h:1330
Data class for QModuleBase.
Definition Module.h:1220
Parameter class for QModuleBase.
Definition Module.h:1306
QModuleParamsBase(ItemIDType ID, const DynExpCore &Core)
Constructs the parameters for a QModuleBase instance.
Definition Module.h:1312
Window class for Qt-based user interfaces belonging to DynExp modules. User interface Qt window class...
Definition Module.h:1079
QModuleBase & Owner
Module owning this user interface window (reference, because it should never change nor be nullptr).
Definition Module.h:1162
QModuleWidget(QModuleBase &Owner, QWidget *Parent=nullptr)
Constructs a QModuleWidget instance.
Definition Module.cpp:417
void UnlockObject(LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer)
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer....
Definition Object.h:3570
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:3554
Holds a bitset containing flags to indicate which features a certain instrument/ module etc....
Definition Util.h:1231
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...