DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExp::HardwareAdapterSerialPortWorker Class Reference

Qt worker for serial/COM port communication in a separate thread. More...

+ Inheritance diagram for DynExp::HardwareAdapterSerialPortWorker:

Public Slots

void Init (QString PortName, QSerialPort::BaudRate BaudRate, QSerialPort::DataBits DataBits, QSerialPort::StopBits StopBits, QSerialPort::Parity Parity)
 Initializes HardwareAdapterSerialPortWorker::Port for serial communication with the given settings. More...
 
- Public Slots inherited from DynExp::QSerialCommunicationHardwareAdapterWorker
void Open ()
 Opens the communication connection. More...
 
void Close ()
 Closes the communication connection. More...
 
void Reset ()
 Resets the worker and the communication connection. More...
 
void Clear ()
 Clears the communication connection's buffers and state. More...
 
void Flush ()
 Flushes the communication connection's buffers. More...
 
void Read ()
 Reads from the communication connection's hardware interface. More...
 
void Write (const QString String)
 Writes String to the communication connection's hardware interface. More...
 
void Write_endl ()
 Writes end of the line character(s) to the communication connection's hardware interface. More...
 

Public Member Functions

 HardwareAdapterSerialPortWorker ()
 
virtual ~HardwareAdapterSerialPortWorker ()
 
- Public Member Functions inherited from DynExp::QSerialCommunicationHardwareAdapterWorker
 QSerialCommunicationHardwareAdapterWorker ()=default
 
virtual ~QSerialCommunicationHardwareAdapterWorker ()=0
 
- Public Member Functions inherited from Util::QWorker
void MoveToWorkerThread (DynExp::ItemIDType ID)
 Moves the instance to DynExpCore's worker thread. Do not call from constructor since derived classes have not been instantiated yet in that case. This would prevent QObjects contained in derived classes to be also moved to the worker thread. More...
 
auto GetOwner () const noexcept
 Returns this worker instance's owner. More...
 

Private Slots

void OnDataAvailable ()
 Qt slot called when Port has received data which can be read. More...
 

Private Member Functions

bool CheckError (const std::source_location Location=std::source_location::current()) const
 Checks whether Port is in an error state. If this is the case, sets an exception using QSerialCommunicationHardwareAdapterWorker::SetException(). More...
 
virtual void OpenChild () override
 Opens the communication connection. More...
 
virtual void CloseChild () override
 Closes the communication connection. More...
 
virtual void ResetChild () override
 Resets the worker and the communication connection. More...
 
virtual void ClearChild () override
 Clears the communication connection's buffers and state. More...
 
virtual void FlushChild () override
 Flushes the communication connection's buffers. More...
 
virtual void ReadChild () override
 Reads from the communication connection's hardware interface. More...
 
virtual void WriteChild (const QString &String) override
 Writes String to the communication connection's hardware interface. More...
 
virtual void Write_endl_Child () override
 Writes end of the line character(s) to the communication connection's hardware interface. More...
 

Private Attributes

QSerialPort Port
 COM port for serial communication. More...
 

Additional Inherited Members

- Protected Member Functions inherited from DynExp::QSerialCommunicationHardwareAdapterWorker
void SetCommunicationChannelOpened () const noexcept
 Calls QSerialCommunicationHardwareAdapter::SetCommunicationChannelOpened on QWorker::Owner. Does nothing if QWorker::Owner is nullptr. More...
 
void SetCommunicationChannelClosed () const noexcept
 Calls QSerialCommunicationHardwareAdapter::SetCommunicationChannelClosed on QWorker::Owner. Does nothing if QWorker::Owner is nullptr. More...
 
void DataRead (const std::string &String) const
 Calls QSerialCommunicationHardwareAdapter::DataRead on QWorker::Owner. Does nothing if QWorker::Owner is nullptr. More...
 
template<typename ExceptionType >
void SetException (const ExceptionType &Exception) const
 Calls QSerialCommunicationHardwareAdapter::SetException on QWorker::Owner. Does nothing if QWorker::Owner is nullptr. More...
 
- Protected Member Functions inherited from Util::QWorker
 QWorker ()=default
 
 ~QWorker ()=default
 

