10 auto InstrParams = DynExp::dynamic_Params_cast<RS_SMC100A>(Instance.
ParamsGetter());
11 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(Instance.
InstrumentDataGetter());
13 Instance.
LockObject(InstrParams->HardwareAdapter, InstrData->HardwareAdapter);
22 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(Instance.
InstrumentDataGetter());
31 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(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_SMC100A>(Instance.
InstrumentDataGetter());
73 *InstrData->HardwareAdapter <<
"OUTPut1:STATe ON";
80 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(Instance.
InstrumentDataGetter());
82 *InstrData->HardwareAdapter <<
"OUTPut1:STATe OFF";
89 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(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_SMC100ATasks::StartTask>(
nullptr));
104 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(Instance.
InstrumentDataGetter());
109 *InstrData->HardwareAdapter << std::string(
"SOURce1:LFOutput1:FREQuency:MODE CW");
110 *InstrData->HardwareAdapter << std::string(
"SOURce1:LFOutput1:FREQuency ")
111 +
Util::ToStr(ModulationDesc.FrequencyInHz, 0) +
" Hz";
119 *InstrData->HardwareAdapter << std::string(
"SOURce1:FM1:SOURce INT");
120 *InstrData->HardwareAdapter << std::string(
"SOURce1:FM1:DEViation ")
123 *InstrData->HardwareAdapter <<
"SOURce1:AM1:STATe 0";
124 *InstrData->HardwareAdapter <<
"SOURce1:PM1:STATe 0";
125 *InstrData->HardwareAdapter <<
"SOURce1:FM1:STATe 1";
129 *InstrData->HardwareAdapter << std::string(
"SOURce1:AM1:SOURce INT");
130 *InstrData->HardwareAdapter << std::string(
"SOURce1:AM1:DEPTh ")
133 *InstrData->HardwareAdapter <<
"SOURce1:FM1:STATe 0";
134 *InstrData->HardwareAdapter <<
"SOURce1:PM1:STATe 0";
135 *InstrData->HardwareAdapter <<
"SOURce1:AM1:STATe 1";
139 *InstrData->HardwareAdapter << std::string(
"SOURce1:PM1:SOURce INT");
140 *InstrData->HardwareAdapter << std::string(
"SOURce1:PM1:DEViation ")
143 *InstrData->HardwareAdapter <<
"SOURce1:AM1:STATe 0";
144 *InstrData->HardwareAdapter <<
"SOURce1:FM1:STATe 0";
145 *InstrData->HardwareAdapter <<
"SOURce1:PM1:STATe 1";
149 *InstrData->HardwareAdapter <<
"SOURce1:AM1:STATe 0";
150 *InstrData->HardwareAdapter <<
"SOURce1:FM1:STATe 0";
151 *InstrData->HardwareAdapter <<
"SOURce1:PM1:STATe 0";
154 *InstrData->HardwareAdapter << std::string(
"SOURce1:LFOutput1:STATe ") +
162 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(Instance.
InstrumentDataGetter());
166 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:RETRace ")
167 + (SweepDesc.Retrace ?
"1" :
"0");
168 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:DWELl ")
169 +
Util::ToStr(SweepDesc.TimeDiffPerSample_ms, 3) +
" ms";
170 *InstrData->HardwareAdapter << std::string(
"SOURce1:FREQuency:STARt ")
172 *InstrData->HardwareAdapter << std::string(
"SOURce1:FREQuency:STOP ")
174 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:SPACing LINear");
175 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:SHAPe SAWTooth");
176 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:FREQuency:STEP:LINear ")
177 +
Util::ToStr(SweepDesc.ValueDiffPerSample, 0) +
" Hz";
179 *InstrData->HardwareAdapter <<
"SOURce1:POWer:MODE CW";
180 *InstrData->HardwareAdapter <<
"SOURce1:FREQuency:MODE SWEep";
186 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:POWer:RETRace ")
187 + (SweepDesc.Retrace ?
"1" :
"0");
188 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:POWer:DWELl ")
189 +
Util::ToStr(SweepDesc.TimeDiffPerSample_ms, 3) +
" ms";
190 *InstrData->HardwareAdapter << std::string(
"SOURce1:POWer:STARt ")
192 *InstrData->HardwareAdapter << std::string(
"SOURce1:POWer:STOP ")
195 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:POWer:SHAPe SAWTooth");
196 *InstrData->HardwareAdapter << std::string(
"SOURce1:SWEep:POWer:STEP ")
197 +
Util::ToStr(SweepDesc.ValueDiffPerSample, 2) +
" dB";
199 *InstrData->HardwareAdapter <<
"SOURce1:FREQuency:MODE CW";
200 *InstrData->HardwareAdapter <<
"SOURce1:POWer:MODE SWEep";
206 *InstrData->HardwareAdapter <<
"SOURce1:FREQuency:MODE CW";
207 *InstrData->HardwareAdapter <<
"SOURce1:POWer:MODE CW";
217 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(Instance.
InstrumentDataGetter());
221 *InstrData->HardwareAdapter << std::string(
"TRIGger1:FSWeep:SOURce ")
223 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:FREQuency:MODE AUTO";
225 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:FREQuency:EXECute";
229 *InstrData->HardwareAdapter << std::string(
"TRIGger1:PSWeep:SOURce ")
231 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:POWer:MODE AUTO";
233 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:POWer:EXECute";
241 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(Instance.
InstrumentDataGetter());
245 *InstrData->HardwareAdapter << std::string(
"TRIGger1:FSWeep:SOURce ")
247 if (TriggerDesc.TriggerMode == FunctionGeneratorDefs::TriggerDescType::TriggerModeType::ExternStep)
248 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:FREQuency:MODE STEP";
250 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:FREQuency:MODE AUTO";
254 *InstrData->HardwareAdapter << std::string(
"TRIGger1:PSWeep:SOURce ")
256 if (TriggerDesc.TriggerMode == FunctionGeneratorDefs::TriggerDescType::TriggerModeType::ExternStep)
257 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:POWer:MODE STEP";
259 *InstrData->HardwareAdapter <<
"SOURce1:SWEep:POWer:MODE AUTO";
262 *InstrData->HardwareAdapter << std::string(
"SOURce:INPut:TRIGger:SLOPe ") +
270 NumFailedStatusUpdateAttempts = 0;
283 case FunctionGeneratorDefs::TriggerDescType::TriggerModeType::ExternStep:
return "EXTernal";
284 case FunctionGeneratorDefs::TriggerDescType::TriggerModeType::Manual:
return "SINGle";
299 auto InstrParams = DynExp::dynamic_Params_cast<FunctionGenerator>(
GetNonConstParams());
302 InstrParams->Amplitude = FunctionDesc.
Amplitude;
303 InstrParams->Offset = 0;
304 InstrParams->PhaseInRad = FunctionDesc.
PhaseInRad;
305 InstrParams->DutyCycle = 0;
306 InstrParams->Autostart = Autostart;
309 MakeAndEnqueueTask<RS_SMC100ATasks::SetSineFunctionTask>(FunctionDesc, Autostart, CallbackFunc);
315 MakeAndEnqueueTask<RS_SMC100ATasks::SetModulationTask>(ModulationDesc, CallbackFunc);
321 MakeAndEnqueueTask<RS_SMC100ATasks::SetSweepTask>(SweepDesc, CallbackFunc);
326 MakeAndEnqueueTask<RS_SMC100ATasks::ForceTriggerTask>(CallbackFunc);
331 auto InstrData = DynExp::dynamic_InstrumentData_cast<RS_SMC100A>(
GetInstrumentData());
333 return InstrData->IsRunning();
344 MakeAndEnqueueTask<RS_SMC100ATasks::SetTriggerTask>(TriggerDesc, CallbackFunc);
Implementation of an instrument to control the Rohde & Schwarz SMC100A 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 Util::OptionalBool IsRunning() const override
Determines whether the underlying hardware adapter is running a data acquisition or writing data.
void ResetImpl(dispatch_tag< FunctionGenerator >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
RS_SMC100A(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
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 void SetSweep(const FunctionGeneratorDefs::SweepDescType &SweepDesc, bool PersistParams=false, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Configures the function generator to perform a sweep.
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.
static const char * TriggerModeToCmdString(FunctionGeneratorDefs::TriggerDescType::TriggerModeType TriggerMode) noexcept
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.
Thrown when a requested feature is either under development and thus not implemented yet or when a sp...
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...