Commit 7fa4fdb0e355d97fa0358a1049783cc856f01ebf

Authored by 고영탁
1 parent d51f0a938c
Exists in master and in 2 other branches fhd, fhd-demo

인포 데이터 다운로드 기능 개발

- 인포데이터 다운로드 기능 개발
app/gui/oven_control/fileprocessdlg.cpp
1 1 #include <QTimer>
2   -#include <QFile>
3 2 #include "fileprocessdlg.h"
4 3 #include "ui_fileprocessdlg.h"
5 4 #include "fileprocessor.h"
6 5 #include "ovenstatics.h"
  6 +#include "stringer.h"
7 7 #include <QDebug>
  8 +
  9 +
  10 +#define ERROR_LOG_FILE_TOP "/GasErrorHistoryTop.log"
  11 +#define ERROR_LOG_FILE_STEAM "/GasErrorHistorySteam.log"
  12 +#define ERROR_LOG_FILE_BOTTOM "/GasErrorHistoryBottom.log"
  13 +#define ERROR_LOG_FILE_TOTAL "/TotalError.log"
  14 +
8 15 FileProcessDlg::FileProcessDlg(QWidget *parent, ConfigType type, bool isDown) :
9 16 QDialog(parent),
10 17 ui(new Ui::FileProcessDlg)
... ... @@ -58,8 +65,199 @@ void FileProcessDlg::on_ctrBtnCancel_clicked()
58 65 close();
59 66 }
60 67  
  68 +void FileProcessDlg::saveHistoryLineData(QTextStream &out, uint16_t i, uint16_t fired_cnt, time_t first_fired, time_t last_fried){
  69 + QString strLine;
  70 + QDateTime dt;
  71 + //for(int i =0;i<m_arrErrorMaxIdx[(uint16_t)type];i++){
  72 + // err_item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[type][i]]);
  73 + strLine = tr("erro%1,").arg(i);
  74 + if(first_fired == 0){
  75 + strLine += "-,0,-";
  76 + }
  77 + else{
  78 + dt.setTime_t(first_fired);
  79 + strLine+= Stringer::DateTimeString(dt,Stringer::datetime_string_type_oneline) + ",";
  80 + strLine += QString("%1").arg(fired_cnt) + ",";
  81 + dt.setTime_t(last_fried);
  82 + strLine += Stringer::DateTimeString(dt,Stringer::datetime_string_type_oneline) + ",";
  83 + }
  84 + out << strLine << "\n";
  85 + qDebug() << strLine;
  86 + //}
  87 +}
  88 +
  89 +void FileProcessDlg::saveHistoryTotalData(QTextStream &out){
  90 + int i = 0;
  91 + error_item *item;
  92 + time_t firsttimebuf=0,lasttimebuf=0;
  93 + uint16_t firecntbuf=0;
  94 + QString strLine;
  95 + QDateTime dt;
  96 + OvenStatistics *ovenst = OvenStatistics::getInstance();
  97 +
  98 + //01 상부 점화 장치 데이터 초기화
  99 +// for(i=0;i<m_arrErrorMaxIdx[ERROR_HISTORY_UPPERBUNNER];i++){
  100 +// item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_UPPERBUNNER][i]]);
  101 +// if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
  102 +// else{
  103 +// if( firsttimebuf > item->first_fired && item->first_fired != 0 ) firsttimebuf = item->first_fired;
  104 +// if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
  105 +// firecntbuf += item->fired_cnt;
  106 +// }
  107 +
  108 +// }
  109 +// total_items[0].fired_cnt = firecntbuf;
  110 +// total_items[0].first_fired = firsttimebuf;
  111 +// total_items[0].last_fried = lasttimebuf;
  112 +
  113 +
  114 +}
  115 +
