Blame view

app/gui/oven_control/cook.cpp 11.7 KB
8c2952457   김태훈   응용 프로그램 추가
1
  #include "cook.h"
99b8066f4   김태훈   V0.1.1
2
3
  #include <QtCore>
  #include <QtDebug>
8c2952457   김태훈   응용 프로그램 추가
4
  #include <cmath>
99b8066f4   김태훈   V0.1.1
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
  AbstractCook::~AbstractCook()
  {
      for (int idx = 0; idx < 5; idx++)
          if (configurations[idx] != NULL)
          {
              delete configurations[idx];
              configurations[idx] = NULL;
          }
  }
  
  Cook::CookType AbstractCook::type()
  {
      return type_;
  }
  
  QString AbstractCook::name()
  {
      return name_;
  }
  
  int AbstractCook::time()
  {
      int t = time_;
      for (int idx = 0; idx < 5; idx++)
          if (configurations[idx] != NULL)
              t = configurations[idx]->configureTime(t);
  
      return t;
  }
  
  bool AbstractCook::interTempEnabled()
  {
      return interTempEnabled_;
  }
6f96c947a   김태훈   GUI 0.1.4
39
40
41
42
  void AbstractCook::setInterTempEnabled(bool enabled)
  {
      interTempEnabled_ = enabled;
  }
99b8066f4   김태훈   V0.1.1
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  int AbstractCook::interTemp()
  {
      int t = interTemp_;
      for (int idx = 0; idx < 5; idx++)
          if (configurations[idx] != NULL)
              t = configurations[idx]->configureInterTemp(t);
  
      return t;
  }
  
  Cook::Step AbstractCook::currentStep()
  {
      return step(currentStepIndex());
  }
  
  int AbstractCook::currentStepIndex()
  {
      return currentStep_;
  }
  
  void AbstractCook::setCurrentStepIndex(int index)
  {
d66d7f5b4   김태훈   GUI 버전 0.1.2
65
      if (index < stepCount_ && index >= 0)
99b8066f4   김태훈   V0.1.1
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
          currentStep_ = index;
  }
  
  int AbstractCook::stepCount()
  {
      return stepCount_;
  }
  
  Cook::Step AbstractCook::step(int index)
  {
      if (index < stepCount_)
      {
          Cook::Step s = stepList[index];
          for (int idx = 0; idx < 5; idx++)
              if (configurations[idx] != NULL)
                  s = configurations[idx]->configureStep(s);
  
          return s;
      }
      else
          return Cook::Step { Cook::Invalid, Cook::SteamMode, 0, 0 };
  }
  
  Cook::StepClass Cook::classify(Cook::StepType type)
  {
      switch (type)
      {
      case Preheat:
          return PreheatClass;
      case PutThermometer:
      case Load:
      case Cut:
      case Pour:
          return DoorClass;
      case Bake:
      case Dry:
      case Ferment:
      case BlowSteam:
      case CoolDown:
      case Steam:
      case Roast:
      case Boil:
      case Thicken:
      case WarmUp:
      case MakeCrispy:
      case Finish:
      case Damp:
      case Defer:
      case Grill:
      case End:
      case Burn:
      case Fry:
      case HeatUp:
      case Ripen:
      case RipenKeep:
      case BoilSteadily:
      case CookGratin:
      case Brown:
      case Simmer:
      case Moisten:
          return CookClass;
      default:
          return InvalidClass;
      }
  }
  
  Cook::Configuration AbstractCookConfig::type()
  {
      return type_;
  }
  
  QString AbstractCookConfig::icon()
  {
      return icon_;
  }
  
  QString AbstractCookConfig::overlayIcon()
  {
      return overayIcon_;
  }
  
  QString AbstractCookConfig::minLabel()
  {
      return minLabel_;
  }
  
  QString AbstractCookConfig::maxLabel()
  {
      return maxLabel_;
  }
  
  QString AbstractCookConfig::currentLabel()
  {
      return currentLabel_;
  }
  
  int AbstractCookConfig::count()
  {
      return count_;
  }
  
  void AbstractCookConfig::setCount(int value)
  {
      count_ = value;
      if (current_ > count_)
          current_ = count_;
  }
  
  int AbstractCookConfig::current()
  {
      return current_;
  }
  
  void AbstractCookConfig::setCurrent(int value)
  {
      current_ = qBound(1, value, count_);
  }
  
  int AbstractCookConfig::standard()
  {
      return standard_;
  }
  
  void AbstractCookConfig::setStandard(int value)
