Blame view

app/gui/oven_control/fantestwindow.cpp 7.08 KB
8c2952457   김태훈   응용 프로그램 추가
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
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
  #include "fantestwindow.h"
  #include "ui_fantestwindow.h"
  
  FanTestWindow::FanTestWindow(QWidget *parent, UdpHandler *udp) :
      QMainWindow(parent),
      ui(new Ui::FanTestWindow), udp(udp)
  {
      ui->setupUi(this);
      ui->clockContainer->setParent(ui->upperStack);
      connect(udp, SIGNAL(changed()), this, SLOT(onDataChanged()));
  
      currentFan = Fan1;
      direction1 = direction2 = ClockWise;
      rpm1 = rpm2 = 500;
  
      udp->set(TG_OVEN_MODE, 4);
      udp->turnOn(TG_SYSTEM);
      udp->turnOn(TG_MANUAL_FAN1);
      udp->turnOn(TG_MANUAL_FAN2);
      udp->set(TG_FAN1_RPM, rpm1);
      udp->set(TG_FAN2_RPM, rpm2);
      udp->set(TG_FAN1_RPM, direction1);
      udp->set(TG_FAN2_RPM, direction2);
  
      onDataChanged();
  }
  
  FanTestWindow::~FanTestWindow()
  {
      delete ui;
  }
  
  void FanTestWindow::onDataChanged()
  {
      if (udp->convection1())
          ui->start1Button->setText("STOP");
      else
          ui->start1Button->setText("START");
  
      if (udp->convection2())
          ui->start2Button->setText("STOP");
      else
          ui->start2Button->setText("START");
  
      int rpm;
      Direction dir;
  
      QString unselectedStyle("color: white");
      QString selectedStyle("color: yellow");
  
      ui->motorLabel1->setStyleSheet(unselectedStyle);
      ui->motorLabel2->setStyleSheet(unselectedStyle);
      ui->directionLabelLeft->setStyleSheet(unselectedStyle);
      ui->directionLabelRight->setStyleSheet(unselectedStyle);
      ui->rpmLabel500->setStyleSheet(unselectedStyle);
      ui->rpmLabel725->setStyleSheet(unselectedStyle);
      ui->rpmLabel950->setStyleSheet(unselectedStyle);
      ui->rpmLabel1175->setStyleSheet(unselectedStyle);
      ui->rpmLabel1400->setStyleSheet(unselectedStyle);
  
      switch (currentFan)
      {
      case Fan1:
          rpm = rpm1;
          dir = direction1;
          ui->fanLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_08.png"));
          ui->motorLabel1->setStyleSheet(selectedStyle);
          break;
      case Fan2:
          rpm = rpm2;
          dir = direction2;
          ui->fanLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_09.png"));
          ui->motorLabel2->setStyleSheet(selectedStyle);
          break;
      default:
          rpm = 500;
          dir = ClockWise;
          ui->fanLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_08.png"));
          ui->motorLabel1->setStyleSheet(selectedStyle);
      }
  
      switch (rpm)
      {
      case 500:
          ui->rpmLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_01.png"));
          ui->rpmLabel500->setStyleSheet(selectedStyle);
          break;
      case 725:
          ui->rpmLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_02.png"));
          ui->rpmLabel725->setStyleSheet(selectedStyle);
          break;
      case 950:
          ui->rpmLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_03.png"));
          ui->rpmLabel950->setStyleSheet(selectedStyle);
          break;
      case 1175:
          ui->rpmLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_04.png"));
          ui->rpmLabel1175->setStyleSheet(selectedStyle);
          break;
      case 1400:
          ui->rpmLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_05.png"));
          ui->rpmLabel1400->setStyleSheet(selectedStyle);
          break;
      default:
          ui->rpmLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_01.png"));
          ui->rpmLabel500->setStyleSheet(selectedStyle);
      }
  
      switch (dir)
      {
      case ClockWise:
          ui->directionLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_06.png"));
          ui->directionLabelRight->setStyleSheet(selectedStyle);
          break;
      case CounterClockWise:
          ui->directionLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_07.png"));
          ui->directionLabelLeft->setStyleSheet(selectedStyle);
          break;
      default:
          ui->directionLabel->setPixmap(QPixmap(":/images/images/config_service/091_set_eng_icon_pan_06.png"));
          ui->directionLabelRight->setStyleSheet(selectedStyle);
      }
  
      QString buf;
      ui->motor1RpmLabel->setText(buf.sprintf("%d rpm", rpm1));
      ui->motor2RpmLabel->setText(buf.sprintf("%d rpm", rpm2));
  }
  
  void FanTestWindow::on_rpmButton_clicked()
  {
      int *target;
      switch (currentFan)
      {
      case Fan1:
          target = &rpm1;
          break;
      case Fan2:
          target = &rpm2;
          break;
      default:
          return;
      }
  
      switch (*target)
      {
      case 500:
          *target = 725;
          break;
      case 725:
          *target = 950;
          break;
      case 950:
          *target = 1175;
          break;
      case 1175:
          *target = 1400;
          break;
      case 1400:
          *target = 500;
          break;
      default:
          *target = 500;
      }
  
      setRpm(currentFan, *target);
  
      onDataChanged();
  }
  
  void FanTestWindow::on_directionButton_clicked()
  {
      Direction *target;
      switch (currentFan)
      {
      case Fan1:
          target = &direction1;
          break;
      case Fan2:
          target = &direction2;
          break;
      default:
          return;
      }
  
      switch (*target)
      {
      case ClockWise:
          *target = CounterClockWise;
          break;
      case CounterClockWise:
          *target = ClockWise;
          break;
      default:
          return;
      }
  
      setDirection(currentFan, *target);
  
      onDataChanged();
  }
  
  void FanTestWindow::on_motorButton_clicked()
  {
      switch (currentFan)
      {
      case Fan1:
          currentFan = Fan2;
          break;
      case Fan2:
          currentFan = Fan1;
          break;
      default:
          currentFan = Fan1;
      }
  
      onDataChanged();
  }
  
  void FanTestWindow::on_start1Button_clicked()
  {
      if (udp->convection1())
          stop(Fan1);
      else
          start(Fan1);
  }
  
  void FanTestWindow::on_start2Button_clicked()
  {
      if (udp->convection2())
          stop(Fan2);
      else
          start(Fan2);
  }
  
  void FanTestWindow::on_backButton_clicked()
  {
      stop(Fan1);
      stop(Fan2);
  
      udp->turnOff(TG_MANUAL_FAN1);
      udp->turnOff(TG_MANUAL_FAN2);
      udp->turnOff(TG_SYSTEM);
  
      deleteLater();
  }
  
  void FanTestWindow::setRpm(Fan fan, int rpm)
  {
      switch (fan)
      {
      case Fan1:
          udp->set(TG_FAN1_RPM, rpm);
          break;
      case Fan2:
          udp->set(TG_FAN2_RPM, rpm);
          break;
      }
  }
  
  void FanTestWindow::setDirection(Fan fan, Direction direction)
  {
      int dir;
      switch (direction)
      {
      case ClockWise:
          dir = 0;
          break;
      case CounterClockWise:
          dir = 1;
          break;
      default:
          return;
      }
  
      switch (fan)
      {
      case Fan1:
          udp->set(TG_FAN1_DIRECTOIN, dir);
          break;
      case Fan2:
          udp->set(TG_FAN2_DIRECTOIN, dir);
          break;
      }
  }
  
  void FanTestWindow::start(Fan fan)
  {
      switch (fan)
      {
      case Fan1:
          udp->turnOn(TG_FAN1_MANUAL);
          break;
      case Fan2:
          udp->turnOn(TG_FAN2_MANUAL);
          break;
      }
  }
  
  void FanTestWindow::stop(Fan fan)
  {
      switch (fan)
      {
      case Fan1:
          udp->turnOff(TG_FAN1_MANUAL);
          break;
      case Fan2:
          udp->turnOff(TG_FAN2_MANUAL);
          break;
      }
  }