DynExp
Highly flexible laboratory automation for dynamically changing experiments.
RS_SMB100B.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_SMB100B;
18 
19  namespace RS_SMB100BTasks
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_SMB100BData(size_t BufferSizeInSamples = 0) : FunctionGeneratorData(std::make_unique<BasicSampleStream>(BufferSizeInSamples)) {}
123  virtual ~RS_SMB100BData() = 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_SMB100BParams() = default;
144 
145  virtual const char* GetParamClassTag() const noexcept override { return "RS_SMB100BParams"; }
146 
148  "HardwareAdapter", "R&S SMB100B controller", "Underlying hardware adapter of this instrument", DynExpUI::Icons::HardwareAdapter };
149 
150  private:
153  };
154 
156  {
157  public:
160 
162  virtual ~RS_SMB100BConfigurator() = default;
163 
164  private:
165  virtual DynExp::ParamsBasePtrType MakeParams(DynExp::ItemIDType ID, const DynExp::DynExpCore& Core) const override { return DynExp::MakeParams<RS_SMB100BConfigurator>(ID, Core); }
166  };
167 
169  {
170  public:
174 
176 
177  constexpr static auto Name() noexcept { return "R&S SMB100B"; }
178 
179  RS_SMB100B(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType&& Params);
180  virtual ~RS_SMB100B() {}
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_SMB100BTasks::StartTask>(CallbackFunc); }
190  virtual void Stop(DynExp::TaskBase::CallbackType CallbackFunc = nullptr) const override { MakeAndEnqueueTask<RS_SMB100BTasks::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, -145, 0 }; }
208  virtual FunctionGeneratorDefs::FunctionDescType GetMaxCapsChild() const override { return { 6e9, 36, 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_SMB100BTasks::InitTask>(); }
219  virtual std::unique_ptr<DynExp::ExitTaskBase> MakeExitTask() const override { return DynExp::MakeTask<RS_SMB100BTasks::ExitTask>(); }
220  virtual std::unique_ptr<DynExp::UpdateTaskBase> MakeUpdateTask() const override { return DynExp::MakeTask<RS_SMB100BTasks::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 ~RS_SMB100BConfigurator()=default
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_SMB100B.h:165
virtual void ResetImpl(dispatch_tag< RS_SMB100BData >)
Definition: RS_SMB100B.h:132
void ResetImpl(dispatch_tag< FunctionGeneratorData >) override final
Definition: RS_SMB100B.cpp:271
virtual ~RS_SMB100BData()=default
DynExp::LinkedObjectWrapperContainer< DynExp::SerialCommunicationHardwareAdapter > HardwareAdapter
Definition: RS_SMB100B.h:128
FunctionGeneratorDefs::SweepDescType::SweepType CurrentSweepType
Definition: RS_SMB100B.h:136
bool IsRunning() const noexcept
Definition: RS_SMB100B.h:125
RS_SMB100BData(size_t BufferSizeInSamples=0)
Definition: RS_SMB100B.h:122
auto GetCurrentSweepType() const noexcept
Definition: RS_SMB100B.h:126
Param< DynExp::ObjectLink< DynExp::SerialCommunicationHardwareAdapter > > HardwareAdapter
Definition: RS_SMB100B.h:147
void ConfigureParamsImpl(dispatch_tag< FunctionGeneratorParams >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition: RS_SMB100B.h:151
virtual ~RS_SMB100BParams()=default
RS_SMB100BParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Definition: RS_SMB100B.h:142
virtual void ConfigureParamsImpl(dispatch_tag< RS_SMB100BParams >)
Definition: RS_SMB100B.h:152
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_SMB100B.h:145
virtual void ExitFuncImpl(dispatch_tag< ExitTask >, DynExp::InstrumentInstance &Instance)
Definition: RS_SMB100B.h:30
void ExitFuncImpl(dispatch_tag< FunctionGeneratorTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
Definition: RS_SMB100B.cpp:18
ForceTriggerTask(CallbackType CallbackFunc) noexcept
Definition: RS_SMB100B.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_SMB100B.cpp:218
void InitFuncImpl(dispatch_tag< FunctionGeneratorTasks::InitTask >, DynExp::InstrumentInstance &Instance) override final
Initializes the respective instrument within the instrument inheritance hierarchy....
Definition: RS_SMB100B.cpp:8
virtual void InitFuncImpl(dispatch_tag< InitTask >, DynExp::InstrumentInstance &Instance)
Definition: RS_SMB100B.h:24
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_SMB100B.cpp:102
FunctionGeneratorDefs::ModulationDescType ModulationDesc
Definition: RS_SMB100B.h:79
SetModulationTask(const FunctionGeneratorDefs::ModulationDescType &ModulationDesc, CallbackType CallbackFunc) noexcept
Definition: RS_SMB100B.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_SMB100B.cpp:87
SetSineFunctionTask(const FunctionGeneratorDefs::SineFunctionDescType &FunctionDesc, bool Autostart, CallbackType CallbackFunc) noexcept
Definition: RS_SMB100B.h:60
FunctionGeneratorDefs::SineFunctionDescType FunctionDesc
Definition: RS_SMB100B.h:66
SetSweepTask(const FunctionGeneratorDefs::SweepDescType &SweepDesc, CallbackType CallbackFunc) noexcept
Definition: RS_SMB100B.h:85
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_SMB100B.cpp:163
FunctionGeneratorDefs::SweepDescType SweepDesc
Definition: RS_SMB100B.h:91
FunctionGeneratorDefs::TriggerDescType TriggerDesc
Definition: RS_SMB100B.h:112
SetTriggerTask(const FunctionGeneratorDefs::TriggerDescType &TriggerDesc, CallbackType CallbackFunc) noexcept
Definition: RS_SMB100B.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_SMB100B.cpp:242
StartTask(CallbackType CallbackFunc) noexcept
Definition: RS_SMB100B.h:42
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_SMB100B.cpp:69
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_SMB100B.cpp:78
StopTask(CallbackType CallbackFunc) noexcept
Definition: RS_SMB100B.h:51
void UpdateFuncImpl(dispatch_tag< FunctionGeneratorTasks::UpdateTask >, DynExp::InstrumentInstance &Instance) override final
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
Definition: RS_SMB100B.cpp:27
virtual void UpdateFuncImpl(dispatch_tag< UpdateTask >, DynExp::InstrumentInstance &Instance)
Definition: RS_SMB100B.h:36
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_SMB100B.cpp:344
constexpr static auto Name() noexcept
Definition: RS_SMB100B.h:177
virtual FunctionGeneratorDefs::FunctionDescType GetMaxCapsChild() const override
Returns the maximal values assignable to a description of a generic periodic function.
Definition: RS_SMB100B.h:208
RS_SMB100B(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Definition: RS_SMB100B.cpp:292
virtual Util::OptionalBool IsRunning() const override
Determines whether the underlying hardware adapter is running a data acquisition or writing data.
Definition: RS_SMB100B.cpp:332
virtual DataStreamInstrumentData::UnitType GetValueUnit() const noexcept override
Determines which unit corresponds to the values managed by this DataStreamInstrument instance....
Definition: RS_SMB100B.h:185
virtual FunctionGeneratorDefs::FunctionDescType GetMinCapsChild() const override
Returns the minimal values assignable to a description of a generic periodic function.
Definition: RS_SMB100B.h:207
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_SMB100B.cpp:297
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_SMB100B.h:190
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_SMB100B.h:189
virtual void ForceTrigger(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Forces the generation of the waveform ignoring the trigger.
Definition: RS_SMB100B.cpp:327
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_SMB100B.h:220
virtual Util::FeatureTester< TriggerCapsType > GetTriggerCapsChild() const override
Returns the trigger features the function generator is capable of.
Definition: RS_SMB100B.h:213
virtual void ResetImpl(dispatch_tag< RS_SMB100B >)
Definition: RS_SMB100B.h:205
virtual FunctionGeneratorDefs::FunctionDescType GetParamDefaultsChild() const override
Returns the default values to assign to a description of a generic periodic function.
Definition: RS_SMB100B.h:209
virtual bool IsPhaseAdjustable() const noexcept override
Determines whether the function generator has the capability to set the phase of the generated wavefo...
Definition: RS_SMB100B.h:186
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_SMB100B.h:219
virtual Util::FeatureTester< QuantityCapsType > GetModulationCapsChild() const override
Returns the modulation types the function generator is capable of.
Definition: RS_SMB100B.h:211
virtual Util::FeatureTester< QuantityCapsType > GetSweepCapsChild() const override
Returns the sweep types the function generator is capable of.
Definition: RS_SMB100B.h:212
virtual Util::FeatureTester< WaveformCapsType > GetWaveformCapsChild() const override
Returns the waveform types the function generator is able to produce.
Definition: RS_SMB100B.h:210
virtual std::chrono::milliseconds GetTaskQueueDelay() const override
Specifies in which time intervals the instrument's task queue runs to handle pending tasks.
Definition: RS_SMB100B.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_SMB100B.cpp:321
static const char * TriggerModeToCmdString(FunctionGeneratorDefs::TriggerDescType::TriggerModeType TriggerMode) noexcept
Definition: RS_SMB100B.cpp:280
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_SMB100B.cpp:339
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_SMB100B.cpp:315
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_SMB100B.h:218
virtual std::string GetName() const override
Returns the name of this Object type.
Definition: RS_SMB100B.h:182
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...