8c2952457   김태훈   응용 프로그램 추가
190
  {
99b8066f4   김태훈   V0.1.1
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
      standard_ = qBound(1, value, count_);
      setCurrent(standard_);
  }
  
  int AbstractCookConfig::configureTime(int standardTime)
  {
      return standardTime;
  }
  
  int AbstractCookConfig::configureInterTemp(int standardInterTemp)
  {
      return standardInterTemp;
  }
  
  Cook::Step AbstractCookConfig::configureStep(Cook::Step standardStep)
  {
      return standardStep;
  }
  
  BrightnessConfig::BrightnessConfig()
  {
      type_ = Cook::Brightness;
05f2a7552   김태훈   image 관리 구조 변경
213
214
      icon_ = ":/images/slider_icon/gau_icon_01.png";
      overayIcon_ = ":/images/slider_icon/gau_icon_01_ov.png";
99b8066f4   김태훈   V0.1.1
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
      minLabel_ = "연한색";
      maxLabel_ = "진한색";
  }
  
  Cook::Step BrightnessConfig::configureStep(Cook::Step standardStep)
  {
      int dVal = current_ - standard_;
      qreal m = 1.0 - 0.05 * dVal;
  
      standardStep.humidity =
              qBound(0, (int) round(standardStep.humidity * m), 100);
  
      return standardStep;
  }
  
  TimeConfig::TimeConfig()
  {
      type_ = Cook::Time;
05f2a7552   김태훈   image 관리 구조 변경
233
234
      icon_ = ":/images/slider_icon/time.png";
      overayIcon_ = ":/images/slider_icon/time_ov.png";
99b8066f4   김태훈   V0.1.1
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
      minLabel_ = "단시간";
      maxLabel_ = "장시간";
  }
  
  int TimeConfig::configureTime(int standardTime)
  {
      int dVal = current_ - standard_;
      qreal m = 1.0 + 0.1 * dVal;
  
      standardTime = qBound(0, (int) round(standardTime * m), 24 * 60 * 60);
  
      return standardTime;
  }
  
  BurnDegreeConfig::BurnDegreeConfig()
  {
      type_ = Cook::BurnDegree;
05f2a7552   김태훈   image 관리 구조 변경
252
253
      icon_ = ":/images/slider_icon/gau_icon_02.png";
      overayIcon_ = ":/images/slider_icon/gau_icon_02_ov.png";
99b8066f4   김태훈   V0.1.1
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
      minLabel_ = "중간 익힘";
      maxLabel_ = "완전 익힘";
  }
  
  Cook::Step BurnDegreeConfig::configureStep(Cook::Step standardStep)
  {
      int dVal = current_ - standard_;
      qreal m = 1.0 + 0.03 * dVal;
  
      standardStep.temp =
              qBound(30, (int) round(standardStep.temp * m), 300);
  
      return standardStep;
  }
  
  int BurnDegreeConfig::configureInterTemp(int standardInterTemp)
  {
      int dVal = current_ - standard_;
      qreal m = 1.0 + 0.03 * dVal;
  
      standardInterTemp = qBound(0, (int) round(standardInterTemp * m), 99);
  
      return standardInterTemp;
  }
  
  QString Cook::name(Cook::StepType type)
  {
      switch (type)
      {
      case Cook::Roast:
          return "로스팅";
      case Cook::Grill:
          return "그릴";
      case Cook::Boil:
          return "끓이기";
      case Cook::BoilSteadily:
          return "뭉근하게 끓이기";
      case Cook::HeatUp:
          return "온도 높이기";
      case Cook::Thicken:
          return "걸쭉하게 만들기";
      case Cook::WarmUp:
          return "데우기";
      case Cook::Simmer:
          return "약한 불로 끓이기";
      case Cook::End:
          return "종료";
      case Cook::MakeCrispy:
          return "바삭함 주기";
      case Cook::Brown:
          return "브라우닝(갈색 내기)";
      case Cook::BlowSteam:
          return "스팀 쏘이기";
      case Cook::Damp:
          return "습윤 주기";
      case Cook::Finish:
          return "피니싱";
      case Cook::Burn:
          return "그을리기";
      case Cook::CookGratin:
          return "그라탱 요리";
      case Cook::CoolDown:
          return "식히기";
      case Cook::Defer:
          return "보류";
      case Cook::RipenKeep:
          return "숙성 & 보존";
      case Cook::Bake:
          return "베이킹";
      case Cook::Fry:
          return "기름에 재빨리 볶기";
      case Cook::Steam:
          return "찌기";
      case Cook::Ripen:
          return "촉촉하게";
      case Cook::Ferment:
          return "숙성";
      case Cook::Moisten:
          return "발효";
      case Cook::Dry:
          return "건조시키기";
      default:
          return "";
      }
  }
  
  QString Cook::icon(Cook::StepType type)
  {
      switch (type)
      {
      case Cook::Roast:
      case Cook::Grill:
05f2a7552   김태훈   image 관리 구조 변경
346
          return ":/images/cook_step_type/sys_icon_01.png";
99b8066f4   김태훈   V0.1.1
347
348
349
350
351
352
      case Cook::Boil:
      case Cook::BoilSteadily:
      case Cook::HeatUp:
      case Cook::Thicken:
      case Cook::WarmUp:
      case Cook::Simmer:
05f2a7552   김태훈   image 관리 구조 변경
353
          return ":/images/cook_step_type/sys_icon_02.png";
99b8066f4   김태훈   V0.1.1
354
      case Cook::End:
05f2a7552   김태훈   image 관리 구조 변경
355
          return ":/images/cook_step_type/sys_icon_03.png";
99b8066f4   김태훈   V0.1.1
356
357
358
359
      case Cook::MakeCrispy:
      case Cook::Brown:
      case Cook::BlowSteam:
      case Cook::Damp:
05f2a7552   김태훈   image 관리 구조 변경
360
          return ":/images/cook_step_type/sys_icon_04.png";
99b8066f4   김태훈   V0.1.1
361
      case Cook::Finish:
05f2a7552   김태훈   image 관리 구조 변경
362
          return ":/images/cook_step_type/sys_icon_05.png";
99b8066f4   김태훈   V0.1.1
363
364
      case Cook::Burn:
      case Cook::CookGratin:
05f2a7552   김태훈   image 관리 구조 변경
365
          return ":/images/cook_step_type/sys_icon_06.png";
99b8066f4   김태훈   V0.1.1
366
      case Cook::CoolDown:
05f2a7552   김태훈   image 관리 구조 변경
367
          return ":/images/cook_step_type/sys_icon_07.png";
99b8066f4   김태훈   V0.1.1
368
369
      case Cook::Defer:
      case Cook::RipenKeep:
05f2a7552   김태훈   image 관리 구조 변경
370
          return ":/images/cook_step_type/sys_icon_08.png";
99b8066f4   김태훈   V0.1.1
371
      case Cook::Bake:
05f2a7552   김태훈   image 관리 구조 변경
372
          return ":/images/cook_step_type/sys_icon_09.png";
99b8066f4   김태훈   V0.1.1
373
374
      case Cook::Fry:
      case Cook::Steam:
05f2a7552   김태훈   image 관리 구조 변경
375
          return ":/images/cook_step_type/sys_icon_10.png";
99b8066f4   김태훈   V0.1.1
376
377
378
      case Cook::Ripen:
      case Cook::Ferment:
      case Cook::Moisten:
05f2a7552   김태훈   image 관리 구조 변경
379
          return ":/images/cook_step_type/sys_icon_11.png";
99b8066f4   김태훈   V0.1.1
380
      case Cook::Dry:
05f2a7552   김태훈   image 관리 구조 변경
381
          return ":/images/cook_step_type/sys_icon_12.png";
99b8066f4   김태훈   V0.1.1
382
383
384
385
386
387
388
389
390
391
      default:
          return "";
      }
  }
  
  QString Cook::icon(Cook::CookType type)
  {
      switch (type)
      {
      case Poultry:
05f2a7552   김태훈   image 관리 구조 변경
392
          return ":/images/cook_type/poultry_ov.png";
99b8066f4   김태훈   V0.1.1
393
      case Meat:
05f2a7552   김태훈   image 관리 구조 변경
394
          return ":/images/cook_type/meat_ov.png";
99b8066f4   김태훈   V0.1.1
395
      case Fish:
05f2a7552   김태훈   image 관리 구조 변경
396
          return ":/images/cook_type/fish_ov.png";
99b8066f4   김태훈   V0.1.1
397
      case Desert:
05f2a7552   김태훈   image 관리 구조 변경
398
          return ":/images/cook_type/desert_ov.png";
99b8066f4   김태훈   V0.1.1
399
      case Vegetable:
05f2a7552   김태훈   image 관리 구조 변경
400
          return ":/images/cook_type/vegetable_ov.png";
99b8066f4   김태훈   V0.1.1
401
      case Bread:
05f2a7552   김태훈   image 관리 구조 변경
402
          return ":/images/cook_type/bread_ov.png";
99b8066f4   김태훈   V0.1.1
403
      case Etc:
05f2a7552   김태훈   image 관리 구조 변경
404
          return ":/images/cook_type/etc_ov.png";
99b8066f4   김태훈   V0.1.1
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
      default:
          return "";
      }
  }
  
  FriedRice::FriedRice()
  {
      name_ = QCoreApplication::tr("볶음밥");
      currentStep_ = 0;
      stepCount_ = 4;
  
      stepList[0] = { Cook::Preheat, Cook::CombiMode, 100, 150 };
      stepList[1] = { Cook::Load, Cook::CombiMode, 0, 0 };
      stepList[2] = { Cook::Roast, Cook::CombiMode, 80, 130 };
      stepList[3] = { Cook::Roast, Cook::DryMode, 30, 170 };
  }
  
  ChickenCook::ChickenCook()
  {
      type_ = Cook::Poultry;
      name_ = QCoreApplication::tr("닭고기 요리");
      currentStep_ = 0;
      stepCount_ = 5;
  
      stepList[0] = { Cook::Preheat, Cook::CombiMode, 100, 230 };
      stepList[1] = { Cook::Load, Cook::CombiMode, 0, 0 };
      stepList[2] = { Cook::Roast, Cook::CombiMode, 90, 210 };
      stepList[3] = { Cook::Roast, Cook::CombiMode, 50, 173 };
      stepList[4] = { Cook::Roast, Cook::DryMode, 50, 200 };
  
      time_ = 39 * 60;
      interTempEnabled_ = true;
      interTemp_ = 88;
  
      BrightnessConfig *brightness = new BrightnessConfig;
      brightness->setCount(5);
      brightness->setStandard(3);
      brightness->setCurrent(3);
      configurations[0] = brightness;
  
      BurnDegreeConfig *burnDegree = new BurnDegreeConfig;
      burnDegree->setCount(3);
      burnDegree->setStandard(3);
      burnDegree->setCurrent(3);
      configurations[1] = burnDegree;
  }
  
  MeatPie::MeatPie()
  {
      type_ = Cook::Meat;
      name_ = QCoreApplication::tr("고기 파이");
      currentStep_ = 0;
      stepCount_ = 5;
  
      stepList[0] = { Cook::Preheat, Cook::DryMode, 100, 211 };
      stepList[1] = { Cook::Load, Cook::DryMode, 0, 0 };
      stepList[2] = { Cook::Bake, Cook::DryMode, 100, 191 };
      stepList[3] = { Cook::CoolDown, Cook::DryMode, 100, 120 };
      stepList[4] = { Cook::Bake, Cook::DryMode, 40, 120 };
05f2a7552   김태훈   image 관리 구조 변경
464
      time_ = (1 * 60 + 17) * 60;
99b8066f4   김태훈   V0.1.1
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
      interTempEnabled_ = true;
      interTemp_ = 62;
  
      BrightnessConfig *brightness = new BrightnessConfig;
      brightness->setCount(5);
      brightness->setStandard(3);
      brightness->setCurrent(3);
      configurations[0] = brightness;
  
      BurnDegreeConfig *burnDegree = new BurnDegreeConfig;
      burnDegree->setCount(3);
      burnDegree->setStandard(2);
      burnDegree->setCurrent(2);
      configurations[1] = burnDegree;
  }
  
  Croissant::Croissant()
  {
      type_ = Cook::Bread;
      name_ = QCoreApplication::tr("크로와상/페이스트리");
      currentStep_ = 0;
      stepCount_ = 6;
  
      stepList[0] = { Cook::Preheat, Cook::CombiMode, 100, 180 };
      stepList[1] = { Cook::Load, Cook::DryMode, 0, 0 };
      stepList[2] = { Cook::BlowSteam, Cook::SteamMode, 100, 98 };
      stepList[3] = { Cook::Bake, Cook::DryMode, 100, 170 };
      stepList[4] = { Cook::Bake, Cook::DryMode, 70, 170 };
      stepList[5] = { Cook::Bake, Cook::DryMode, 20, 170 };
  
      time_ = 18 * 60;
      interTempEnabled_ = false;
      interTemp_ = 0;
  
      BrightnessConfig *brightness = new BrightnessConfig;
      brightness->setCount(5);
      brightness->setStandard(3);
      brightness->setCurrent(3);
      configurations[0] = brightness;
  
      TimeConfig *timeConf = new TimeConfig;
      timeConf->setCount(3);
      timeConf->setStandard(2);
      timeConf->setCurrent(2);
      configurations[4] = timeConf;
8c2952457   김태훈   응용 프로그램 추가
510
  }