gastestwindow.h 1.28 KB
#ifndef GASTESTWINDOW_H
#define GASTESTWINDOW_H

#include <QMainWindow>
#include <QTimer>

#include "udphandler.h"

namespace Ui {
class GasTestWindow;
}

class GasTestWindow : public QMainWindow
{
    Q_OBJECT

public:
    enum Target {
        Upper, Lower, Steam
    };

    enum Phase {
        Idle,
        Min, MinStopping,
        Max, MaxStopping
    };

    explicit GasTestWindow(Target target, QWidget *parent = 0);
    ~GasTestWindow();

protected:
    void keyPressEvent(QKeyEvent *event);
    void keyReleaseEvent(QKeyEvent *event);

private slots:
    void updateView();
    void onDataChanged();
    void startMin();
    void startMax();
    void stop();

    void runUpper(int rpm);
    void runLower(int rpm);
    void runSteam(int rpm);
    void stopUpper();
    void stopLower();
    void stopSteam();

    int minRpm();
    int maxRpm();

    bool isHalf();
    bool isRunning();
    int currentRpm();

    void on_minButton_clicked();
    void on_maxButton_clicked();
    void on_backButton_clicked();


private:
    Ui::GasTestWindow *ui;
    UdpHandler *udp;
    Target target;
    Phase phase = Idle;
    QTimer stopTimer;

    QWidget *pushed = NULL;

    void onEncoderLeft();
    void onEncoderRight();
    void onEncoderClicked(QWidget *clicked);
};


#endif // GASTESTWINDOW_H