Blame view

app/gui/oven_control/configdoormonitoring.cpp 4.66 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;
      }
  }