Blame view

app/gui/oven_control/washwindow.cpp 6.13 KB
00a512484   김태훈   세척 모드 화면 추가
1
2
  #include "washwindow.h"
  #include "ui_washwindow.h"
05f2a7552   김태훈   image 관리 구조 변경
3
4
5
  #include <QSignalMapper>
  
  WashWindow::WashWindow(QWidget *parent, UdpHandler *udp) :
00a512484   김태훈   세척 모드 화면 추가
6
      QMainWindow(parent),
05f2a7552   김태훈   image 관리 구조 변경
7
8
      ui(new Ui::WashWindow),
      udp(udp),
61ba89b34   김태훈   GUI V0.1.6
9
10
11
12
13
      selected(false),
      opened(false),
      started(false),
      run(false),
      type(0)
00a512484   김태훈   세척 모드 화면 추가
14
15
16
17
18
19
  {
      ui->setupUi(this);
  
      ui->clockContainer->setParent(ui->upperStack);
      ui->progressContainer->setParent(ui->upperStack);
      setAttribute(Qt::WA_DeleteOnClose);
05f2a7552   김태훈   image 관리 구조 변경
20
21
22
  
      udp->turnOff(TG_SYSTEM);
      connect(udp, SIGNAL(changed()), SLOT(onChanged()));
05f2a7552   김태훈   image 관리 구조 변경
23
      ui->animation->load(":/images/animation/wash_04.png");
61ba89b34   김태훈   GUI V0.1.6
24
      ui->closeDoorArrow->hide();
05f2a7552   김태훈   image 관리 구조 변경
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  
      QSignalMapper *sm = new QSignalMapper(this);
      connect(sm, SIGNAL(mapped(int)), SLOT(start(int)));
  
      sm->setMapping(ui->washButton_1, 1);
      sm->setMapping(ui->washButton_2, 2);
      sm->setMapping(ui->washButton_3, 3);
      sm->setMapping(ui->washButton_4, 4);
      sm->setMapping(ui->washButton_5, 5);
  
      connect(ui->washButton_1, SIGNAL(clicked()), sm, SLOT(map()));
      connect(ui->washButton_2, SIGNAL(clicked()), sm, SLOT(map()));
      connect(ui->washButton_3, SIGNAL(clicked()), sm, SLOT(map()));
      connect(ui->washButton_4, SIGNAL(clicked()), sm, SLOT(map()));
      connect(ui->washButton_5, SIGNAL(clicked()), sm, SLOT(map()));
61ba89b34   김태훈   GUI V0.1.6
40
41
42
      returnToClockTimer.setSingleShot(true);
      returnToClockTimer.setInterval(10 * 1000);
      connect(&returnToClockTimer, SIGNAL(timeout()), SLOT(returnToClock()));
00a512484   김태훈   세척 모드 화면 추가
43
44
45
46
47
48
  }
  
  WashWindow::~WashWindow()
  {
      delete ui;
  }
05f2a7552   김태훈   image 관리 구조 변경
49
50
51
  
  void WashWindow::start(int type)
  {
61ba89b34   김태훈   GUI V0.1.6
52
      if (selected)
05f2a7552   김태훈   image 관리 구조 변경
53
54
55
56
          return;
  
      if (type < 1 || type > 5)
          return;
61ba89b34   김태훈   GUI V0.1.6
57
      selected = true;
05f2a7552   김태훈   image 관리 구조 변경
58
61ba89b34   김태훈   GUI V0.1.6
59
60
61
      this->type = type;
  
      returnToClockTimer.stop();
05f2a7552   김태훈   image 관리 구조 변경
62
61ba89b34   김태훈   GUI V0.1.6
63
64
65
66
67
68
      ui->animation->clear();
      ui->animation->load(":/images/animation/pull_01.png");
      ui->animation->load(":/images/animation/pull_02.png");
      ui->animation->load(":/images/animation/pull_03.png");
      ui->animation->load(":/images/animation/pull_04.png");
      ui->animation->show();
05f2a7552   김태훈   image 관리 구조 변경
69
      ui->animation->start(300);
61ba89b34   김태훈   GUI V0.1.6
70
71
72
  
      udp->set(TG_OVEN_MODE, 2);
      udp->turnOn(TG_SYSTEM);
05f2a7552   김태훈   image 관리 구조 변경
73
74
75
76
77
78
  }
  
  void WashWindow::stop()
  {
      udp->turnOff(TG_CLEANING);
  }
