DynExp
Highly flexible laboratory automation for dynamically changing experiments.
|
Public Types | |
using | ParamsType = NIDAQHardwareAdapterParams |
using | ConfigType = NIDAQHardwareAdapterConfigurator |
using | ChannelHandleType = NIDAQTask::ChannelHandleType |
Public Types inherited from DynExp::HardwareAdapterBase | |
using | ParamsType = HardwareAdapterParamsBase |
Type of the parameter class belonging to this Object type. Declare this alias in every derived class with the respective parameter class accompanying the derived Object . More... | |
using | ConfigType = HardwareAdapterConfiguratorBase |
Type of the configurator class belonging to this Object type. Declare this alias in every derived class with the respective configurator class accompanying the derived Object . More... | |
Public Types inherited from DynExp::Object | |
using | ParamsType = ParamsBase |
Type of the parameter class belonging to this Object type. Declare this alias in every derived class with the respective parameter class accompanying the derived Object . More... | |
using | ParamsTypeSyncPtrType = Util::SynchronizedPointer< ParamsType > |
Alias for the return type of Object::GetParams(). Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More... | |
using | ParamsConstTypeSyncPtrType = Util::SynchronizedPointer< const ParamsType > |
Alias for the return type of Object::GetParams() const. Parameters wrapped into Util::SynchronizedPointer can be accessed in a thread-safe way. More... | |
using | ConfigType = ConfiguratorBase |
Type of the configurator class belonging to this Object type. Declare this alias in every derived class with the respective configurator class accompanying the derived Object . More... | |
using | ParamsGetterType = Util::CallableMemberWrapper< Object, decltype(&Object::GetParams)> |
Invoking an instance of this alias is supposed to call Object::GetParams() of the instance the Util::CallableMemberWrapper has been constructed with. More... | |
Public Member Functions | |
NIDAQHardwareAdapter (const std::thread::id OwnerThreadID, DynExp::ParamsBasePtrType &&Params) | |
virtual | ~NIDAQHardwareAdapter () |
virtual std::string | GetName () const override |
Returns the name of this Object type. More... | |
virtual std::string | GetCategory () const override |
Returns the category of this Object type. More... | |
ChannelHandleType | InitializeDigitalInChannel (std::string_view ChannelName, double Timeout=0) const |
ChannelHandleType | InitializeDigitalOutChannel (std::string_view ChannelName, NIDAQOutputPortParamsExtension::UseOnlyOnBrdMemType UseOnlyOnBrdMem, double Timeout=0) const |
ChannelHandleType | InitializeAnalogInChannel (std::string_view ChannelName, double MinValue, double MaxValue, double Timeout=0, int32_t TerminalConfig=DAQmx_Val_RSE) const |
ChannelHandleType | InitializeAnalogOutChannel (std::string_view ChannelName, double MinValue, double MaxValue, NIDAQOutputPortParamsExtension::UseOnlyOnBrdMemType UseOnlyOnBrdMem, double Timeout=0) const |
bool | DeregisterChannel (ChannelHandleType ChannelHandle) const |
std::vector< NIDAQTask::DigitalValueType > | ReadDigitalValues (ChannelHandleType ChannelHandle) const |
int32_t | WriteDigitalValues (ChannelHandleType ChannelHandle, const std::vector< NIDAQTask::DigitalValueType > &Values) const |
std::vector< NIDAQTask::AnalogValueType > | ReadAnalogValues (ChannelHandleType ChannelHandle) const |
int32_t | WriteAnalogValues (ChannelHandleType ChannelHandle, const std::vector< NIDAQTask::AnalogValueType > &Values) const |
void | StartTask (ChannelHandleType ChannelHandle) const |
void | StopTask (ChannelHandleType ChannelHandle) const |
void | RestartTask (ChannelHandleType ChannelHandle) const |
bool | HasFinishedTask (ChannelHandleType ChannelHandle) const |
const NIDAQTask * | GetTask (ChannelHandleType ChannelHandle) const |
Public Member Functions inherited from DynExp::HardwareAdapterBase | |
HardwareAdapterBase (const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params) | |
Constructs a hardware adapter instance. More... | |
virtual | ~HardwareAdapterBase ()=0 |
void | ResetException () const |
Sets LastException to nullptr in a thread-safe way. More... | |
bool | IsConnected () const noexcept |
Determines the connection status of the hardware interface. More... | |
Public Member Functions inherited from Util::INonCopyable | |
INonCopyable (const INonCopyable &)=delete | |
INonCopyable & | operator= (const INonCopyable &)=delete |
Public Member Functions inherited from DynExp::Object | |
ItemIDType | GetID () const noexcept |
Returns the ID of this Object instance. Thread-safe since ID is const. More... | |
std::string | GetCategoryAndName () const |
Builds a string from an Object's category and name to allow the user to identify an Object's type. More... | |
void | EnsureReadyState (bool IsAutomaticStartup) |
Ensures that this Object instance is ready by possibly starting its worker thread or by opening connections to hardware devices. More... | |
void | CheckLinkedObjectStates () const |
Checks whether Object instances this instance uses are in a ready state. Override CheckLinkedObjectStatesChild() to implement this behavior. More... | |
void | Reset () |
Resets this Object instance (including all its derived classes) by calling ResetImpl() . A reset implies that the derived classes reload all their parameters from Params and that all LinkedObjectWrapper instances owned by this Object instance become invalidated. More... | |
void | BlockIfUnused (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) |
Blocks this Object instance setting Object::IsBlocked to true. Refer to Object::IsBlocked for the consequences. More... | |
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 pointer to the locked Params. More... | |
ParamsTypeSyncPtrType | GetParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) |
Locks the mutex of the parameter class instance Params assigned to this Object instance and returns a pointer to the locked Params. More... | |
auto | GetObjectName (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const |
Returns the name of this Object instance. More... | |
bool | IsSharedUsageEnabled (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const |
Returns whether shared usage has been enabled for this Object instance. Refer to ParamsBase::UsageType. More... | |
void | SetWarning (std::string Description, int ErrorCode) const |
Setter for Object::Warning. Sets the warning by a description and an error code. More... | |
void | SetWarning (const Util::Exception &e) const |
Setter for Object::Warning. Sets the warning by retrieving the warning data from an exception e . More... | |
void | ClearWarning () const |
Resets Object::Warning. More... | |
auto | GetWarning () const |
Returns Object::Warning in a thread-safe way by copying its internal data. More... | |
std::exception_ptr | GetException (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Returns a pointer to the exception which has caused this Object instance to fail. More... | |
bool | IsReady () const |
Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) and not blocked (refer to Object::IsBlocked). More... | |
auto | GetUseCount (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Counts the registered useres in a thread-safe way. More... | |
bool | IsUnused (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Returns whether this Object instance is used by other instances. More... | |
auto | GetUserIDs (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Returns a list of the IDs of the registered users in a thread-safe way. More... | |
auto | GetUserNamesString (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const |
Builds a string describing which users are registered containing their object names, categories and type names in a thread-safe way. More... | |
Static Public Member Functions | |
constexpr static auto | Name () noexcept |
constexpr static auto | Category () noexcept |
static auto | Enumerate () |
Static Public Member Functions inherited from DynExp::HardwareAdapterBase | |
constexpr static auto | Category () noexcept |
Every derived class has to redefine this function. More... | |
Static Public Member Functions inherited from DynExp::Object | |
static std::string | CategoryAndNameToStr (const std::string &Category, const std::string &Name) |
Builds a string from an Object's category and name to allow the user to identify an Object's type. More... | |
Private Types | |
using | TasksMapType = std::unordered_map< ChannelHandleType, std::shared_ptr< NIDAQTask > > |
Private Member Functions | |
void | ResetImpl (dispatch_tag< HardwareAdapterBase >) override final |
virtual void | ResetImpl (dispatch_tag< NIDAQHardwareAdapter >) |
void | EnsureReadyStateChild () override final |
Ensures that this Object instance is ready by possibly starting its worker thread or by opening connections to hardware devices. More... | |
bool | IsReadyChild () const override final |
Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) and not blocked (refer to Object::IsBlocked). More... | |
bool | IsConnectedChild () const noexcept override final |
Determines the connection status of the hardware interface. More... | |
void | CheckError (const int32_t Result, const std::source_location Location=std::source_location::current()) const |
void | CheckReadError (NIDAQTask *Task, const int32_t Result, const std::source_location Location=std::source_location::current()) const |
NIDAQSyms::TaskHandle | CreateTaskUnsafe () const |
void | InitializeTaskTimingUnsafe (NIDAQTask *Task, double Timeout, double SamplingRate, DynExpInstr::NumericSampleStreamParamsExtension::SamplingModeType SamplingMode) const |
void | InitializeTriggerUnsafe (NIDAQTask *Task, NIDAQHardwareAdapterParams::TriggerModeType TriggerMode, std::string_view TriggerChannelName) const |
void | StartTaskUnsafe (NIDAQTask *Task) const |
void | StopTaskUnsafe (NIDAQTask *Task) const |
void | RestartTaskUnsafe (NIDAQTask *Task) const |
bool | HasFinishedTaskUnsafe (NIDAQTask *Task) const |
ChannelHandleType | ChannelNameToChannelHandle (std::string_view ChannelName) const |
bool | TaskExistsUnsafe (ChannelHandleType ChannelHandle) const |
bool | TaskExistsUnsafe (std::string_view ChannelName) const |
NIDAQTask * | GetTaskUnsafe (ChannelHandleType ChannelHandle) const |
NIDAQTask * | GetTaskUnsafe (std::string_view ChannelName) const |
ChannelHandleType | InsertTaskUnsafe (std::string_view ChannelName, std::shared_ptr< NIDAQTask > &&TaskHandle) const |
ChannelHandleType | CreateTaskIfNotExistsUnsafe (std::string_view ChannelName, NIDAQTask::ChannelType Type) const |
bool | RemoveTaskUnsafe (ChannelHandleType ChannelHandle) const |
Private Attributes | |
TasksMapType | Tasks |
Additional Inherited Members | |
Public Attributes inherited from DynExp::Object | |
LinkedObjectWrapperOnlyType | LinkedObjectWrapperOnly |
Allow exclusive access to some of Object's private methods to any LinkedObjectWrapper<T>. More... | |
Static Public Attributes inherited from DynExp::HardwareAdapterBase | |
static constexpr auto | ShortTimeoutDefault = std::chrono::milliseconds(10) |
Default timeout e.g. used as a default for calls to Object::GetException(). More... | |
static constexpr auto | HardwareOperationTimeout = std::chrono::milliseconds(100) |
Default timeout used to lock the mutex provided by the base class Util::ILockable to synchronize access to the hardware interface in between multiple instrument threads. More... | |
Static Public Attributes inherited from Util::ILockable | |
static constexpr std::chrono::milliseconds | DefaultTimeout = std::chrono::milliseconds(10) |
Duration which is used as a default timeout within all methods of this class if no different duration is passed to them. More... | |
Static Public Attributes inherited from DynExp::Object | |
static constexpr std::chrono::milliseconds | GetParamsTimeoutDefault = std::chrono::milliseconds(100) |
Default timeout used by Object::GetParams() to lock the mutex of the parameter instance assigned to this Object instance. More... | |
Protected Types inherited from Util::ILockable | |
using | MutexType = std::timed_mutex |
using | LockType = std::unique_lock< MutexType > |
Protected Member Functions inherited from DynExp::HardwareAdapterBase | |
void | ThrowException (std::exception_ptr Exception) const |
Stores Exception in LastException, wraps it in a Util::ForwardedException and throws the wrapped excetion by calling Util::ForwardException(). More... | |
void | ThrowExceptionUnsafe (std::exception_ptr Exception) const |
Stores Exception in LastException, wraps it in a Util::ForwardedException and throws the wrapped excetion by calling Util::ForwardException(). More... | |
void | SetExceptionUnsafe (std::exception_ptr Exception) const |
Stores Exception in LastException. More... | |
auto | GetExceptionUnsafe () const |
Getter for LastException. More... | |
Protected Member Functions inherited from Util::ILockable | |
ILockable ()=default | |
~ILockable ()=default | |
LockType | AcquireLock (const std::chrono::milliseconds Timeout=DefaultTimeout) const |
Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded. More... | |
Protected Member Functions inherited from Util::INonCopyable | |
constexpr | INonCopyable ()=default |
~INonCopyable ()=default | |
Protected Member Functions inherited from DynExp::Object | |
Object (const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params) | |
Constructs an Object instance. More... | |
virtual | ~Object ()=0 |
void | EnsureCallFromOwningThread () const |
Asserts that the call to this function is performed from the thread which constructed this Object instance (the thread with the id stored in Object::OwnerThreadID). More... | |
ParamsTypeSyncPtrType | GetNonConstParams (const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const |
Allows derived Objects to edit their own parameters - even in const task functions (for instruments) or event functions (for modules). More... | |
auto | LockUserList (const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) |
Locks the user list for thread-safe manipulation. More... | |
void | DeregisterAllUnsafe () |
Deregisters all users and notifies them that they need to check the states of their used linked objects. More... | |
auto | GetUseCountUnsafe () |
auto | GetUserNamesStringUnsafe () const |
bool | IsUnusedUnsafe () |
Returns whether this Object instance is used by other instances (not thread-safe). More... | |
Definition at line 158 of file HardwareAdapterNIDAQ.h.
Definition at line 163 of file HardwareAdapterNIDAQ.h.
Definition at line 162 of file HardwareAdapterNIDAQ.h.
Definition at line 161 of file HardwareAdapterNIDAQ.h.
|
private |
Definition at line 197 of file HardwareAdapterNIDAQ.h.
DynExpHardware::NIDAQHardwareAdapter::NIDAQHardwareAdapter | ( | const std::thread::id | OwnerThreadID, |
DynExp::ParamsBasePtrType && | Params | ||
) |
Definition at line 118 of file HardwareAdapterNIDAQ.cpp.
|
virtual |
Definition at line 123 of file HardwareAdapterNIDAQ.cpp.
|
inlinestaticconstexprnoexcept |
Definition at line 166 of file HardwareAdapterNIDAQ.h.
|
private |
Definition at line 606 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 502 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 523 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 656 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 536 of file HardwareAdapterNIDAQ.cpp.
bool DynExpHardware::NIDAQHardwareAdapter::DeregisterChannel | ( | ChannelHandleType | ChannelHandle | ) | const |
Definition at line 263 of file HardwareAdapterNIDAQ.cpp.
|
finaloverrideprivatevirtual |
Ensures that this Object
instance is ready by possibly starting its worker thread or by opening connections to hardware devices.
Implements DynExp::HardwareAdapterBase.
Definition at line 479 of file HardwareAdapterNIDAQ.cpp.
|
static |
Definition at line 44 of file HardwareAdapterNIDAQ.cpp.
|
inlineoverridevirtual |
Returns the category of this Object
type.
Reimplemented from DynExp::HardwareAdapterBase.
Definition at line 173 of file HardwareAdapterNIDAQ.h.
|
inlineoverridevirtual |
Returns the name of this Object
type.
Implements DynExp::Object.
Definition at line 172 of file HardwareAdapterNIDAQ.h.
const NIDAQTask * DynExpHardware::NIDAQHardwareAdapter::GetTask | ( | ChannelHandleType | ChannelHandle | ) | const |
Definition at line 461 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 621 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 631 of file HardwareAdapterNIDAQ.cpp.
bool DynExpHardware::NIDAQHardwareAdapter::HasFinishedTask | ( | ChannelHandleType | ChannelHandle | ) | const |
Definition at line 454 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 597 of file HardwareAdapterNIDAQ.cpp.
NIDAQHardwareAdapter::ChannelHandleType DynExpHardware::NIDAQHardwareAdapter::InitializeAnalogInChannel | ( | std::string_view | ChannelName, |
double | MinValue, | ||
double | MaxValue, | ||
double | Timeout = 0 , |
||
int32_t | TerminalConfig = DAQmx_Val_RSE |
||
) | const |
Definition at line 195 of file HardwareAdapterNIDAQ.cpp.
NIDAQHardwareAdapter::ChannelHandleType DynExpHardware::NIDAQHardwareAdapter::InitializeAnalogOutChannel | ( | std::string_view | ChannelName, |
double | MinValue, | ||
double | MaxValue, | ||
NIDAQOutputPortParamsExtension::UseOnlyOnBrdMemType | UseOnlyOnBrdMem, | ||
double | Timeout = 0 |
||
) | const |
Definition at line 226 of file HardwareAdapterNIDAQ.cpp.
NIDAQHardwareAdapter::ChannelHandleType DynExpHardware::NIDAQHardwareAdapter::InitializeDigitalInChannel | ( | std::string_view | ChannelName, |
double | Timeout = 0 |
||
) | const |
Definition at line 129 of file HardwareAdapterNIDAQ.cpp.
NIDAQHardwareAdapter::ChannelHandleType DynExpHardware::NIDAQHardwareAdapter::InitializeDigitalOutChannel | ( | std::string_view | ChannelName, |
NIDAQOutputPortParamsExtension::UseOnlyOnBrdMemType | UseOnlyOnBrdMem, | ||
double | Timeout = 0 |
||
) | const |
Definition at line 159 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 549 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 567 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 636 of file HardwareAdapterNIDAQ.cpp.
|
finaloverrideprivatevirtualnoexcept |
Determines the connection status of the hardware interface.
Implements DynExp::HardwareAdapterBase.
Definition at line 494 of file HardwareAdapterNIDAQ.cpp.
|
finaloverrideprivatevirtual |
Returns wheter this Object
instance is ready (e.g. it is running or connected to a hardware device) and not blocked (refer to Object::IsBlocked).
Object
instance is ready, false otherwise. Implements DynExp::Object.
Definition at line 484 of file HardwareAdapterNIDAQ.cpp.
|
inlinestaticconstexprnoexcept |
Definition at line 165 of file HardwareAdapterNIDAQ.h.
std::vector< NIDAQTask::AnalogValueType > DynExpHardware::NIDAQHardwareAdapter::ReadAnalogValues | ( | ChannelHandleType | ChannelHandle | ) | const |
Definition at line 355 of file HardwareAdapterNIDAQ.cpp.
std::vector< NIDAQTask::DigitalValueType > DynExpHardware::NIDAQHardwareAdapter::ReadDigitalValues | ( | ChannelHandleType | ChannelHandle | ) | const |
Definition at line 270 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 683 of file HardwareAdapterNIDAQ.cpp.
|
finaloverrideprivate |
Definition at line 468 of file HardwareAdapterNIDAQ.cpp.
|
inlineprivatevirtual |
Definition at line 200 of file HardwareAdapterNIDAQ.h.
void DynExpHardware::NIDAQHardwareAdapter::RestartTask | ( | ChannelHandleType | ChannelHandle | ) | const |
Definition at line 447 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 591 of file HardwareAdapterNIDAQ.cpp.
void DynExpHardware::NIDAQHardwareAdapter::StartTask | ( | ChannelHandleType | ChannelHandle | ) | const |
Definition at line 433 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 577 of file HardwareAdapterNIDAQ.cpp.
void DynExpHardware::NIDAQHardwareAdapter::StopTask | ( | ChannelHandleType | ChannelHandle | ) | const |
Definition at line 440 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 585 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 611 of file HardwareAdapterNIDAQ.cpp.
|
private |
Definition at line 616 of file HardwareAdapterNIDAQ.cpp.
int32_t DynExpHardware::NIDAQHardwareAdapter::WriteAnalogValues | ( | ChannelHandleType | ChannelHandle, |
const std::vector< NIDAQTask::AnalogValueType > & | Values | ||
) | const |
Definition at line 398 of file HardwareAdapterNIDAQ.cpp.
int32_t DynExpHardware::NIDAQHardwareAdapter::WriteDigitalValues | ( | ChannelHandleType | ChannelHandle, |
const std::vector< NIDAQTask::DigitalValueType > & | Values | ||
) | const |
Definition at line 320 of file HardwareAdapterNIDAQ.cpp.
|
mutableprivate |
Definition at line 230 of file HardwareAdapterNIDAQ.h.