DynExp
Highly flexible laboratory automation for dynamically changing experiments.
AnalogIn.h
Go to the documentation of this file.
1 // This file is part of DynExp.
2 
9 #pragma once
10 
11 #include "stdafx.h"
12 #include "InputPort.h"
13 
14 namespace DynExpInstr
15 {
16  class AnalogIn;
17 
21  namespace AnalogInTasks
22  {
27  {
29 
34  };
35 
40  {
42 
47  };
48 
53  {
55 
60  };
61  }
62 
66  class AnalogInData : public InputPortData
67  {
68  public:
70 
77  AnalogInData(size_t BufferSizeInSamples = 1) : InputPortData(std::make_unique<SampleStreamType>(BufferSizeInSamples)) {}
78 
83 
84  virtual ~AnalogInData() = default;
85 
86  private:
87  void ResetImpl(dispatch_tag<InputPortData>) override final;
89  };
90 
95  {
96  public:
102  : InputPortParams(ID, Core) {}
103 
104  virtual ~AnalogInParams() = 0;
105 
106  virtual const char* GetParamClassTag() const noexcept override { return "AnalogInParams"; }
107 
108  protected:
109  void DisableUserEditable();
110 
111  private:
114 
115  DummyParam Dummy = { *this };
116  };
117 
122  {
123  public:
126 
127  AnalogInConfigurator() = default;
128  virtual ~AnalogInConfigurator() = 0;
129  };
130 
135  class AnalogIn : public InputPort
136  {
137  public:
141 
150 
151  constexpr static auto Name() noexcept { return "Analog In"; }
152  constexpr static auto Category() noexcept { return "I/O"; }
153 
158  : InputPort(OwnerThreadID, std::move(Params)) {}
159 
160  virtual ~AnalogIn() = 0;
161 
162  virtual std::string GetName() const override { return Name(); }
163  virtual std::string GetCategory() const override { return Category(); }
164 
171 
180 
187 
194 
202 
203  private:
204  void ResetImpl(dispatch_tag<InputPort>) override final;
205  virtual void ResetImpl(dispatch_tag<AnalogIn>) = 0;
206 
207  virtual std::unique_ptr<DynExp::InitTaskBase> MakeInitTask() const override { return DynExp::MakeTask<AnalogInTasks::InitTask>(); }
208  virtual std::unique_ptr<DynExp::ExitTaskBase> MakeExitTask() const override { return DynExp::MakeTask<AnalogInTasks::ExitTask>(); }
209  virtual std::unique_ptr<DynExp::UpdateTaskBase> MakeUpdateTask() const override { return DynExp::MakeTask<AnalogInTasks::UpdateTask>(); }
210  };
211 }
Defines a generic input port meta instrument which is used to read data from hardware and to write th...
Configurator class for AnalogIn.
Definition: AnalogIn.h:122
Data class for AnalogIn.
Definition: AnalogIn.h:67
AnalogInData(size_t BufferSizeInSamples=1)
Constructs a DataStreamInstrumentData instance.
Definition: AnalogIn.h:77
void ResetImpl(dispatch_tag< InputPortData >) override final
Definition: AnalogIn.cpp:8
AnalogInData(DataStreamBasePtrType &&SampleStream)
Constructs a DataStreamInstrumentData instance.
Definition: AnalogIn.h:82
virtual ~AnalogInData()=default
virtual void ResetImpl(dispatch_tag< AnalogInData >)
Definition: AnalogIn.h:88
Parameter class for AnalogIn.
Definition: AnalogIn.h:95
virtual const char * GetParamClassTag() const noexcept override
This function is intended to be overridden once in each derived class returning the name of the respe...
Definition: AnalogIn.h:106
AnalogInParams(DynExp::ItemIDType ID, const DynExp::DynExpCore &Core)
Constructs the parameters for a AnalogIn instance.
Definition: AnalogIn.h:101
virtual void ConfigureParamsImpl(dispatch_tag< AnalogInParams >)
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition: AnalogIn.h:113
DummyParam Dummy
Dummy parameter which is to be owned once by parameter classes that do not contain any other paramete...
Definition: AnalogIn.h:115
void DisableUserEditable()
Calls DynExp::ParamsBase::DisableUserEditable() on all bundled parameters.
Definition: AnalogIn.cpp:17
void ConfigureParamsImpl(dispatch_tag< InputPortParams >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition: AnalogIn.h:112
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
Definition: AnalogIn.h:40
virtual void ExitFuncImpl(dispatch_tag< ExitTask >, DynExp::InstrumentInstance &Instance)
Deinitializes the respective instrument within the instrument inheritance hierarchy....
Definition: AnalogIn.h:46
void ExitFuncImpl(dispatch_tag< InputPortTasks::ExitTask >, DynExp::InstrumentInstance &Instance) override final
Deinitializes the respective instrument within the instrument inheritance hierarchy....
Definition: AnalogIn.h:41
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
Definition: AnalogIn.h:27
void InitFuncImpl(dispatch_tag< InputPortTasks::InitTask >, DynExp::InstrumentInstance &Instance) override final
Initializes the respective instrument within the instrument inheritance hierarchy....
Definition: AnalogIn.h:28
virtual void InitFuncImpl(dispatch_tag< InitTask >, DynExp::InstrumentInstance &Instance)
Initializes the respective instrument within the instrument inheritance hierarchy....
Definition: AnalogIn.h:33
Defines a task for updating an instrument within an instrument inheritance hierarchy....
Definition: AnalogIn.h:53
virtual void UpdateFuncImpl(dispatch_tag< UpdateTask >, DynExp::InstrumentInstance &Instance)
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
Definition: AnalogIn.h:59
void UpdateFuncImpl(dispatch_tag< InputPortTasks::UpdateTask >, DynExp::InstrumentInstance &Instance) override final
Updates the respective instrument within the instrument inheritance hierarchy. Call UpdateFuncImpl() ...
Definition: AnalogIn.h:54
Meta instrument for a single analog input port based on the data stream and generic input port meta i...
Definition: AnalogIn.h:136
virtual AnalogInData::SampleStreamType::SampleType Get(DynExp::TaskBase::CallbackType CallbackFunc=nullptr) const
Reads one sample from the sample stream. CallbackFunc gets called after the task DataStreamInstrument...
Definition: AnalogIn.cpp:29
virtual DataStreamInstrumentData::UnitType GetValueUnit() const override
Determines which unit corresponds to the values managed by this DataStreamInstrument instance....
Definition: AnalogIn.h:170
AnalogIn(const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params)
Constructs an instrument instance.
Definition: AnalogIn.h:157
virtual ~AnalogIn()=0
Definition: AnalogIn.cpp:25
virtual AnalogInData::SampleStreamType::SampleType GetSync() const
Synchronized version of Get(), which blocks until a DataStreamInstrument::ReadData() task getting enq...
Definition: AnalogIn.cpp:39
virtual std::string GetName() const override
Returns the name of this Object type.
Definition: AnalogIn.h:162
virtual std::unique_ptr< DynExp::UpdateTaskBase > MakeUpdateTask() const override
Factory function for an update task (UpdateTaskBase). Override to define the desired update task in d...
Definition: AnalogIn.h:209
virtual std::unique_ptr< DynExp::InitTaskBase > MakeInitTask() const override
Factory function for an init task (InitTaskBase). Override to define the desired initialization task ...
Definition: AnalogIn.h:207
constexpr static auto Name() noexcept
Every derived class has to redefine this function.
Definition: AnalogIn.h:151
virtual std::string GetCategory() const override
Returns the category of this Object type.
Definition: AnalogIn.h:163
virtual std::unique_ptr< DynExp::ExitTaskBase > MakeExitTask() const override
Factory function for an exit task (ExitTaskBase). Override to define the desired deinitialization tas...
Definition: AnalogIn.h:208
void ResetImpl(dispatch_tag< InputPort >) override final
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
Definition: AnalogIn.cpp:49
virtual void ResetImpl(dispatch_tag< AnalogIn >)=0
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual NumericSampleStreamParamsExtension::ValueType GetNumericSampleStreamParams() const
Retrieves sample stream settings of the instrument's data stream from the instrument's or from the un...
Definition: AnalogIn.h:178
constexpr static auto Category() noexcept
Every derived class has to redefine this function.
Definition: AnalogIn.h:152
SampleT SampleType
Alias for SampleT.
UnitType
Units which can be used for data stream instruments.
const DataStreamBasePtrType SampleStream
Refer to DynExp::InstrumentDataBase::Reset(). Using tag dispatch mechanism to ensure that ResetImpl()...
Configurator class for InputPort.
Definition: InputPort.h:143
Data class for InputPort.
Definition: InputPort.h:98
Parameter class for InputPort.
Definition: InputPort.h:116
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
Definition: InputPort.h:54
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
Definition: InputPort.h:27
Defines a task for updating an instrument within an instrument inheritance hierarchy....
Definition: InputPort.h:67
Generic input port meta instrument based on the data stream meta instrument to read data from hardwar...
Definition: InputPort.h:157
Type containing the values of all the parameters belonging to NumericSampleStreamParamsExtension.
Implements a circular data stream based on Util::circularbuf using samples of an arithmetic type Samp...
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition: DynExpCore.h:127
Defines a task for deinitializing an instrument within an instrument inheritance hierarchy....
Definition: Instrument.h:1144
Refer to DynExp::ParamsBase::dispatch_tag.
Definition: Instrument.h:1151
Defines a task for initializing an instrument within an instrument inheritance hierarchy....
Definition: Instrument.h:1113
Refer to DynExp::ParamsBase::dispatch_tag.
Definition: Instrument.h:1120
Base class for instruments. Instruments comprise virtual devices (meta instruments) and physial devic...
Definition: Instrument.h:451
Configurator class for InstrumentBase.
Definition: Instrument.h:435
Data structure to contain data which is synchronized in between different threads....
Definition: Instrument.h:135
Refer to ParamsBase::dispatch_tag.
Definition: Instrument.h:146
Defines data for a thread belonging to a InstrumentBase instance. Refer to RunnableInstance.
Definition: Instrument.h:772
Parameter class for InstrumentBase.
Definition: Instrument.h:401
const std::thread::id OwnerThreadID
Thread id of the thread which has constructed (and owns) this Object instance.
Definition: Object.h:2302
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
Definition: Object.h:2303
Refer to ParamsBase::dispatch_tag.
Definition: Object.h:2018
Dummy parameter which is to be owned once by parameter classes that do not contain any other paramete...
Definition: Object.h:522
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
Definition: Object.h:1779
const DynExpCore & Core
Reference to DynExp's core.
Definition: Object.h:1780
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Definition: Object.h:349
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....
Definition: Instrument.h:939
Defines a task for updating an instrument within an instrument inheritance hierarchy....
Definition: Instrument.h:1175
Refer to DynExp::ParamsBase::dispatch_tag.
Definition: Instrument.h:1182
DynExp's instrument namespace contains the implementation of DynExp instruments which extend DynExp's...
Definition: Instrument.h:1254
NumericSampleStream< double > AnalogSampleStream
Alias for a numeric sample stream of double samples.
DataStreamPtrType< DataStreamBase > DataStreamBasePtrType
Type of a pointer owning a DataStreamBase instance.
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
Definition: Object.h:1807
size_t ItemIDType
ID type of objects/items managed by DynExp.
Accumulates include statements to provide a precompiled header.