DynExp
Highly flexible laboratory automation for dynamically changing experiments.
SwabianInstrumentsPulseStreamer.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 SwabianInstrumentsPulseStreamer;
19 
20  namespace SwabianInstrumentsPulseStreamerTasks
21  {
23  {
26  };
27 
29  {
32  };
33 
35  {
38  };
39 
40  class WriteTask : public DynExp::TaskBase
41  {
42  public:
44 
45  private:
47  };
48 
49  class ClearTask : public DynExp::TaskBase
50  {
51  public:
53 
54  private:
56  };
57 
58  class StartTask : public DynExp::TaskBase
59  {
60  public:
62 
63  private:
65  };
66 
67  class StopTask : public DynExp::TaskBase
68  {
69  public:
71 
72  private:
74  };
75 
77  {
78  public:
80 
81  private:
83  };
84 
86  {
87  public:
89 
90  private:
92  };
93 
95  {
96  public:
98 
99  private:
100  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
101  };
102 
104  {
105  public:
108 
109  private:
110  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
111 
113  };
114 
116  {
117  public:
120 
121  private:
122  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
123 
125  };
126 
128  {
129  public:
131 
132  private:
133  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
134  };
135 
137  {
138  public:
141 
142  private:
143  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
144 
145  const int64_t NumRuns;
146  };
147  }
148 
150  {
153 
154  public:
156 
157  SwabianInstrumentsPulseStreamerData(size_t BufferSizeInSamples = 0) : FunctionGeneratorData(std::make_unique<SampleStreamType>(BufferSizeInSamples)) {}
159 
160  auto GetChannel() const noexcept { return Channel; }
161  bool IsDigitalChannel() const noexcept;
162 
163  // Functions giving information about the instrument (data is obtained asynchronously).
164  bool IsStreaming() const noexcept{ return Streaming; }
165  bool HasFinished() const noexcept{ return Finished; }
166 
168 
169  private:
170  void ResetImpl(dispatch_tag<FunctionGeneratorData>) override final;
172 
174  bool Streaming = false;
175  bool Finished = false;
176 
178  };
179 
181  {
182  public:
184  : FunctionGeneratorParams(ID, Core), StreamSizeParams(*this, 100) {}
186 
187  virtual const char* GetParamClassTag() const noexcept override { return "SwabianInstrumentsPulseStreamerParams"; }
188 
190  "HardwareAdapter", "Device hardware adapter", "Underlying Swabian Instruments Pulse Streamer device used by this pulse streamer channel instrument",
194  "OutputChannel", "Output channel", "Output channel of the pulse streamer this instrument uses.",
195  true, DynExpHardware::SIPulseStreamerHardwareAdapterParams::OutputChannelType::DO0 };
196 
197  // Stream size of OutputPortData's sample stream in samples.
199 
200  private:
203  };
204 
206  {
207  public:
210 
213 
214  private:
215  virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override { return DynExp::MakeParams<SwabianInstrumentsPulseStreamerConfigurator>(ID, Core); }
216  };
217 
219  {
220  public:
224 
225  constexpr static auto Name() noexcept { return "Swabian Instruments Pulse Streamer"; }
226 
229 
230  virtual std::string GetName() const override { return Name(); }
231 
232  virtual std::chrono::milliseconds GetTaskQueueDelay() const override { return std::chrono::milliseconds(100); }
233  virtual DataStreamInstrumentData::UnitType GetValueUnit() const noexcept override;
234 
235  // Tasks
236  virtual void WriteData(DynExp::TaskBase::CallbackType CallbackFunc) const override { MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::WriteTask>(CallbackFunc); }
237  virtual void ClearData(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::ClearTask>(CallbackFunc); }
238  virtual void Start(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::StartTask>(CallbackFunc); }
239  virtual void Stop(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::StopTask>(CallbackFunc); }
240  virtual void Restart(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::RestartTask>(CallbackFunc); }
241  virtual void ResetStreamSize(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::ResetBufferSizeTask>(CallbackFunc); }
242  virtual void ForceTrigger(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { return MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::ForceTriggerTask>(CallbackFunc); }
244  virtual void ForceFinalSample(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const { return MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::ForceFinalSampleTask>(CallbackFunc); }
245  virtual void SetNumRuns(int64_t NumRuns, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
246 
247  // Functions giving information about the instrument (data is obtained synchronously).
248  virtual Util::OptionalBool HasFinished() const override;
249  virtual Util::OptionalBool IsRunning() const override;
250 
251  private:
252  void ResetImpl(dispatch_tag<FunctionGenerator>) override final;
254 
260 
261  virtual void SetTriggerChild(const FunctionGeneratorDefs::TriggerDescType& TriggerDesc,
262  bool PersistParams, DynExp::TaskBase::CallbackType CallbackFunc) const override;
263 
264  virtual std::unique_ptr<DynExp::InitTaskBase> MakeInitTask() const override { return DynExp::MakeTask<SwabianInstrumentsPulseStreamerTasks::InitTask>(); }
265  virtual std::unique_ptr<DynExp::ExitTaskBase> MakeExitTask() const override { return DynExp::MakeTask<SwabianInstrumentsPulseStreamerTasks::ExitTask>(); }
266  virtual std::unique_ptr<DynExp::UpdateTaskBase> MakeUpdateTask() const override { return DynExp::MakeTask<SwabianInstrumentsPulseStreamerTasks::UpdateTask>(); }
267  };
268 }
Defines DynExp's core module as an interface between the UI and DynExp objects.
Implementation of a function generator meta instrument to generate waveforms.
Implementation of a hardware adapter to control Swabian Instruments Pulse Streamer 8/2 hardware.
static Util::TextValueListType< OutputChannelType > OutputChannelTypeStrList()
Implements a circular data stream based on Util::circularbuf using samples of type BasicSample.
UnitType
Units which can be used for data stream instruments.
Configurator class for FunctionGenerator.
Data class for FunctionGenerator.
Parameter class for FunctionGenerator.
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
Defines a task for updating an instrument within an instrument inheritance hierarchy....
Function generator meta instrument based on the data stream meta instrument to generate waveforms by ...
@ CanForce
Triggering can be forced (executed by the software).
@ CanConfigure
Trigger settings can be adjusted by the software.
Bundles parameters to describe a data stream's stream size.
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...
DynExp::LinkedObjectWrapperContainer< DynExpHardware::SIPulseStreamerHardwareAdapter > HardwareAdapter
virtual void ResetImpl(dispatch_tag< SwabianInstrumentsPulseStreamerData >)
DynExpHardware::SIPulseStreamerHardwareAdapterParams::OutputChannelType Channel
void ResetImpl(dispatch_tag< FunctionGeneratorData >) override final
Param< DynExpHardware::SIPulseStreamerHardwareAdapterParams::OutputChannelType > Channel
virtual void ConfigureParamsImpl(dispatch_tag< SwabianInstrumentsPulseStreamerParams >)
SwabianInstrumentsPulseStreamerParams(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 ConfigureParamsImpl(dispatch_tag< FunctionGeneratorParams >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Param< DynExp::ObjectLink< DynExpHardware::SIPulseStreamerHardwareAdapter > > HardwareAdapter
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 ExitFuncImpl(dispatch_tag< FunctionGeneratorTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
virtual void ExitFuncImpl(dispatch_tag< ExitTask >, DynExp::InstrumentInstance &Instance)
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...
virtual void InitFuncImpl(dispatch_tag< InitTask >, DynExp::InstrumentInstance &Instance)
void InitFuncImpl(dispatch_tag< FunctionGeneratorTasks::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...
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...
SetConstantOutputTask(const DynExpHardware::SIPulseStreamerHardwareAdapter::PulseType &Pulse, CallbackType CallbackFunc) noexcept
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...
SetNumRunsTask(int64_t NumRuns, CallbackType CallbackFunc) noexcept
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...
SetTriggerTask(const FunctionGeneratorDefs::TriggerDescType &TriggerDesc, CallbackType CallbackFunc) noexcept
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...
void UpdateFuncImpl(dispatch_tag< FunctionGeneratorTasks::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)
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 FunctionGeneratorDefs::FunctionDescType GetMaxCapsChild() const override
Returns the maximal values assignable to a description of a generic periodic function.
virtual Util::OptionalBool IsRunning() const override
Determines whether the underlying hardware adapter is running a data acquisition or writing data.
virtual void ResetStreamSize(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Enqueues a task to reset the size of the instrument's sample stream to its default value.
virtual void Restart(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Enqueues a task to make the underlying hardware adapter restart data acquisition or writing data....
virtual std::string GetName() const override
Returns the name of this Object type.
virtual std::unique_ptr< DynExp::ExitTaskBase > MakeExitTask() const override
Factory function for an exit task (ExitTaskBase). Override to define the desired deinitialization tas...
virtual void ClearData(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Enqueues a task to clear the underlying hardware adapter's buffer.
virtual void Stop(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Enqueues a task to make the underlying hardware adapter stop data acquisition or writing data.
virtual Util::FeatureTester< TriggerCapsType > GetTriggerCapsChild() const override
Returns the trigger features the function generator is capable of.
virtual std::unique_ptr< DynExp::InitTaskBase > MakeInitTask() const override
Factory function for an init task (InitTaskBase). Override to define the desired initialization task ...
virtual FunctionGeneratorDefs::FunctionDescType GetParamDefaultsChild() const override
Returns the default values to assign to a description of a generic periodic function.
virtual void SetTriggerChild(const FunctionGeneratorDefs::TriggerDescType &TriggerDesc, bool PersistParams, DynExp::TaskBase::CallbackType CallbackFunc) const override
SetTrigger() configures the function generator's trigger, which determines when the waveform generati...
virtual FunctionGeneratorDefs::FunctionDescType GetMinCapsChild() const override
Returns the minimal values assignable to a description of a generic periodic function.
virtual void SetConstantOutput(const DynExpHardware::SIPulseStreamerHardwareAdapter::PulseType &Pulse, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
virtual void SetNumRuns(int64_t NumRuns, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
virtual DataStreamInstrumentData::UnitType GetValueUnit() const noexcept override
Determines which unit corresponds to the values managed by this DataStreamInstrument instance....
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...
virtual std::chrono::milliseconds GetTaskQueueDelay() const override
Specifies in which time intervals the instrument's task queue runs to handle pending tasks.
virtual Util::OptionalBool HasFinished() const override
Determines whether the underlying hardware adapter finished data acquisition or writing data.
virtual void WriteData(DynExp::TaskBase::CallbackType CallbackFunc) const override
Enqueues a task to write data from the data stream to the hardware.
virtual Util::FeatureTester< WaveformCapsType > GetWaveformCapsChild() const override
Returns the waveform types the function generator is able to produce.
virtual void ForceFinalSample(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
SwabianInstrumentsPulseStreamer(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
void ResetImpl(dispatch_tag< FunctionGenerator >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual void ResetImpl(dispatch_tag< SwabianInstrumentsPulseStreamer >)
virtual void ForceTrigger(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Forces the generation of the waveform ignoring the trigger.
virtual void Start(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Enqueues a task to make the underlying hardware adapter start data acquisition or writing data.
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
Holds a bitset containing flags to indicate which features a certain instrument/ module etc....
Definition: Util.h:1231
Data type which stores an optional bool value (unknown, false, true). The type evaluates to bool whil...
Definition: Util.h:549
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
Definition: Instrument.h:1254
constexpr auto HardwareAdapter
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.
Accumulates include statements to provide a precompiled header.
Swabian Instruments Pulse Streamer 8/2's internal representation of a single pulse.
Type describing a generic periodic function.
Type describing trigger parameters determining when the waveform is generated.