#ifndef BASECONN_H #define BASECONN_H #include #include #include #include #include #include #include #include #include #include #include #include "headers/appsettings.h" #include "headers/speedtimer.h" class BaseConn : public QObject { Q_OBJECT Q_PROPERTY(QString ipAdress WRITE setIP READ getIP) Q_PROPERTY(QString state READ getState NOTIFY stateChanged) Q_PROPERTY(int progress READ getProgress NOTIFY progressChanged) Q_PROPERTY(QStringList connections READ getConnections NOTIFY connectionsChanged) Q_PROPERTY(QString nextRemoteAction READ getNextRemoteAction NOTIFY nextRemoteActionChanged) Q_PROPERTY(float nextRemoteActionDelayProg READ getNextRemoteActionDelayProg NOTIFY nextRemoteActionDelayProgChanged) public: explicit BaseConn(QObject *parent = nullptr); // values for the socket connection int connection_progress; QString ip; qint16 port = 3563; int errors; int errors_until_disconnect = 4; // the current state QString state; // can be: // - 'disconnected' // - 'connecting' // - 'connected' QStringList connections; QString latestReadReply; //---general status values---// private: QDateTime *date; //to get the current time QTcpSocket *socket; //socket for communication with the extention QList speedTimers; QTimer *refreshTimer; QSemaphore remoteSessions; int nextConnectionId; struct waitingRequest { int id; QEventLoop * loop; QString reply; }; QList waitingRequests; QString nextRemoteAction; float nextRemoteActionDelayProg; signals: void stateChanged(); //is emitted, when the connection state changes void progressChanged(); //is emmited during the connection process when the progress changes void gotUnexpectedReply(QString reply); void connectionsChanged(); void connectionSlotReleased(); void nextRemoteActionChanged(); void nextRemoteActionDelayProgChanged(); public slots: Q_INVOKABLE bool connectToHost(); //function to connect to the base station Q_INVOKABLE QString sendCommand(QString command); Q_INVOKABLE bool refreshConnections(); void refreshTimers(); bool startTimers(); bool stopTimers(QString type); bool resetTimers(); // functions for the qml adapter QString getIP() const; void setIP(const QString &ipAdress); QString getState() const; void setState(QString newState); int getProgress() const; QStringList getConnections(); QString getNextRemoteAction(); float getNextRemoteActionDelayProg(); private slots: void readyRead(); }; #endif // BASECONN_H