61 116 void FileProcessDlg::infodataDownload(){
  117 + QString strUsbPath;
  118 + QString strFile;
  119 + QFile file;
  120 + error_item *item;
  121 + OvenStatistics *ovenst = OvenStatistics::getInstance();
  122 + time_t firsttimebuf=0,lasttimebuf=0;
  123 + uint16_t firecntbuf=0;
  124 + uint16_t erridx = 0;
  125 + int i;
62 126  
  127 + if(FileProcessor::detectUSB(strUsbPath)){
  128 + //Top
  129 + strFile = strUsbPath + ERROR_LOG_FILE_TOP;
  130 + qDebug() << strUsbPath;
  131 + file.setFileName(strFile);
  132 + if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
  133 + QTextStream out(&file);
  134 + out << tr("Gas Error History\n") << "Top Ignition Box" <<"\n";
  135 + out << tr("no,") << tr("First Appearance,") << tr("Counter,") << tr("Last Appearance\n");
  136 + for(i =0;i<m_arrErrorMaxIdx[ERROR_HISTORY_UPPERBUNNER];i++){
  137 + item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_UPPERBUNNER][i]]);
  138 + saveHistoryLineData(out,i+1,item->fired_cnt,item->first_fired,item->last_fried);
  139 + }
  140 + file.close();
  141 + }
  142 + ui->ctrWjProcess->setValue(25);
  143 + ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초"));
  144 + //Bottom
  145 + strFile = strUsbPath + ERROR_LOG_FILE_BOTTOM;
  146 + qDebug() << strUsbPath;
  147 + file.setFileName(strFile);
  148 + if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
  149 + QTextStream out(&file);
  150 + out << tr("Gas Error History\n") << "Bottom Ignition Box" <<"\n";
  151 + out << tr("no,") << tr("First Appearance,") << tr("Counter,") << tr("Last Appearance\n");
  152 + for(i =0;i<m_arrErrorMaxIdx[ERROR_HISTORY_LOWERBUNNER];i++){
  153 + item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_LOWERBUNNER][i]]);
  154 + saveHistoryLineData(out,i+1,item->fired_cnt,item->first_fired,item->last_fried);
  155 + }
  156 + file.close();
  157 + }
  158 + ui->ctrWjProcess->setValue(50);
  159 + ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초"));
  160 + //Steam
  161 + strFile = strUsbPath + ERROR_LOG_FILE_STEAM;
  162 + qDebug() << strUsbPath;
  163 + file.setFileName(strFile);
  164 + if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
  165 + QTextStream out(&file);
  166 + out << tr("Gas Error History\n") << "Steam Ignition Box" <<"\n";
  167 + out << tr("no,") << tr("First Appearance,") << tr("Counter,") << tr("Last Appearance\n");
  168 + for(i =0;i<m_arrErrorMaxIdx[ERROR_HISTORY_STEAMBUNNER];i++){
  169 + item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_STEAMBUNNER][i]]);
  170 + saveHistoryLineData(out,i+1,item->fired_cnt,item->first_fired,item->last_fried);
  171 + }
  172 + file.close();
  173 + }
  174 + ui->ctrWjProcess->setValue(75);
  175 + ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초"));
  176 + //Total
  177 + strFile = strUsbPath + ERROR_LOG_FILE_TOTAL;
  178 + qDebug() << strUsbPath;
  179 + file.setFileName(strFile);
  180 + if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
  181 + QTextStream out(&file);
  182 + out << tr("Service Error History\n\n");
  183 + out << tr("no,") << tr("First Appearance,") << tr("Counter,") << tr("Last Appearance\n");
  184 + //01 상부 점화 장치 데이터 초기화
  185 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  186 + for(i=0;i<m_arrErrorMaxIdx[ERROR_HISTORY_UPPERBUNNER];i++){
  187 + item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_UPPERBUNNER][i]]);
  188 + if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
  189 + else{
  190 + if( (firsttimebuf > item->first_fired && item->first_fired != 0) || firsttimebuf == 0 ) firsttimebuf = item->first_fired;
  191 + if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
  192 + firecntbuf += item->fired_cnt;
  193 + }
  194 + }
  195 + saveHistoryLineData(out,erridx+1, firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  196 + //02 스팀 점화 장치 데이터 초기화
  197 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  198 + for(i=0;i<m_arrErrorMaxIdx[ERROR_HISTORY_STEAMBUNNER];i++){
  199 + item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_STEAMBUNNER][i]]);
  200 + if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
  201 + else{
  202 + if((firsttimebuf > item->first_fired && item->first_fired != 0) || firsttimebuf == 0 ) firsttimebuf = item->first_fired;
  203 + if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
  204 + firecntbuf += item->fired_cnt;
  205 + }
  206 + }
  207 + saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  208 + //03 하부 점화 장치 데이터 초기화
  209 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  210 + for(i=0;i<m_arrErrorMaxIdx[ERROR_HISTORY_LOWERBUNNER];i++){
  211 + item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_LOWERBUNNER][i]]);
  212 + if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
  213 + else{
  214 + if((firsttimebuf > item->first_fired && item->first_fired != 0) || firsttimebuf == 0 ) firsttimebuf = item->first_fired;
  215 + if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
  216 + firecntbuf += item->fired_cnt;
  217 + }
  218 + }
  219 + saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  220 + //04 WATER
  221 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  222 + item = &(ovenst->srvdata->err_log.items.inner_temp_fail);
  223 + firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
  224 + item = &(ovenst->srvdata->err_log.items.qunching_temp_fail);
  225 + if( firsttimebuf > item->first_fired && item->first_fired != 0 ) firsttimebuf = item->first_fired;
  226 + if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
  227 + firecntbuf += item->fired_cnt;
  228 + saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  229 + //05 구성품
  230 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  231 + saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  232 + //07 B1 센서 에러
  233 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  234 + item = &(ovenst->srvdata->err_log.items.inner_temp_high_alarm);
  235 + firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
  236 + saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  237 + //08 B2 센서 에러
  238 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  239 + item = &(ovenst->srvdata->err_log.items.qunching_temp_high_alarm);
  240 + saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  241 + //10 B4 센서 에러
  242 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  243 + item = &(ovenst->srvdata->err_log.items.wall_temp1_high_alarm);
  244 + firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
  245 + saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  246 + //11 B5 센서 에러
  247 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  248 + item = &(ovenst->srvdata->err_log.items.steam_gen_temp_high_alram);
  249 + firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
  250 + saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  251 + firecntbuf = 0;firsttimebuf = 0; lasttimebuf=0;
  252 + item = &(ovenst->srvdata->err_log.items.water_level_sensor_fail);
  253 + firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
  254 + saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
  255 + file.close();
  256 + }
  257 + ui->ctrWjProcess->setValue(100);
  258 + ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료"));
  259 + QTimer::singleShot(1000,this,SLOT(close()));
  260 + }
