diff --git a/app/gui/oven_control/dirtylevel.cpp b/app/gui/oven_control/dirtylevel.cpp new file mode 100644 index 0000000..d72d618 --- /dev/null +++ b/app/gui/oven_control/dirtylevel.cpp @@ -0,0 +1,51 @@ +#include "dirtylevel.h" + +#include + +namespace { +QDateTime cookStartTime; +qint64 cookingTime; +int cookingCount; +} + + +void DirtyLevel::cookStart() +{ + cookStartTime = QDateTime.currentDateTime(); + cookingCount++; +} + +void DirtyLevel::cookEnd() +{ + cookingTime += cookStartTime.secsTo(QDateTime.currentDateTime()); +} + +int DirtyLevel::dirty() +{ + if (cookingCount < 1) + return 0; + if (cookingTime < 1 * 3600) + return 1; + if (cookingTime < 3 * 3600) + return 2; + if (cookingTime < 5 * 3600) + return 3; + if (cookingTime < 7 * 3600) + return 4; + return 5; +} + +int DirtyLevel::state() +{ + if (cookingCount < 1) + return 0; + if (cookingCount < 4) + return 1; + if (cookingCount < 7) + return 2; + if (cookingCount < 10) + return 3; + if (cookingCount < 13) + return 4; + return 5; +} diff --git a/app/gui/oven_control/dirtylevel.h b/app/gui/oven_control/dirtylevel.h new file mode 100644 index 0000000..adf970b --- /dev/null +++ b/app/gui/oven_control/dirtylevel.h @@ -0,0 +1,13 @@ +#ifndef DIRTYLEVEL_H +#define DIRTYLEVEL_H + + +namespace DirtyLevel { +void cookStart(); +void cookEnd(); + +int dirty(); +int state(); +} + +#endif // DIRTYLEVEL_H diff --git a/app/gui/oven_control/oven_control.pro b/app/gui/oven_control/oven_control.pro index 9a15201..e5268e8 100644 --- a/app/gui/oven_control/oven_control.pro +++ b/app/gui/oven_control/oven_control.pro @@ -100,7 +100,8 @@ SOURCES += main.cpp\ electricmodelsettingwindow.cpp \ system.cpp \ servicepassinputdlg.cpp \ - backlight.cpp + backlight.cpp \ + dirtylevel.cpp HEADERS += mainwindow.h \ cook.h \ @@ -190,7 +191,8 @@ HEADERS += mainwindow.h \ electricmodelsettingwindow.h \ system.h \ servicepassinputdlg.h \ - backlight.h + backlight.h \ + dirtylevel.h FORMS += mainwindow.ui \ manualcookwindow.ui \