10 auto InstrParams = DynExp::dynamic_Params_cast<RS_SMB100B>(Instance.
ParamsGetter());
11 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
13 Instance.
LockObject(InstrParams->HardwareAdapter, InstrData->HardwareAdapter);
22 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
31 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
32 bool UpdateError =
false;
36 *InstrData->HardwareAdapter <<
"OUTPut1:STATe?";
37 InstrData->Running = InstrData->HardwareAdapter->WaitForLine(3) ==
"1";
44 if (InstrData->NumFailedStatusUpdateAttempts++ >= 3)
49 InstrData->NumFailedStatusUpdateAttempts = 0;
71 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
73 *InstrData->HardwareAdapter <<
"OUTPut1:STATe ON";
80 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
82 *InstrData->HardwareAdapter <<
"OUTPut1:STATe OFF";
89 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
91 *InstrData->HardwareAdapter <<
"SOURce1:FREQuency:MODE CW";
92 *InstrData->HardwareAdapter <<
"SOURce1:FREQuency:CW " +
Util::ToStr(FunctionDesc.FrequencyInHz);
93 *InstrData->HardwareAdapter <<
"SOURce1:POWer:MODE CW";
94 *InstrData->HardwareAdapter <<
"SOURce1:POWer:POWer " +
Util::ToStr(FunctionDesc.Amplitude);
97 InstrData->EnqueueTask(DynExp::MakeTask<RS_SMB100BTasks::StartTask>(
nullptr));
104 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
109 *InstrData->HardwareAdapter << std::string(
"SOURce1:LFOutput1:SHAPe SINE");
110 *InstrData->HardwareAdapter << std::string(
"SOURce1:LFOutput1:FREQuency ")
111 +
Util::ToStr(ModulationDesc.FrequencyInHz, 0) +
" Hz";
116 *InstrData->HardwareAdapter << std::string(
"SOURce1:LFOutput1:SHAPe PULSe");
117 *InstrData->HardwareAdapter << std::string(
"SOURce1:LFOutput1:SHAPe:PULSe:PERiod ")
118 +
Util::ToStr(1 / ModulationDesc.FrequencyInHz, 8) +
" s";
119 *InstrData->HardwareAdapter << std::string(
"SOURce1:LFOutput1:SHAPe:PULSe:DCYCle ")
120 +
Util::ToStr(ModulationDesc.PulseDutyCycle * 100, 3);
125 *InstrData->HardwareAdapter << std::string(
"SOURce1:FM1:SOURce LF1");
126 *InstrData->HardwareAdapter << std::string(
"SOURce1:FM1:DEViation ")
129 *InstrData->HardwareAdapter <<
"SOURce1:AM1:STATe 0";
130 *InstrData->HardwareAdapter <<
"SOURce1:PM1:STATe 0";
131 *InstrData->HardwareAdapter <<
"SOURce1:FM1:STATe 1";
135 *InstrData->HardwareAdapter << std::string(
"SOURce1:AM1:SOURce LF1");
136 *InstrData->HardwareAdapter << std::string(
"SOURce1:AM1:DEPTh ")
139 *InstrData->HardwareAdapter <<
"SOURce1:FM1:STATe 0";
140 *InstrData->HardwareAdapter <<
"SOURce1:PM1:STATe 0";
141 *InstrData->HardwareAdapter <<
"SOURce1:AM1:STATe 1";
145 *InstrData->HardwareAdapter << std::string(
"SOURce1:PM1:SOURce LF1");
146 *InstrData->HardwareAdapter << std::string(
"SOURce1:PM1:DEViation ")
149 *InstrData->HardwareAdapter <<
"SOURce1:AM1:STATe 0";
150 *InstrData->HardwareAdapter <<
"SOURce1:FM1:STATe 0";
151 *InstrData->HardwareAdapter <<
"SOURce1:PM1:STATe 1";
155 *InstrData->HardwareAdapter <<
"SOURce1:AM1:STATe 0";
156 *InstrData->HardwareAdapter <<
"SOURce1:FM1:STATe 0";
157 *InstrData->HardwareAdapter <<
"SOURce1:PM1:STATe 0";
165 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
169 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:RETRace ")
170 + (SweepDesc.Retrace ?
"1" :
"0");
171 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:DWELl ")
172 +
Util::ToStr(SweepDesc.TimeDiffPerSample_ms, 3) +
" ms";
173 *InstrData->HardwareAdapter << std::string(
"SOURce1:FREQuency:STARt ")
175 *InstrData->HardwareAdapter << std::string(
"SOURce1:FREQuency:STOP ")
177 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:SPACing LINear");
178 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:SHAPe SAWTooth");
179 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:STEP:LINear ")
180 +
Util::ToStr(SweepDesc.ValueDiffPerSample, 0) +
" Hz";
182 *InstrData->HardwareAdapter <<
"SOURce1:POWer:MODE CW";
183 *InstrData->HardwareAdapter <<
"SOURce1:FREQuency:MODE SWEep";
189 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:POWer:RETRace ")
190 + (SweepDesc.Retrace ?
"1" :
"0");
191 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:POWer:DWELl ")
192 +
Util::ToStr(SweepDesc.TimeDiffPerSample_ms, 3) +
" ms";
193 *InstrData->HardwareAdapter << std::string(
"SOURce1:POWer:STARt ")
195 *InstrData->HardwareAdapter << std::string(
"SOURce1:POWer:STOP ")
197 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:POWer:SPACing LINear");
198 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:POWer:SHAPe SAWTooth");
199 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:POWer:STEP ")
200 +
Util::ToStr(SweepDesc.ValueDiffPerSample, 2) +
" dB";
202 *InstrData->HardwareAdapter <<
"SOURce1:FREQuency:MODE CW";
203 *InstrData->HardwareAdapter <<
"SOURce1:POWer:MODE SWEep";
209 *InstrData->HardwareAdapter <<
"SOURce1:FREQuency:MODE CW";
210 *InstrData->HardwareAdapter <<
"SOURce1:POWer:MODE CW";
220 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
224 *InstrData->HardwareAdapter << std::string(
"TRIGger1:FSWeep:SOURce ")
226 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:FREQuency:MODE AUTO";
228 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:FREQuency:EXECute";
232 *InstrData->HardwareAdapter << std::string(
"TRIGger1:PSWeep:SOURce ")
234 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:POWer:MODE AUTO";
236 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:POWer:EXECute";
244 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(Instance.
InstrumentDataGetter());
248 *InstrData->HardwareAdapter << std::string(
"TRIGger1:FSWeep:SOURce ")
250 if (TriggerDesc.TriggerMode == FunctionGeneratorDefs::TriggerDescType::TriggerModeType::ExternStep)
251 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:FREQuency:MODE STEP";
253 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:FREQuency:MODE AUTO";
257 *InstrData->HardwareAdapter << std::string(
"TRIGger1:PSWeep:SOURce ")
259 if (TriggerDesc.TriggerMode == FunctionGeneratorDefs::TriggerDescType::TriggerModeType::ExternStep)
260 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:POWer:MODE STEP";
262 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:POWer:MODE AUTO";
265 *InstrData->HardwareAdapter << std::string(
"SOURce:INPut:TRIGger:SLOPe ") +
273 NumFailedStatusUpdateAttempts = 0;
286 case FunctionGeneratorDefs::TriggerDescType::TriggerModeType::ExternStep:
return "EXTernal";
287 case FunctionGeneratorDefs::TriggerDescType::TriggerModeType::Manual:
return "SINGle";
302 auto InstrParams = DynExp::dynamic_Params_cast<FunctionGenerator>(
GetNonConstParams());
305 InstrParams->Amplitude = FunctionDesc.
Amplitude;
306 InstrParams->Offset = 0;
307 InstrParams->PhaseInRad = FunctionDesc.
PhaseInRad;
308 InstrParams->DutyCycle = 0;
309 InstrParams->Autostart = Autostart;
312 MakeAndEnqueueTask<RS_SMB100BTasks::SetSineFunctionTask>(FunctionDesc, Autostart, CallbackFunc);
318 MakeAndEnqueueTask<RS_SMB100BTasks::SetModulationTask>(ModulationDesc, CallbackFunc);
324 MakeAndEnqueueTask<RS_SMB100BTasks::SetSweepTask>(SweepDesc, CallbackFunc);
329 MakeAndEnqueueTask<RS_SMB100BTasks::ForceTriggerTask>(CallbackFunc);
334 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMB100B>(
GetInstrumentData());
336 return InstrData->IsRunning();
347 MakeAndEnqueueTask<RS_SMB100BTasks::SetTriggerTask>(TriggerDesc, CallbackFunc);
Implementation of an instrument to control the Rohde & Schwarz SMB100B function generator.
Function generator meta instrument based on the data stream meta instrument to generate waveforms by ...
void ResetImpl(dispatch_tag< FunctionGeneratorData >) override final
void ExitFuncImpl(dispatch_tag< FunctionGeneratorTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes 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...
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...
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...
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 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...
RS_SMB100B(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
virtual Util::OptionalBool IsRunning() const override
Determines whether the underlying hardware adapter is running a data acquisition or writing data.
virtual void SetSineFunction(const FunctionGeneratorDefs::SineFunctionDescType &FunctionDesc, bool PersistParams=false, bool Autostart=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Generates a sine function.
virtual void ForceTrigger(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Forces the generation of the waveform ignoring the trigger.
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.
static const char * TriggerModeToCmdString(FunctionGeneratorDefs::TriggerDescType::TriggerModeType TriggerMode) noexcept
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 SetModulation(const FunctionGeneratorDefs::ModulationDescType &ModulationDesc, bool PersistParams=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Configures the function generator to perform a modulation.
Refer to DynExp::ParamsBase::dispatch_tag.
Refer to DynExp::ParamsBase::dispatch_tag.
InstrumentDataTypeSyncPtrType GetInstrumentData(const std::chrono::milliseconds Timeout=GetInstrumentDataTimeoutDefault)
Locks the mutex of the instrument data class instance InstrumentData assigned to this InstrumentBase ...
Refer to ParamsBase::dispatch_tag.
Defines data for a thread belonging to a InstrumentBase instance. Refer to RunnableInstance.
const InstrumentBase::InstrumentDataGetterType InstrumentDataGetter
Getter for instrument's data. Refer to InstrumentBase::InstrumentDataGetterType.
ParamsTypeSyncPtrType GetNonConstParams(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Allows derived Objects to edit their own parameters - even in const task functions (for instruments) ...
Refer to ParamsBase::dispatch_tag.
const Object::ParamsGetterType ParamsGetter
Invoke to obtain the parameters (derived from ParamsBase) of Owner.
void UnlockObject(LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer)
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer....
void LockObject(const ParamsBase::Param< ObjectLink< ObjectT >> &LinkParam, LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault)
Locks an Object instance referenced by a parameter LinkParam of type ParamsBase::Param< ObjectLink< O...
const auto & GetOwner() const noexcept
Returns Owner.
Defines an exception caused by a serial communication operation of a hardware adapter.
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....
Defines the return type of task functions.
Refer to DynExp::ParamsBase::dispatch_tag.
Data type which stores an optional bool value (unknown, false, true). The type evaluates to bool whil...
Thrown when an operation timed out before it could be completed, especially used for locking shared d...
@ Fall
Trigger on falling edge.
@ ExternSingle
Run once after an external trigger signal has been detected.
@ Continuous
Run continuously disabling the trigger.
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
std::string ToStr(const T &Value, int Precision=-1)
Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.
Accumulates include statements to provide a precompiled header.
double FrequencyInHz
Frequency of the function in Hz.
double Amplitude
Amplitude of the function.
Type describing modulation parameters for a waveform.
@ Sine
Sinusoidally modulate the affected quantity.
@ Pulse
Pulse (binary) modulation switching the affected quantity between two values.
@ Phase
Modulation affecting the waveform's phase.
@ Frequency
Modulation affecting the waveform's frequency.
@ Amplitude
Modulation affecting the waveform's amplitude.
Type describing a sine function.
double PhaseInRad
Phase of the function in radians.
Type describing sweep parameters for a waveform.
@ Frequency
Sweep the waveform's frequency.
@ Disabled
Sweep functionality disabled.
@ Amplitude
Sweep the waveform's amplitude.
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...