63 261 }
64 262  
65 263 void FileProcessDlg::servicedataDownload(){
... ...
app/gui/oven_control/fileprocessdlg.h
... ... @@ -2,10 +2,15 @@
2 2 #define FILEPROCESSDLG_H
3 3  
4 4 #include <QDialog>
  5 +#include <QFile>
  6 +#include <QTextStream>
5 7 #include "config.h"
6 8 #include "servicedata.h"
  9 +#include "historylistwindow.h"
7 10  
8 11 using namespace Define;
  12 +using namespace ERROR_LOG_SPACE;
  13 +
9 14  
10 15 namespace Ui {
11 16 class FileProcessDlg;
... ... @@ -15,17 +20,9 @@ class FileProcessDlg : public QDialog
15 20 {
16 21 Q_OBJECT
17 22  
18   - const uint8_t m_arrErrorMaxIdx[4] = {3,4,3,11};
19   -
20   - const char m_strInfoName[4][64] = {"Top Ignition Box\0",
21   - "Steam Ignition Box\0","Bottom Ignition Box\0","Service Total\0"};
22   - const uint16_t m_arrErrorIdxs[3][20] = { //서비스 에러 기록 종합은 합산
23   - {ERROR_IDX_upper_fire_fail,ERROR_IDX_upper_pan_fail,ERROR_IDX_upper_motor_fail},
24   - {ERROR_IDX_steam_fire_fail,ERROR_IDX_steam_pan_fail,ERROR_IDX_water_level_sensor_fail,ERROR_IDX_steam_gen_temp_high_alram},
25   - {ERROR_IDX_lower_fire_fail,ERROR_IDX_lower_pan_fail,ERROR_IDX_lower_motor_fail}
26   - };
27   -
28 23  
  24 + void saveHistoryLineData(QTextStream &out, uint16_t i, uint16_t cnt, time_t first_fired, time_t last_fried);
  25 + void saveHistoryTotalData(QTextStream &out);
29 26  
30 27 public:
31 28 explicit FileProcessDlg(QWidget *parent = 0, ConfigType type = config_invalid, bool isDown = true);
... ... @@ -40,6 +37,7 @@ private slots:
40 37 void configDownload();
41 38 void configUpload();
42 39  
  40 +
43 41 private:
44 42 Ui::FileProcessDlg *ui;
45 43 ConfigType m_nCfgtype;
... ...
app/gui/oven_control/historylistwindow.cpp
... ... @@ -179,14 +179,16 @@ void HistoryListWindow::setTotalServiceDataSet(void){
179 179 //01 상부 점화 장치 데이터 초기화
180 180 for(i=0;i<m_arrErrorMaxIdx[ERROR_HISTORY_UPPERBUNNER];i++){
181 181 item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_UPPERBUNNER][i]]);
  182 +
182 183 if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
183 184 else{
184   - if( firsttimebuf > item->first_fired && item->first_fired != 0 ) firsttimebuf = item->first_fired;
  185 + qDebug() << "item cnt " << item->fired_cnt <<" first "<< item->first_fired <<" last " << item->last_fried;
  186 + if( (firsttimebuf > item->first_fired && item->first_fired != 0) || firsttimebuf == 0 ) firsttimebuf = item->first_fired;
185 187 if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
186 188 firecntbuf += item->fired_cnt;
187 189 }
188   -
189 190 }
  191 + qDebug() << "total cnt " << firecntbuf <<" first "<< firsttimebuf<<" last " << lasttimebuf;
190 192 total_items[0].fired_cnt = firecntbuf;
191 193 total_items[0].first_fired = firsttimebuf;
192 194 total_items[0].last_fried = lasttimebuf;
... ... @@ -197,7 +199,7 @@ void HistoryListWindow::setTotalServiceDataSet(void){
197 199 item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_STEAMBUNNER][i]]);
198 200 if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
199 201 else{
200   - if( firsttimebuf > item->first_fired && item->first_fired != 0 ) firsttimebuf = item->first_fired;
  202 + if((firsttimebuf > item->first_fired && item->first_fired != 0) || firsttimebuf == 0) firsttimebuf = item->first_fired;
201 203 if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
202 204 firecntbuf += item->fired_cnt;
203 205 }
... ... @@ -211,7 +213,7 @@ void HistoryListWindow::setTotalServiceDataSet(void){
211 213 item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_LOWERBUNNER][i]]);
212 214 if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
213 215 else{
214   - if( firsttimebuf > item->first_fired && item->first_fired != 0 ) firsttimebuf = item->first_fired;
  216 + if((firsttimebuf > item->first_fired && item->first_fired != 0)|| firsttimebuf == 0 ) firsttimebuf = item->first_fired;
215 217 if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
216 218 firecntbuf += item->fired_cnt;
217 219 }
... ...
app/gui/oven_control/historylistwindow.h
... ... @@ -12,13 +12,28 @@ class HistoryListWindow;
12 12  
13 13 #define MAX_DISP_ITEM 10
14 14  
15   -enum ERROR_HISTORY_TYPE{
16   - ERROR_HISTORY_UPPERBUNNER=0,
17   - ERROR_HISTORY_STEAMBUNNER,
18   - ERROR_HISTORY_LOWERBUNNER,
19   - ERROR_HISTORY_TOTAL
20   -};
  15 +namespace ERROR_LOG_SPACE {
  16 + enum ERROR_HISTORY_TYPE{
  17 + ERROR_HISTORY_UPPERBUNNER=0,
  18 + ERROR_HISTORY_STEAMBUNNER,
  19 + ERROR_HISTORY_LOWERBUNNER,
  20 + ERROR_HISTORY_TOTAL
  21 + };
  22 +
  23 + const uint8_t m_arrErrorMaxIdx[4] = {3,4,3,11};
  24 +
  25 + const char m_strWindowName[4][64] = {"상부점화장치\0",
  26 + "스팀점화장치\0","하부점화장치\0","서비스에러기록종합\0"};
  27 + const uint16_t m_arrErrorIdxs[3][20] = { //서비스 에러 기록 종합은 합산
  28 + {ERROR_IDX_upper_fire_fail,ERROR_IDX_upper_pan_fail,ERROR_IDX_upper_motor_fail},
  29 + {ERROR_IDX_steam_fire_fail,ERROR_IDX_steam_pan_fail,ERROR_IDX_water_level_sensor_fail,ERROR_IDX_steam_gen_temp_high_alram},
  30 + {ERROR_IDX_lower_fire_fail,ERROR_IDX_lower_pan_fail,ERROR_IDX_lower_motor_fail}
  31 + };
21 32  
  33 +}
  34 +
  35 +
  36 +using namespace ERROR_LOG_SPACE;
