DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
LaserScanningSpectroscopy.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#include "../../Instruments/InterModuleCommunicator.h"
14
15#include "CommonModuleEvents.h"
16
17#include <QWidget>
18
19namespace Ui
20{
21 class LaserScanningSpectroscopy;
22}
23
25{
26 class LaserScanningSpectroscopy;
27 class LaserScanningSpectroscopyData;
28
34
36
38 {
39 Q_OBJECT
40
41 public:
44
45 bool AllowResize() const noexcept override final { return true; }
46 const auto GetUI() const noexcept { return ui.get(); }
47 bool GetUIInitialized() const noexcept { return UIInitialized; }
48
50
51 private:
52 std::unique_ptr<Ui::LaserScanningSpectroscopy> ui;
53
54 bool UIInitialized = false;
55
56 private slots:
58 };
59
101
103 {
104 public:
107
108 virtual const char* GetParamClassTag() const noexcept override { return "LaserScanningSpectroscopyParams"; }
109
110 Param<DynExp::ObjectLink<DynExpInstr::Laser>> Laser = { *this, GetCore().GetInstrumentManager(),
111 "Laser", "Laser", "Laser instrument to perform spectroscopy with by scanning its frequency", DynExpUI::Icons::Instrument };
113 "PLEInterModuleCommunicator", "PLE inter-module communicator", "Inter-module communicator to control data acquisition", DynExpUI::Icons::Instrument, true };
115 "WFInterModuleCommunicator", "WF inter-module communicator", "Inter-module communicator to communicate with widefield microscope module", DynExpUI::Icons::Instrument, true };
117 "Capturing time difference (ms)", "Time difference between capturing events in continuous scan mode",
118 false, 500, 1};
119
120 private:
122 };
123
125 {
126 public:
129
132
133 private:
134 virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override final { return DynExp::MakeParams<LaserScanningSpectroscopyConfigurator>(ID, Core); }
135 };
136
138 {
139 public:
143
144 constexpr static auto Name() noexcept { return "Laser Scanning Spectroscopy"; }
145 constexpr static auto Category() noexcept { return "Experiments"; }
146
148 virtual ~LaserScanningSpectroscopy() = default;
149
150 virtual std::string GetName() const override { return Name(); }
151 virtual std::string GetCategory() const override { return Category(); }
152
153 std::chrono::milliseconds GetMainLoopDelay() const override final { return std::chrono::milliseconds(50); }
154
155 private:
157
158 void ResetImpl(dispatch_tag<QModuleBase>) override final;
159
160 std::unique_ptr<DynExp::QModuleWidget> MakeUIWidget() override final;
161 void UpdateUIChild(const ModuleBase::ModuleDataGetterType& ModuleDataGetter) override final;
162
163 // Helper functions
164 bool IsReadyState() const noexcept;
165 bool IsSettingFrequencyState() const noexcept;
166 bool IsCapturingState() const noexcept;
167 void FrequencyStep(DynExp::ModuleInstance* Instance) const;
168 std::filesystem::path BuildFilename(Util::SynchronizedPointer<ModuleDataType>& ModuleData, std::string_view FilenameSuffix) const;
169
170 // Events, run in module thread
171 void OnInit(DynExp::ModuleInstance* Instance) const override final;
172 void OnExit(DynExp::ModuleInstance* Instance) const override final;
173 void OnStart(DynExp::ModuleInstance* Instance) const;
174 void OnStartClicked(DynExp::ModuleInstance* Instance, bool) const;
175 void OnStop(DynExp::ModuleInstance* Instance) const;
176 void OnStopClicked(DynExp::ModuleInstance* Instance, bool) const;
177 void OnLowerFrequencyLimitChanged(DynExp::ModuleInstance* Instance, double LowerFrequencyLimit) const;
178 void OnUpperFrequencyLimitChanged(DynExp::ModuleInstance* Instance, double UpperFrequencyLimit) const;
179 void OnFrequencyRangeChanged(DynExp::ModuleInstance* Instance, double FrequencyRange) const;
180 void OnCenterFrequencyChanged(DynExp::ModuleInstance* Instance, double CenterFrequency) const;
181 void OnStepSizeChanged(DynExp::ModuleInstance* Instance, double StepSize) const;
182 void OnNumberOfStepsChanged(DynExp::ModuleInstance* Instance, int NumberOfSteps) const;
183 void OnNumberOfRepetitionsChanged(DynExp::ModuleInstance* Instance, int NumberOfRepetitions) const;
184 void OnScanBackAndForthToggled(DynExp::ModuleInstance* Instance, bool Checked) const;
185 void OnStartAtToggled(DynExp::ModuleInstance* Instance, bool) const;
186 void OnPathChanged(DynExp::ModuleInstance* Instance, const std::string& SaveFilename) const;
187 void OnPathChanged(DynExp::ModuleInstance* Instance, const QString SaveFilename) const;
188 void OnFinishedCapturing(DynExp::ModuleInstance* Instance) const;
189
190 // State functions for state machine
191 StateType ReadyStateFunc(DynExp::ModuleInstance& Instance);
192 StateType WaitForSettingFrequencyStateFunc(DynExp::ModuleInstance& Instance);
193 StateType WaitForCapturingStateFunc(DynExp::ModuleInstance& Instance);
194
195 // States for state machine
196 static constexpr auto ReadyState = Util::StateMachineState(StateType::Ready,
198 static constexpr auto WaitForSettingFrequencyState = Util::StateMachineState(StateType::WaitForSettingFrequency,
199 &LaserScanningSpectroscopy::WaitForSettingFrequencyStateFunc, "Laser stabilizes at target Frequency...");
200 static constexpr auto WaitForCapturingState = Util::StateMachineState(StateType::WaitForCapturing,
202
203 // Logical const-ness: allow events to set the state machine's current state.
205
206 // Indicates waiting time within measurements.
207 mutable std::chrono::system_clock::time_point WaitingEndTimePoint;
208
210 };
211}
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.
LaserStateType
Possible laser states.
Definition Laser.h:106
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...
DynExp::LinkedObjectWrapperContainer< DynExpInstr::Laser > Laser
virtual void ResetImpl(dispatch_tag< LaserScanningSpectroscopyData >)
DynExp::LinkedObjectWrapperContainer< DynExpInstr::InterModuleCommunicator > PLECommunicator
DynExp::LinkedObjectWrapperContainer< DynExpInstr::InterModuleCommunicator > WFCommunicator
Param< DynExp::ObjectLink< DynExpInstr::InterModuleCommunicator > > PLECommunicator
Param< DynExp::ObjectLink< DynExpInstr::InterModuleCommunicator > > WFCommunicator
void ConfigureParamsImpl(dispatch_tag< QModuleParamsBase >) override final
LaserScanningSpectroscopyParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
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...
void InitializeUI(Util::SynchronizedPointer< LaserScanningSpectroscopyData > &ModuleData)
bool AllowResize() const noexcept override final
Indicates the resizing behavior of the user interface window. Override to adjust.
virtual std::string GetName() const override
Returns the name of this Object type.
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...
std::chrono::milliseconds GetMainLoopDelay() const override final
Specifies in which time intervals the module's event queue runs to handle pending events.
void OnStartAtToggled(DynExp::ModuleInstance *Instance, bool) const
void OnNumberOfRepetitionsChanged(DynExp::ModuleInstance *Instance, int NumberOfRepetitions) const
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...
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.
std::filesystem::path BuildFilename(Util::SynchronizedPointer< ModuleDataType > &ModuleData, std::string_view FilenameSuffix) const
void OnStepSizeChanged(DynExp::ModuleInstance *Instance, double StepSize) const
void OnExit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread terminates (not due to an exception,...
void OnLowerFrequencyLimitChanged(DynExp::ModuleInstance *Instance, double LowerFrequencyLimit) const
void OnPathChanged(DynExp::ModuleInstance *Instance, const std::string &SaveFilename) const
void OnNumberOfStepsChanged(DynExp::ModuleInstance *Instance, int NumberOfSteps) const
void OnUpperFrequencyLimitChanged(DynExp::ModuleInstance *Instance, double UpperFrequencyLimit) const
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
void OnScanBackAndForthToggled(DynExp::ModuleInstance *Instance, bool Checked) const
void OnFrequencyRangeChanged(DynExp::ModuleInstance *Instance, double FrequencyRange) const
void OnCenterFrequencyChanged(DynExp::ModuleInstance *Instance, double CenterFrequency) 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
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
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
State machine state as used by class StateMachine. A state mainly wraps a state function of the membe...
Definition Util.h:1367
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Definition Util.h:170
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.