DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExp::QSerialCommunicationHardwareAdapter Class Referenceabstract

SerialCommunicationHardwareAdapter is based on a Qt communication object (wrapped by QSerialCommunicationHardwareAdapterWorker) which cannot be shared between different threads. Instead, it lives in a DynExpCore's worker thread. QSerialCommunicationHardwareAdapter just pushes messages to it and allows the QSerialCommunicationHardwareAdapterWorker instance to communicate its state and data to the corresponding QSerialCommunicationHardwareAdapter instance. More...

+ Inheritance diagram for DynExp::QSerialCommunicationHardwareAdapter:

Classes

class  QSerialCommunicationHardwareAdapterWorkerOnlyType
 Allow exclusive access to some of QSerialCommunicationHardwareAdapter's private methods to QSerialCommunicationHardwareAdapterWorkerOnlyType. More...
 

Public Types

using ParamsType = QSerialCommunicationHardwareAdapterParams
 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 = QSerialCommunicationHardwareAdapterConfigurator
 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 QWorkerPtrType = std::unique_ptr< QSerialCommunicationHardwareAdapterWorker >
 Pointer-type owning the related QSerialCommunicationHardwareAdapterWorker instance. More...
 
- Public Types inherited from DynExp::SerialCommunicationHardwareAdapter
using ParamsType = SerialCommunicationHardwareAdapterParams
 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 = SerialCommunicationHardwareAdapterConfigurator
 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::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...
 

Signals

Qt signals

Signals emitted by this hardware adapter. The worker instance's slots are connected to them to handles the signals.

void OpenSig ()
 Opens the communication connection. More...
 
void CloseSig ()
 Closes the communication connection. More...
 
void ResetSig ()
 Resets the worker and the communication connection. More...
 
void ClearSig () const
 Clears the communication connection's buffers and state. More...
 
void FlushSig () const
 Flushes the communication connection's buffers. More...
 
void ReadSig () const
 Reads from the communication connection's hardware interface. More...
 
void WriteSig (const QString String) const
 Writes String to the communication connection's hardware interface. More...
 
void Write_endl_Sig () const
 Writes end of the line character(s) to the communication connection's hardware interface. More...
 

