Blame view

app/app-prime-modbus/include/dirtylevel.cpp 882 Bytes
ac60b5cec   김태훈   음향 효과 일부 적용 및 소스 ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  #include "dirtylevel.h"
  
  #include <QDateTime>
  
  namespace {
  QDateTime cookStartTime;
  qint64 cookingTime;
  int cookingCount;
  }
  
  
  void DirtyLevel::cookStart()
  {
      cookStartTime = QDateTime.currentDateTime();
      cookingCount++;
  }
  
  void DirtyLevel::cookEnd()
  {
      cookingTime += cookStartTime.secsTo(QDateTime.currentDateTime());
  }
  
  int DirtyLevel::dirty()
  {
      if (cookingCount < 1)
          return 0;
      if (cookingTime < 1 * 3600)
          return 1;
      if (cookingTime < 3 * 3600)
          return 2;
      if (cookingTime < 5 * 3600)
          return 3;
      if (cookingTime < 7 * 3600)
          return 4;
      return 5;
  }
  
  int DirtyLevel::state()
  {
      if (cookingCount < 1)
          return 0;
      if (cookingCount < 4)
          return 1;
      if (cookingCount < 7)
          return 2;
      if (cookingCount < 10)
          return 3;
      if (cookingCount < 13)
          return 4;
      return 5;
  }