From 8e11aab8db75fe2cd9adb34f615e8c481eb884bc Mon Sep 17 00:00:00 2001 From: victor Date: Mon, 22 May 2017 19:37:35 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=9C=84=EC=B9=98=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gui/oven_control/dirtylevel.cpp | 51 +++++++++++++++++++++++++++++++++++ app/gui/oven_control/dirtylevel.h | 13 +++++++++ app/gui/oven_control/oven_control.pro | 6 +++-- 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 app/gui/oven_control/dirtylevel.cpp create mode 100644 app/gui/oven_control/dirtylevel.h 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 \ -- 2.1.4