DynExp
Highly flexible laboratory automation for dynamically changing experiments.
QutoolsQuTAG.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"
15 
16 namespace DynExpInstr
17 {
18  class QutoolsQuTAG;
19  class QutoolsQuTAGData;
20 
21  namespace QutoolsQuTAGTasks
22  {
24 
26  {
29  };
30 
32  {
35  };
36 
38  {
41  };
42 
43  class ReadDataTask final : public DynExp::TaskBase
44  {
45  public:
47 
48  private:
50  };
51 
52  class SetStreamSizeTask final : public DynExp::TaskBase
53  {
54  public:
56 
57  private:
59 
60  const size_t BufferSizeInSamples;
61  };
62 
63  class ClearTask final : public DynExp::TaskBase
64  {
65  public:
67 
68  private:
70  };
71 
72  class ConfigureInputTask final : public DynExp::TaskBase
73  {
74  public:
77 
78  private:
80 
81  const bool UseRisingEdge;
82  const double ThresholdInVolts;
83  };
84 
86  {
87  public:
89 
90  private:
92 
94  };
95 
97  {
98  public:
100 
101  private:
102  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
103 
105  };
106 
107  class SetDelayTask final : public DynExp::TaskBase
108  {
109  public:
111 
112  private:
113  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
114 
116  };
117 
118  class SetHBTActiveTask final : public DynExp::TaskBase
119  {
120  public:
122 
123  private:
124  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
125 
126  const bool Enable;
127  };
128 
129  class ConfigureHBTTask final : public DynExp::TaskBase
130  {
131  public:
134 
135  private:
136  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
137 
139  const size_t BinCount;
140  };
141 
142  class ResetHBTTask final : public DynExp::TaskBase
143  {
144  public:
146 
147  private:
148  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
149  };
150  }
151 
153  {
154  public:
156  virtual ~QutoolsQuTAGData() = default;
157 
159 
160  auto GetChannel() const noexcept { return Channel; }
162 
163  private:
164  void ResetImpl(dispatch_tag<TimeTaggerData>) override final;
166 
168  };
169 
171  {
172  public:
174  virtual ~QutoolsQuTAGParams() = default;
175 
176  virtual const char* GetParamClassTag() const noexcept override { return "QutoolsQuTAGParams"; }
177 
179  "HardwareAdapter", "qutools TDC device", "Underlying hardware adapter of this instrument", DynExpUI::Icons::HardwareAdapter };
180  Param<ParamsConfigDialog::NumberType> Channel = { *this, "Channel", "Channel",
181  "Channel of the quTAG device this instrument refers to", true, 0, 0, std::numeric_limits<DynExpHardware::QutoolsTDCHardwareAdapter::ChannelType>::max(), 1, 0 };
182  Param<ParamsConfigDialog::NumberType> CrossCorrChannel = { *this, "CrossCorrChannel", "Correlation channel",
183  "Channel of the quTAG device to compute correlations (e.g. g(2)) with", false, 1, 0, std::numeric_limits<DynExpHardware::QutoolsTDCHardwareAdapter::ChannelType>::max(), 1, 0 };
184 
185  private:
188  };
189 
191  {
192  public:
195 
197  virtual ~QutoolsQuTAGConfigurator() = default;
198 
199  private:
200  virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override { return DynExp::MakeParams<QutoolsQuTAGConfigurator>(ID, Core); }
201  };
202 
203  class QutoolsQuTAG : public TimeTagger
204  {
205  public:
209 
210  constexpr static auto Name() noexcept { return "qutools quTAG"; }
211 
213  virtual ~QutoolsQuTAG() {}
214 
215  virtual std::string GetName() const override { return Name(); }
216 
217  virtual double GetMinThresholdInVolts() const noexcept override { return -2; }
218  virtual double GetMaxThresholdInVolts() const noexcept override { return 3; }
219 
220  virtual Util::picoseconds GetResolution() const override;
221  virtual size_t GetBufferSize() const override;
222 
223  virtual void ReadData(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::ReadDataTask>(CallbackFunc); }
224  virtual void SetStreamSize(size_t BufferSizeInSamples, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::SetStreamSizeTask>(BufferSizeInSamples, CallbackFunc); }
225  virtual void Clear(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::ClearTask>(CallbackFunc); }
226  virtual void ConfigureInput(bool UseRisingEdge, double ThresholdInVolts, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::ConfigureInputTask>(UseRisingEdge, ThresholdInVolts, CallbackFunc); }
227  virtual void SetExposureTime(Util::picoseconds ExposureTime, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::SetExposureTimeTask>(ExposureTime, CallbackFunc); }
228  virtual void SetCoincidenceWindow(Util::picoseconds CoincidenceWindow, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::SetCoincidenceWindowTask>(CoincidenceWindow, CallbackFunc); }
229  virtual void SetDelay(Util::picoseconds Delay, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::SetDelayTask>(Delay, CallbackFunc); }
230  virtual void SetHBTActive(bool Enable, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::SetHBTActiveTask>(Enable, CallbackFunc); }
231  virtual void ConfigureHBT(Util::picoseconds BinWidth, size_t BinCount, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::ConfigureHBTTask>(BinWidth, BinCount, CallbackFunc); }
232  virtual void ResetHBT(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<QutoolsQuTAGTasks::ResetHBTTask>(CallbackFunc); }
233 
234  private:
235  void ResetImpl(dispatch_tag<TimeTagger>) override final;
237 
238  virtual std::unique_ptr<DynExp::InitTaskBase> MakeInitTask() const override { return DynExp::MakeTask<QutoolsQuTAGTasks::InitTask>(); }
239  virtual std::unique_ptr<DynExp::ExitTaskBase> MakeExitTask() const override { return DynExp::MakeTask<QutoolsQuTAGTasks::ExitTask>(); }
240  virtual std::unique_ptr<DynExp::UpdateTaskBase> MakeUpdateTask() const override { return DynExp::MakeTask<QutoolsQuTAGTasks::UpdateTask>(); }
241  };
242 }
Defines DynExp's core module as an interface between the UI and DynExp objects.
Implementation of a hardware adapter to control qutools TDC hardware.
Defines a time tagging meta instrument to assign timestamps to (e.g. photon) detection events.
virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core) const override
Override to make derived classes call DynExp::MakeParams with the correct configurator type derived f...
Definition: QutoolsQuTAG.h:200
virtual ~QutoolsQuTAGConfigurator()=default
virtual ~QutoolsQuTAGData()=default
void SetChannel(DynExpHardware::QutoolsTDCHardwareAdapter::ChannelType Channel) noexcept
Definition: QutoolsQuTAG.h:161
DynExpHardware::QutoolsTDCHardwareAdapter::ChannelType Channel
Definition: QutoolsQuTAG.h:165
void ResetImpl(dispatch_tag< TimeTaggerData >) override final
DynExp::LinkedObjectWrapperContainer< DynExpHardware::QutoolsTDCHardwareAdapter > HardwareAdapter
Definition: QutoolsQuTAG.h:158
virtual void ResetImpl(dispatch_tag< QutoolsQuTAGData >)
Definition: QutoolsQuTAG.h:165
auto GetChannel() const noexcept
Definition: QutoolsQuTAG.h:160
Param< ParamsConfigDialog::NumberType > CrossCorrChannel
Definition: QutoolsQuTAG.h:182
Param< ParamsConfigDialog::NumberType > Channel
Definition: QutoolsQuTAG.h:180
Param< DynExp::ObjectLink< DynExpHardware::QutoolsTDCHardwareAdapter > > HardwareAdapter
Definition: QutoolsQuTAG.h:178
virtual ~QutoolsQuTAGParams()=default
virtual void ConfigureParamsImpl(dispatch_tag< QutoolsQuTAGParams >)
Definition: QutoolsQuTAG.h:187
QutoolsQuTAGParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Definition: QutoolsQuTAG.h:173
void ConfigureParamsImpl(dispatch_tag< TimeTaggerParams >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition: QutoolsQuTAG.h:186
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...
Definition: QutoolsQuTAG.h:176
ClearTask(CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:66
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
ConfigureHBTTask(Util::picoseconds BinWidth, size_t BinCount, CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:132
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
ConfigureInputTask(bool UseRisingEdge, double ThresholdInVolts, CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:75
virtual void ExitFuncImpl(dispatch_tag< ExitTask >, DynExp::InstrumentInstance &Instance)
Definition: QutoolsQuTAG.h:34
void ExitFuncImpl(dispatch_tag< TimeTaggerTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
virtual void InitFuncImpl(dispatch_tag< InitTask >, DynExp::InstrumentInstance &Instance)
Definition: QutoolsQuTAG.h:28
void InitFuncImpl(dispatch_tag< TimeTaggerTasks::InitTask >, DynExp::InstrumentInstance &Instance) override final
Initializes the respective instrument within the instrument inheritance hierarchy....
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
ReadDataTask(CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:46
ResetHBTTask(CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:145
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
SetCoincidenceWindowTask(Util::picoseconds CoincidenceWindow, CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:99
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
SetDelayTask(Util::picoseconds Delay, CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:110
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
SetExposureTimeTask(Util::picoseconds ExposureTime, CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:88
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
SetHBTActiveTask(bool Enable, CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:121
SetStreamSizeTask(size_t BufferSizeInSamples, CallbackType CallbackFunc) noexcept
Definition: QutoolsQuTAG.h:55
virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance &Instance) override
Runs the task. Override RunChild() to define a derived task's action(s). Any exception leaving RunChi...
void UpdateFuncImpl(dispatch_tag< TimeTaggerTasks::UpdateTask >, DynExp::InstrumentInstance &Instance) override final
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
virtual void UpdateFuncImpl(dispatch_tag< UpdateTask >, DynExp::InstrumentInstance &Instance)
Definition: QutoolsQuTAG.h:40
virtual std::unique_ptr< DynExp::UpdateTaskBase > MakeUpdateTask() const override
Factory function for an update task (UpdateTaskBase). Override to define the desired update task in d...
Definition: QutoolsQuTAG.h:240
constexpr static auto Name() noexcept
Definition: QutoolsQuTAG.h:210
virtual void SetStreamSize(size_t BufferSizeInSamples, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Enqueues a task to set the size of the instrument's sample stream. The default implementation just ca...
Definition: QutoolsQuTAG.h:224
QutoolsQuTAG(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
virtual double GetMaxThresholdInVolts() const noexcept override
Determines the maximal configurable threshold voltage, which needs to be exceeded at the time tagger'...
Definition: QutoolsQuTAG.h:218
virtual Util::picoseconds GetResolution() const override
Determines the time tagger's time resolution in assigning timestamps to events.
virtual void ConfigureInput(bool UseRisingEdge, double ThresholdInVolts, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Configures the input channel of the physical device related to this instrument.
Definition: QutoolsQuTAG.h:226
virtual void SetExposureTime(Util::picoseconds ExposureTime, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Configures the time tagger's exposure time. This is e.g. relevant to determine count rates in the Tim...
Definition: QutoolsQuTAG.h:227
virtual std::unique_ptr< DynExp::ExitTaskBase > MakeExitTask() const override
Factory function for an exit task (ExitTaskBase). Override to define the desired deinitialization tas...
Definition: QutoolsQuTAG.h:239
void ResetImpl(dispatch_tag< TimeTagger >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual size_t GetBufferSize() const override
Determines the time tagger's internal buffer size for storing time-tagged events.
virtual void SetCoincidenceWindow(Util::picoseconds CoincidenceWindow, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Configures the time tagger's coincidence window.
Definition: QutoolsQuTAG.h:228
virtual std::string GetName() const override
Returns the name of this Object type.
Definition: QutoolsQuTAG.h:215
virtual std::unique_ptr< DynExp::InitTaskBase > MakeInitTask() const override
Factory function for an init task (InitTaskBase). Override to define the desired initialization task ...
Definition: QutoolsQuTAG.h:238
virtual void ResetHBT(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Resets the time tagger's HBT unit for g^(2) measurements.
Definition: QutoolsQuTAG.h:232
virtual void ResetImpl(dispatch_tag< QutoolsQuTAG >)
Definition: QutoolsQuTAG.h:236
virtual void Clear(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Clears the recorded time-tagged events from the hardware buffer of the underlying hardware adapter.
Definition: QutoolsQuTAG.h:225
virtual void SetHBTActive(bool Enable, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Enables or disables the time tagger's HBT unit for g^(2) measurements.
Definition: QutoolsQuTAG.h:230
virtual void ConfigureHBT(Util::picoseconds BinWidth, size_t BinCount, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Configures the time tagger's HBT unit for g^(2) measurements.
Definition: QutoolsQuTAG.h:231
virtual void ReadData(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Enqueues a task to read data from the hardware to the data stream. The default implementation does no...
Definition: QutoolsQuTAG.h:223
virtual double GetMinThresholdInVolts() const noexcept override
Determines the minimal configurable threshold voltage, which needs to be exceeded at the time tagger'...
Definition: QutoolsQuTAG.h:217
virtual void SetDelay(Util::picoseconds Delay, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Configures the time tagger's channel delay. This is useful to compensate different signal delays betw...
Definition: QutoolsQuTAG.h:229
Configurator class for TimeTagger.
Definition: TimeTagger.h:241
Data class for TimeTagger.
Definition: TimeTagger.h:98
Parameter class for TimeTagger.
Definition: TimeTagger.h:202
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
Definition: TimeTagger.h:54
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
Definition: TimeTagger.h:27
Defines a task for updating an instrument within an instrument inheritance hierarchy....
Definition: TimeTagger.h:67
Meta instrument for a time tagging device to assign timestamps to (e.g. photon) detection events base...
Definition: TimeTagger.h:255
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition: DynExpCore.h:127
Refer to DynExp::ParamsBase::dispatch_tag.
Definition: Instrument.h:1151
Refer to DynExp::ParamsBase::dispatch_tag.
Definition: Instrument.h:1120
Base class for instruments. Instruments comprise virtual devices (meta instruments) and physial devic...
Definition: Instrument.h:451
Configurator class for InstrumentBase.
Definition: Instrument.h:435
Data structure to contain data which is synchronized in between different threads....
Definition: Instrument.h:135
Refer to ParamsBase::dispatch_tag.
Definition: Instrument.h:146
Defines data for a thread belonging to a InstrumentBase instance. Refer to RunnableInstance.
Definition: Instrument.h:772
Parameter class for InstrumentBase.
Definition: Instrument.h:401
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
Refer to ParamsBase::dispatch_tag.
Definition: Object.h:2018
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 all tasks being processed by instruments. The class must not contain public virtual fu...
Definition: Instrument.h:892
std::function< void(const TaskBase &, ExceptionContainer &)> CallbackType
Type of a callback function which is invoked when a task has finished, failed or has been aborted....
Definition: Instrument.h:939
TaskBase(CallbackType CallbackFunc=nullptr) noexcept
Constructs an instrument task.
Definition: Instrument.h:979
const CallbackType CallbackFunc
This callback function is called after the task has finished (either successfully or not) with a refe...
Definition: Instrument.h:1072
Defines the return type of task functions.
Definition: Instrument.h:824
Refer to DynExp::ParamsBase::dispatch_tag.
Definition: Instrument.h:1182
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Definition: Util.h:170
void UpdateStreamMode(Util::SynchronizedPointer< QutoolsQuTAGData > &InstrData)
Definition: QutoolsQuTAG.cpp:8
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
Definition: Instrument.h:1254
constexpr auto HardwareAdapter
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.
std::chrono::duration< double, std::pico > picoseconds
Extends std::chrono by a duration data type for picoseconds.
Definition: Util.h:762
Accumulates include statements to provide a precompiled header.