Commit f4f894f09b255438d822baa02caaa0cf23d2b40a

Authored by 김태훈
1 parent 29a473b4ec
Exists in master and in 2 other branches fhd, fhd-demo

청결/관리 상태 저장 값 Getter/Setter 추가

app/gui/oven_control/dirtylevel.cpp
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 4
5 namespace { 5 namespace {
6 QDateTime cookStartTime; 6 QDateTime cookStartTime;
  7 +bool cookStarted = false;
7 qint64 cookingTime; 8 qint64 cookingTime;
8 int cookingCount; 9 int cookingCount;
9 10
@@ -38,13 +39,18 @@ void decountState(int level) @@ -38,13 +39,18 @@ void decountState(int level)
38 39
39 void DirtyLevel::cookStart() 40 void DirtyLevel::cookStart()
40 { 41 {
  42 + cookStarted = true;
41 cookStartTime = QDateTime::currentDateTime(); 43 cookStartTime = QDateTime::currentDateTime();
42 - cookingCount++; 44 + ::cookingCount++;
43 } 45 }
44 46
45 void DirtyLevel::cookEnd() 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 void DirtyLevel::wash(int type) 56 void DirtyLevel::wash(int type)
@@ -52,23 +58,23 @@ void DirtyLevel::wash(int type) @@ -52,23 +58,23 @@ void DirtyLevel::wash(int type)
52 switch (type) 58 switch (type)
53 { 59 {
54 case 1: 60 case 1:
55 - cookingTime = qMax(cookingTime - 2 * 3600, 0); 61 + ::cookingTime = qMax(::cookingTime - 2 * 3600, (qint64) 0);
56 decountState(1); 62 decountState(1);
57 break; 63 break;
58 case 2: 64 case 2:
59 - cookingTime = qMax(cookingTime - 3 * 3600, 0); 65 + ::cookingTime = qMax(::cookingTime - 3 * 3600, (qint64) 0);
60 decountState(1); 66 decountState(1);
61 break; 67 break;
62 case 3: 68 case 3:
63 - cookingTime = qMax(cookingTime - 4 * 3600, 0); 69 + ::cookingTime = qMax(::cookingTime - 4 * 3600, (qint64) 0);
64 decountState(2); 70 decountState(2);
65 break; 71 break;
66 case 4: 72 case 4:
67 - cookingTime = qMax(cookingTime - 10 * 3600, 0); 73 + ::cookingTime = qMax(::cookingTime - 10 * 3600, (qint64) 0);
68 decountState(2); 74 decountState(2);
69 break; 75 break;
70 case 5: 76 case 5:
71 - cookingTime = qMax(cookingTime - 2 * 3600, 0); 77 + ::cookingTime = qMax(::cookingTime - 2 * 3600, (qint64) 0);
72 decountState(1); 78 decountState(1);
73 break; 79 break;
74 } 80 }
@@ -76,30 +82,50 @@ void DirtyLevel::wash(int type) @@ -76,30 +82,50 @@ void DirtyLevel::wash(int type)
76 82
77 int DirtyLevel::dirty() 83 int DirtyLevel::dirty()
78 { 84 {
79 - if (cookingCount < 1) 85 + if (::cookingCount < 1)
80 return 0; 86 return 0;
81 - if (cookingTime < 1 * 3600) 87 + if (::cookingTime < 1 * 3600)
82 return 1; 88 return 1;
83 - if (cookingTime < 3 * 3600) 89 + if (::cookingTime < 3 * 3600)
84 return 2; 90 return 2;
85 - if (cookingTime < 5 * 3600) 91 + if (::cookingTime < 5 * 3600)
86 return 3; 92 return 3;
87 - if (cookingTime < 7 * 3600) 93 + if (::cookingTime < 7 * 3600)
88 return 4; 94 return 4;
89 return 5; 95 return 5;
90 } 96 }
91 97
92 int DirtyLevel::state() 98 int DirtyLevel::state()
93 { 99 {
94 - if (cookingCount < 1) 100 + if (::cookingCount < 1)
95 return 0; 101 return 0;
96 - if (cookingCount <= 5) 102 + if (::cookingCount <= 5)
97 return 1; 103 return 1;
98 - if (cookingCount <= 10) 104 + if (::cookingCount <= 10)
99 return 2; 105 return 2;
100 - if (cookingCount <= 15) 106 + if (::cookingCount <= 15)
101 return 3; 107 return 3;
102 - if (cookingCount <= 20) 108 + if (::cookingCount <= 20)
103 return 4; 109 return 4;
104 return 5; 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 #ifndef DIRTYLEVEL_H 1 #ifndef DIRTYLEVEL_H
2 #define DIRTYLEVEL_H 2 #define DIRTYLEVEL_H
3 3
  4 +#include <QtCore>
4 5
5 namespace DirtyLevel { 6 namespace DirtyLevel {
6 void cookStart(); 7 void cookStart();
@@ -9,6 +10,11 @@ void wash(int type); @@ -9,6 +10,11 @@ void wash(int type);
9 10
10 int dirty(); 11 int dirty();
11 int state(); 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 #endif // DIRTYLEVEL_H 20 #endif // DIRTYLEVEL_H