From 29a473b4ecacdfc1b80a267e757542c88b4d1300 Mon Sep 17 00:00:00 2001 From: victor Date: Mon, 22 May 2017 20:10:42 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B2=AD=EA=B2=B0/=EA=B4=80=EB=A6=AC=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EA=B8=B0=EB=8A=A5=20=EB=BC=88=EB=8C=80=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/gui/oven_control/dirtylevel.cpp | 62 ++++++++++++++++++++++++++++++++++--- app/gui/oven_control/dirtylevel.h | 1 + 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/app/gui/oven_control/dirtylevel.cpp b/app/gui/oven_control/dirtylevel.cpp index 8d13120..4285c05 100644 --- a/app/gui/oven_control/dirtylevel.cpp +++ b/app/gui/oven_control/dirtylevel.cpp @@ -6,6 +6,33 @@ namespace { QDateTime cookStartTime; qint64 cookingTime; int cookingCount; + +void decountState(int level) +{ + int current = DirtyLevel::state(); + int target = qMax(current - level, 0); + switch (target) + { + case 0: + cookingCount = 0; + break; + case 1: + cookingCount = 1; + break; + case 2: + cookingCount = 6; + break; + case 3: + cookingCount = 11; + break; + case 4: + cookingCount = 16; + break; + case 5: + cookingCount = 21; + break; + } +} } @@ -20,6 +47,33 @@ void DirtyLevel::cookEnd() cookingTime += cookStartTime.secsTo(QDateTime::currentDateTime()); } +void DirtyLevel::wash(int type) +{ + switch (type) + { + case 1: + cookingTime = qMax(cookingTime - 2 * 3600, 0); + decountState(1); + break; + case 2: + cookingTime = qMax(cookingTime - 3 * 3600, 0); + decountState(1); + break; + case 3: + cookingTime = qMax(cookingTime - 4 * 3600, 0); + decountState(2); + break; + case 4: + cookingTime = qMax(cookingTime - 10 * 3600, 0); + decountState(2); + break; + case 5: + cookingTime = qMax(cookingTime - 2 * 3600, 0); + decountState(1); + break; + } +} + int DirtyLevel::dirty() { if (cookingCount < 1) @@ -39,13 +93,13 @@ int DirtyLevel::state() { if (cookingCount < 1) return 0; - if (cookingCount < 4) + if (cookingCount <= 5) return 1; - if (cookingCount < 7) + if (cookingCount <= 10) return 2; - if (cookingCount < 10) + if (cookingCount <= 15) return 3; - if (cookingCount < 13) + if (cookingCount <= 20) return 4; return 5; } diff --git a/app/gui/oven_control/dirtylevel.h b/app/gui/oven_control/dirtylevel.h index adf970b..efa487e 100644 --- a/app/gui/oven_control/dirtylevel.h +++ b/app/gui/oven_control/dirtylevel.h @@ -5,6 +5,7 @@ namespace DirtyLevel { void cookStart(); void cookEnd(); +void wash(int type); int dirty(); int state(); -- 2.1.4