DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
LaserControl.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 "../MetaInstruments/Laser.h"
13
14#include <QWidget>
15
16namespace Ui
17{
18 class LaserControl;
19}
20
21namespace DynExpModule
22{
23 class LaserControl;
24 class LaserControlData;
25
27 {
28 Q_OBJECT
29
30 public:
33
34 bool AllowResize() const noexcept override final { return false; }
35
36 const auto GetUI() const noexcept { return ui.get(); }
37
40
41 private:
42 std::unique_ptr<Ui::LaserControl> ui;
43 };
44
87
89 {
90 public:
92 virtual ~LaserControlParams() = default;
93
94 virtual const char* GetParamClassTag() const noexcept override { return "LaserControlParams"; }
95
96 Param<DynExp::ObjectLink<DynExpInstr::Laser>> Laser = { *this, GetCore().GetInstrumentManager(),
97 "Laser", "Laser", "Underlying laser instrument to be controlled by this module", DynExpUI::Icons::Instrument };
98
99 private:
101 };
102
104 {
105 public:
108
110 virtual ~LaserControlConfigurator() = default;
111
112 private:
113 virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override final { return DynExp::MakeParams<LaserControlConfigurator>(ID, Core); }
114 };
115
117 {
118 public:
122
123 constexpr static auto Name() noexcept { return "Laser Control"; }
124 constexpr static auto Category() noexcept { return "I/O"; }
125
128 virtual ~LaserControl() = default;
129
130 virtual std::string GetName() const override { return Name(); }
131 virtual std::string GetCategory() const override { return Category(); }
132
133 std::chrono::milliseconds GetMainLoopDelay() const override final { return std::chrono::milliseconds(50); }
134
135 private:
137
138 void ResetImpl(dispatch_tag<QModuleBase>) override final;
139
140 std::unique_ptr<DynExp::QModuleWidget> MakeUIWidget() override final;
141 void UpdateUIChild(const ModuleBase::ModuleDataGetterType& ModuleDataGetter) override final;
142
143 // Events, run in module thread
144 void OnInit(DynExp::ModuleInstance* Instance) const override final;
145 void OnExit(DynExp::ModuleInstance* Instance) const override final;
146
147 void OnEnableToggled(DynExp::ModuleInstance* Instance, bool) const;
148 void OnScanToggled(DynExp::ModuleInstance* Instance, bool) const;
149 void OnFrequencyValueChanged(DynExp::ModuleInstance* Instance, double Frequency) const;
150 void OnWavelengthValueChanged(DynExp::ModuleInstance* Instance, double Wavelength) const;
151 void OnIntensityValueChanged(DynExp::ModuleInstance* Instance, double Intensity) const;
152 void OnScanRangeValueChanged(DynExp::ModuleInstance* Instance, double ScanRange) const;
153 void OnScanRateValueChanged(DynExp::ModuleInstance* Instance, double ScanRate) const;
154
156 };
157}
Defines DynExp's core module as an interface between the UI and DynExp objects.
FrequencyUnitType
Supported laser frequency units.
Definition Laser.h:74
LaserStateType
Possible laser states.
Definition Laser.h:106
IntensityUnitType
Supported laser intensity units.
Definition Laser.h:85
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...
double IntensityInLaserUnitToW(double Value) const
DynExpInstr::LaserData::IntensityUnitType IntensityUnit
bool IsUIInitialized() const noexcept
void ResetImpl(dispatch_tag< QModuleDataBase >) override final
double FrequencyInLaserUnitToHz(double Value) const
double FrequencyInHzToLaserUnit(double Value) const
double IntensityInWToLaserUnit(double Value) const
DynExpInstr::LaserData::FrequencyUnitType FrequencyUnit
DynExpInstr::LaserData::LaserStateType LaserState
virtual ~LaserControlData()=default
virtual void ResetImpl(dispatch_tag< LaserControlData >)
DynExp::LinkedObjectWrapperContainer< DynExpInstr::Laser > Laser
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 ~LaserControlParams()=default
Param< DynExp::ObjectLink< DynExpInstr::Laser > > Laser
LaserControlParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
void ConfigureParamsImpl(dispatch_tag< QModuleParamsBase >) override final
void InitializeUI(Util::SynchronizedPointer< LaserControlData > &ModuleData)
void UpdateUI(Util::SynchronizedPointer< LaserControlData > &ModuleData)
const auto GetUI() const noexcept
std::unique_ptr< Ui::LaserControl > ui
bool AllowResize() const noexcept override final
Indicates the resizing behavior of the user interface window. Override to adjust.
std::chrono::milliseconds GetMainLoopDelay() const override final
Specifies in which time intervals the module's event queue runs to handle pending events.
void OnScanToggled(DynExp::ModuleInstance *Instance, bool) const
static constexpr auto Name() noexcept
void OnWavelengthValueChanged(DynExp::ModuleInstance *Instance, double Wavelength) const
static constexpr auto Category() noexcept
void OnIntensityValueChanged(DynExp::ModuleInstance *Instance, double Intensity) 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...
virtual std::string GetCategory() const override
Returns the category of this Object type.
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...
virtual ~LaserControl()=default
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
void OnScanRangeValueChanged(DynExp::ModuleInstance *Instance, double ScanRange) const
void OnScanRateValueChanged(DynExp::ModuleInstance *Instance, double ScanRate) const
LaserControl(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
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
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 OnFrequencyValueChanged(DynExp::ModuleInstance *Instance, double Frequency) const
void OnEnableToggled(DynExp::ModuleInstance *Instance, bool) 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 holds a pointer (LinkedObjectWrapperPointer) to a LinkedObjectWrapper. Intances of this cl...
Definition Object.h:3168
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
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
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Definition Util.h:170
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
Accumulates include statements to provide a precompiled header.