Blame view

app/gui/oven_control/configdoormonitoring.cpp 5.41 KB
663943a37   고영탁   설정 기능 마무리 진행 중
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
  #include <QDebug>
  #include "configdoormonitoring.h"
  #include "ui_configdoormonitoring.h"
  #include "config1digitsetandenablesetdlg.h"
  
  
  
  ConfigDoorMonitoring::ConfigDoorMonitoring(QWidget *parent, ConfigType idx) :
      QMainWindow(parent),
      ui(new Ui::ConfigDoorMonitoring)
  {
      ui->setupUi(this);
      ui->clockContainer->setParent(ui->upperStack);
      setAttribute(Qt::WA_DeleteOnClose);
      m_nCfgType = idx;
  
      if(m_nCfgType == config_cooking_door_monitoring){
          ui->ctrLbTitle->setText(tr("전문가설정 > 조리중 문열림 시간 모니터링"));
      }
  
      Config *cfg = Config::getInstance();
      config_item item;
      item = cfg->getConfigValue(m_nCfgType);
      m_nSetStage = item.d8.d8_0;
      m_n1Stage = item.d8.d8_1;
      m_n2Stage = item.d8.d8_2;
      m_n3Stage = item.d8.d8_3;
  
      m_pSignalMapper = new QSignalMapper(this);
      m_pSignalMapper->setMapping(ui->ctrBtn_1,1);
      m_pSignalMapper->setMapping(ui->ctrBtn_2,2);
      m_pSignalMapper->setMapping(ui->ctrBtn_3,3);
  
      connect(ui->ctrBtn_1,  SIGNAL(clicked(bool)),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrBtn_2,  SIGNAL(clicked(bool)),m_pSignalMapper, SLOT(map()));
      connect(ui->ctrBtn_3,  SIGNAL(clicked(bool)),m_pSignalMapper, SLOT(map()));
      connect(m_pSignalMapper, SIGNAL(mapped(int)), this, SLOT(onBtnClicked(int)));
  
      reloadUi();
  }
  
  ConfigDoorMonitoring::~ConfigDoorMonitoring()
  {
      delete ui;
  }
  
  void ConfigDoorMonitoring::on_backButton_clicked()
  {
      Config* cfg = Config::getInstance();
      config_item item;
      item.d8.d8_0 = m_nSetStage;
      item.d8.d8_1 = m_n1Stage;
      item.d8.d8_2 = m_n2Stage;
      item.d8.d8_3 = m_n3Stage;
      cfg->setConfigValue(m_nCfgType, item);
      close();
  }
  
  
  void ConfigDoorMonitoring::reloadUi(){
      switch(m_nSetStage){
          case 0:
              m_n1Stage = 0;
              m_n2Stage = 0;
              m_n3Stage = 0;
              ui->ctrBtn_1->setEnabled(true);
              ui->ctrBtn_2->setEnabled(false);
              ui->ctrBtn_3->setEnabled(false);
              ui->ctrLbSet_1->setText("-");
              ui->ctrLbSet_2->setText("-");
              ui->ctrLbSet_3->setText("-");
              qDebug() << "0 stage";
          break;
      case 1:
              m_n2Stage = 0;
              m_n3Stage = 0;
              ui->ctrBtn_1->setEnabled(true);
              ui->ctrBtn_2->setEnabled(true);
              ui->ctrBtn_3->setEnabled(false);
              ui->ctrLbSet_1->setText(QString("%1 s").arg(m_n1Stage));
              ui->ctrLbSet_2->setText("-");
              ui->ctrLbSet_3->setText("-");
          break;
      case 2:
          m_n3Stage = 0;
          ui->ctrBtn_1->setEnabled(true);
          ui->ctrBtn_2->setEnabled(true);
          ui->ctrBtn_3->setEnabled(true);
          ui->ctrLbSet_1->setText(QString("%1 s").arg(m_n1Stage));
          ui->ctrLbSet_2->setText(QString("%1 s").arg(m_n2Stage));
          ui->ctrLbSet_3->setText("-");
          break;
      case 3:
          ui->ctrBtn_1->setEnabled(true);
          ui->ctrBtn_2->setEnabled(true);
          ui->ctrBtn_3->setEnabled(true);
          ui->ctrLbSet_1->setText(QString("%1 s").arg(m_n1Stage));
          ui->ctrLbSet_2->setText(QString("%1 s").arg(m_n2Stage));
          ui->ctrLbSet_3->setText(QString("%1 s").arg(m_n3Stage));
          break;
      }
  }
  
  
  void ConfigDoorMonitoring::onBtnClicked(const int sel){
      Config1DigitSetAndEnableSetDlg* dlg;
      switch(sel){
          case 1:
              dlg = new Config1DigitSetAndEnableSetDlg(this, m_n1Stage);
              dlg->exec();
              if(dlg->getResult() == result_disable){
                  m_nSetStage = 0;
                  m_n1Stage = 0;
              }
              else if(dlg->getResult() == result_ok){
                  m_nSetStage = 1;
                  m_n1Stage = dlg->getValue();
              }
              dlg->deleteLater();
              reloadUi();
              break;
          case 2:
              dlg = new Config1DigitSetAndEnableSetDlg(this, m_n2Stage);
              dlg->exec();
              if(dlg->getResult() == result_disable){
                  m_nSetStage = 1;
                  m_n2Stage = 0;
              }
              else if(dlg->getResult() == result_ok){
                  m_nSetStage = 2;
                  m_n2Stage = dlg->getValue();
              }
              dlg->deleteLater();
              reloadUi();
              break;
          case 3:
              dlg = new Config1DigitSetAndEnableSetDlg(this, m_n3Stage);
              dlg->exec();
              if(dlg->getResult() == result_disable){
                  m_nSetStage = 2;
                  m_n3Stage = 0;
              }
              else if(dlg->getResult() == result_ok){
                  m_nSetStage = 3;
                  m_n3Stage = dlg->getValue();
              }
              dlg->deleteLater();
              reloadUi();
              break;
          default:
              break;
      }
  }
ce39b99ff   고영탁   엔코더 구현 진행중
154
155
156
157
  
  void ConfigDoorMonitoring::keyPressEvent(QKeyEvent *event){
      switch (event->key())
      {
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
158
      case 0x01000032:    // Turn left
ce39b99ff   고영탁   엔코더 구현 진행중
159
160
161
162
163
          focusPreviousChild();
          break;
      case 0x01000031:    // Push
  
          break;
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
164
      case 0x01000030:    // Turn right
ce39b99ff   고영탁   엔코더 구현 진행중
165
166
167
168
169
170
          focusNextChild();
          break;
      }
  }
  
  void ConfigDoorMonitoring::keyReleaseEvent(QKeyEvent *event){
63a45681f   고영탁   엔코더 기능 구현
171
172
      switch (event->key())
      {
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
173
      case 0x01000032:    // Turn left
63a45681f   고영탁   엔코더 기능 구현
174
175
176
177
178
179
180
181
182
183
          focusPreviousChild();
          break;
      case 0x01000031:    // Push
      {
          QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
          if(btn != NULL){
              btn->click();
          }
          break;
      }
01249f413   김태훈   엔코더 방향 반전. 하드웨어가 변경됨
184
      case 0x01000030:    // Turn right
63a45681f   고영탁   엔코더 기능 구현
185
186
187
          focusNextChild();
          break;
      }
ce39b99ff   고영탁   엔코더 구현 진행중
188
  }