61ba89b34   김태훈   GUI V0.1.6
79
80
81
82
  void WashWindow::returnToClock()
  {
      ui->upperStack->setCurrentIndex(0);
  }
05f2a7552   김태훈   image 관리 구조 변경
83
84
  void WashWindow::onChanged()
  {
61ba89b34   김태훈   GUI V0.1.6
85
      if (!selected)
05f2a7552   김태훈   image 관리 구조 변경
86
          return;
61ba89b34   김태훈   GUI V0.1.6
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
190
191
192
193
194
195
196
197
198
199
200
      oven_state_t state;
      udp->fillData(state);
  
      if (!opened)
      {
          if (state.door_state)
          {
              opened = true;
  
              ui->animation->clear();
  
              ui->animation->load(":/images/animation/door_big_09.png");
              ui->animation->load(":/images/animation/door_big_08.png");
              ui->animation->load(":/images/animation/door_big_07.png");
              ui->animation->load(":/images/animation/door_big_06.png");
              ui->animation->load(":/images/animation/door_big_05.png");
              ui->animation->load(":/images/animation/door_big_04.png");
              ui->animation->load(":/images/animation/door_big_03.png");
              ui->animation->load(":/images/animation/door_big_02.png");
              ui->animation->load(":/images/animation/door_big_01.png");
              ui->closeDoorArrow->show();
          }
      }
      else if (!started)
      {
          if (!state.door_state)
          {
              started = true;
  
              ui->closeDoorArrow->hide();
              ui->animation->clear();
  
              ui->animation->load(":/images/animation/wash_01.png");
              ui->animation->load(":/images/animation/wash_02.png");
              ui->animation->load(":/images/animation/wash_03.png");
              ui->animation->load(":/images/animation/wash_04.png");
              ui->washStepGauge->setValue(0);
              ui->washStepTypeLabel->setText("");
              ui->washStepCountLabel->setText("");
  
              ui->upperStack->setCurrentIndex(1);
  
              udp->set(TG_CLEAN_TYPE, type);
              udp->turnOn(TG_CLEANING);
          }
      }
      else if (state.cleaning_sate)
      {
          if (!run)
              run = true;
  
          oven_control_t control;
          udp->fillControl(control);
  
          if (control.clean_total != 0 && control.clean_step != 0 && control.clean_step_type != 0)
          {
              ui->washStepGauge->setMaximum(control.clean_total);
              ui->washStepGauge->setValue(control.clean_step);
              ui->washStepCountLabel->setText(QString().sprintf("%d/%d", control.clean_step, control.clean_total));
  
              switch (control.clean_step_type)
              {
              case 1:
                  ui->washStepTypeLabel->setText("내부 헹굼");
                  break;
              case 2:
                  ui->washStepTypeLabel->setText("Steam Generator Tank 급수");
                  break;
              case 3:
                  ui->washStepTypeLabel->setText("Inner Tank 팬 사이드 세척");
                  break;
              case 4:
                  ui->washStepTypeLabel->setText("Inner Tank 불림");
                  break;
              case 5:
                  ui->washStepTypeLabel->setText("Inner Tank 강 세척");
                  break;
              case 6:
                  ui->washStepTypeLabel->setText("Inner Tank 상부 세척");
                  break;
              case 7:
                  ui->washStepTypeLabel->setText("Inner Tank 스팀 세척");
                  break;
              case 8:
                  ui->washStepTypeLabel->setText("드레인 탱크 헹굼");
                  break;
              case 9:
                  ui->washStepTypeLabel->setText("세제 세척수 만들기");
                  break;
              case 10:
                  ui->washStepTypeLabel->setText("세제 세척수 헹굼");
                  break;
              case 11:
                  ui->washStepTypeLabel->setText("드레인 탱크 헹굼수 채움");
                  break;
              }
          }
      }
      else if (run)
      {
          ui->washStepTypeLabel->setText("세척이 종료되었습니다");
          ui->washStepCountLabel->setText("");
  
          ui->animation->stop();
          ui->animation->clear();
          ui->animation->load(":/images/animation/wash_04.png");
  
          returnToClockTimer.start();
  
          selected = false;
          opened = false;
          started = false;
          run = false;
      }
05f2a7552   김태훈   image 관리 구조 변경
201
202
203
204
205
206
207
  }
  
  void WashWindow::on_backButton_clicked()
  {
      stop();
      close();
  }