Commit b53c48f6a7f6e5c3a2ad0816e6e8f9d6294ff7f3
1 parent
f345e373f6
Exists in
master
and in
2 other branches
세척 관련 관리 자료를 저장하지 않던 문제 수정
Showing
1 changed file
with
66 additions
and
30 deletions
Show diff stats
app/gui/oven_control/dirtylevel.cpp
@@ -2,11 +2,41 @@ | @@ -2,11 +2,41 @@ | ||
2 | 2 | ||
3 | #include <QDateTime> | 3 | #include <QDateTime> |
4 | 4 | ||
5 | +#include "ovenstatics.h" | ||
6 | + | ||
5 | namespace { | 7 | namespace { |
6 | QDateTime cookStartTime; | 8 | QDateTime cookStartTime; |
7 | bool cookStarted = false; | 9 | bool cookStarted = false; |
8 | -qint64 cookingTime; | ||
9 | -int cookingCount; | 10 | + |
11 | +void setCookingTime(qint64 t) | ||
12 | +{ | ||
13 | + OvenStatistics::getInstance()->setTotalCookingTime(t, false); | ||
14 | +} | ||
15 | + | ||
16 | +void addCookingTime(qint64 t) | ||
17 | +{ | ||
18 | + OvenStatistics::getInstance()->addTotalCookingTime(t, false); | ||
19 | +} | ||
20 | + | ||
21 | +qint64 getCookingTime() | ||
22 | +{ | ||
23 | + return OvenStatistics::getInstance()->loadTotalCookingTime(); | ||
24 | +} | ||
25 | + | ||
26 | +void setCookingCount(int c) | ||
27 | +{ | ||
28 | + OvenStatistics::getInstance()->setTotalCookingCount(c, false); | ||
29 | +} | ||
30 | + | ||
31 | +void addCookingCount(int c) | ||
32 | +{ | ||
33 | + OvenStatistics::getInstance()->addTotalCookingCount(c, false); | ||
34 | +} | ||
35 | + | ||
36 | +int getCookingCount() | ||
37 | +{ | ||
38 | + return OvenStatistics::getInstance()->loadTotalCookingCount(); | ||
39 | +} | ||
10 | 40 | ||
11 | void decountState(int level) | 41 | void decountState(int level) |
12 | { | 42 | { |
@@ -15,22 +45,22 @@ void decountState(int level) | @@ -15,22 +45,22 @@ void decountState(int level) | ||
15 | switch (target) | 45 | switch (target) |
16 | { | 46 | { |
17 | case 0: | 47 | case 0: |
18 | - cookingCount = 0; | 48 | + setCookingCount(0); |
19 | break; | 49 | break; |
20 | case 1: | 50 | case 1: |
21 | - cookingCount = 1; | 51 | + setCookingCount(1); |
22 | break; | 52 | break; |
23 | case 2: | 53 | case 2: |
24 | - cookingCount = 6; | 54 | + setCookingCount(6); |
25 | break; | 55 | break; |
26 | case 3: | 56 | case 3: |
27 | - cookingCount = 11; | 57 | + setCookingCount(11); |
28 | break; | 58 | break; |
29 | case 4: | 59 | case 4: |
30 | - cookingCount = 16; | 60 | + setCookingCount(16); |
31 | break; | 61 | break; |
32 | case 5: | 62 | case 5: |
33 | - cookingCount = 21; | 63 | + setCookingCount(21); |
34 | break; | 64 | break; |
35 | } | 65 | } |
36 | } | 66 | } |
@@ -41,91 +71,97 @@ void DirtyLevel::cookStart() | @@ -41,91 +71,97 @@ void DirtyLevel::cookStart() | ||
41 | { | 71 | { |
42 | cookStarted = true; | 72 | cookStarted = true; |
43 | cookStartTime = QDateTime::currentDateTime(); | 73 | cookStartTime = QDateTime::currentDateTime(); |
44 | - ::cookingCount++; | 74 | + ::addCookingCount(1); |
45 | } | 75 | } |
46 | 76 | ||
47 | void DirtyLevel::cookEnd() | 77 | void DirtyLevel::cookEnd() |
48 | { | 78 | { |
49 | if (cookStarted) | 79 | if (cookStarted) |
50 | { | 80 | { |
51 | - cookStarted = true; | ||
52 | - ::cookingTime += cookStartTime.secsTo(QDateTime::currentDateTime()); | 81 | + cookStarted = false; |
82 | + | ||
83 | + ::addCookingTime(cookStartTime.secsTo(QDateTime::currentDateTime())); | ||
53 | } | 84 | } |
54 | } | 85 | } |
55 | 86 | ||
56 | void DirtyLevel::wash(int type) | 87 | void DirtyLevel::wash(int type) |
57 | { | 88 | { |
89 | + qint64 cookingTime = ::getCookingTime(); | ||
58 | switch (type) | 90 | switch (type) |
59 | { | 91 | { |
60 | case 1: | 92 | case 1: |
61 | - ::cookingTime = qMax(::cookingTime - 2 * 3600, (qint64) 0); | 93 | + cookingTime = qMax(cookingTime - 2 * 3600, (qint64) 0); |
62 | decountState(1); | 94 | decountState(1); |
63 | break; | 95 | break; |
64 | case 2: | 96 | case 2: |
65 | - ::cookingTime = qMax(::cookingTime - 3 * 3600, (qint64) 0); | 97 | + cookingTime = qMax(cookingTime - 3 * 3600, (qint64) 0); |
66 | decountState(1); | 98 | decountState(1); |
67 | break; | 99 | break; |
68 | case 3: | 100 | case 3: |
69 | - ::cookingTime = qMax(::cookingTime - 4 * 3600, (qint64) 0); | 101 | + cookingTime = qMax(cookingTime - 4 * 3600, (qint64) 0); |
70 | decountState(2); | 102 | decountState(2); |
71 | break; | 103 | break; |
72 | case 4: | 104 | case 4: |
73 | - ::cookingTime = qMax(::cookingTime - 10 * 3600, (qint64) 0); | 105 | + cookingTime = qMax(cookingTime - 10 * 3600, (qint64) 0); |
74 | decountState(2); | 106 | decountState(2); |
75 | break; | 107 | break; |
76 | case 5: | 108 | case 5: |
77 | - ::cookingTime = qMax(::cookingTime - 2 * 3600, (qint64) 0); | 109 | + cookingTime = qMax(cookingTime - 2 * 3600, (qint64) 0); |
78 | decountState(1); | 110 | decountState(1); |
79 | break; | 111 | break; |
80 | } | 112 | } |
113 | + ::setCookingTime(cookingTime); | ||
81 | } | 114 | } |
82 | 115 | ||
83 | int DirtyLevel::dirty() | 116 | int DirtyLevel::dirty() |
84 | { | 117 | { |
85 | - if (::cookingCount < 1) | 118 | + if (::getCookingCount() < 1) |
86 | return 0; | 119 | return 0; |
87 | - if (::cookingTime < 1 * 3600) | 120 | + |
121 | + qint64 cookingTime = ::getCookingTime(); | ||
122 | + if (cookingTime < 1 * 3600) | ||
88 | return 1; | 123 | return 1; |
89 | - if (::cookingTime < 3 * 3600) | 124 | + if (cookingTime < 3 * 3600) |
90 | return 2; | 125 | return 2; |
91 | - if (::cookingTime < 5 * 3600) | 126 | + if (cookingTime < 5 * 3600) |
92 | return 3; | 127 | return 3; |
93 | - if (::cookingTime < 7 * 3600) | 128 | + if (cookingTime < 7 * 3600) |
94 | return 4; | 129 | return 4; |
95 | return 5; | 130 | return 5; |
96 | } | 131 | } |
97 | 132 | ||
98 | int DirtyLevel::state() | 133 | int DirtyLevel::state() |
99 | { | 134 | { |
100 | - if (::cookingCount < 1) | 135 | + int cookingCount = ::getCookingCount(); |
136 | + if (cookingCount < 1) | ||
101 | return 0; | 137 | return 0; |
102 | - if (::cookingCount <= 5) | 138 | + if (cookingCount <= 5) |
103 | return 1; | 139 | return 1; |
104 | - if (::cookingCount <= 10) | 140 | + if (cookingCount <= 10) |
105 | return 2; | 141 | return 2; |
106 | - if (::cookingCount <= 15) | 142 | + if (cookingCount <= 15) |
107 | return 3; | 143 | return 3; |
108 | - if (::cookingCount <= 20) | 144 | + if (cookingCount <= 20) |
109 | return 4; | 145 | return 4; |
110 | return 5; | 146 | return 5; |
111 | } | 147 | } |
112 | 148 | ||
113 | void DirtyLevel::setCookingTime(qint64 secs) | 149 | void DirtyLevel::setCookingTime(qint64 secs) |
114 | { | 150 | { |
115 | - ::cookingTime = secs; | 151 | + ::setCookingTime(secs); |
116 | } | 152 | } |
117 | 153 | ||
118 | int DirtyLevel::cookingTime() | 154 | int DirtyLevel::cookingTime() |
119 | { | 155 | { |
120 | - return ::cookingTime; | 156 | + return ::getCookingTime(); |
121 | } | 157 | } |
122 | 158 | ||
123 | int DirtyLevel::cookingCount() | 159 | int DirtyLevel::cookingCount() |
124 | { | 160 | { |
125 | - return ::cookingCount; | 161 | + return ::getCookingCount(); |
126 | } | 162 | } |
127 | 163 | ||
128 | void DirtyLevel::setCookingCount(int count) | 164 | void DirtyLevel::setCookingCount(int count) |
129 | { | 165 | { |
130 | - ::cookingCount = count; | 166 | + ::setCookingCount(count); |
131 | } | 167 | } |