Commit f4f894f09b255438d822baa02caaa0cf23d2b40a
1 parent
29a473b4ec
Exists in
master
and in
2 other branches
청결/관리 상태 저장 값 Getter/Setter 추가
Showing
2 changed files
with
49 additions
and
17 deletions
Show diff stats
app/gui/oven_control/dirtylevel.cpp
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | |
| 5 | 5 | namespace { |
| 6 | 6 | QDateTime cookStartTime; |
| 7 | +bool cookStarted = false; | |
| 7 | 8 | qint64 cookingTime; |
| 8 | 9 | int cookingCount; |
| 9 | 10 | |
| ... | ... | @@ -38,13 +39,18 @@ void decountState(int level) |
| 38 | 39 | |
| 39 | 40 | void DirtyLevel::cookStart() |
| 40 | 41 | { |
| 42 | + cookStarted = true; | |
| 41 | 43 | cookStartTime = QDateTime::currentDateTime(); |
| 42 | - cookingCount++; | |
| 44 | + ::cookingCount++; | |
| 43 | 45 | } |
| 44 | 46 | |
| 45 | 47 | void DirtyLevel::cookEnd() |
| 46 | 48 | { |
| 47 | - cookingTime += cookStartTime.secsTo(QDateTime::currentDateTime()); | |
| 49 | + if (cookStarted) | |
| 50 | + { | |
| 51 | + cookStarted = true; | |
| 52 | + ::cookingTime += cookStartTime.secsTo(QDateTime::currentDateTime()); | |
| 53 | + } | |
| 48 | 54 | } |
| 49 | 55 | |
| 50 | 56 | void DirtyLevel::wash(int type) |
| ... | ... | @@ -52,23 +58,23 @@ void DirtyLevel::wash(int type) |
| 52 | 58 | switch (type) |
| 53 | 59 | { |
| 54 | 60 | case 1: |
| 55 | - cookingTime = qMax(cookingTime - 2 * 3600, 0); | |
| 61 | + ::cookingTime = qMax(::cookingTime - 2 * 3600, (qint64) 0); | |
| 56 | 62 | decountState(1); |
| 57 | 63 | break; |
| 58 | 64 | case 2: |
| 59 | - cookingTime = qMax(cookingTime - 3 * 3600, 0); | |
| 65 | + ::cookingTime = qMax(::cookingTime - 3 * 3600, (qint64) 0); | |
| 60 | 66 | decountState(1); |
| 61 | 67 | break; |
| 62 | 68 | case 3: |
| 63 | - cookingTime = qMax(cookingTime - 4 * 3600, 0); | |
| 69 | + ::cookingTime = qMax(::cookingTime - 4 * 3600, (qint64) 0); | |
| 64 | 70 | decountState(2); |
| 65 | 71 | break; |
| 66 | 72 | case 4: |
| 67 | - cookingTime = qMax(cookingTime - 10 * 3600, 0); | |
| 73 | + ::cookingTime = qMax(::cookingTime - 10 * 3600, (qint64) 0); | |
| 68 | 74 | decountState(2); |
| 69 | 75 | break; |
| 70 | 76 | case 5: |
| 71 | - cookingTime = qMax(cookingTime - 2 * 3600, 0); | |
| 77 | + ::cookingTime = qMax(::cookingTime - 2 * 3600, (qint64) 0); | |
| 72 | 78 | decountState(1); |
| 73 | 79 | break; |
| 74 | 80 | } |
| ... | ... | @@ -76,30 +82,50 @@ void DirtyLevel::wash(int type) |
| 76 | 82 | |
| 77 | 83 | int DirtyLevel::dirty() |
| 78 | 84 | { |
| 79 | - if (cookingCount < 1) | |
| 85 | + if (::cookingCount < 1) | |
| 80 | 86 | return 0; |
| 81 | - if (cookingTime < 1 * 3600) | |
| 87 | + if (::cookingTime < 1 * 3600) | |
| 82 | 88 | return 1; |
| 83 | - if (cookingTime < 3 * 3600) | |
| 89 | + if (::cookingTime < 3 * 3600) | |
| 84 | 90 | return 2; |
| 85 | - if (cookingTime < 5 * 3600) | |
| 91 | + if (::cookingTime < 5 * 3600) | |
| 86 | 92 | return 3; |
| 87 | - if (cookingTime < 7 * 3600) | |
| 93 | + if (::cookingTime < 7 * 3600) | |
| 88 | 94 | return 4; |
| 89 | 95 | return 5; |
| 90 | 96 | } |
| 91 | 97 | |
| 92 | 98 | int DirtyLevel::state() |
| 93 | 99 | { |
| 94 | - if (cookingCount < 1) | |
| 100 | + if (::cookingCount < 1) | |
| 95 | 101 | return 0; |
| 96 | - if (cookingCount <= 5) | |
| 102 | + if (::cookingCount <= 5) | |
| 97 | 103 | return 1; |
| 98 | - if (cookingCount <= 10) | |
| 104 | + if (::cookingCount <= 10) | |
| 99 | 105 | return 2; |
| 100 | - if (cookingCount <= 15) | |
| 106 | + if (::cookingCount <= 15) | |
| 101 | 107 | return 3; |
| 102 | - if (cookingCount <= 20) | |
| 108 | + if (::cookingCount <= 20) | |
| 103 | 109 | return 4; |
| 104 | 110 | return 5; |
| 105 | 111 | } |
| 112 | + | |
| 113 | +void DirtyLevel::setCookingTime(qint64 secs) | |
| 114 | +{ | |
| 115 | + ::cookingTime = secs; | |
| 116 | +} | |
| 117 | + | |
| 118 | +int DirtyLevel::cookingTime() | |
| 119 | +{ | |
| 120 | + return ::cookingTime; | |
| 121 | +} | |
| 122 | + | |
| 123 | +int DirtyLevel::cookingCount() | |
| 124 | +{ | |
| 125 | + return ::cookingCount; | |
| 126 | +} | |
| 127 | + | |
| 128 | +void DirtyLevel::setCookingCount(int count) | |
| 129 | +{ | |
| 130 | + ::cookingCount = count; | |
| 131 | +} | ... | ... |
app/gui/oven_control/dirtylevel.h
| 1 | 1 | #ifndef DIRTYLEVEL_H |
| 2 | 2 | #define DIRTYLEVEL_H |
| 3 | 3 | |
| 4 | +#include <QtCore> | |
| 4 | 5 | |
| 5 | 6 | namespace DirtyLevel { |
| 6 | 7 | void cookStart(); |
| ... | ... | @@ -9,6 +10,11 @@ void wash(int type); |
| 9 | 10 | |
| 10 | 11 | int dirty(); |
| 11 | 12 | int state(); |
| 13 | + | |
| 14 | +int cookingTime(); | |
| 15 | +void setCookingTime(qint64 secs); | |
| 16 | +int cookingCount(); | |
| 17 | +void setCookingCount(int count); | |
| 12 | 18 | } |
| 13 | 19 | |
| 14 | 20 | #endif // DIRTYLEVEL_H | ... | ... |