DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
SpectrumViewer.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/Spectrometer.h"
14#include "../../Instruments/InterModuleCommunicator.h"
15
16#include "CommonModuleEvents.h"
18
20{
21 class SpectrumViewer;
22
24 {
25 public:
27 {
29
30 QList<QPointF> Samples;
31 };
32
34 virtual ~SpectrumViewerData() = default;
35
36 bool IsUIInitialized() const noexcept { return UIInitialized; }
37 void SetUIInitialized() noexcept { UIInitialized = true; }
38
39 auto& GetSpectrometer() { return Spectrometer; }
40 auto& GetCommunicator() { return Communicator; }
41
52 std::string AutoSaveFilename;
54
57
58 private:
59 void ResetImpl(dispatch_tag<QMLModuleDataBase>) override final;
61
62 void Init();
63
65
68 };
69
71 {
72 public:
74 virtual ~SpectrumViewerParams() = default;
75
76 virtual const char* GetParamClassTag() const noexcept override { return "SpectrumViewerParams"; }
77
79 "Spectrometer", "Spectrometer", "Underlying spectrometer instrument to be used as a data source", DynExpUI::Icons::Instrument };
81 "InterModuleCommunicator", "Inter-module communicator", "Inter-module communicator to control this module with", DynExpUI::Icons::Instrument, true };
82
83 private:
85 };
86
88 {
89 public:
92
94 virtual ~SpectrumViewerConfigurator() = default;
95
96 private:
97 virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override final { return DynExp::MakeParams<SpectrumViewerConfigurator>(ID, Core); }
98 };
99
101 {
102 public:
106
107 constexpr static auto Name() noexcept { return "Spectrum Viewer"; }
108 constexpr static auto Category() noexcept { return "Image Capturing"; }
109
112 virtual ~SpectrumViewer() = default;
113
114 virtual std::string GetName() const override { return Name(); }
115 virtual std::string GetCategory() const override { return Category(); }
116
117 std::chrono::milliseconds GetMainLoopDelay() const override final { return std::chrono::milliseconds(50); }
118
119 private:
121
122 void ResetImpl(dispatch_tag<QMLModuleBase>) override final;
123
124 void MakeConnections(QObject* Backend) override final;
125 QAnyStringView GetModuleSourceUri() const noexcept override final { return "Modules.SpectrumViewer"; }
126 QAnyStringView GetModuleSourceTypeName() const noexcept override final { return "SpectrumViewer"; }
127 void UpdateUIChild(const ModuleBase::ModuleDataGetterType& ModuleDataGetter) override final;
128
130
131 // Events, run in module thread
132 void OnInit(DynExp::ModuleInstance* Instance) const override final;
133 void OnExit(DynExp::ModuleInstance* Instance) const override final;
134
135 void OnRunClicked(DynExp::ModuleInstance* Instance) const;
136 void OnStopClicked(DynExp::ModuleInstance* Instance) const;
137 void OnSilentModeToggled(DynExp::ModuleInstance* Instance, bool Checked) const;
138 void OnExposureTimeChanged(DynExp::ModuleInstance* Instance, int Value) const;
139 void OnLowerLimitChanged(DynExp::ModuleInstance* Instance, double Value) const;
140 void OnUpperLimitChanged(DynExp::ModuleInstance* Instance, double Value) const;
141 void OnSetFilename(DynExp::ModuleInstance* Instance, const std::string& SaveFilename) const;
142 void OnTrigger(DynExp::ModuleInstance* Instance) const;
143 void OnStop(DynExp::ModuleInstance* Instance) const;
146
147 // Events, run in UI thread
148 void OnSaveSpectrum() const;
149
150 void FinishedSavingData() const noexcept { IsSavingData = false; }
152
156 mutable std::atomic_bool IsSavingData = false;
157
159
167 };
168}
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.
Events for inter-module communication handled by the DynExpModule::SpectrumViewer::SpectrumViewer mod...
CapturingStateType
Possible spectrometer states.
std::chrono::milliseconds TimeType
Time type describing the spectrometer's times like its exposure time.
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::SpectrometerData::TimeType CurrentExposureTime
DynExpInstr::SpectrometerData::CapturingStateType CapturingState
DynExpInstr::SpectrometerData::TimeType MinExposureTime
DynExp::LinkedObjectWrapperContainer< DynExpInstr::InterModuleCommunicator > Communicator
DynExpInstr::SpectrometerData::TimeType MaxExposureTime
virtual void ResetImpl(dispatch_tag< SpectrumViewerData >)
DynExp::LinkedObjectWrapperContainer< DynExpInstr::Spectrometer > Spectrometer
void ResetImpl(dispatch_tag< QMLModuleDataBase >) 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...
void ConfigureParamsImpl(dispatch_tag< QMLModuleParamsBase >) override final
Param< DynExp::ObjectLink< DynExpInstr::Spectrometer > > Spectrometer
SpectrumViewerParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Param< DynExp::ObjectLink< DynExpInstr::InterModuleCommunicator > > Communicator
void OnExit(DynExp::ModuleInstance *Instance) const override final
This event is triggered right before the module thread terminates (not due to an exception,...
static constexpr auto Category() noexcept
void SaveSpectrum(Util::SynchronizedPointer< SpectrumViewerData > &ModuleData)
void OnUpperLimitChanged(DynExp::ModuleInstance *Instance, double Value) const
void MakeConnections(QObject *Backend) override final
Use QModuleBase::Connect() to connect Qt QML signals to the module's event functions.
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...
SpectrumViewer(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
void OnRunClicked(DynExp::ModuleInstance *Instance) 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...
void OnPauseSpectrumRecording(DynExp::ModuleInstance *Instance) const
QAnyStringView GetModuleSourceTypeName() const noexcept override final
Used by QModuleBase::MakeUIWidget to construct the module's user interface QML widget.
std::atomic_bool IsSavingData
If data is currently being saved to file, do not update internal data.
QAnyStringView GetModuleSourceUri() const noexcept override final
Used by QModuleBase::MakeUIWidget to construct the module's user interface QML widget.
void OnLowerLimitChanged(DynExp::ModuleInstance *Instance, double Value) const
void OnTrigger(DynExp::ModuleInstance *Instance) const
QObject SignalContext
Does nothing but ensures that this module's Qt connections are disconnected when SignalContext is des...
void OnSetFilename(DynExp::ModuleInstance *Instance, const std::string &SaveFilename) const
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
virtual std::string GetName() const override
Returns the name of this Object type.
static constexpr auto Name() noexcept
void OnSilentModeToggled(DynExp::ModuleInstance *Instance, bool Checked) const
void OnStop(DynExp::ModuleInstance *Instance) const
virtual std::string GetCategory() const override
Returns the category of this Object type.
void OnResumeSpectrumRecording(DynExp::ModuleInstance *Instance) const
void OnStopClicked(DynExp::ModuleInstance *Instance) const
std::chrono::milliseconds GetMainLoopDelay() const override final
Specifies in which time intervals the module's event queue runs to handle pending events.
void ResetImpl(dispatch_tag< QMLModuleBase >) override final
void OnExposureTimeChanged(DynExp::ModuleInstance *Instance, int Value) 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:3176
const std::unique_ptr< ModuleDataType > ModuleData
Module data belonging to this ModuleBase instance.
Definition Module.h:789
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
Holds a CallableMemberWrapper and invokes its callable when being destroyed.
Definition Util.h:495
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Definition Util.h:171
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.
std::string ToStr(DynExpInstr::SpectrometerData::TimeType ExposureTime, const DynExpModule::Graph::LineGraphPlotInfo &PlotInfo) const