100 lines
3.5 KiB
C++
100 lines
3.5 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
*
|
|
* Copyright (C) 2013 - 2024, nymea GmbH
|
|
* Copyright (C) 2024 - 2025, chargebyte austria GmbH
|
|
*
|
|
* This file is part of libnymea-app.
|
|
*
|
|
* libnymea-app is free software: you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
* as published by the Free Software Foundation, either version 3
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* libnymea-app is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with libnymea-app. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
#ifndef MODBUSRTUMASTER_H
|
|
#define MODBUSRTUMASTER_H
|
|
|
|
#include <QUuid>
|
|
#include <QObject>
|
|
|
|
#include "types/serialport.h"
|
|
|
|
class ModbusRtuMaster : public QObject
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(QUuid modbusUuid READ modbusUuid CONSTANT)
|
|
Q_PROPERTY(QString serialPort READ serialPort NOTIFY serialPortChanged)
|
|
Q_PROPERTY(qint32 baudrate READ baudrate NOTIFY baudrateChanged)
|
|
Q_PROPERTY(SerialPort::SerialPortParity parity READ parity NOTIFY parityChanged)
|
|
Q_PROPERTY(SerialPort::SerialPortDataBits dataBits READ dataBits NOTIFY dataBitsChanged)
|
|
Q_PROPERTY(SerialPort::SerialPortStopBits stopBits READ stopBits NOTIFY stopBitsChanged)
|
|
Q_PROPERTY(uint numberOfRetries READ numberOfRetries WRITE setNumberOfRetries NOTIFY numberOfRetriesChanged)
|
|
Q_PROPERTY(uint timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged)
|
|
Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
|
|
|
|
public:
|
|
explicit ModbusRtuMaster(QObject *parent = nullptr);
|
|
|
|
QUuid modbusUuid() const;
|
|
void setModbusUuid(const QUuid &modbusUuid);
|
|
|
|
QString serialPort() const;
|
|
void setSerialPort(const QString &serialPort);
|
|
|
|
qint32 baudrate() const;
|
|
void setBaudrate(qint32 baudrate);
|
|
|
|
SerialPort::SerialPortParity parity() const;
|
|
void setParity(SerialPort::SerialPortParity parity);
|
|
|
|
SerialPort::SerialPortDataBits dataBits() const;
|
|
void setDataBits(SerialPort::SerialPortDataBits dataBits);
|
|
|
|
SerialPort::SerialPortStopBits stopBits() const;
|
|
void setStopBits(SerialPort::SerialPortStopBits stopBits);
|
|
|
|
uint numberOfRetries() const;
|
|
void setNumberOfRetries(uint numberOfRetries);
|
|
|
|
uint timeout() const;
|
|
void setTimeout(uint timeout);
|
|
|
|
bool connected() const;
|
|
void setConnected(bool connected);
|
|
|
|
signals:
|
|
void connectedChanged(bool connected);
|
|
void serialPortChanged(const QString &serialPort);
|
|
void baudrateChanged(quint32 baudrate);
|
|
void parityChanged(SerialPort::SerialPortParity parity);
|
|
void dataBitsChanged(SerialPort::SerialPortDataBits dataBits);
|
|
void stopBitsChanged(SerialPort::SerialPortStopBits stopBits);
|
|
void numberOfRetriesChanged(uint numberOfRetries);
|
|
void timeoutChanged(uint timeout);
|
|
|
|
private:
|
|
QUuid m_modbusUuid;
|
|
QString m_serialPort;
|
|
qint32 m_baudrate;
|
|
SerialPort::SerialPortParity m_parity;
|
|
SerialPort::SerialPortDataBits m_dataBits;
|
|
SerialPort::SerialPortStopBits m_stopBits;
|
|
uint m_numberOfRetries = 3;
|
|
uint m_timeout = 100;
|
|
bool m_connected = false;
|
|
|
|
};
|
|
|
|
#endif // MODBUSRTUMASTER_H
|