#pragma once #include #include #include #include class QSerialPort; class IStand : public QObject { Q_OBJECT public: virtual ~IStand() = default; signals: void moveFinished(); public: virtual bool resetPosSteps() = 0; virtual int posSteps() = 0; virtual double posMm() = 0; /*! * \warning be careful when rounding mm to steps */ virtual bool moveMm(const double mm) = 0; virtual bool moveSteps(const int steps) = 0; }; // TODO: think if QObject is needed class Esp32Stand : public IStand { public: explicit Esp32Stand(const QHostAddress &address, const uint32_t port, const uint32_t stepsPerMm); ~Esp32Stand() override = default; public: bool resetPosSteps() override; int posSteps() override; double posMm() override; bool moveMm(const double mm) override; bool moveSteps(const int steps) override; private: QString m_apiRoot; uint32_t m_stepsPerMm{0}; QNetworkAccessManager *m_manager{nullptr}; int m_posSteps{0}; }; class PrinterClient : public QObject { // Q_OBJECT public: explicit PrinterClient(QObject *parent = nullptr); // ~PrinterClient() override = default; // ~PrinterClient // signals: // void newData(const QString output); public: void sendCommand(const QString command); private: void onReadyRead(); void onErrorOccured(QSerialPort::SerialPortError error); private: QSerialPort* m_serialPort { nullptr }; };