22 37  
23 38  
24 39 class HistoryListWindow : public QMainWindow
... ... @@ -44,15 +59,6 @@ private slots:
44 59 private:
45 60 Ui::HistoryListWindow *ui;
46 61  
47   - const uint8_t m_arrErrorMaxIdx[4] = {3,4,3,11};
48   -
49   - const char m_strWindowName[4][64] = {"상부점화장치\0",
50   - "스팀점화장치\0","하부점화장치\0","서비스에러기록종합\0"};
51   - const uint16_t m_arrErrorIdxs[3][20] = { //서비스 에러 기록 종합은 합산
52   - {ERROR_IDX_upper_fire_fail,ERROR_IDX_upper_pan_fail,ERROR_IDX_upper_motor_fail},
53   - {ERROR_IDX_steam_fire_fail,ERROR_IDX_steam_pan_fail,ERROR_IDX_water_level_sensor_fail,ERROR_IDX_steam_gen_temp_high_alram},
54   - {ERROR_IDX_lower_fire_fail,ERROR_IDX_lower_pan_fail,ERROR_IDX_lower_motor_fail}
55   - };
56 62  
57 63 QLabel* m_ctrlFirstTimeLabels[10];
58 64 QLabel* m_ctrlCountLabels[10];
... ...
app/gui/oven_control/inputoverwatcher.cpp
... ... @@ -8,10 +8,9 @@
8 8  
9 9 InputOverwatcher::InputOverwatcher(QObject *parent) : QObject(parent)
10 10 {
11   - Define::config_item item = Config::getInstance()->getConfigValue(Define::config_set_auto_darkness);
12 11  
13 12 timer.setSingleShot(true);
14   - timer.setInterval(item.d32 * 60000);
  13 + timer.setInterval(5 * 60000); //Default Value is 5min
15 14 connect(&timer, SIGNAL(timeout()), SLOT(lowerBacklight()));
16 15 }
17 16  
... ...
app/gui/oven_control/servicedata.cpp
... ... @@ -98,6 +98,7 @@ bool ServiceData::loadServiceData(void){
98 98 DirtyLevel::setCookingCount(temp_cookingCount);
99 99 DirtyLevel::setCookingTime(temp_cookingTime);
100 100 close(fd);
  101 + qDebug() <<"FRAM Load Success";
101 102 }else{
102 103 qDebug()<<"FRAM FILE Open fail!!";
103 104 }
... ...