DynExp
Highly flexible laboratory automation for dynamically changing experiments.
RS_SMC100A.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"
14 
15 namespace DynExpInstr
16 {
17  class RS_SMC100A;
18 
19  namespace RS_SMC100ATasks
20  {
22  {
25  };
26 
28  {
31  };
32 
34  {
37  };
38 
39  class StartTask : public DynExp::TaskBase
40  {
41  public:
43 
44  private:
46  };
47 
48  class StopTask : public DynExp::TaskBase
49  {
50  public:
52 
53  private:
55  };
56 
58  {
59  public:
62 
63  private:
65 
67  bool Autostart;
68  };
69 
71  {
72  public:
75 
76  private:
78 
80  };
81 
83  {
84  public:
87 
88  private:
90 
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  }
115 
117  {
120 
121  public:
122  RS_SMC100AData(size_t BufferSizeInSamples = 0) : FunctionGeneratorData(std::make_unique<BasicSampleStream>(BufferSizeInSamples)) {}
123  virtual ~RS_SMC100AData() = default;
124 
125  bool IsRunning() const noexcept { return Running; }
126  auto GetCurrentSweepType() const noexcept { return CurrentSweepType; }
127 
129 
130  private:
131  void ResetImpl(dispatch_tag<FunctionGeneratorData>) override final;
133 
135  bool Running = false;
137  };
138 
140  {
141  public:
143  virtual ~RS_SMC100AParams() = default;
144 
145  virtual const char* GetParamClassTag() const noexcept override { return "RS_SMC100AParams"; }
146 
148  "HardwareAdapter", "R&S SMC100A controller", "Underlying hardware adapter of this instrument", DynExpUI::Icons::HardwareAdapter };
149 
150  private:
153  };
154 
156  {
157  public:
160 
162  virtual ~RS_SMC100AConfigurator() = default;
163 
164  private:
165  virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override { return DynExp::MakeParams<RS_SMC100AConfigurator>(ID, Core); }
166  };
167 
169  {
170  public:
174 
176 
177  constexpr static auto Name() noexcept { return "R&S SMC100A"; }
178 
179  RS_SMC100A(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType&& Params);
180  virtual ~RS_SMC100A() {}
181 
182  virtual std::string GetName() const override { return Name(); }
183 
184  virtual std::chrono::milliseconds GetTaskQueueDelay() const override { return std::chrono::milliseconds(100); }
186  virtual bool IsPhaseAdjustable() const noexcept override { return false; }
187 
188  // Tasks
189  virtual void Start(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<RS_SMC100ATasks::StartTask>(CallbackFunc); }
190  virtual void Stop(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<RS_SMC100ATasks::StopTask>(CallbackFunc); }
191 
192  virtual void SetSineFunction(const FunctionGeneratorDefs::SineFunctionDescType& FunctionDesc,
193  bool PersistParams = false, bool Autostart = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override;
194  virtual void SetModulation(const FunctionGeneratorDefs::ModulationDescType& ModulationDesc,
195  bool PersistParams = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override;
196  virtual void SetSweep(const FunctionGeneratorDefs::SweepDescType& SweepDesc,
197  bool PersistParams = false, DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override;
198  virtual void ForceTrigger(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override;
199 
200  // Functions giving information about the instrument.
201  virtual Util::OptionalBool IsRunning() const override;
202 
203  private:
204  void ResetImpl(dispatch_tag<FunctionGenerator>) override final;
206 
207  virtual FunctionGeneratorDefs::FunctionDescType GetMinCapsChild() const override { return { 8e3, -120, 0 }; }
208  virtual FunctionGeneratorDefs::FunctionDescType GetMaxCapsChild() const override { return { 3.2e9, 19, 0}; }
209  virtual FunctionGeneratorDefs::FunctionDescType GetParamDefaultsChild() const override { return { 2.87e9, -10, 0}; }
210  virtual Util::FeatureTester<WaveformCapsType> GetWaveformCapsChild() const override { return std::array{ WaveformCapsType::Sine }; }
214 
215  virtual void SetTriggerChild(const FunctionGeneratorDefs::TriggerDescType& TriggerDesc,
216  bool PersistParams, DynExp::TaskBase::CallbackType CallbackFunc) const override;
217 
218  virtual std::unique_ptr<DynExp::InitTaskBase> MakeInitTask() const override { return DynExp::MakeTask<RS_SMC100ATasks::InitTask>(); }
219  virtual std::unique_ptr<DynExp::ExitTaskBase> MakeExitTask() const override { return DynExp::MakeTask<RS_SMC100ATasks::ExitTask>(); }
220  virtual std::unique_ptr<DynExp::UpdateTaskBase> MakeUpdateTask() const override { return DynExp::MakeTask<RS_SMC100ATasks::UpdateTask>(); }
221  };
222 }
Defines DynExp's core module as an interface between the UI and DynExp objects.
Implementation of a function generator meta instrument to generate waveforms.
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.
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: RS_SMC100A.h:165
virtual ~RS_SMC100AConfigurator()=default
auto GetCurrentSweepType() const noexcept
Definition: RS_SMC100A.h:126
DynExp::LinkedObjectWrapperContainer< DynExp::SerialCommunicationHardwareAdapter > HardwareAdapter
Definition: RS_SMC100A.h:128
FunctionGeneratorDefs::SweepDescType::SweepType CurrentSweepType
Definition: RS_SMC100A.h:136
virtual void ResetImpl(dispatch_tag< RS_SMC100AData >)
Definition: RS_SMC100A.h:132
RS_SMC100AData(size_t BufferSizeInSamples=0)
Definition: RS_SMC100A.h:122
virtual ~RS_SMC100AData()=default
void ResetImpl(dispatch_tag< FunctionGeneratorData >) override final
Definition: RS_SMC100A.cpp:268
bool IsRunning() const noexcept
Definition: RS_SMC100A.h:125
virtual void ConfigureParamsImpl(dispatch_tag< RS_SMC100AParams >)
Definition: RS_SMC100A.h:152
void ConfigureParamsImpl(dispatch_tag< FunctionGeneratorParams >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition: RS_SMC100A.h:151
virtual ~RS_SMC100AParams()=default
RS_SMC100AParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Definition: RS_SMC100A.h:142
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: RS_SMC100A.h:145
Param< DynExp::ObjectLink< DynExp::SerialCommunicationHardwareAdapter > > HardwareAdapter
Definition: RS_SMC100A.h:147
void ExitFuncImpl(dispatch_tag< FunctionGeneratorTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
Definition: RS_SMC100A.cpp:18
virtual void ExitFuncImpl(dispatch_tag< ExitTask >, DynExp::InstrumentInstance &Instance)
Definition: RS_SMC100A.h:30
ForceTriggerTask(CallbackType CallbackFunc) noexcept
Definition: RS_SMC100A.h:97
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...
Definition: RS_SMC100A.cpp:215
virtual void InitFuncImpl(dispatch_tag< InitTask >, DynExp::InstrumentInstance &Instance)
Definition: RS_SMC100A.h:24
void InitFuncImpl(dispatch_tag< FunctionGeneratorTasks::InitTask >, DynExp::InstrumentInstance &Instance) override final
Initializes the respective instrument within the instrument inheritance hierarchy....
Definition: RS_SMC100A.cpp:8
SetModulationTask(const FunctionGeneratorDefs::ModulationDescType &ModulationDesc, CallbackType CallbackFunc) noexcept
Definition: RS_SMC100A.h:73
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...
Definition: RS_SMC100A.cpp:102
FunctionGeneratorDefs::ModulationDescType ModulationDesc
Definition: RS_SMC100A.h:79
FunctionGeneratorDefs::SineFunctionDescType FunctionDesc
Definition: RS_SMC100A.h:66
SetSineFunctionTask(const FunctionGeneratorDefs::SineFunctionDescType &FunctionDesc, bool Autostart, CallbackType CallbackFunc) noexcept
Definition: RS_SMC100A.h:60
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...
Definition: RS_SMC100A.cpp:87
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...
Definition: RS_SMC100A.cpp:160
SetSweepTask(const FunctionGeneratorDefs::SweepDescType &SweepDesc, CallbackType CallbackFunc) noexcept
Definition: RS_SMC100A.h:85
FunctionGeneratorDefs::SweepDescType SweepDesc
Definition: RS_SMC100A.h:91
FunctionGeneratorDefs::TriggerDescType TriggerDesc
Definition: RS_SMC100A.h:112
SetTriggerTask(const FunctionGeneratorDefs::TriggerDescType &TriggerDesc, CallbackType CallbackFunc) noexcept
Definition: RS_SMC100A.h:106
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...
Definition: RS_SMC100A.cpp:239
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...
Definition: RS_SMC100A.cpp:69
StartTask(CallbackType CallbackFunc) noexcept
Definition: RS_SMC100A.h:42
StopTask(CallbackType CallbackFunc) noexcept
Definition: RS_SMC100A.h:51
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...
Definition: RS_SMC100A.cpp:78
void UpdateFuncImpl(dispatch_tag< FunctionGeneratorTasks::UpdateTask >, DynExp::InstrumentInstance &Instance) override final
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
Definition: RS_SMC100A.cpp:27
virtual void UpdateFuncImpl(dispatch_tag< UpdateTask >, DynExp::InstrumentInstance &Instance)
Definition: RS_SMC100A.h:36
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.
Definition: RS_SMC100A.h:190
virtual Util::OptionalBool IsRunning() const override
Determines whether the underlying hardware adapter is running a data acquisition or writing data.
Definition: RS_SMC100A.cpp:329
void ResetImpl(dispatch_tag< FunctionGenerator >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
Definition: RS_SMC100A.cpp:336
virtual std::unique_ptr< DynExp::InitTaskBase > MakeInitTask() const override
Factory function for an init task (InitTaskBase). Override to define the desired initialization task ...
Definition: RS_SMC100A.h:218
RS_SMC100A(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Definition: RS_SMC100A.cpp:289
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...
Definition: RS_SMC100A.cpp:341
virtual Util::FeatureTester< QuantityCapsType > GetSweepCapsChild() const override
Returns the sweep types the function generator is capable of.
Definition: RS_SMC100A.h:212
virtual std::chrono::milliseconds GetTaskQueueDelay() const override
Specifies in which time intervals the instrument's task queue runs to handle pending tasks.
Definition: RS_SMC100A.h:184
virtual void SetSweep(const FunctionGeneratorDefs::SweepDescType &SweepDesc, bool PersistParams=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Configures the function generator to perform a sweep.
Definition: RS_SMC100A.cpp:318
virtual void SetSineFunction(const FunctionGeneratorDefs::SineFunctionDescType &FunctionDesc, bool PersistParams=false, bool Autostart=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Generates a sine function.
Definition: RS_SMC100A.cpp:294
virtual bool IsPhaseAdjustable() const noexcept override
Determines whether the function generator has the capability to set the phase of the generated wavefo...
Definition: RS_SMC100A.h:186
virtual void ForceTrigger(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Forces the generation of the waveform ignoring the trigger.
Definition: RS_SMC100A.cpp:324
virtual FunctionGeneratorDefs::FunctionDescType GetMaxCapsChild() const override
Returns the maximal values assignable to a description of a generic periodic function.
Definition: RS_SMC100A.h:208
static const char * TriggerModeToCmdString(FunctionGeneratorDefs::TriggerDescType::TriggerModeType TriggerMode) noexcept
Definition: RS_SMC100A.cpp:277
virtual Util::FeatureTester< WaveformCapsType > GetWaveformCapsChild() const override
Returns the waveform types the function generator is able to produce.
Definition: RS_SMC100A.h:210
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: RS_SMC100A.h:220
virtual void ResetImpl(dispatch_tag< RS_SMC100A >)
Definition: RS_SMC100A.h:205
virtual std::unique_ptr< DynExp::ExitTaskBase > MakeExitTask() const override
Factory function for an exit task (ExitTaskBase). Override to define the desired deinitialization tas...
Definition: RS_SMC100A.h:219
virtual FunctionGeneratorDefs::FunctionDescType GetMinCapsChild() const override
Returns the minimal values assignable to a description of a generic periodic function.
Definition: RS_SMC100A.h:207
virtual std::string GetName() const override
Returns the name of this Object type.
Definition: RS_SMC100A.h:182
virtual void SetModulation(const FunctionGeneratorDefs::ModulationDescType &ModulationDesc, bool PersistParams=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Configures the function generator to perform a modulation.
Definition: RS_SMC100A.cpp:312
virtual Util::FeatureTester< QuantityCapsType > GetModulationCapsChild() const override
Returns the modulation types the function generator is capable of.
Definition: RS_SMC100A.h:211
constexpr static auto Name() noexcept
Definition: RS_SMC100A.h:177
virtual DataStreamInstrumentData::UnitType GetValueUnit() const noexcept override
Determines which unit corresponds to the values managed by this DataStreamInstrument instance....
Definition: RS_SMC100A.h:185
virtual FunctionGeneratorDefs::FunctionDescType GetParamDefaultsChild() const override
Returns the default values to assign to a description of a generic periodic function.
Definition: RS_SMC100A.h:209
virtual Util::FeatureTester< TriggerCapsType > GetTriggerCapsChild() const override
Returns the trigger features the function generator is capable of.
Definition: RS_SMC100A.h:213
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.
Definition: RS_SMC100A.h:189
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
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.
Type describing a generic periodic function.
Type describing modulation parameters for a waveform.
Type describing sweep parameters for a waveform.
Type describing trigger parameters determining when the waveform is generated.
TriggerModeType
Type to determine the trigger mode. Not a strongly-typed enum to allow using the enumeration in a Dyn...