Blame view

app/gui/oven_control/realtimepartswindow.cpp 4.64 KB
9146b87b4   고영탁   엔코더 작업 진행중
1
  #include <QKeyEvent>
6a965b9f1   고영탁   엔지니어 모드 2차 구현
2
3
4
  #include "realtimepartswindow.h"
  #include "ui_realtimepartswindow.h"
  #include "ovenstatics.h"
66e60ceb5   김태훈   모든 버튼에 음향 효과 추가
5
  #include "soundplayer.h"
6a965b9f1   고영탁   엔지니어 모드 2차 구현
6
14a73498f   김태훈   소스 코드 정리
7
  RealtimePartsWindow::RealtimePartsWindow(QWidget *parent) :
6a965b9f1   고영탁   엔지니어 모드 2차 구현
8
      QMainWindow(parent),
14a73498f   김태훈   소스 코드 정리
9
      ui(new Ui::RealtimePartsWindow)
6a965b9f1   고영탁   엔지니어 모드 2차 구현
10
11
  {
      ui->setupUi(this);
eea7d3d59   김태훈   Segmentation Faul...
12
13
      ui->clockContainer->setParent(ui->upperStack);
      setAttribute(Qt::WA_DeleteOnClose);
66e60ceb5   김태훈   모든 버튼에 음향 효과 추가
14
15
      foreach (QPushButton *button, findChildren<QPushButton *>())
          connect(button, &QPushButton::pressed, SoundPlayer::playClick);
6a965b9f1   고영탁   엔지니어 모드 2차 구현
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
  //    for(i=0;i<CONTROL_LIST_COL_MAX;i++){
  //        for(j=0;i<CONTROL_LIST_ITEM_MAX;j++){
  //            m_arrLbState[i][j]=NULL;
  //        }
  //    }
  
      m_arrLbState[0][0] = ui->m_ctrlLbListState_1_1;
      m_arrLbState[0][1] = ui->m_ctrlLbListState_1_2;
      m_arrLbState[0][2] = ui->m_ctrlLbListState_1_3;
      m_arrLbState[0][3] = ui->m_ctrlLbListState_1_4;
      m_arrLbState[0][4] = ui->m_ctrlLbListState_1_5;
      m_arrLbState[0][5] = ui->m_ctrlLbListState_1_6;
      m_arrLbState[0][6] = ui->m_ctrlLbListState_1_7;
      m_arrLbState[0][7] = ui->m_ctrlLbListState_1_8;
  
      m_arrLbState[1][0] = ui->m_ctrlLbListState_2_1;
      m_arrLbState[1][1] = ui->m_ctrlLbListState_2_2;
      m_arrLbState[1][2] = ui->m_ctrlLbListState_2_3;
      m_arrLbState[1][3] = ui->m_ctrlLbListState_2_4;
      m_arrLbState[1][4] = ui->m_ctrlLbListState_2_5;
      m_arrLbState[1][5] = ui->m_ctrlLbListState_2_6;
      m_arrLbState[1][6] = ui->m_ctrlLbListState_2_7;
      m_arrLbState[1][7] = ui->m_ctrlLbListState_2_8;
  
      m_arrLbState[2][0] = ui->m_ctrlLbListState_3_1;
      m_arrLbState[2][1] = ui->m_ctrlLbListState_3_2;
      m_arrLbState[2][2] = ui->m_ctrlLbListState_3_3;
      m_arrLbState[2][3] = ui->m_ctrlLbListState_3_4;
      m_arrLbState[2][4] = ui->m_ctrlLbListState_3_5;
      m_arrLbState[2][5] = ui->m_ctrlLbListState_3_6;
      m_arrLbState[2][6] = ui->m_ctrlLbListState_3_7;
      m_arrLbState[2][7] = ui->m_ctrlLbListState_3_8;
  
  
      reloadUi();
3f5f5d4ce   고영탁   디버깅 요청 사항 적용
51
52
53
      timer = new QTimer(this);
      connect(timer, SIGNAL(timeout()),this,SLOT(oneSecTimerFired()));
      timer->start(1000); //1000ms fired
6a965b9f1   고영탁   엔지니어 모드 2차 구현
54
  }
3f5f5d4ce   고영탁   디버깅 요청 사항 적용
55
14a73498f   김태훈   소스 코드 정리
56
  RealtimePartsWindow::~RealtimePartsWindow()
6a965b9f1   고영탁   엔지니어 모드 2차 구현
57
  {
6a965b9f1   고영탁   엔지니어 모드 2차 구현
58
  }
