10 auto InstrParams = DynExp::dynamic_Params_cast<ZI_MFLI>(Instance.
ParamsGetter());
13 Instance.
LockObject(InstrParams->HardwareAdapter, InstrData->HardwareAdapter);
28 InstrData->HardwareAdapter->StopAcquisition();
29 InstrData->HardwareAdapter->SetEnabled(GetUsedDemodulator(),
false);
45 bool UpdateError =
false;
49 InstrData->SetSensitivity(InstrData->HardwareAdapter->GetInputRange(GetUsedSignalInput()));
50 InstrData->SetPhase(InstrData->HardwareAdapter->GetDemodPhase(GetUsedDemodulator()));
51 InstrData->SetTimeConstant(InstrData->HardwareAdapter->GetDemodTimeConstant(GetUsedDemodulator()));
52 InstrData->SetFilterOrder(InstrData->HardwareAdapter->GetDemodFilterOrder(GetUsedDemodulator()));
53 InstrData->SetTriggerMode(InstrData->HardwareAdapter->GetTriggerMode());
54 InstrData->SetTriggerEdge(InstrData->HardwareAdapter->GetTriggerEdge());
55 InstrData->SetSamplingRate(InstrData->HardwareAdapter->GetDemodSamplingRate(GetUsedDemodulator()));
56 InstrData->SetEnable(InstrData->HardwareAdapter->GetEnabled(GetUsedDemodulator()));
58 InstrData->NegInputLoad = InstrData->HardwareAdapter->GetNegInputLoad(GetUsedSignalInput());
59 InstrData->PosInputLoad = InstrData->HardwareAdapter->GetPosInputLoad(GetUsedSignalInput());
61 InstrData->OscillatorFrequency = InstrData->HardwareAdapter->GetOscillatorFrequency(0);
62 InstrData->AcquisitionProgress = InstrData->HardwareAdapter->GetAcquisitionProgress();
69 if (InstrData->NumFailedStatusUpdateAttempts++ >= 3)
74 InstrData->NumFailedStatusUpdateAttempts = 0;
99 auto LockinSamples = InstrData->HardwareAdapter->GetAcquiredData();
101 for (
const auto& Sample : LockinSamples)
102 SampleStream->
WriteSample({ Sample.GetDisambiguatedValue(InstrData->GetSignalType()), Sample.Time });
111 InstrData->HardwareAdapter->ClearAcquiredData();
120 InstrData->HardwareAdapter->StartAcquisition(GetUsedDemodulator(), InstrData->GetSampleStream()->GetStreamSizeWrite());
129 InstrData->HardwareAdapter->StopAcquisition();
138 InstrData->HardwareAdapter->SetInputRange(GetUsedSignalInput(), Sensitivity);
147 InstrData->HardwareAdapter->AutoAdjustInputRange(GetUsedSignalInput());
156 InstrData->HardwareAdapter->SetDemodPhase(GetUsedDemodulator(), Phase);
165 InstrData->HardwareAdapter->AutoAdjustDemodPhase(GetUsedDemodulator());
174 InstrData->HardwareAdapter->SetDemodTimeConstant(GetUsedDemodulator(), TimeConstant);
183 InstrData->HardwareAdapter->SetDemodFilterOrder(GetUsedDemodulator(), FilterOrder);
192 InstrData->HardwareAdapter->SetTriggerMode(TriggerMode, GetUsedDemodulator(), TriggerChannel);
201 InstrData->HardwareAdapter->SetTriggerEdge(TriggerEdge);
219 InstrData->HardwareAdapter->SetDemodSamplingRate(GetUsedDemodulator(), SamplingRate);
228 InstrData->HardwareAdapter->SetEnabled(GetUsedDemodulator(), Enable);
237 InstrData->HardwareAdapter->ForceTrigger();
257 OscillatorFrequency = 0;
258 AcquisitionProgress = -1;
260 NumFailedStatusUpdateAttempts = 0;
268 {
"Voltage", DynExpHardware::ZILabOneHardwareAdapter::SignalInputType::Voltage },
269 {
"Differential voltage", DynExpHardware::ZILabOneHardwareAdapter::SignalInputType::DifferentialVoltage },
270 {
"Current", DynExpHardware::ZILabOneHardwareAdapter::SignalInputType::Current },
278 SignalInput(
DynExpHardware::ZILabOneHardwareAdapter::SignalInputType::Voltage), UsedDemodulator(0), TriggerChannel(1)
284 auto InstrData = DynExp::dynamic_InstrumentData_cast<ZI_MFLI>(
GetInstrumentData());
286 return InstrData->HardwareAdapter->HasFinishedAcquisition();
297 auto InstrParams = DynExp::dynamic_Params_cast<ZI_MFLI>(
GetParams());
309 auto InstrParams = DynExp::dynamic_Params_cast<ZI_MFLI>(
GetParams());
311 if (InstrParams->AutoApplyParams == LockinAmplifierParams::AutoApplyParamsType::AutoApply)
Implementation of an instrument to control the Zurich Instruments MFLI lock-in amplifier.
constexpr static bool DetermineOverload(double PosInputLoad, double NegInputLoad)
Implements a circular data stream based on Util::circularbuf using samples of type BasicSample.
void WriteSample(const SampleT &Sample)
Writes a single sample to the stream's buffer StreamBuffer.
Meta instrument for a lock-in amplifier based on the data stream meta instrument.
void ResetImpl(dispatch_tag< LockinAmplifierData >) override final
static Util::TextValueListType< DynExpHardware::ZILabOneHardwareAdapter::SignalInputType > SignalInputTypeStrList()
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 ExitFuncImpl(dispatch_tag< LockinAmplifierTasks::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< LockinAmplifierTasks::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...
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< LockinAmplifierTasks::UpdateTask >, DynExp::InstrumentInstance &Instance) override final
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
auto GetUsedSignalInput() const noexcept
auto GetUsedDemodulator() const noexcept
virtual void SetPhase(double Phase, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Sets the phase of the lock-in amplifier's demodulator.
virtual void SetTriggerMode(LockinAmplifierDefs::TriggerModeType TriggerMode, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Sets the lock-in amplifier's trigger mode.
virtual void SetEnable(bool Enable, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Enables or disables the lock-in amplifier's demodulator.
virtual void SetFilterOrder(uint8_t FilterOrder, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Sets the filter order/quality of the lock-in amplifier's low-poss filter.
virtual Util::OptionalBool HasFinished() const override
Determines whether the underlying hardware adapter finished data acquisition or writing data.
virtual void SetSamplingRate(double SamplingRate, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Sets the lock-in amplifier's sampling rate.
virtual void ApplyFromParamsImpl(dispatch_tag< LockinAmplifier >) const override
Refer to ApplyFromParams(). Using tag dispatch mechanism to ensure that ApplyFromParamsImpl() of ever...
ZI_MFLI(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
std::atomic< DynExpHardware::ZILabOneHardwareAdapter::SignalInputType > SignalInput
virtual void SetSignalType(LockinAmplifierDefs::SignalType SignalType, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Sets the lock-in amplifier's signal coordinate type to read out.
void ResetImpl(dispatch_tag< LockinAmplifier >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual void SetTimeConstant(double TimeConstant, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Sets the time constant of the lock-in amplifier's low-poss filter.
virtual void SetTriggerEdge(LockinAmplifierDefs::TriggerEdgeType TriggerEdge, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Sets the lock-in amplifier's trigger edge.
virtual Util::OptionalBool IsRunning() const override
Determines whether the underlying hardware adapter is running a data acquisition or writing data.
virtual void SetSensitivity(double Sensitivity, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const override
Sets the lock-in amplifier's sensitivity/amplification.
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.
ParamsConstTypeSyncPtrType GetParams(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a...
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 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...
DynExp's hardware namespace contains the implementation of DynExp hardware adapters which extend DynE...
@ Fall
Trigger on falling edge.
SignalType
Type specifying different signal coordinates a lock-in amplifier can record. Not a strongly-typed enu...
@ R
Radial component of the signal in polar coordinates.
@ ExternSingle
Run once after an external trigger signal has been detected.
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::vector< std::pair< TextType, ValueType > > TextValueListType
Type of a list containing key-value pairs where key is a text of type Util::TextType.
Accumulates include statements to provide a precompiled header.