#ifndef LINERINGER_H
#define LINERINGER_H

#include <QWidget>
#include <QModbusTcpClient>
#include <QModbusRtuSerialMaster>
#include <QSerialPortInfo>
#include <QSerialPort>
#include <QMessageBox>
#include <QProgressDialog>

namespace Ui {
class LineRinger;
}

class LineRinger : public QWidget
{
    Q_OBJECT

public:
    enum callStatus{
        NOERROR = 0,
        ERROR = 1,
        INTERRUPT = 2
    };

    explicit LineRinger(QWidget *parent = nullptr);
    ~LineRinger();
    callStatus lineCall();

signals:
    void stopLineCall();

private slots:
    void on_connectButton_clicked();

    void on_ringButton_clicked();

    void on_checkAutoBaud_stateChanged(int arg1);

private:
    Ui::LineRinger *ui;

    void syncColumnHeaders();

    struct deviceOnLine
    {
        uint8_t adr;
        unsigned baudRate;
        QString fields[7] = {"Undefined", "Undefined", "Undefined", "Undefined", "Undefined", "Undefined", "Undefined"};
    };
    QVector<deviceOnLine>devicesList;
    bool isAutoBaud = false;
    unsigned currentBaudRate;

    QModbusClient *modbusDevice = nullptr;
};

#endif // LINERINGER_H
