10 auto InstrData = DynExp::dynamic_InstrumentData_cast<DataStreamInstrument>(Instance.
InstrumentDataGetter());
19 for (
const auto& Sample : Samples)
20 WriteBasicSampleChild(Sample);
30 for (decltype(Count) i = 0; i < Count; ++i)
31 Samples.push_back(ReadBasicSampleChild());
50 return std::min(GetNumSamplesWritten() - Count, GetStreamSizeRead());
55 auto OldReadPos = GetReadPosition();
56 auto ReadLength = Util::NumToT<signed long long>(GetNumRecentBasicSamples(Count));
57 SeekEqual(std::ios_base::in);
58 SeekRel(-ReadLength, std::ios_base::cur, std::ios_base::in);
59 auto Samples = ReadBasicSamples(ReadLength);
60 SeekAbs(OldReadPos, std::ios_base::in);
73 {
"Perform reading/writing only once.", SamplingModeType::Single },
90 case UnitType::Arbitrary:
return "a.u.";
91 case UnitType::LogicLevel:
return "TTL";
92 case UnitType::Counts:
return "#";
93 case UnitType::Volt:
return "V";
94 case UnitType::Ampere:
return "A";
95 case UnitType::Power_W:
return "W";
96 case UnitType::Power_dBm:
return "dBm";
97 default:
return "<unknown unit>";
102 : SampleStream(std::move(SampleStream)), HardwareMinValue(0), HardwareMaxValue(0), ValueUnit(
UnitType::Arbitrary)
150 MakeAndEnqueueTask<DataStreamInstrumentTasks::SetStreamSizeTask>(BufferSizeInSamples, CallbackFunc);
Implementation of a data stream meta instrument and of data streams input/output devices might work o...
size_t GetNumRecentBasicSamples(size_t Count) const
Determines the amount of samples which have been written to the stream after the last Count samples....
BasicSampleListType ReadRecentBasicSamples(size_t Count)
Reads the most recent samples from the stream skipping Count samples. Also refer to GetNumRecentBasic...
virtual void WriteBasicSampleChild(const BasicSample &Sample)
Writes a single basic sample to the stream.
BasicSampleListType ReadBasicSamples(size_t Count)
Reads a list of basic sample from the stream.
std::vector< BasicSample > BasicSampleListType
Type of a list containing data stream samples of type BasicSample.
virtual BasicSample ReadBasicSampleChild()
Reads a single basic sample from the stream.
void WriteBasicSamples(const BasicSampleListType &Samples)
Writes a list of basic sample to the stream.
virtual ~DataStreamInstrumentConfigurator()=0
UnitType
Units which can be used for data stream instruments.
@ Arbitrary
Arbitrary units (a.u.)
ValueType HardwareMaxValue
Maximal possible value to read/write from/to the hardware adapter.
DataStreamInstrumentData(DataStreamBasePtrType &&SampleStream)
Constructs a DataStreamInstrumentData instance.
UnitType ValueUnit
Unit type of the values to be read/written from/to the hardware adapter.
static const char * UnitTypeToStr(const UnitType &Unit)
Returns a descriptive string of a respective unit to be e.g. used in plots.
const DataStreamBasePtrType SampleStream
Refer to DynExp::InstrumentDataBase::Reset(). Using tag dispatch mechanism to ensure that ResetImpl()...
void ResetImpl(dispatch_tag< InstrumentDataBase >) override final
ValueType HardwareMinValue
Minimal possible value to read/write from/to the hardware adapter.
virtual ~DataStreamInstrumentParams()=0
const size_t BufferSizeInSamples
New stream buffer size in samples.
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 void WriteData(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Enqueues a task to write data from the data stream to the hardware.
virtual void ClearData(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Enqueues a task to clear the underlying hardware adapter's buffer.
virtual void Restart(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Enqueues a task to make the underlying hardware adapter restart data acquisition or writing data....
virtual void ReadData(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Enqueues a task to read data from the hardware to the data stream. The default implementation does no...
virtual void SetStreamSize(size_t BufferSizeInSamples, DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Enqueues a task to set the size of the instrument's sample stream. The default implementation just ca...
virtual ~DataStreamInstrument()=0
virtual void Start(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Enqueues a task to make the underlying hardware adapter start data acquisition or writing data.
bool CanRead(const std::chrono::milliseconds Timeout=GetInstrumentDataTimeoutDefault) const
Calls ReadData(), locks the instrument data, and determines whether at least one sample can be read f...
void Clear(const std::chrono::milliseconds Timeout=GetInstrumentDataTimeoutDefault) const
Immediately clears the instrument's data stream and then issues a ClearData task by locking the instr...
virtual void Stop(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Enqueues a task to make the underlying hardware adapter stop data acquisition or writing data.
void ResetImpl(dispatch_tag< InstrumentBase >) override final
static Util::TextValueListType< SamplingModeType > SamplingModeTypeStrList()
Maps description strings to the SamplingModeType enum's items.
void DisableUserEditable()
Calls DynExp::ParamsBase::DisableUserEditable() on all bundled parameters.
void DisableUserEditable()
Calls DynExp::ParamsBase::DisableUserEditable() on all bundled parameters.
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.
static void DisableUserEditable(ParamBase &Param) noexcept
Sets the UserEditable property of the parameter Param to false. Refer to ParamBase::UserEditable.
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.
An invalid argument like a null pointer has been passed to a function.
Thrown when a requested feature is either under development and thus not implemented yet or when a sp...
@ Continuous
Run continuously disabling the trigger.
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
DataStreamPtrType< DataStreamBase > DataStreamBasePtrType
Type of a pointer owning a DataStreamBase instance.
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.
Defines a trivially-copyable basic sample as time (t)-value (f(t)) pairs (t, f(t)).