18 class HardwareAdapterTcpSocket;
34 const std::source_location Location = std::source_location::current()) noexcept
50 :
ServerName{ Owner,
"ServerName",
"Server name",
51 "IP address or host name of the server to connect to", true,
"localhost" },
52 Port{ Owner,
"Port",
"Server port",
53 "Port of the remote server to connect to", true, 1000, 1, std::numeric_limits<uint16_t>::max(), 1, 0 }
81 virtual const char*
GetParamClassTag() const noexcept
override {
return "HardwareAdapterTcpSocketParams"; }
158 bool IsOpen() const noexcept;
172 virtual
void WriteChild(const QString& String) override;
193 constexpr
static auto Name() noexcept {
return "TCP Socket"; }
198 virtual std::string
GetName()
const override {
return Name(); }
201 QWorkerPtrType MakeWorker()
override;
212 void ResetImpl(dispatch_tag<QSerialCommunicationHardwareAdapter>)
override final;
Implementation of DynExp hardware adapter objects.
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Defines the base class for a hardware adapter object. Hardware adapters describe interfaces/connectio...
Configurator class for HardwareAdapterBase.
Parameter class for HardwareAdapterBase.
Configurator class for HardwareAdapterTcpSocket.
virtual ParamsBasePtrType MakeParams(ItemIDType ID, const DynExpCore &Core) const override
Override to make derived classes call DynExp::MakeParams with the correct configurator type derived f...
HardwareAdapterTcpSocketConfigurator()=default
virtual ~HardwareAdapterTcpSocketConfigurator()=default
Parameter class for HardwareAdapterTcpSocket.
void ConfigureParamsImpl(dispatch_tag< QSerialCommunicationHardwareAdapterParams >) override final
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
HardwareAdapterTcpSocketParams(ItemIDType ID, const DynExpCore &Core)
Constructs the parameters for a HardwareAdapterTcpSocket instance.
NetworkParamsExtension NetworkParams
Bundles several parameters to describe a network connection. Use in parameter classes.
virtual void ConfigureParamsImpl(dispatch_tag< HardwareAdapterTcpSocketParams >)
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
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...
virtual ~HardwareAdapterTcpSocketParams()=default
Qt worker for network communication in a separate thread.
virtual void ResetChild() override
Resets the worker and the communication connection.
bool IsOpen() const noexcept
Checks whether Socket is connected.
virtual void Write_endl_Child() override
Writes end of the line character(s) to the communication connection's hardware interface.
HardwareAdapterTcpSocketWorker()
virtual void ClearChild() override
Clears the communication connection's buffers and state.
void OnDisconnected()
Qt slot called when Socket has been disconnected. Calls QSerialCommunicationHardwareAdapterWorker::Se...
void Init(QString ServerName, quint16 Port)
Initializes HardwareAdapterTcpSocketWorker::Socket for TCP communication with the given settings.
QString ServerName
IP address to connect to.
virtual void WriteChild(const QString &String) override
Writes String to the communication connection's hardware interface.
void OnConnected()
Qt slot called when Socket has been connected. Calls QSerialCommunicationHardwareAdapterWorker::SetCo...
virtual void OpenChild() override
Opens the communication connection.
void OnDataAvailable()
Qt slot called when Socket has received data which can be read. Calls QSerialCommunicationHardwareAda...
virtual ~HardwareAdapterTcpSocketWorker()
virtual void CloseChild() override
Closes the communication connection.
void OnErrorOccurred(QAbstractSocket::SocketError SocketError)
Qt slot called when Socket transitioned into an error state. Calls QSerialCommunicationHardwareAdapte...
QTcpSocket Socket
COM port for serial communication.
quint16 Port
Network port to connect to.
virtual void FlushChild() override
Flushes the communication connection's buffers.
virtual void ReadChild() override
Reads from the communication connection's hardware interface.
bool IsOpening() const noexcept
Checks whether Socket is connecting right now.
Implements a hardware adapter to communicate with text-based commands over TCP sockets.
constexpr static auto Name() noexcept
Every derived class has to redefine this function.
virtual void ResetImpl(dispatch_tag< HardwareAdapterTcpSocket >)
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
virtual ~HardwareAdapterTcpSocket()=default
void InitSig(QString ServerName, quint16 Port)
Initializes HardwareAdapterTcpSocketWorker::Socket for TCP communication with the given settings.
void InitWorker() override
Tells the worker instance to perform initialization steps, e.g. by emitting a Qt signal which is rece...
virtual std::string GetName() const override
Returns the name of this Object type.
Defines an exception caused by a hardware operation on an ethernet interface (e.g....
NetworkException(std::string Description, const int ErrorCode, const std::source_location Location=std::source_location::current()) noexcept
Constructs a NetworkException instance.
Bundles several parameters to describe a network connection. Use in parameter classes.
NetworkParamsExtension(DynExp::ParamsBase &Owner)
Constructs a NetworkParamsExtension instance.
std::string MakeAddress() const
Builds a network address from the parameters' content.
DynExp::ParamsBase::Param< ParamsConfigDialog::NumberType > Port
Network port.
DynExp::ParamsBase::Param< ParamsConfigDialog::TextType > ServerName
IP address.
Refer to ParamsBase::dispatch_tag.
Abstract base class for object parameter classes. Each class derived from class Object must be accomp...
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
const DynExpCore & Core
Reference to DynExp's core.
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Configurator class for QSerialCommunicationHardwareAdapter.
Parameter class for QSerialCommunicationHardwareAdapter.
Qt worker which performs actual serial communication hardware operations in a separate thread in orde...
SerialCommunicationHardwareAdapter is based on a Qt communication object (wrapped by QSerialCommunica...
Defines an exception caused by a serial communication operation of a hardware adapter.
const int ErrorCode
DynExp error code from DynExpErrorCodes::DynExpErrorCodes
DynExp's main namespace contains the implementation of DynExp including classes to manage resources (...
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
size_t ItemIDType
ID type of objects/items managed by DynExp.
std::string ToStr(const T &Value, int Precision=-1)
Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.
Accumulates include statements to provide a precompiled header.