Blame view

app/gui/oven_control/realtimesensorwindow.cpp 4.61 KB
6a965b9f1   고영탁   엔지니어 모드 2차 구현
1
2
3
  #include "realtimesensorwindow.h"
  #include "ui_realtimesensorwindow.h"
  #include "ovenstatics.h"
14a73498f   김태훈   소스 코드 정리
4
  RealtimeSensorWindow::RealtimeSensorWindow(QWidget *parent) :
6a965b9f1   고영탁   엔지니어 모드 2차 구현
5
      QMainWindow(parent),
14a73498f   김태훈   소스 코드 정리
6
      ui(new Ui::RealtimeSensorWindow)
6a965b9f1   고영탁   엔지니어 모드 2차 구현
7
  {
42410a75c   김태훈   오타 수정
8
      OvenStatistics* ovs = OvenStatistics::getInstance();
6a965b9f1   고영탁   엔지니어 모드 2차 구현
9
      int i = 0;
eea7d3d59   김태훈   Segmentation Faul...
10
6a965b9f1   고영탁   엔지니어 모드 2차 구현
11
      ui->setupUi(this);
eea7d3d59   김태훈   Segmentation Faul...
12
13
      ui->clockContainer->setParent(ui->upperStack);
      setAttribute(Qt::WA_DeleteOnClose);
6a965b9f1   고영탁   엔지니어 모드 2차 구현
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
      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[0][8] = ui->m_ctrlLbListState_1_9;
  
      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[1][8] = ui->m_ctrlLbListState_2_9;
  
      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;
      m_arrLbState[2][8] = ui->m_ctrlLbListState_3_9;
  
      m_arrLbState[3][0] = ui->m_ctrlLbListState_4_1;
      m_arrLbState[3][1] = ui->m_ctrlLbListState_4_2;
      m_arrLbState[3][2] = ui->m_ctrlLbListState_4_3;
      m_arrLbState[3][3] = ui->m_ctrlLbListState_4_4;
      m_arrLbState[3][4] = ui->m_ctrlLbListState_4_5;
      m_arrLbState[3][5] = ui->m_ctrlLbListState_4_6;
      m_arrLbState[3][6] = ui->m_ctrlLbListState_4_7;
      m_arrLbState[3][7] = ui->m_ctrlLbListState_4_8;
      m_arrLbState[3][8] = ui->m_ctrlLbListState_4_9;
  
      for(i=0;i<REALSENSOR_CONTROL_LIST_ITEM_MAX;i++){
14a73498f   김태훈   소스 코드 정리
55
          m_arrSensorItems[i] = &(ovs->srvdata->sensor_log.values[m_arrSensorItemIdxs[i]]);
6a965b9f1   고영탁   엔지니어 모드 2차 구현
56
57
58
      }
      reloadUi();
  }
14a73498f   김태훈   소스 코드 정리
59
  RealtimeSensorWindow::~RealtimeSensorWindow()
6a965b9f1   고영탁   엔지니어 모드 2차 구현
60
61
62
  {
      delete ui;
  }
14a73498f   김태훈   소스 코드 정리
63
  void RealtimeSensorWindow::on_backButton_clicked()
6a965b9f1   고영탁   엔지니어 모드 2차 구현
64
  {
eea7d3d59   김태훈   Segmentation Faul...
65
      close();
6a965b9f1   고영탁   엔지니어 모드 2차 구현
66
67
68
69
  }
  
  uint16_t i_temp1,i_temp2;
  type_temp temp_temp;
14a73498f   김태훈   소스 코드 정리
70
  void RealtimeSensorWindow::reloadUi(void){
6a965b9f1   고영탁   엔지니어 모드 2차 구현
71
72
73
74
      char strTime[64];
      QString strTemp="";
      struct tm *timeptr;
      int i = 0;
42410a75c   김태훈   오타 수정
75
      OvenStatistics* ovs = OvenStatistics::getInstance();
6a965b9f1   고영탁   엔지니어 모드 2차 구현
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
      if(ovs!= NULL){
          for(i=0;i<REALSENSOR_CONTROL_LIST_ITEM_MAX;i++){
              i_temp1 = i;
              i_temp2 = ovs->getSensorTypeByIdx(m_arrSensorItemIdxs[i]);
              temp_temp = ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]);
  
              if(ovs->getSensorTypeByIdx(m_arrSensorItemIdxs[i]) == 2 )
                      strTemp.sprintf("%d℃",ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).itemp/10);
              else if(ovs->getSensorTypeByIdx(m_arrSensorItemIdxs[i]) == 1 )
                      strTemp.sprintf("%d℃",ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).utemp);
              else  strTemp.sprintf("%d℃",ovs->getCurSensorValueByIdx(m_arrSensorItemIdxs[i]).itemp);
              m_arrLbState[0][i]->setText(strTemp);
          }
  
          for(i=0;i<REALSENSOR_CONTROL_LIST_ITEM_MAX;i++){
              if(ovs->getSensorTypeByIdx(m_arrSensorItemIdxs[i]) == 2 )
                      strTemp.sprintf("%d℃",m_arrSensorItems[i]->high_temp.itemp/10);
              else if(ovs->getSensorTypeByIdx(m_arrSensorItemIdxs[i]) == 1)
                      strTemp.sprintf("%d℃",m_arrSensorItems[i]->high_temp.utemp);
              else  strTemp.sprintf("%d℃",m_arrSensorItems[i]->high_temp.itemp);
              m_arrLbState[1][i]->setText(strTemp);
          }
  
          for(i=0;i<REALSENSOR_CONTROL_LIST_ITEM_MAX;i++){
              strTemp.sprintf("%d℃", m_arrCriticalValue[i]);
              m_arrLbState[2][i]->setText(strTemp);
          }
  
  
          for(i=0;i<REALSENSOR_CONTROL_LIST_ITEM_MAX;i++){
              if(m_arrSensorItems[i]->last_high_time !=0){
cefd483e4   고영탁   에러 수정
107
                  timeptr = localtime(&(m_arrSensorItems[i]->last_high_time));
6a965b9f1   고영탁   엔지니어 모드 2차 구현
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
                  strftime(strTime,64,"%y-%m-%d
  %H:%M:%S",timeptr);
                  m_arrLbState[3][i]->setText(strTime);
              }
              else{
                  m_arrLbState[3][i]->setText("-");
              }
          }
  
  
  
  
      }
  
  }