Detailed Description

Qt worker for serial/COM port communication in a separate thread.

Definition at line 96 of file HardwareAdapterSerialPort.h.

Constructor & Destructor Documentation

◆ HardwareAdapterSerialPortWorker()

DynExp::HardwareAdapterSerialPortWorker::HardwareAdapterSerialPortWorker ( )

Definition at line 30 of file HardwareAdapterSerialPort.cpp.

◆ ~HardwareAdapterSerialPortWorker()

virtual DynExp::HardwareAdapterSerialPortWorker::~HardwareAdapterSerialPortWorker ( )
inlinevirtual

Definition at line 102 of file HardwareAdapterSerialPort.h.

Member Function Documentation

◆ CheckError()

bool DynExp::HardwareAdapterSerialPortWorker::CheckError ( const std::source_location  Location = std::source_location::current()) const
private

Checks whether Port is in an error state. If this is the case, sets an exception using QSerialCommunicationHardwareAdapterWorker::SetException().

Parameters
LocationLocation from which this function is called. Do not pass anything.
Returns
Returns false in case of an error, true otherwise.

Definition at line 52 of file HardwareAdapterSerialPort.cpp.

◆ ClearChild()

void DynExp::HardwareAdapterSerialPortWorker::ClearChild ( )
overrideprivatevirtual

Clears the communication connection's buffers and state.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 92 of file HardwareAdapterSerialPort.cpp.

◆ CloseChild()

void DynExp::HardwareAdapterSerialPortWorker::CloseChild ( )
overrideprivatevirtual

Closes the communication connection.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 74 of file HardwareAdapterSerialPort.cpp.

◆ FlushChild()

void DynExp::HardwareAdapterSerialPortWorker::FlushChild ( )
overrideprivatevirtual

Flushes the communication connection's buffers.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 98 of file HardwareAdapterSerialPort.cpp.

◆ Init

void DynExp::HardwareAdapterSerialPortWorker::Init ( QString  PortName,
QSerialPort::BaudRate  BaudRate,
QSerialPort::DataBits  DataBits,
QSerialPort::StopBits  StopBits,
QSerialPort::Parity  Parity 
)
slot

Initializes HardwareAdapterSerialPortWorker::Port for serial communication with the given settings.

Parameters
PortNameCOM port name
BaudRateBaud rate
DataBitsAmount of data bits
StopBitsAmount of stop bits
ParityParity setting

Definition at line 36 of file HardwareAdapterSerialPort.cpp.

◆ OnDataAvailable

void DynExp::HardwareAdapterSerialPortWorker::OnDataAvailable ( )
privateslot

Qt slot called when Port has received data which can be read.

Definition at line 47 of file HardwareAdapterSerialPort.cpp.

◆ OpenChild()

void DynExp::HardwareAdapterSerialPortWorker::OpenChild ( )
overrideprivatevirtual

Opens the communication connection.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 64 of file HardwareAdapterSerialPort.cpp.

◆ ReadChild()

void DynExp::HardwareAdapterSerialPortWorker::ReadChild ( )
overrideprivatevirtual

Reads from the communication connection's hardware interface.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 104 of file HardwareAdapterSerialPort.cpp.

◆ ResetChild()

void DynExp::HardwareAdapterSerialPortWorker::ResetChild ( )
overrideprivatevirtual

Resets the worker and the communication connection.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 85 of file HardwareAdapterSerialPort.cpp.

◆ Write_endl_Child()

void DynExp::HardwareAdapterSerialPortWorker::Write_endl_Child ( )
overrideprivatevirtual

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

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 123 of file HardwareAdapterSerialPort.cpp.

◆ WriteChild()

void DynExp::HardwareAdapterSerialPortWorker::WriteChild ( const QString &  String)
overrideprivatevirtual

Writes String to the communication connection's hardware interface.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 113 of file HardwareAdapterSerialPort.cpp.

Member Data Documentation

◆ Port

QSerialPort DynExp::HardwareAdapterSerialPortWorker::Port
private

COM port for serial communication.

Definition at line 138 of file HardwareAdapterSerialPort.h.


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