Blame view

app/gui/oven_control/burnertestwindow.cpp 3.49 KB
8c2952457   김태훈   응용 프로그램 추가
1
2
3
4
  #include "burnertestwindow.h"
  #include "ui_burnertestwindow.h"
  
  #include <QTimer>
538041ab9   김태훈   소스 코드 구조 개선
5
  BurnerTestWindow::BurnerTestWindow(QWidget *parent) :
8c2952457   김태훈   응용 프로그램 추가
6
      QMainWindow(parent),
538041ab9   김태훈   소스 코드 구조 개선
7
      ui(new Ui::BurnerTestWindow)
8c2952457   김태훈   응용 프로그램 추가
8
9
  {
      ui->setupUi(this);
6f96c947a   김태훈   GUI 0.1.4
10
8c2952457   김태훈   응용 프로그램 추가
11
      ui->clockContainer->setParent(ui->upperStack);
6f96c947a   김태훈   GUI 0.1.4
12
      setAttribute(Qt::WA_DeleteOnClose);
8c2952457   김태훈   응용 프로그램 추가
13
538041ab9   김태훈   소스 코드 구조 개선
14
      udp = UdpHandler::getInstance();
8c2952457   김태훈   응용 프로그램 추가
15
16
17
18
19
20
21
22
23
24
25
      steamTimer.setInterval(5 * 60 * 1000);
      upperTimer.setInterval(5 * 60 * 1000);
      lowerTimer.setInterval(5 * 60 * 1000);
  
      connect(&steamTimer, SIGNAL(timeout()), this, SLOT(steamOff()));
      connect(&upperTimer, SIGNAL(timeout()), this, SLOT(upperOff()));
      connect(&lowerTimer, SIGNAL(timeout()), this, SLOT(lowerOff()));
  
      connect(this->udp, SIGNAL(changed()), this, SLOT(onDataChanged()));
  
      udp->set(TG_OVEN_MODE, 4);
8c2952457   김태훈   응용 프로그램 추가
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
      udp->turnOn(TG_MANUAL_BURNER1);
      udp->turnOn(TG_MANUAL_BURNER2);
      udp->turnOn(TG_MANUAL_BURNER3);
  
      onDataChanged();
  }
  
  BurnerTestWindow::~BurnerTestWindow()
  {
      delete ui;
  }
  
  void BurnerTestWindow::onDataChanged()
  {
      oven_state_t oven;
      udp->fillData(oven);
  
      int steam = oven.onoff_state1 & 0x0004;
      int upper = oven.onoff_state1 & 0x0001;
      int lower = oven.onoff_state1 & 0x0002;
  
      if (steam)
          ui->steamBurnerButton->setText("STOP");
      else
          ui->steamBurnerButton->setText("START");
  
      if (upper)
          ui->upperBurnerButton->setText("STOP");
      else
          ui->upperBurnerButton->setText("START");
  
      if (lower)
          ui->lowerBurnerButton->setText("STOP");
      else
          ui->lowerBurnerButton->setText("START");
  
      QString buf;
      ui->t1->setText(buf.sprintf("%d℃", oven.sensor1));
      ui->t5->setText(buf.sprintf("%d℃", oven.sensor5));
  
      if (steam && oven.curr_humidity >= 100)
      {
          steamTimer.stop();
          steamOff();
      }
  
      if ((upper || lower) && oven.curr_heat >= 150)
      {
          upperTimer.stop();
          lowerTimer.stop();
          upperOff();
          lowerOff();
      }
  }
  
  void BurnerTestWindow::on_steamBurnerButton_clicked()
  {
      oven_state_t oven;
      udp->fillData(oven);
  
      int sw = oven.onoff_state1 & 0x0004;
      if (sw)
      {
          steamTimer.stop();
          steamOff();
      }
      else
      {
          steamTimer.start();
          steamOn();
      }
  }
  
  void BurnerTestWindow::on_upperBurnerButton_clicked()
  {
      oven_state_t oven;
      udp->fillData(oven);
  
      int sw = oven.onoff_state1 & 0x0001;
      if (sw)
      {
          upperTimer.stop();
          upperOff();
      }
      else
      {
          upperTimer.start();
          upperOn();
      }
  }
  
  void BurnerTestWindow::on_lowerBurnerButton_clicked()
  {
      oven_state_t oven;
      udp->fillData(oven);
  
      int sw = oven.onoff_state1 & 0x0002;
      if (sw)
      {
          lowerTimer.stop();
          lowerOff();
      }
      else
      {
          lowerTimer.start();
          lowerOn();
      }
  }
  
  void BurnerTestWindow::on_backButton_clicked()
  {
      udp->turnOff(TG_BUNNER1_MANUAL);
      udp->turnOff(TG_BUNNER2_MANUAL);
      udp->turnOff(TG_BUNNER3_MANUAL);
      udp->turnOff(TG_MANUAL_BURNER1);
      udp->turnOff(TG_MANUAL_BURNER2);
      udp->turnOff(TG_MANUAL_BURNER3);
8c2952457   김태훈   응용 프로그램 추가
143
6f96c947a   김태훈   GUI 0.1.4
144
      close();
8c2952457   김태훈   응용 프로그램 추가
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
  }
  
  void BurnerTestWindow::steamOn()
  {
      udp->turnOn(TG_BUNNER3_MANUAL);
  }
  
  void BurnerTestWindow::steamOff()
  {
      udp->turnOff(TG_BUNNER3_MANUAL);
  }
  
  void BurnerTestWindow::upperOn()
  {
      udp->turnOn(TG_BUNNER1_MANUAL);
  }
  
  void BurnerTestWindow::upperOff()
  {
      udp->turnOff(TG_BUNNER1_MANUAL);
  }
  
  void BurnerTestWindow::lowerOn()
  {
      udp->turnOn(TG_BUNNER2_MANUAL);
  }
  
  void BurnerTestWindow::lowerOff()
  {
      udp->turnOff(TG_BUNNER2_MANUAL);
  }