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

Qt worker for network communication in a separate thread. More...

+ Inheritance diagram for DynExp::HardwareAdapterTcpSocketWorker:

Public Slots

void Init (QString ServerName, quint16 Port)
 Initializes HardwareAdapterTcpSocketWorker::Socket for TCP 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

 HardwareAdapterTcpSocketWorker ()
 
virtual ~HardwareAdapterTcpSocketWorker ()
 
- 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 OnConnected ()
 Qt slot called when Socket has been connected. Calls QSerialCommunicationHardwareAdapterWorker::SetCommunicationChannelOpened(). More...
 
void OnDisconnected ()
 Qt slot called when Socket has been disconnected. Calls QSerialCommunicationHardwareAdapterWorker::SetCommunicationChannelClosed(). More...
 
void OnErrorOccurred (QAbstractSocket::SocketError SocketError)
 Qt slot called when Socket transitioned into an error state. Calls QSerialCommunicationHardwareAdapterWorker::SetException() to store a NetworkException constructed from SocketError. More...
 
void OnDataAvailable ()
 Qt slot called when Socket has received data which can be read. Calls QSerialCommunicationHardwareAdapterWorker::Read(). More...
 

Private Member Functions

bool IsOpen () const noexcept
 Checks whether Socket is connected. More...
 
bool IsOpening () const noexcept
 Checks whether Socket is connecting right now. 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

QString ServerName
 IP address to connect to. More...
 
quint16 Port
 Network port to connect to. More...
 
QTcpSocket Socket
 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 network communication in a separate thread.

Definition at line 109 of file HardwareAdapterEthernet.h.

Constructor & Destructor Documentation

◆ HardwareAdapterTcpSocketWorker()

DynExp::HardwareAdapterTcpSocketWorker::HardwareAdapterTcpSocketWorker ( )

Definition at line 9 of file HardwareAdapterEthernet.cpp.

◆ ~HardwareAdapterTcpSocketWorker()

virtual DynExp::HardwareAdapterTcpSocketWorker::~HardwareAdapterTcpSocketWorker ( )
inlinevirtual

Definition at line 115 of file HardwareAdapterEthernet.h.

Member Function Documentation

◆ ClearChild()

void DynExp::HardwareAdapterTcpSocketWorker::ClearChild ( )
overrideprivatevirtual

Clears the communication connection's buffers and state.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 77 of file HardwareAdapterEthernet.cpp.

◆ CloseChild()

void DynExp::HardwareAdapterTcpSocketWorker::CloseChild ( )
overrideprivatevirtual

Closes the communication connection.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 65 of file HardwareAdapterEthernet.cpp.

◆ FlushChild()

void DynExp::HardwareAdapterTcpSocketWorker::FlushChild ( )
overrideprivatevirtual

Flushes the communication connection's buffers.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 82 of file HardwareAdapterEthernet.cpp.

◆ Init

void DynExp::HardwareAdapterTcpSocketWorker::Init ( QString  ServerName,
quint16  Port 
)
slot

Initializes HardwareAdapterTcpSocketWorker::Socket for TCP communication with the given settings.

Parameters
ServerNameIP address
PortNetwork port

Definition at line 21 of file HardwareAdapterEthernet.cpp.

◆ IsOpen()

bool DynExp::HardwareAdapterTcpSocketWorker::IsOpen ( ) const
privatenoexcept

Checks whether Socket is connected.

Returns
Returns true if Socket is in a connected or bound state, false otherwise.

Definition at line 47 of file HardwareAdapterEthernet.cpp.

◆ IsOpening()

bool DynExp::HardwareAdapterTcpSocketWorker::IsOpening ( ) const
privatenoexcept

Checks whether Socket is connecting right now.

Returns
Returns true if Socket is in a connecting or host look-up state, false otherwise.

Definition at line 53 of file HardwareAdapterEthernet.cpp.

◆ OnConnected

void DynExp::HardwareAdapterTcpSocketWorker::OnConnected ( )
privateslot

Qt slot called when Socket has been connected. Calls QSerialCommunicationHardwareAdapterWorker::SetCommunicationChannelOpened().

Definition at line 27 of file HardwareAdapterEthernet.cpp.

◆ OnDataAvailable

void DynExp::HardwareAdapterTcpSocketWorker::OnDataAvailable ( )
privateslot

Qt slot called when Socket has received data which can be read. Calls QSerialCommunicationHardwareAdapterWorker::Read().

Definition at line 42 of file HardwareAdapterEthernet.cpp.

◆ OnDisconnected

void DynExp::HardwareAdapterTcpSocketWorker::OnDisconnected ( )
privateslot

Qt slot called when Socket has been disconnected. Calls QSerialCommunicationHardwareAdapterWorker::SetCommunicationChannelClosed().

Definition at line 32 of file HardwareAdapterEthernet.cpp.

◆ OnErrorOccurred

void DynExp::HardwareAdapterTcpSocketWorker::OnErrorOccurred ( QAbstractSocket::SocketError  SocketError)
privateslot

Qt slot called when Socket transitioned into an error state. Calls QSerialCommunicationHardwareAdapterWorker::SetException() to store a NetworkException constructed from SocketError.

Parameters
SocketErrorInformation about the error occurred to Socket.

Definition at line 37 of file HardwareAdapterEthernet.cpp.

◆ OpenChild()

void DynExp::HardwareAdapterTcpSocketWorker::OpenChild ( )
overrideprivatevirtual

Opens the communication connection.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 59 of file HardwareAdapterEthernet.cpp.

◆ ReadChild()

void DynExp::HardwareAdapterTcpSocketWorker::ReadChild ( )
overrideprivatevirtual

Reads from the communication connection's hardware interface.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 88 of file HardwareAdapterEthernet.cpp.

◆ ResetChild()

void DynExp::HardwareAdapterTcpSocketWorker::ResetChild ( )
overrideprivatevirtual

Resets the worker and the communication connection.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 71 of file HardwareAdapterEthernet.cpp.

◆ Write_endl_Child()

void DynExp::HardwareAdapterTcpSocketWorker::Write_endl_Child ( )
overrideprivatevirtual

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

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 103 of file HardwareAdapterEthernet.cpp.

◆ WriteChild()

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

Writes String to the communication connection's hardware interface.

Implements DynExp::QSerialCommunicationHardwareAdapterWorker.

Definition at line 96 of file HardwareAdapterEthernet.cpp.

Member Data Documentation

◆ Port

quint16 DynExp::HardwareAdapterTcpSocketWorker::Port
private

Network port to connect to.

Definition at line 176 of file HardwareAdapterEthernet.h.

◆ ServerName

QString DynExp::HardwareAdapterTcpSocketWorker::ServerName
private

IP address to connect to.

Definition at line 175 of file HardwareAdapterEthernet.h.

◆ Socket

QTcpSocket DynExp::HardwareAdapterTcpSocketWorker::Socket
private

COM port for serial communication.

Definition at line 178 of file HardwareAdapterEthernet.h.


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