10 auto InstrParams = DynExp::dynamic_Params_cast<SwabianInstrumentsPulseStreamer>(Instance.
ParamsGetter());
11 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
13 InstrData->Channel = InstrParams->Channel;
14 Instance.
LockObject(InstrParams->HardwareAdapter, InstrData->HardwareAdapter);
15 InstrData->GetSampleStream()->SetStreamSize(InstrParams->StreamSizeParams.StreamSize);
24 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
33 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
34 bool UpdateError =
false;
38 auto InstrParams = DynExp::dynamic_Params_cast<SwabianInstrumentsPulseStreamer>(Instance.
ParamsGetter());
39 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
41 InstrData->Streaming = InstrData->HardwareAdapter->IsStreaming();
42 InstrData->Finished = InstrData->HardwareAdapter->HasFinished();
49 if (InstrData->NumFailedStatusUpdateAttempts++ >= 3)
54 InstrData->NumFailedStatusUpdateAttempts = 0;
69 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
72 const auto Samples = SampleStream->
ReadSamples(SampleStream->GetStreamSizeRead());
76 std::vector<DynExpHardware::SIPulseStreamerHardwareAdapter::SampleType> TransformedSamples;
77 for (
const auto& Sample : Samples)
79 const auto Timestamp = std::chrono::nanoseconds(Util::NumToT<std::chrono::nanoseconds::rep>(Sample.Time * std::nano::den));
81 if (InstrData->IsDigitalChannel())
82 TransformedSamples.emplace_back(InstrData->GetChannel(), Timestamp, Sample.Value != 0);
84 TransformedSamples.emplace_back(InstrData->GetChannel(), Timestamp,
88 InstrData->HardwareAdapter->SetSamples(InstrData->GetChannel(), TransformedSamples);
95 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
97 InstrData->HardwareAdapter->SetSamples(InstrData->GetChannel(), { { InstrData->GetChannel(), std::chrono::nanoseconds(0), 0 } });
104 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
106 InstrData->HardwareAdapter->RearmTrigger();
113 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
115 InstrData->HardwareAdapter->SetConstantOutput();
122 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
124 InstrData->HardwareAdapter->RearmTrigger();
131 auto InstrParams = DynExp::dynamic_Params_cast<SwabianInstrumentsPulseStreamer>(Instance.
ParamsGetter());
132 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
134 InstrData->GetSampleStream()->SetStreamSize(InstrParams->StreamSizeParams.StreamSize);
141 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
143 InstrData->HardwareAdapter->ForceTrigger();
150 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
153 DynExpHardware::SIPulseStreamerHardwareAdapterParams::TriggerModeType::Normal : DynExpHardware::SIPulseStreamerHardwareAdapterParams::TriggerModeType::Single;
154 auto TriggerEdge = DynExpHardware::SIPulseStreamerHardwareAdapterParams::TriggerEdgeType::Software;
155 switch (TriggerDesc.TriggerMode)
158 TriggerEdge = DynExpHardware::SIPulseStreamerHardwareAdapterParams::TriggerEdgeType::Immediate;
161 case FunctionGeneratorDefs::TriggerDescType::TriggerModeType::ExternStep:
163 DynExpHardware::SIPulseStreamerHardwareAdapterParams::TriggerEdgeType::FallingEdge : DynExpHardware::SIPulseStreamerHardwareAdapterParams::TriggerEdgeType::RisingEdge;
166 InstrData->HardwareAdapter->SetTrigger(TriggerEdge, TriggerMode);
173 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
175 InstrData->HardwareAdapter->SetConstantOutput(
Pulse);
182 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
184 InstrData->HardwareAdapter->ForceFinalSample();
191 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(Instance.
InstrumentDataGetter());
193 InstrData->HardwareAdapter->SetNumRuns(NumRuns);
200 return GetChannel() != DynExpHardware::SIPulseStreamerHardwareAdapterParams::OutputChannelType::AO0 &&
201 GetChannel() != DynExpHardware::SIPulseStreamerHardwareAdapterParams::OutputChannelType::AO1;
209 NumFailedStatusUpdateAttempts = 0;
221 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(
GetInstrumentData());
228 return MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::SetConstantOutputTask>(Pulse, CallbackFunc);
233 return MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::SetNumRunsTask>(NumRuns, CallbackFunc);
238 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(
GetInstrumentData());
240 return InstrData->HardwareAdapter->HasFinished();
245 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(
GetInstrumentData());
247 return InstrData->HardwareAdapter->IsStreaming();
257 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(
GetInstrumentData());
259 return InstrData->IsDigitalChannel() ?
265 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(
GetInstrumentData());
267 return InstrData->IsDigitalChannel() ?
273 auto InstrData = DynExp::dynamic_InstrumentData_cast<SwabianInstrumentsPulseStreamer>(
GetInstrumentData());
275 return InstrData->IsDigitalChannel() ?
282 MakeAndEnqueueTask<SwabianInstrumentsPulseStreamerTasks::SetTriggerTask>(TriggerDesc, CallbackFunc);
Implementation of an instrument to control a single output of the Swabian Instruments Pulse Streamer ...
Defines an exception caused by an operation involving the gRPC library and communication over a TCP s...
Implements a circular data stream based on Util::circularbuf using samples of type BasicSample.
std::vector< SampleT > ReadSamples(size_t Count)
Reads multiple samples from the stream's buffer StreamBuffer.
UnitType
Units which can be used for data stream instruments.
@ LogicLevel
Logic level (TTL) units (1 or 0)
@ Volt
Voltage in Volt (V)
Function generator meta instrument based on the data stream meta instrument to generate waveforms by ...
bool IsDigitalChannel() const noexcept
void ResetImpl(dispatch_tag< FunctionGeneratorData >) override final
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< 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...
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...
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 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 FunctionGeneratorDefs::FunctionDescType GetMaxCapsChild() const override
Returns the maximal values assignable to a description of a generic periodic function.
virtual Util::OptionalBool IsRunning() const override
Determines whether the underlying hardware adapter is running a data acquisition or writing data.
virtual FunctionGeneratorDefs::FunctionDescType GetParamDefaultsChild() const override
Returns the default values to assign to a description of a generic periodic function.
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 FunctionGeneratorDefs::FunctionDescType GetMinCapsChild() const override
Returns the minimal values assignable to a description of a generic periodic function.
virtual void SetConstantOutput(const DynExpHardware::SIPulseStreamerHardwareAdapter::PulseType &Pulse, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
virtual void SetNumRuns(int64_t NumRuns, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
virtual DataStreamInstrumentData::UnitType GetValueUnit() const noexcept override
Determines which unit corresponds to the values managed by this DataStreamInstrument instance....
virtual Util::OptionalBool HasFinished() const override
Determines whether the underlying hardware adapter finished data acquisition or writing data.
SwabianInstrumentsPulseStreamer(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
void ResetImpl(dispatch_tag< FunctionGenerator >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
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.
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.
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...
@ Pulse
Manually defined pulses.
@ 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.
Accumulates include statements to provide a precompiled header.
Swabian Instruments Pulse Streamer 8/2's internal representation of a single pulse.
static int16_t MakeValueFromVoltage(const double Voltage)
Type describing a generic periodic function.
Type describing trigger parameters determining when the waveform is generated.