DynExp
Highly flexible laboratory automation for dynamically changing experiments.
LockinAmplifierControl.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/LockinAmplifier.h"
13 
14 #include <QWidget>
15 #include "ui_LockinAmplifierControl.h"
16 
17 namespace DynExpModule
18 {
19  class LockinAmplifierControl;
20  class LockinAmplifierControlData;
21 
23  {
24  Q_OBJECT
25 
26  public:
29 
30  bool AllowResize() const noexcept override final { return false; }
31 
32  const auto& GetUI() const noexcept { return ui; }
33  bool GetUIInitialized() const noexcept { return UIInitialized; }
34 
36 
37  private:
38  Ui::LockinAmplifierControl ui;
39 
40  bool UIInitialized = false;
41  };
42 
44  {
45  public:
47  virtual ~LockinAmplifierControlData() = default;
48 
49  auto& GetLockinAmplifier() noexcept { return LockinAmplifier; }
50  auto& GetLockinAmplifier() const noexcept { return LockinAmplifier; }
51 
53  double CurrentPhase{}; // in rad
54  double CurrentTimeConstant{}; // in s
55  uint8_t CurrentFilterOrder{};
59  double CurrentSamplingRate{}; // in samples/s
60  bool CurrentEnable{};
66  std::string SensitivityUnitString;
67 
68  private:
69  void ResetImpl(dispatch_tag<QModuleDataBase>) override final;
71 
72  void Init();
73 
75  };
76 
78  {
79  public:
81  virtual ~LockinAmplifierControlParams() = default;
82 
83  virtual const char* GetParamClassTag() const noexcept override { return "LockinAmplifierControlParams"; }
84 
86  "LockinAmplifier", "Lock-in amplifier", "Underlying lock-in amplifier to be controlled", DynExpUI::Icons::Instrument };
87 
88  private:
90  };
91 
93  {
94  public:
97 
100 
101  private:
102  virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override final { return DynExp::MakeParams<LockinAmplifierControlConfigurator>(ID, Core); }
103  };
104 
106  {
107  public:
111 
112  constexpr static auto Name() noexcept { return "Lock-in Amplifier Control"; }
113  constexpr static auto Category() noexcept { return "I/O"; }
114 
116  : QModuleBase(OwnerThreadID, std::move(Params)) {}
117  virtual ~LockinAmplifierControl() = default;
118 
119  virtual std::string GetName() const override { return Name(); }
120  virtual std::string GetCategory() const override { return Category(); }
121 
122  std::chrono::milliseconds GetMainLoopDelay() const override final { return std::chrono::milliseconds(100); }
123 
124  private:
126 
127  void ResetImpl(dispatch_tag<QModuleBase>) override final;
128 
129  std::unique_ptr<DynExp::QModuleWidget> MakeUIWidget() override final;
130  void UpdateUIChild(const ModuleBase::ModuleDataGetterType& ModuleDataGetter) override final;
131 
132  // Events, run in module thread
133  void OnInit(DynExp::ModuleInstance* Instance) const override final;
134  void OnExit(DynExp::ModuleInstance* Instance) const override final;
135 
136  void OnSensitivityChanged(DynExp::ModuleInstance* Instance, double Value) const;
137  void OnAutoRangeClicked(DynExp::ModuleInstance* Instance, bool) const;
138  void OnPhaseChanged(DynExp::ModuleInstance* Instance, double Value) const;
139  void OnAutoPhaseClicked(DynExp::ModuleInstance* Instance, bool) const;
140  void OnTimeConstantChanged(DynExp::ModuleInstance* Instance, double Value) const;
141  void OnFilterOrderChanged(DynExp::ModuleInstance* Instance, int Value) const;
142  void OnTriggerModeChanged(DynExp::ModuleInstance* Instance, int Index) const;
143  void OnTriggerEdgeChanged(DynExp::ModuleInstance* Instance, int Index) const;
144  void OnForceTriggerClicked(DynExp::ModuleInstance* Instance, bool) const;
145  void OnSignalTypeChanged(DynExp::ModuleInstance* Instance, int Index) const;
146  void OnSamplingRateChanged(DynExp::ModuleInstance* Instance, double Value) const;
147  void OnEnableClicked(DynExp::ModuleInstance* Instance, int Value) const;
148  void OnPersistParamsClicked(DynExp::ModuleInstance* Instance, bool) const;
149 
150  static const char* ProgressBarRedStylesheet;
151  static const char* ProgressBarGreenStylesheet;
152 
154  };
155 }
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...
void ResetImpl(dispatch_tag< QModuleDataBase >) override final
DynExp::LinkedObjectWrapperContainer< DynExpInstr::LockinAmplifier > LockinAmplifier
DynExpInstr::LockinAmplifierDefs::TriggerEdgeType CurrentTriggerEdge
virtual void ResetImpl(dispatch_tag< LockinAmplifierControlData >)
DynExpInstr::LockinAmplifierDefs::TriggerModeType CurrentTriggerMode
DynExpInstr::LockinAmplifierDefs::SignalType CurrentSignal
LockinAmplifierControlParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
void ConfigureParamsImpl(dispatch_tag< QModuleParamsBase >) 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...
Param< DynExp::ObjectLink< DynExpInstr::LockinAmplifier > > LockinAmplifier
bool AllowResize() const noexcept override final
Indicates the resizing behavior of the user interface window. Override to adjust.
void InitializeUI(Util::SynchronizedPointer< LockinAmplifierControlData > &ModuleData)
LockinAmplifierControlWidget(LockinAmplifierControl &Owner, QModuleWidget *parent=nullptr)
void OnSignalTypeChanged(DynExp::ModuleInstance *Instance, int Index) const
constexpr static auto Name() noexcept
std::chrono::milliseconds GetMainLoopDelay() const override final
Specifies in which time intervals the module's event queue runs to handle pending events.
void OnAutoPhaseClicked(DynExp::ModuleInstance *Instance, bool) const
void OnTimeConstantChanged(DynExp::ModuleInstance *Instance, double Value) const
void OnPersistParamsClicked(DynExp::ModuleInstance *Instance, bool) const
void OnFilterOrderChanged(DynExp::ModuleInstance *Instance, int Value) const
void OnPhaseChanged(DynExp::ModuleInstance *Instance, double Value) const
void UpdateUIChild(const ModuleBase::ModuleDataGetterType &ModuleDataGetter) override final
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 ~LockinAmplifierControl()=default
void OnTriggerModeChanged(DynExp::ModuleInstance *Instance, int Index) const
void ResetImpl(dispatch_tag< QModuleBase >) override final
void OnForceTriggerClicked(DynExp::ModuleInstance *Instance, bool) const
void OnAutoRangeClicked(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...
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 OnEnableClicked(DynExp::ModuleInstance *Instance, int Value) const
virtual std::string GetCategory() const override
Returns the category of this Object type.
LockinAmplifierControl(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
void OnTriggerEdgeChanged(DynExp::ModuleInstance *Instance, int Index) const
void OnSamplingRateChanged(DynExp::ModuleInstance *Instance, double Value) const
constexpr static auto Category() noexcept
void OnSensitivityChanged(DynExp::ModuleInstance *Instance, double Value) const
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition: DynExpCore.h:127
Base class for modules. Modules implement programs on their own (e.g. measurement protocols or server...
Definition: Module.h:392
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
ModuleBase(const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
Constructs a ModuleBase instance.
Definition: Module.cpp:189
Configurator class for ModuleBase.
Definition: Module.h:374
Data structure to contain data which is synchronized in between different threads....
Definition: Module.h:171
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
Parameter class for ModuleBase.
Definition: Module.h:337
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 ItemIDType ID
ID of the Object this parameter class instance belongs to.
Definition: Object.h:1779
const auto & GetCore() const noexcept
Returns a reference to DynExp's core.
Definition: Object.h:1677
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
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Definition: Util.h:170
TriggerEdgeType
Type to determine at which edge of a trigger signal to trigger. Not a strongly-typed enum to allow us...
SignalType
Type specifying different signal coordinates a lock-in amplifier can record. Not a strongly-typed enu...
TriggerModeType
Type to determine the trigger mode. Not a strongly-typed enum to allow using the enumeration in a Dyn...
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.