DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
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
16namespace DynExpInstr
17{
18 class SwabianInstrumentsPulseStreamer;
19
20 namespace SwabianInstrumentsPulseStreamerTasks
21 {
27
33
39
41 {
42 public:
44
45 private:
47 };
48
50 {
51 public:
53
54 private:
56 };
57
59 {
60 public:
62
63 private:
65 };
66
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:
101 };
102
114
126
128 {
129 public:
131
132 private:
134 };
135
137 {
138 public:
141
142 private:
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:
172
174 bool Streaming = false;
175 bool Finished = false;
176
178 };
179
181 {
182 public:
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",
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)
void ConfigureParamsImpl(dispatch_tag< FunctionGeneratorParams >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
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< 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...
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 Util::FeatureTester< WaveformCapsType > GetWaveformCapsChild() const override
Returns the waveform types the function generator is able to produce.
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 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::unique_ptr< DynExp::ExitTaskBase > MakeExitTask() const override
Factory function for an exit task (ExitTaskBase). Override to define the desired deinitialization tas...
virtual Util::FeatureTester< TriggerCapsType > GetTriggerCapsChild() const override
Returns the trigger features the function generator is capable of.
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::InitTaskBase > MakeInitTask() const override
Factory function for an init task (InitTaskBase). Override to define the desired initialization task ...
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 void ForceFinalSample(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
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.
Refer to DynExp::ParamsBase::dispatch_tag.
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
This class holds a pointer (LinkedObjectWrapperPointer) to a LinkedObjectWrapper. Intances of this cl...
Definition Object.h:3160
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 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 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...
Defines the return type of task functions.
Definition Instrument.h:824
Refer to DynExp::ParamsBase::dispatch_tag.
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...
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.