DynExp
Highly flexible laboratory automation for dynamically changing experiments.
FunctionGenerator.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 "DataStreamInstrument.h"
13 
14 namespace DynExpInstr
15 {
16  class FunctionGenerator;
17 
21  namespace FunctionGeneratorDefs
22  {
27  None,
28  Sine,
29  Rect,
30  Ramp,
31  Pulse
32  };
33 
38  {
39  constexpr FunctionDescType() noexcept = default;
40 
47  constexpr FunctionDescType(double FrequencyInHz, double Amplitude, double Offset) noexcept
49 
50  double FrequencyInHz{};
51  double Amplitude{};
52  double Offset{};
53  };
54 
59  {
60  constexpr SineFunctionDescType() noexcept = default;
61 
69  constexpr SineFunctionDescType(double FrequencyInHz, double Amplitude, double Offset, double PhaseInRad) noexcept
71 
72  double PhaseInRad{};
73  };
74 
79  {
80  constexpr RectFunctionDescType() noexcept = default;
81 
90  constexpr RectFunctionDescType(double FrequencyInHz, double Amplitude, double Offset, double PhaseInRad, double DutyCycle) noexcept
92 
93  double PhaseInRad{};
94  double DutyCycle{};
95  };
96 
101  {
102  constexpr RampFunctionDescType() noexcept = default;
103 
112  constexpr RampFunctionDescType(double FrequencyInHz, double Amplitude, double Offset, double PhaseInRad, double RiseFallRatio) noexcept
114 
115  double PhaseInRad{};
116  double RiseFallRatio{};
117  };
118 
123  {
130  using PulsesType = std::map<double, double>;
131 
132  PulsesDescType() = default;
133 
138  PulsesDescType(const PulsesDescType& Other) : Pulses(Other.Pulses), Offset(Other.Offset) {}
139 
146 
153 
161 
173  PulsesDescType(const std::vector<double>& PulseStarts, const std::vector<double>& PulseAmplitudes, double Offset = 0.0);
174 
183 
187  void Reset() { Pulses.clear(); }
188 
195 
196  double Offset{};
197  };
198 
203  {
207  enum class ModulationType {
208  Disabled,
209  Amplitude,
210  Frequency,
211  Phase
212  };
213 
217  enum class ModulationShapeType {
218  Sine,
219  Pulse
220  };
221 
222  ModulationDescType() noexcept = default;
223 
233  ModulationShapeType Shape = ModulationShapeType::Sine, double PulseDutyCycle = .5) noexcept
236 
238  double Depth{};
239  double FrequencyInHz{};
241  double PulseDutyCycle{};
242  };
243 
248  {
252  enum class SweepType {
253  Disabled,
254  Amplitude,
255  Frequency
256  };
257 
258  SweepDescType() noexcept = default;
259 
269  SweepDescType(SweepType Type, double Min, double Max, double ValueDiffPerSample, double TimeDiffPerSample_ms, bool Retrace) noexcept
271 
273  double Min{};
274  double Max{};
277  bool Retrace{};
278  };
279 
284  {
294  Manual
295  };
296 
304  Fall
305  };
306 
307  TriggerDescType() noexcept = default;
308 
316 
319  };
320 
325  constexpr FunctionDescType GetDefaultMinFunctionDesc() { return { 0.0, std::numeric_limits<double>::lowest(), std::numeric_limits<double>::lowest() }; }
326 
331  constexpr FunctionDescType GetDefaultMaxFunctionDesc() { return { std::numeric_limits<double>::max(), std::numeric_limits<double>::max(), std::numeric_limits<double>::max() }; }
332 
337  constexpr FunctionDescType GetDefaultDefaultFunctionDesc() { return { 1, 1, 0 }; }
338 
344  inline constexpr Util::seconds PeriodFromFunctionDesc(const FunctionDescType& FunctionDesc);
345 
355  inline double RectFunc(double DutyCycle, double Phase);
356 
366  inline double InvRectFunc(double DutyCycle, double Phase);
367 
379  inline double RampFunc(double RiseFallRatio, double Phase);
380  }
381 
385  namespace FunctionGeneratorTasks
386  {
391  {
393 
398  };
399 
404  {
406 
411  };
412 
417  {
419 
424  };
425 
430  {
431  public:
440 
441  private:
442  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
443 
445 
450  bool Autostart;
451  };
452 
457  {
458  public:
467 
468  private:
469  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
470 
472  bool Autostart;
473  };
474 
479  {
480  public:
489 
490  private:
491  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
492 
494  bool Autostart;
495  };
496 
501  {
502  public:
511 
512  private:
513  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
514 
516  bool Autostart;
517  };
518 
523  {
524  public:
533 
534  private:
535  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
536 
538  bool Autostart;
539  };
540 
549  {
550  public:
556  : TaskBase(nullptr), TriggerDesc(TriggerDesc) {}
557 
558  private:
559  virtual DynExp::TaskResultType RunChild(DynExp::InstrumentInstance& Instance) override;
560 
562  };
563  }
564 
569  {
577 
578  public:
583 
584  virtual ~FunctionGeneratorData() = default;
585 
586  auto GetCurrentWaveformType() const noexcept { return CurrentWaveformType; }
587  auto GetCurrentFrequencyInHz() const noexcept { return CurrentFrequencyInHz; }
588  auto GetCurrentAmplitude() const noexcept { return CurrentAmplitude; }
589  auto GetCurrentOffset() const noexcept { return CurrentOffset; }
590  auto GetCurrentPhaseInRad() const noexcept { return CurrentPhaseInRad; }
591  auto GetCurrentDutyCycle() const noexcept { return CurrentDutyCycle; }
592  auto GetCurrentTriggerMode() const noexcept { return CurrentTriggerMode; }
593  auto GetCurrentTriggerEdge() const noexcept { return CurrentTriggerEdge; }
594  auto GetShouldAutostart() const noexcept { return ShouldAutostart; }
595  auto GetCurrentPulses() const noexcept { return CurrentPulses; }
596 
597  private:
598  void ResetImpl(dispatch_tag<DataStreamInstrumentData>) override final;
599 
604 
610  bool DataHasBeenUpdated{ false };
611 
614  double CurrentAmplitude{};
615  double CurrentOffset{};
616  double CurrentPhaseInRad{};
617  double CurrentDutyCycle{};
621 
623  };
624 
629  {
630  public:
636 
637  virtual ~FunctionGeneratorParams() = 0;
638 
639  virtual const char* GetParamClassTag() const noexcept override { return "FunctionGeneratorParams"; }
640 
645 
651 
657 
663 
668  Param<double> PhaseInRad = { *this, "PhaseInRad", 0, 0, 2.0 * std::numbers::pi };
669 
674  Param<double> DutyCycle = { *this, "DutyCycle", .5, 0, 1 };
675 
680  ListParam<double> PulseStarts = { *this, "PulseStarts", {}, 0};
681 
686  ListParam<double> PulseAmplitudes = { *this, "PulseAmplitudes", {} };
687 
692 
697 
703  Param<bool> Autostart = { *this, "Autostart", false };
704 
705  private:
708  };
709 
714  {
715  public:
718 
720  virtual ~FunctionGeneratorConfigurator() = 0;
721  };
722 
729  {
730  public:
734 
743 
748  enum class WaveformCapsType {
749  UserDefined,
750  Sine,
751  Rect,
752  Ramp,
753  Pulse,
754  NUM_ELEMENTS
755  };
756 
761  enum class QuantityCapsType {
762  Amplitude,
763  Frequency,
764  Phase,
765  NUM_ELEMENTS
766  };
767 
772  enum class TriggerCapsType {
773  CanConfigure,
774  CanForce,
775  NUM_ELEMENTS
776  };
777 
778  constexpr static auto Name() noexcept { return "Function Generator"; }
779  constexpr static auto Category() noexcept { return "I/O"; }
780 
785  : DataStreamInstrument(OwnerThreadID, std::move(Params)) {}
786 
787  virtual ~FunctionGenerator() = 0;
788 
789  virtual std::string GetName() const override { return Name(); }
790  virtual std::string GetCategory() const override { return Category(); }
791 
799 
804 
809  virtual bool IsPhaseAdjustable() const noexcept { return true; }
811 
818 
828  virtual void SetSineFunction(const FunctionGeneratorDefs::SineFunctionDescType& FunctionDesc,
829  bool PersistParams = false, bool Autostart = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
830 
841  virtual void SetRectFunction(const FunctionGeneratorDefs::RectFunctionDescType& FunctionDesc,
842  bool PersistParams = false, bool Autostart = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
843 
854  virtual void SetRampFunction(const FunctionGeneratorDefs::RampFunctionDescType& FunctionDesc,
855  bool PersistParams = false, bool Autostart = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
856 
867  virtual void SetPulseFunction(const FunctionGeneratorDefs::PulsesDescType& FunctionDesc,
868  bool PersistParams = false, bool Autostart = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
869 
878  bool Autostart = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
879 
890  virtual void SetModulation(const FunctionGeneratorDefs::ModulationDescType& ModulationDesc,
891  bool PersistParams = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
892 
903  virtual void SetSweep(const FunctionGeneratorDefs::SweepDescType& SweepDesc,
904  bool PersistParams = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
905 
920  void SetTrigger(const FunctionGeneratorDefs::TriggerDescType& TriggerDesc,
921  bool PersistParams = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
922 
929  virtual void ForceTrigger(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const;
930 
935  virtual void ForceTriggerSync() const;
937 
938  private:
939  void ResetImpl(dispatch_tag<DataStreamInstrument>) override final;
941 
954 
959 
962  virtual void SetTriggerChild(const FunctionGeneratorDefs::TriggerDescType& TriggerDesc,
963  bool PersistParams, DynExp::TaskBase::CallbackType CallbackFunc) const;
965 
966  virtual std::unique_ptr<DynExp::InitTaskBase> MakeInitTask() const override { return DynExp::MakeTask<FunctionGeneratorTasks::InitTask>(); }
967  virtual std::unique_ptr<DynExp::ExitTaskBase> MakeExitTask() const override { return DynExp::MakeTask<FunctionGeneratorTasks::ExitTask>(); }
968  virtual std::unique_ptr<DynExp::UpdateTaskBase> MakeUpdateTask() const override { return DynExp::MakeTask<FunctionGeneratorTasks::UpdateTask>(); }
969  };
970 }
Implementation of a data stream meta instrument and of data streams input/output devices might work o...
std::vector< BasicSample > BasicSampleListType
Type of a list containing data stream samples of type BasicSample.
Configurator class for DataStreamInstrument.
Data class for DataStreamInstrument.
const DataStreamBasePtrType SampleStream
Refer to DynExp::InstrumentDataBase::Reset(). Using tag dispatch mechanism to ensure that ResetImpl()...
Parameter class for DataStreamInstrument.
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....
Implementation of the data stream meta instrument, which is a base class for all instruments reading/...
Configurator class for FunctionGenerator.
Data class for FunctionGenerator.
virtual void ResetImpl(dispatch_tag< FunctionGeneratorData >)
auto GetCurrentAmplitude() const noexcept
Returns CurrentAmplitude.
auto GetCurrentWaveformType() const noexcept
Returns CurrentWaveformType.
FunctionGeneratorDefs::TriggerDescType::TriggerModeType CurrentTriggerMode
Current trigger mode.
virtual ~FunctionGeneratorData()=default
FunctionGeneratorDefs::TriggerDescType::TriggerEdgeType CurrentTriggerEdge
Current edge type to trigger on.
auto GetCurrentOffset() const noexcept
Returns CurrentOffset.
auto GetShouldAutostart() const noexcept
Returns ShouldAutostart.
double CurrentAmplitude
Current waveform's amplitude.
double CurrentDutyCycle
Current waveform's duty cycle or rise/fall ratio.
double CurrentOffset
Current waveform's offset.
auto GetCurrentTriggerEdge() const noexcept
Returns CurrentTriggerEdge.
auto GetCurrentFrequencyInHz() const noexcept
Returns CurrentFrequencyInHz.
auto GetCurrentTriggerMode() const noexcept
Returns CurrentTriggerMode.
auto GetCurrentPhaseInRad() const noexcept
Returns CurrentPhaseInRad.
double CurrentPhaseInRad
Current waveform's phase in radians.
FunctionGeneratorDefs::WaveformTypes CurrentWaveformType
Current waveform type.
auto GetCurrentPulses() const noexcept
Returns CurrentPulses.
auto GetCurrentDutyCycle() const noexcept
Returns CurrentDutyCycle.
FunctionGeneratorData(DataStreamBasePtrType &&SampleStream)
Constructs a DataStreamInstrumentData instance.
FunctionGeneratorDefs::PulsesDescType CurrentPulses
Current waveform's pulse segments.
void ResetImpl(dispatch_tag< DataStreamInstrumentData >) override final
double CurrentFrequencyInHz
Current waveform's frequency in Hz.
bool DataHasBeenUpdated
Indicates whether new data has been written to the instrument's data stream which needs now to be tra...
bool ShouldAutostart
Determines whether to directly make the underlying hardware device start generating the function (tru...
Parameter class for FunctionGenerator.
FunctionGeneratorParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Constructs the parameters for a FunctionGenerator instance.
Param< double > DutyCycle
Parameter to store waveform's duty cycle or rise/fall ratio. Refer to FunctionGeneratorDefs::RectFunc...
ListParam< double > PulseStarts
Parameter to store the start times of the waveform's pulse segments. Refer to FunctionGeneratorDefs::...
Param< double > PhaseInRad
Parameter to store waveform's phase in radians. Refer to FunctionGeneratorDefs::SineFunctionDescType:...
Param< FunctionGeneratorDefs::WaveformTypes > WaveformType
Parameter to store the waveform type.
Param< FunctionGeneratorDefs::TriggerDescType::TriggerEdgeType > TriggerEdge
Parameter to store the edge type to trigger on.
ListParam< double > PulseAmplitudes
Parameter to store the amplitudes of the waveform's pulse segments. Refer to FunctionGeneratorDefs::P...
Param< double > FrequencyInHz
Parameter to store waveform's frequency in Hz. Refer to FunctionGeneratorDefs::FunctionDescType::Freq...
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< double > Amplitude
Parameter to store waveform's amplitude. Refer to FunctionGeneratorDefs::FunctionDescType::Amplitude.
Param< bool > Autostart
Determines whether to directly make the underlying hardware device start generating the waveform afte...
Param< double > Offset
Parameter to store waveform's offset to be added to each sample. Refer to FunctionGeneratorDefs::Func...
void ConfigureParamsImpl(dispatch_tag< DataStreamInstrumentParams >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
virtual void ConfigureParamsImpl(dispatch_tag< FunctionGeneratorParams >)
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Param< FunctionGeneratorDefs::TriggerDescType::TriggerModeType > TriggerMode
Parameter to store the trigger mode.
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
void ExitFuncImpl(dispatch_tag< DataStreamInstrumentTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
virtual void ExitFuncImpl(dispatch_tag< ExitTask >, DynExp::InstrumentInstance &Instance)
Deinitializes the respective instrument within the instrument inheritance hierarchy....
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
virtual void InitFuncImpl(dispatch_tag< InitTask >, DynExp::InstrumentInstance &Instance)
Initializes the respective instrument within the instrument inheritance hierarchy....
void InitFuncImpl(dispatch_tag< DataStreamInstrumentTasks::InitTask >, DynExp::InstrumentInstance &Instance) override final
Initializes the respective instrument within the instrument inheritance hierarchy....
Task to write an arbitrary function defined by a list of samples to the related data stream instrumen...
bool Autostart
Determines whether to directly make the underlying hardware device start generating the function (tru...
SetArbitraryFunctionTask(DataStreamBase::BasicSampleListType &&Samples, bool Autostart, CallbackType CallbackFunc) noexcept
Constructs a SetArbitraryFunctionTask 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...
DataStreamBase::BasicSampleListType Samples
Samples the function consists of.
Task to write a function consisting of pulse segments to the related data stream instrument.
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...
SetPulseFunctionTask(const FunctionGeneratorDefs::PulsesDescType &FunctionDesc, bool Autostart, CallbackType CallbackFunc) noexcept
Constructs a SetPulseFunctionTask instance.
FunctionGeneratorDefs::PulsesDescType FunctionDesc
Description of the pulse function.
bool Autostart
Determines whether to directly make the underlying hardware device start generating the function (tru...
Task to write a ramp function to the related data stream instrument.
bool Autostart
Determines whether to directly make the underlying hardware device start generating the function (tru...
FunctionGeneratorDefs::RampFunctionDescType FunctionDesc
Description of the ramp function.
SetRampFunctionTask(const FunctionGeneratorDefs::RampFunctionDescType &FunctionDesc, bool Autostart, CallbackType CallbackFunc) noexcept
Constructs a SetRampFunctionTask 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...
Task to write a rectangular function to the related data stream instrument.
bool Autostart
Determines whether to directly make the underlying hardware device start generating the function (tru...
FunctionGeneratorDefs::RectFunctionDescType FunctionDesc
Description of the rectangular function.
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...
SetRectFunctionTask(const FunctionGeneratorDefs::RectFunctionDescType &FunctionDesc, bool Autostart, CallbackType CallbackFunc) noexcept
Constructs a SetRectFunctionTask instance.
Task to write a sine function to the related data stream instrument.
bool Autostart
Determines whether to directly make the underlying hardware device start generating the function (tru...
FunctionGeneratorDefs::SineFunctionDescType FunctionDesc
Description of the sine function.
SetSineFunctionTask(const FunctionGeneratorDefs::SineFunctionDescType &FunctionDesc, bool Autostart, CallbackType CallbackFunc) noexcept
Constructs a SetSineFunctionTask 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...
Task to initialize the trigger of the related function generator instrument. The task only updates Fu...
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) noexcept
Constructs a SetTriggerTask instance.
FunctionGeneratorDefs::TriggerDescType TriggerDesc
Trigger settings to apply.
Defines a task for updating an instrument within an instrument inheritance hierarchy....
virtual void UpdateFuncImpl(dispatch_tag< UpdateTask >, DynExp::InstrumentInstance &Instance)
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
void UpdateFuncImpl(dispatch_tag< DataStreamInstrumentTasks::UpdateTask >, DynExp::InstrumentInstance &Instance) override final
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
Function generator meta instrument based on the data stream meta instrument to generate waveforms by ...
virtual Util::FeatureTester< QuantityCapsType > GetModulationCapsChild() const
Returns the modulation types the function generator is capable of.
virtual void ForceTriggerSync() const
Synchronized version of ForceTrigger(), which blocks until the task enqueued by ForceTrigger() has be...
QuantityCapsType
Type enumerating quantities the function generator might be able to modulate or sweep (in hardware).
@ NUM_ELEMENTS
Must be last. Refer to Util::FeatureTester.
virtual void SetModulation(const FunctionGeneratorDefs::ModulationDescType &ModulationDesc, bool PersistParams=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Configures the function generator to perform a modulation.
FunctionGenerator(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs an instrument instance.
virtual bool IsPhaseAdjustable() const noexcept
Determines whether the function generator has the capability to set the phase of the generated wavefo...
virtual std::string GetCategory() const override
Returns the category of this Object type.
WaveformCapsType
Type enumerating waveform types the function generator might be able to produce (in hardware).
@ NUM_ELEMENTS
Must be last. Refer to Util::FeatureTester.
void ResetImpl(dispatch_tag< DataStreamInstrument >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual FunctionGeneratorDefs::FunctionDescType GetParamDefaultsChild() const
Returns the default values to assign to a description of a generic periodic function.
FunctionGeneratorDefs::FunctionDescType GetParamDefaults() const
Returns the default values to assign to a description of a generic periodic function.
virtual FunctionGeneratorDefs::FunctionDescType GetMaxCapsChild() const
Returns the maximal values assignable to a description of a generic periodic function.
virtual void ResetImpl(dispatch_tag< FunctionGenerator >)=0
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual void SetRampFunction(const FunctionGeneratorDefs::RampFunctionDescType &FunctionDesc, bool PersistParams=false, bool Autostart=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Generates a ramp function.
virtual std::unique_ptr< DynExp::ExitTaskBase > MakeExitTask() const override
Factory function for an exit task (ExitTaskBase). Override to define the desired deinitialization tas...
Util::FeatureTester< WaveformCapsType > GetWaveformCaps() const
Returns the waveform types the function generator is able to produce.
virtual void SetRectFunction(const FunctionGeneratorDefs::RectFunctionDescType &FunctionDesc, bool PersistParams=false, bool Autostart=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Generates a rectangular function.
FunctionGeneratorDefs::FunctionDescType GetMinCaps() const
Returns the minimal values assignable to a description of a generic periodic function.
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::string GetName() const override
Returns the name of this Object type.
virtual void SetTriggerChild(const FunctionGeneratorDefs::TriggerDescType &TriggerDesc, bool PersistParams, DynExp::TaskBase::CallbackType CallbackFunc) const
SetTrigger() configures the function generator's trigger, which determines when the waveform generati...
virtual void SetSweep(const FunctionGeneratorDefs::SweepDescType &SweepDesc, bool PersistParams=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Configures the function generator to perform a sweep.
virtual void SetPulseFunction(const FunctionGeneratorDefs::PulsesDescType &FunctionDesc, bool PersistParams=false, bool Autostart=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Generates a function consisting of pulse segments.
TriggerCapsType
Type enumerating trigger features the function generator might be capable of (in hardware).
@ NUM_ELEMENTS
Must be last. Refer to Util::FeatureTester.
@ CanForce
Triggering can be forced (executed by the software).
@ CanConfigure
Trigger settings can be adjusted by the software.
virtual Util::FeatureTester< QuantityCapsType > GetSweepCapsChild() const
Returns the sweep types the function generator is capable of.
constexpr static auto Category() noexcept
Every derived class has to redefine this function.
FunctionGeneratorDefs::FunctionDescType GetMaxCaps() const
Returns the maximal values assignable to a description of a generic periodic function.
virtual FunctionGeneratorDefs::FunctionDescType GetMinCapsChild() const
Returns the minimal values assignable to a description of a generic periodic function.
virtual std::unique_ptr< DynExp::InitTaskBase > MakeInitTask() const override
Factory function for an init task (InitTaskBase). Override to define the desired initialization task ...
Util::FeatureTester< QuantityCapsType > GetSweepCaps() const
Returns the sweep types the function generator is capable of.
virtual void SetSineFunction(const FunctionGeneratorDefs::SineFunctionDescType &FunctionDesc, bool PersistParams=false, bool Autostart=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Generates a sine function.
virtual void ForceTrigger(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Forces the generation of the waveform ignoring the trigger.
Util::FeatureTester< TriggerCapsType > GetTriggerCaps() const
Returns the trigger features the function generator is capable of.
virtual Util::FeatureTester< WaveformCapsType > GetWaveformCapsChild() const =0
Returns the waveform types the function generator is able to produce.
virtual Util::FeatureTester< TriggerCapsType > GetTriggerCapsChild() const
Returns the trigger features the function generator is capable of.
virtual void SetArbitraryFunction(DataStreamBase::BasicSampleListType &&Samples, bool Autostart=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Generates an arbitrary function defined by the function samples.
constexpr static auto Name() noexcept
Every derived class has to redefine this function.
Util::FeatureTester< QuantityCapsType > GetModulationCaps() const
Returns the modulation types the function generator is capable of.
void SetTrigger(const FunctionGeneratorDefs::TriggerDescType &TriggerDesc, bool PersistParams=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
SetTrigger() configures the function generator's trigger, which determines when the waveform generati...
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition: DynExpCore.h:127
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
Definition: Instrument.h:1144
Refer to DynExp::ParamsBase::dispatch_tag.
Definition: Instrument.h:1151
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
Definition: Instrument.h:1113
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 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
Defines a task for updating an instrument within an instrument inheritance hierarchy....
Definition: Instrument.h:1175
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
double RectFunc(double DutyCycle, double Phase)
Calculates the value of a rectangular function depending on the current Phase.
constexpr Util::seconds PeriodFromFunctionDesc(const FunctionDescType &FunctionDesc)
Calculates the period from the given function description.
double InvRectFunc(double DutyCycle, double Phase)
Calculates the value of an inverse rectangular function depending on the current Phase.
constexpr FunctionDescType GetDefaultMinFunctionDesc()
Determines minimal values assignable to a description of a generic periodic function.
WaveformTypes
Type to determine the waveform type.
@ Pulse
Manually defined pulses.
@ None
Unspecified/arbitrary waveform.
double RampFunc(double RiseFallRatio, double Phase)
Calculates the value of a ramp function depending on the current Phase.
constexpr FunctionDescType GetDefaultMaxFunctionDesc()
Determines maximal values assignable to a description of a generic periodic function.
constexpr FunctionDescType GetDefaultDefaultFunctionDesc()
Determines default values to assign to a description of a generic periodic function.
@ Rise
Trigger on rising edge.
@ Continuous
Run continuously disabling the trigger.
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
Definition: Instrument.h:1254
DataStreamPtrType< DataStreamBase > DataStreamBasePtrType
Type of a pointer owning a DataStreamBase instance.
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 > seconds
Extends std::chrono by a duration data type for seconds capable of storing fractions of seconds.
Definition: Util.h:761
Accumulates include statements to provide a precompiled header.
Type describing a generic periodic function.
double Offset
Offset of the function to be added to each sample.
double FrequencyInHz
Frequency of the function in Hz.
Type describing modulation parameters for a waveform.
ModulationShapeType
Type to determine the shape of the modulation.
@ Pulse
Pulse (binary) modulation switching the affected quantity between two values.
double PulseDutyCycle
Duty cycle (in between 0 and 1) of the pulses in case of binary modulation (Shape is ModulationShapeT...
double Depth
Depth (amplitude) of the modulation.
ModulationShapeType Shape
Shape of the modulation.
ModulationType
Type to determine the modulation type.
@ Frequency
Modulation affecting the waveform's frequency.
@ Amplitude
Modulation affecting the waveform's amplitude.
double FrequencyInHz
Frequency of the modulation in Hz.
Type describing function consisting of a series of pulses.
void Reset()
Removes all pulse segments from Pulses.
double Offset
Offset of the function to be added to each sample.
PulsesDescType & operator=(PulsesDescType &&Other)
Move assignment operator. Reset() is called on Other after the operation.
PulsesType Pulses
Series of segments forming the pulse sequence. The resulting function stays constant during a segment...
PulsesDescType(const PulsesDescType &Other)
Copy constructs a PulsesDescType instance.
std::map< double, double > PulsesType
Type containing pulses as tuples (time [s], value). The time refers to the beginning of a segment whe...
PulsesDescType(const PulsesType &Pulses)
Constructs a PulsesDescType instance copying Pulses and setting Offset to 0.
double PhaseInRad
Phase of the function in radians.
double RiseFallRatio
Ratio between the ramp's falling and rising edge lengths (in between 0 and 1)
double PhaseInRad
Phase of the function in radians.
double DutyCycle
Duty cycle of the function (in between 0 and 1)
double PhaseInRad
Phase of the function in radians.
Type describing sweep parameters for a waveform.
double Max
Maximal value where the sweep ends.
bool Retrace
If true, retraces the sweep going back to its start value after its end has been reached.
double Min
Minimal value where the sweep starts.
double TimeDiffPerSample_ms
Time per sweep sample in milliseconds.
double ValueDiffPerSample
Value difference in between subsequent samples of the sweep.
Type describing trigger parameters determining when the waveform is generated.
TriggerEdgeType
Type to determine at which edge of a trigger signal to trigger. Not a strongly-typed enum to allow us...
TriggerEdgeType TriggerEdge
Edge to trigger on.
TriggerModeType
Type to determine the trigger mode. Not a strongly-typed enum to allow using the enumeration in a Dyn...
@ ExternStep
Advance by a single (sweep) sample after an external trigger signal has been detected.
@ Continuous
Run continuously disabling the trigger.
@ ExternSingle
Run once after an external trigger signal has been detected.