#ifndef OVEN_H #define OVEN_H #include #include #include class OvenInterface : public QObject { Q_OBJECT public: OvenInterface(QObject *parent = 0) : QObject(parent) {} virtual ~OvenInterface(){} virtual int currentTemp() = 0; virtual int currentHumidity() = 0; virtual int currentInterTemp() = 0; virtual bool door() = 0; signals: void doorOpened(); void doorClosed(); public slots: // virtual void setMode(Oven::Mode mode) = 0; virtual void setHumidity(int percentage) = 0; virtual void setTemp(int celsius) = 0; virtual void setTime(int secs) = 0; virtual void setInterTemp(int celsius) = 0; virtual void setFan(int rpm) = 0; virtual void startCooking() = 0; virtual void stopCooking() = 0; virtual void startPreheating() = 0; virtual void stopPreheating() = 0; virtual void startCooldown() = 0; virtual void stopCooldown() = 0; virtual void startHumidification() = 0; virtual void stopHumidification() = 0; virtual void startWashing() = 0; virtual void stopWashing() = 0; virtual void openDamper() = 0; virtual void closeDamper() = 0; }; Q_DECLARE_INTERFACE(OvenInterface, "OvenInterface") class Oven : public QObject { Q_OBJECT public: enum Mode { HeatMode, SteamMode, CombinationMode }; private: explicit Oven(QObject *parent = 0); Mode mode_; int humidity_; int temp_; int time_; bool interTempEnabled_ = false; int interTemp_; int fan_; // 1 ~ 5 bool cooking_ = false; bool preheating_ = false; bool cooldown_ = false; bool damper_ = false; // true: open, false: close bool humidification_ = false; bool door_ = false; // true: open, false: close int currentHumidity_; int currentTemp_; int currentInterTemp_; bool isInterTempValid_; QTime interTempValidTime; bool damperRepeat; bool damperRepeatInfinitely; int damperRepeatRuntime; int damperRepeatDelay; int damperRepeatCount; QTimer damperRepeatRuntimeTimer; QTimer damperRepeatDelayTimer; bool damperRepeatPaused; bool damperRepeatPausedOnRuntime; int damperRepeatRemainingTime; bool humidificationRepeat; bool humidificationRepeatInfinitely; int humidificationRepeatRuntime; int humidificationRepeatDelay; int humidificationRepeatCount; QTimer humidificationRepeatRuntimeTimer; QTimer humidificationRepeatDelayTimer; bool humidificationRepeatPaused; bool humidificationRepeatPausedOnRuntime; int humidificationRepeatRemainingTime; bool paused_; QTimer cookingTimer; QTimer damperTimer; QTimer humidificationTimer; QTimer interTempTimer; OvenInterface *interface; static Oven *instance; public: static Oven *getInstance() { if (instance == 0) instance = new Oven(); return instance; } Mode mode() { return mode_; } int humidity() { return humidity_; } int temp() { return temp_; } int time(); bool interTempEnabled() { return interTempEnabled_; } int interTemp() { return interTemp_; } int fan() { return fan_; } bool cooking() { return cooking_; } bool preheating() { return preheating_; } bool cooldown() { return cooldown_; } bool damper() { return damper_; } bool humidification() { return humidification_; } bool door() { return door_; } bool paused() { return paused_; } int currentTemp() { return currentTemp_; } int currentHumidity() { return currentHumidity_; } int currentInterTemp() { return currentInterTemp_; } bool isInterTempValid(); bool cookingStartable(); bool preheatingStartable(); bool cooldownStartable(); bool humidificationStartable(); bool damperOpenable(); int maxTemp(); int minTemp(); int maxInterTemp(); int minInterTemp(); int maxFan(); int minFan(); signals: void changed(Oven *); void doorOpened(); public slots: void setMode(Mode mode); void setDefault(Mode mode); void setHumidity(int percentage); void setTemp(int celsius); void setTime(int secs); void setInterTempEnabled(bool enabled); void setInterTemp(int celsius); void setFan(int speed); void stop(); void startCooking(); void stopCooking(); void startPreheating(); void stopPreheating(); void startCooldown(); void stopCooldown(); void startHumidification(int secs = 600); void stopHumidification(); void openDamper(int secs = 300); void closeDamper(); void repeatHumidification(int runtime, int delay, int count = 0); void stopRepeatHumidification(); void pauseRepeatHumidification(); void resumeRepeatHumidification(); void repeatDamper(int runtime, int delay, int count = 0); void stopRepeatDamper(); void pauseRepeatDamper(); void resumeRepeatDamper(); void setCurrentHumidity(int percentage); void setCurrentTemp(int celsius); void setCurrentInterTemp(int celsius); void setInterface(OvenInterface *interface); private slots: bool setMode_(Mode mode); bool setHumidity_(int percentage); bool setTemp_(int celsius); bool setInterTempEnabled_(bool enabled); bool setInterTemp_(int celsius); bool setFan_(int speed); void runRepeatHumidification(); void idleRepeatHumidification(); void runRepeatDamper(); void idleRepeatDamper(); void onDoorOpened(); void onDoorClosed(); }; #endif // OVEN_H