Public Member Functions

 QSerialCommunicationHardwareAdapter (const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
 Constructs a hardware adapter instance. More...
 
virtual ~QSerialCommunicationHardwareAdapter ()=0
 
- Public Member Functions inherited from DynExp::SerialCommunicationHardwareAdapter
 SerialCommunicationHardwareAdapter (const std::thread::id OwnerThreadID, ParamsBasePtrType &&Params)
 Constructs a hardware adapter instance. More...
 
virtual ~SerialCommunicationHardwareAdapter ()=0
 
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...
 
auto GetLineEnding () const
 Getter for LineEnding. Thread-safe since LineEnding only changes when Object::Reset() is called (itself calling ResetImpl(dispatch_tag<HardwareAdapterBase>) which calls Init()). LineEnding is still std::atomic since QSerialCommunicationHardwareAdapterWorker running in DynExpCore's worker thread might read it anytime - even if there is no Object instance which makes use of this hardware adapter instance. More...
 
std::string ReadLine () const
 Calls ReadIntoBuffer() before it extracts the first line from the read buffer. More...
 
std::string ReadAll () const
 Calls ReadIntoBuffer() before it extracts the entire content from the read buffer. More...
 
std::string WaitForLine (unsigned int NumTries=10, std::chrono::milliseconds DelayBetweenTries=std::chrono::milliseconds(10)) const
 Calls ReadLine() for NumTries times until a line is received. Makes the calling thread sleep for DelayBetweenTries in between the calls to ReadLine(). More...
 
void Clear () const
 Clears the content and state flags of the read buffer (ReadBuffer) as well as possible internal buffers of the underlying hardware interface. More...
 
void Flush () const
 Flushes the underlying hardware interface and calls ReadIntoBuffer(). More...
 
const SerialCommunicationHardwareAdapteroperator>> (std::stringstream &OutStream) const
 Writes the read buffer's content into OutStream calling ReadAll(). More...
 
const SerialCommunicationHardwareAdapteroperator<< (endl) const
 Writes a new line calling Write_endl(). More...
 
const SerialCommunicationHardwareAdapteroperator<< (const std::stringstream &InStream) const
 Writes the input parameter calling Write(). Also writes endl at the end automatically. More...
 
const SerialCommunicationHardwareAdapteroperator<< (const std::string &Text) const
 Writes the input parameter calling Write(). Also writes endl at the end automatically. More...
 
const SerialCommunicationHardwareAdapteroperator<< (const std::string_view Text) const
 Writes the input parameter calling Write(). Also writes endl at the end automatically. More...
 
const SerialCommunicationHardwareAdapteroperator<< (const char *Text) const
 Writes the input parameter calling Write(). Also writes endl at the end automatically. More...
 
const SerialCommunicationHardwareAdapteroperator<< (const char Char) const
 Writes the input parameter calling Write(). Also writes endl at the end automatically. More...
 
template<typename T >
auto & operator<< (const T &Value) const
 Writes the input parameter calling Write(). Also writes endl at the end automatically. More...
 
- 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
 
INonCopyableoperator= (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...
 

Public Attributes

QSerialCommunicationHardwareAdapterWorkerOnlyType QSerialCommunicationHardwareAdapterWorkerOnly
 Allow exclusive access to some of QSerialCommunicationHardwareAdapter's private methods to QSerialCommunicationHardwareAdapterWorkerOnlyType. More...
 
- Public Attributes inherited from DynExp::Object
LinkedObjectWrapperOnlyType LinkedObjectWrapperOnly
 Allow exclusive access to some of Object's private methods to any LinkedObjectWrapper<T>. More...
 

Private Member Functions

void ResetImpl (dispatch_tag< SerialCommunicationHardwareAdapter >) override final
 Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy. More...
 
virtual void ResetImpl (dispatch_tag< QSerialCommunicationHardwareAdapter >)
 Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy. More...
 
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...
 
Override

Override by derived class.

virtual QWorkerPtrType MakeWorker ()=0
 Abstract factory function for a worker instance derived from QSerialCommunicationHardwareAdapterWorker. Also connects Qt signals to the worker instance's slots. More...
 
virtual void InitWorker ()
 Tells the worker instance to perform initialization steps, e.g. by emitting a Qt signal which is received by the worker's slots. More...
 
Thread-safe public functions

Thread-safe since mutex is locked. To be called from QSerialCommunicationHardwareAdapterWorker. Logical const-ness: QSerialCommunicationHardwareAdapterWorker can only access const members.

void SetCommunicationChannelOpened () const noexcept
 Sets CommunicationChannelOpened to true. More...
 
void SetCommunicationChannelClosed () const noexcept
 Sets CommunicationChannelOpened to false. More...
 
void DataRead (const std::string &String) const
 Passes data to the hardware adapter which has been received by the worker instance. More...
 
template<typename ExceptionType >
void SetException (const ExceptionType &Exception) const noexcept
 Sets Exception as PendingException and stores it by calling HardwareAdapterBase::SetExceptionUnsafe(). More...
 
Not thread-safe

These functions must be called by a function calling AcquireLock() before.

void ClearChild () const override final
 Clears internal buffers of the underlying hardware interface. More...
 
void FlushChild () const override final
 Flushes the underlying hardware interface. More...
 
std::string Read () const override final
 Reads a string from the underlying hardware interface. More...
 
void Write (const std::string &String) const override final
 Writes a string to the underlying hardware interface. More...
 
void Write_endl () const override final
 Writes end of the line characters to the underlying hardware interface. More...
 
void ThrowPendingException () const
 If PendingException is not nullptr, sets it to nullptr and throws the exception calling Util::ForwardException(). Called by overridden methods which perform hardware operations to ensure that the hardware adapter handles exceptions which have occurred in its worker instance. More...
 

Private Attributes

QSerialCommunicationHardwareAdapterWorkerWorker
 Worker instance running in its own thread to handle the actual communication there. More...
 
std::atomic< bool > CommunicationChannelOpened
 Indicates whether the worker instance has opened the communication channel. More...
 
std::exception_ptr PendingException
 Stores exceptions which have occurred in the worker instance thread. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DynExp::SerialCommunicationHardwareAdapter
constexpr static auto Name () noexcept
 Every derived class has to redefine this function. More...
 
constexpr static auto Category () noexcept
 Every derived class has to redefine this function. More...
 
constexpr static std::array< char, 2 > LineEndingToChar (SerialCommunicationHardwareAdapterParams::LineEndingType LineEnding) noexcept
 Converts SerialCommunicationHardwareAdapterParams::LineEndingType to two characters being used as the respective line ending. More...
 
constexpr static unsigned int GetLineEndingLength (SerialCommunicationHardwareAdapterParams::LineEndingType LineEnding) noexcept
 Determines the amount of characters required to express a line ending type defined by SerialCommunicationHardwareAdapterParams::LineEndingType. More...
 
constexpr static auto GetMaxBufferSize () noexcept
 Defines the maximal size of the hardware adapter's (read) buffer. More...
 
- 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...
 
- 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::SerialCommunicationHardwareAdapter
void InsertIntoBuffer (const std::string &String) const
 This method can be called from derived classes to manually insert data into the read buffer. This can be especially useful if there is some callback mechanism which notifies the derived object as soon as data is available. If this mechanism is used, it is fine to let the overridden Read() method just return en empty string. This function is thread-safe. More...
 
- 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...
 

Detailed Description

SerialCommunicationHardwareAdapter is based on a Qt communication object (wrapped by QSerialCommunicationHardwareAdapterWorker) which cannot be shared between different threads. Instead, it lives in a DynExpCore's worker thread. QSerialCommunicationHardwareAdapter just pushes messages to it and allows the QSerialCommunicationHardwareAdapterWorker instance to communicate its state and data to the corresponding QSerialCommunicationHardwareAdapter instance.

Definition at line 628 of file HardwareAdapter.h.

Member Typedef Documentation

◆ ConfigType

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.

Definition at line 663 of file HardwareAdapter.h.

◆ ParamsType

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.

Definition at line 662 of file HardwareAdapter.h.

◆ QWorkerPtrType

Constructor & Destructor Documentation

◆ QSerialCommunicationHardwareAdapter()

DynExp::QSerialCommunicationHardwareAdapter::QSerialCommunicationHardwareAdapter ( const std::thread::id  OwnerThreadID,
ParamsBasePtrType &&  Params 
)

Constructs a hardware adapter instance.

Parameters
OwnerThreadIDThread id of the thread owning the Object instance to be constructed.
ParamsParameter class instance to be assigned to the Object instance to be constructed.
Exceptions
Util::InvalidArgExceptionis thrown if OwnerThreadID is an invalid thread id or if Params is nullptr.

Definition at line 384 of file HardwareAdapter.cpp.

◆ ~QSerialCommunicationHardwareAdapter()

DynExp::QSerialCommunicationHardwareAdapter::~QSerialCommunicationHardwareAdapter ( )
pure virtual

Definition at line 390 of file HardwareAdapter.cpp.

Member Function Documentation

◆ ClearChild()

void DynExp::QSerialCommunicationHardwareAdapter::ClearChild ( ) const
finaloverrideprivatevirtual

Clears internal buffers of the underlying hardware interface.

Reimplemented from DynExp::SerialCommunicationHardwareAdapter.

Definition at line 456 of file HardwareAdapter.cpp.

◆ ClearSig

void DynExp::QSerialCommunicationHardwareAdapter::ClearSig ( ) const
signal

Clears the communication connection's buffers and state.

◆ CloseSig

void DynExp::QSerialCommunicationHardwareAdapter::CloseSig ( )
signal

Closes the communication connection.

◆ DataRead()

void DynExp::QSerialCommunicationHardwareAdapter::DataRead ( const std::string &  String) const
private

Passes data to the hardware adapter which has been received by the worker instance.

Parameters
StringString read by the worker instance

Definition at line 400 of file HardwareAdapter.cpp.

◆ EnsureReadyStateChild()

void DynExp::QSerialCommunicationHardwareAdapter::EnsureReadyStateChild ( )
finaloverrideprivatevirtual

Ensures that this Object instance is ready by possibly starting its worker thread or by opening connections to hardware devices.

Exceptions
Util::InvalidArgExceptionis thrown if Worker is nullptr.

Implements DynExp::HardwareAdapterBase.

Definition at line 413 of file HardwareAdapter.cpp.

◆ FlushChild()

void DynExp::QSerialCommunicationHardwareAdapter::FlushChild ( ) const
finaloverrideprivatevirtual

Flushes the underlying hardware interface.

Reimplemented from DynExp::SerialCommunicationHardwareAdapter.

Definition at line 463 of file HardwareAdapter.cpp.

◆ FlushSig

void DynExp::QSerialCommunicationHardwareAdapter::FlushSig ( ) const
signal

Flushes the communication connection's buffers.

◆ InitWorker()

virtual void DynExp::QSerialCommunicationHardwareAdapter::InitWorker ( )
inlineprivatevirtual

Tells the worker instance to perform initialization steps, e.g. by emitting a Qt signal which is received by the worker's slots.

Reimplemented in DynExp::HardwareAdapterSerialPort, and DynExp::HardwareAdapterTcpSocket.

Definition at line 689 of file HardwareAdapter.h.

◆ IsConnectedChild()

bool DynExp::QSerialCommunicationHardwareAdapter::IsConnectedChild ( ) const
finaloverrideprivatevirtualnoexcept

Determines the connection status of the hardware interface.

Returns
Returns true when the hardware adapter is connected to the physical hardware device, false otherwise.

Implements DynExp::HardwareAdapterBase.

Definition at line 451 of file HardwareAdapter.cpp.

◆ IsReadyChild()

bool DynExp::QSerialCommunicationHardwareAdapter::IsReadyChild ( ) const
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).

Returns
Returns true if this Object instance is ready, false otherwise.

Implements DynExp::Object.

Definition at line 441 of file HardwareAdapter.cpp.

◆ MakeWorker()

virtual QWorkerPtrType DynExp::QSerialCommunicationHardwareAdapter::MakeWorker ( )
privatepure virtual

Abstract factory function for a worker instance derived from QSerialCommunicationHardwareAdapterWorker. Also connects Qt signals to the worker instance's slots.

Returns
Pointer to a new instance of a worker this hardware adapter takes ownership of

Implemented in DynExp::HardwareAdapterSerialPort, and DynExp::HardwareAdapterTcpSocket.

◆ OpenSig

void DynExp::QSerialCommunicationHardwareAdapter::OpenSig ( )
signal

Opens the communication connection.

◆ Read()

std::string DynExp::QSerialCommunicationHardwareAdapter::Read ( ) const
finaloverrideprivatevirtual

Reads a string from the underlying hardware interface.

Returns
String read from the hardware interface

Implements DynExp::SerialCommunicationHardwareAdapter.

Definition at line 470 of file HardwareAdapter.cpp.

◆ ReadSig

void DynExp::QSerialCommunicationHardwareAdapter::ReadSig ( ) const
signal

Reads from the communication connection's hardware interface.

◆ ResetImpl() [1/2]

virtual void DynExp::QSerialCommunicationHardwareAdapter::ResetImpl ( dispatch_tag< QSerialCommunicationHardwareAdapter )
inlineprivatevirtual

Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy.

Reimplemented in DynExp::HardwareAdapterSerialPort, and DynExp::HardwareAdapterTcpSocket.

Definition at line 693 of file HardwareAdapter.h.

◆ ResetImpl() [2/2]

void DynExp::QSerialCommunicationHardwareAdapter::ResetImpl ( dispatch_tag< SerialCommunicationHardwareAdapter )
finaloverrideprivatevirtual

Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every derived class gets called - starting from DynExp::Object, descending the inheritance hierarchy.

Reimplemented from DynExp::SerialCommunicationHardwareAdapter.

Definition at line 405 of file HardwareAdapter.cpp.

◆ ResetSig

void DynExp::QSerialCommunicationHardwareAdapter::ResetSig ( )
signal

Resets the worker and the communication connection.

◆ SetCommunicationChannelClosed()

void DynExp::QSerialCommunicationHardwareAdapter::SetCommunicationChannelClosed ( ) const
inlineprivatenoexcept

Sets CommunicationChannelOpened to false.

Definition at line 710 of file HardwareAdapter.h.

◆ SetCommunicationChannelOpened()

void DynExp::QSerialCommunicationHardwareAdapter::SetCommunicationChannelOpened ( ) const
inlineprivatenoexcept

Sets CommunicationChannelOpened to true.

Definition at line 709 of file HardwareAdapter.h.

◆ SetException()

template<typename ExceptionType >
void DynExp::QSerialCommunicationHardwareAdapter::SetException ( const ExceptionType &  Exception) const
inlineprivatenoexcept

Sets Exception as PendingException and stores it by calling HardwareAdapterBase::SetExceptionUnsafe().

Template Parameters
ExceptionTypeType of the exception to be stored
Parameters
ExceptionException to be stores

Definition at line 725 of file HardwareAdapter.h.

◆ ThrowPendingException()

void DynExp::QSerialCommunicationHardwareAdapter::ThrowPendingException ( ) const
private

If PendingException is not nullptr, sets it to nullptr and throws the exception calling Util::ForwardException(). Called by overridden methods which perform hardware operations to ensure that the hardware adapter handles exceptions which have occurred in its worker instance.

Definition at line 494 of file HardwareAdapter.cpp.

◆ Write()

void DynExp::QSerialCommunicationHardwareAdapter::Write ( const std::string &  String) const
finaloverrideprivatevirtual

Writes a string to the underlying hardware interface.

Parameters
StringString to write

Implements DynExp::SerialCommunicationHardwareAdapter.

Definition at line 480 of file HardwareAdapter.cpp.

◆ Write_endl()

void DynExp::QSerialCommunicationHardwareAdapter::Write_endl ( ) const
finaloverrideprivatevirtual

Writes end of the line characters to the underlying hardware interface.

Implements DynExp::SerialCommunicationHardwareAdapter.

Definition at line 487 of file HardwareAdapter.cpp.

◆ Write_endl_Sig

void DynExp::QSerialCommunicationHardwareAdapter::Write_endl_Sig ( ) const
signal

Writes end of the line character(s) to the communication connection's hardware interface.

◆ WriteSig

void DynExp::QSerialCommunicationHardwareAdapter::WriteSig ( const QString  String) const
signal

Writes String to the communication connection's hardware interface.

Member Data Documentation

◆ CommunicationChannelOpened

std::atomic<bool> DynExp::QSerialCommunicationHardwareAdapter::CommunicationChannelOpened
mutableprivate

Indicates whether the worker instance has opened the communication channel.

Definition at line 780 of file HardwareAdapter.h.

◆ PendingException

std::exception_ptr DynExp::QSerialCommunicationHardwareAdapter::PendingException
mutableprivate

Stores exceptions which have occurred in the worker instance thread.

Definition at line 781 of file HardwareAdapter.h.

◆ QSerialCommunicationHardwareAdapterWorkerOnly

QSerialCommunicationHardwareAdapterWorkerOnlyType DynExp::QSerialCommunicationHardwareAdapter::QSerialCommunicationHardwareAdapterWorkerOnly

Allow exclusive access to some of QSerialCommunicationHardwareAdapter's private methods to QSerialCommunicationHardwareAdapterWorkerOnlyType.

Definition at line 669 of file HardwareAdapter.h.

◆ Worker

QSerialCommunicationHardwareAdapterWorker* DynExp::QSerialCommunicationHardwareAdapter::Worker
private

Worker instance running in its own thread to handle the actual communication there.

Definition at line 779 of file HardwareAdapter.h.


The documentation for this class was generated from the following files: