Commit 29a473b4ecacdfc1b80a267e757542c88b4d1300
1 parent
d66410abd6
Exists in
master
and in
2 other branches
청결/관리 상태 기능 뼈대 추가
Showing
2 changed files
with
59 additions
and
4 deletions
Show diff stats
app/gui/oven_control/dirtylevel.cpp
| ... | ... | @@ -6,6 +6,33 @@ namespace { |
| 6 | 6 | QDateTime cookStartTime; |
| 7 | 7 | qint64 cookingTime; |
| 8 | 8 | int cookingCount; |
| 9 | + | |
| 10 | +void decountState(int level) | |
| 11 | +{ | |
| 12 | + int current = DirtyLevel::state(); | |
| 13 | + int target = qMax(current - level, 0); | |
| 14 | + switch (target) | |
| 15 | + { | |
| 16 | + case 0: | |
| 17 | + cookingCount = 0; | |
| 18 | + break; | |
| 19 | + case 1: | |
| 20 | + cookingCount = 1; | |
| 21 | + break; | |
| 22 | + case 2: | |
| 23 | + cookingCount = 6; | |
| 24 | + break; | |
| 25 | + case 3: | |
| 26 | + cookingCount = 11; | |
| 27 | + break; | |
| 28 | + case 4: | |
| 29 | + cookingCount = 16; | |
| 30 | + break; | |
| 31 | + case 5: | |
| 32 | + cookingCount = 21; | |
| 33 | + break; | |
| 34 | + } | |
| 35 | +} | |
| 9 | 36 | } |
| 10 | 37 | |
| 11 | 38 | |
| ... | ... | @@ -20,6 +47,33 @@ void DirtyLevel::cookEnd() |
| 20 | 47 | cookingTime += cookStartTime.secsTo(QDateTime::currentDateTime()); |
| 21 | 48 | } |
| 22 | 49 | |
| 50 | +void DirtyLevel::wash(int type) | |
| 51 | +{ | |
| 52 | + switch (type) | |
| 53 | + { | |
| 54 | + case 1: | |
| 55 | + cookingTime = qMax(cookingTime - 2 * 3600, 0); | |
| 56 | + decountState(1); | |
| 57 | + break; | |
| 58 | + case 2: | |
| 59 | + cookingTime = qMax(cookingTime - 3 * 3600, 0); | |
| 60 | + decountState(1); | |
| 61 | + break; | |
| 62 | + case 3: | |
| 63 | + cookingTime = qMax(cookingTime - 4 * 3600, 0); | |
| 64 | + decountState(2); | |
| 65 | + break; | |
| 66 | + case 4: | |
| 67 | + cookingTime = qMax(cookingTime - 10 * 3600, 0); | |
| 68 | + decountState(2); | |
| 69 | + break; | |
| 70 | + case 5: | |
| 71 | + cookingTime = qMax(cookingTime - 2 * 3600, 0); | |
| 72 | + decountState(1); | |
| 73 | + break; | |
| 74 | + } | |
| 75 | +} | |
| 76 | + | |
| 23 | 77 | int DirtyLevel::dirty() |
| 24 | 78 | { |
| 25 | 79 | if (cookingCount < 1) |
| ... | ... | @@ -39,13 +93,13 @@ int DirtyLevel::state() |
| 39 | 93 | { |
| 40 | 94 | if (cookingCount < 1) |
| 41 | 95 | return 0; |
| 42 | - if (cookingCount < 4) | |
| 96 | + if (cookingCount <= 5) | |
| 43 | 97 | return 1; |
| 44 | - if (cookingCount < 7) | |
| 98 | + if (cookingCount <= 10) | |
| 45 | 99 | return 2; |
| 46 | - if (cookingCount < 10) | |
| 100 | + if (cookingCount <= 15) | |
| 47 | 101 | return 3; |
| 48 | - if (cookingCount < 13) | |
| 102 | + if (cookingCount <= 20) | |
| 49 | 103 | return 4; |
| 50 | 104 | return 5; |
| 51 | 105 | } | ... | ... |