14a73498f   김태훈   소스 코드 정리
59
  void RealtimePartsWindow::on_backButton_clicked()
6a965b9f1   고영탁   엔지니어 모드 2차 구현
60
  {
eea7d3d59   김태훈   Segmentation Faul...
61
      close();
6a965b9f1   고영탁   엔지니어 모드 2차 구현
62
  }
14a73498f   김태훈   소스 코드 정리
63
  void RealtimePartsWindow::reloadUi(void){
42410a75c   김태훈   오타 수정
64
      OvenStatistics* ovs = OvenStatistics::getInstance();
6a965b9f1   고영탁   엔지니어 모드 2차 구현
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
      QString strTemp = "";
      int i = 0,j=0;
      realtime_data realdata;
      if(ovs  != NULL){
          realdata = ovs->getPartsRealtimeData();
      }
  
      if(realdata.b.ssv_open) ui->m_ctrlLbListState_1_1->setText(tr("ON"));
      else ui->m_ctrlLbListState_1_1->setText(tr("OFF"));
  
      if(realdata.b.qnv_open) ui->m_ctrlLbListState_1_2->setText(tr("ON"));
      else ui->m_ctrlLbListState_1_2->setText(tr("OFF"));
  
      if(realdata.b.snv_open) ui->m_ctrlLbListState_1_3->setText(tr("ON"));
      else ui->m_ctrlLbListState_1_3->setText(tr("OFF"));
3f5f5d4ce   고영탁   디버깅 요청 사항 적용
80
81
82
83
84
85
86
87
88
      //strTemp.sprintf("%d",realdata.b.water_level);
      //ui->m_ctrlLbListState_1_4->setText(strTemp);
      if(realdata.b.water_level == water_level_high){
          ui->m_ctrlLbListState_1_4->setText(tr("HIGH"));
      }
      else if(realdata.b.water_level == water_level_low){
          ui->m_ctrlLbListState_1_4->setText(tr("LOW"));
      }
      else ui->m_ctrlLbListState_1_4->setText(tr("NORMAL"));
6a965b9f1   고영탁   엔지니어 모드 2차 구현
89
90
91
92
93
94
  
      if(realdata.b.sgnv_open) ui->m_ctrlLbListState_1_5->setText(tr("ON"));
      else ui->m_ctrlLbListState_1_5->setText(tr("OFF"));
  
      if(realdata.b.dv_open) ui->m_ctrlLbListState_1_6->setText(tr("ON"));
      else ui->m_ctrlLbListState_1_6->setText(tr("OFF"));
f8661a150   고영탁   엔지니어 모드 디버깅
95
      if(realdata.b.wsv_open) ui->m_ctrlLbListState_1_7->setText(tr("ON"));
6a965b9f1   고영탁   엔지니어 모드 2차 구현
96
97
98
99
      else ui->m_ctrlLbListState_1_7->setText(tr("OFF"));
  
      if(realdata.b.door_open) ui->m_ctrlLbListState_1_8->setText(tr("ON"));
      else ui->m_ctrlLbListState_1_8->setText(tr("OFF"));
3f5f5d4ce   고영탁   디버깅 요청 사항 적용
100
6a965b9f1   고영탁   엔지니어 모드 2차 구현
101
102
103
104
105
106
107
      for(i=1;i<CONTROL_LIST_COL_MAX;i++){
          for(j=0;j<CONTROL_LIST_ITEM_MAX;j++){
              m_arrLbState[i][j]->setText("-");
          }
      }
  
  }
3f5f5d4ce   고영탁   디버깅 요청 사항 적용
108
109
110
111
  
  void RealtimePartsWindow::oneSecTimerFired(void){
      reloadUi();
  }
9146b87b4   고영탁   엔코더 작업 진행중
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
  
  void RealtimePartsWindow::keyPressEvent(QKeyEvent *event)
  {
      switch (event->key())
      {
      case 0x01000030:    // Turn left
          focusPreviousChild();
          break;
      case 0x01000031:    // Push
          break;
      case 0x01000032:    // Turn right
          focusNextChild();
          break;
      }
  }
  
  void RealtimePartsWindow::keyReleaseEvent(QKeyEvent *event)
  {
      switch (event->key())
      {
      case 0x01000030:    // Turn left
          focusPreviousChild();
          break;
      case 0x01000031:    // Push
      {
          QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
          if(btn != NULL){
              btn->click();
          }
          break;
      }
      case 0x01000032:    // Turn right
          focusNextChild();
          break;
      }
  }