diff --git a/app/gui/oven_control/fileprocessdlg.cpp b/app/gui/oven_control/fileprocessdlg.cpp index 1643780..aa2816a 100644 --- a/app/gui/oven_control/fileprocessdlg.cpp +++ b/app/gui/oven_control/fileprocessdlg.cpp @@ -1,4 +1,5 @@ #include +#include #include "fileprocessdlg.h" #include "ui_fileprocessdlg.h" #include "fileprocessor.h" @@ -7,10 +8,11 @@ #include -#define ERROR_LOG_FILE_TOP "/GasErrorHistoryTop.log" -#define ERROR_LOG_FILE_STEAM "/GasErrorHistorySteam.log" -#define ERROR_LOG_FILE_BOTTOM "/GasErrorHistoryBottom.log" -#define ERROR_LOG_FILE_TOTAL "/TotalError.log" +#define ERROR_LOG_FILE_TOP "/GasErrorHistoryTop.csv" +#define ERROR_LOG_FILE_STEAM "/GasErrorHistorySteam.csv" +#define ERROR_LOG_FILE_BOTTOM "/GasErrorHistoryBottom.csv" +#define ERROR_LOG_FILE_TOTAL "/TotalError.csv" +#define SERVICE_DATA_FILE "/ServiceData.csv" FileProcessDlg::FileProcessDlg(QWidget *parent, ConfigType type, bool isDown) : QDialog(parent), @@ -254,6 +256,7 @@ void FileProcessDlg::infodataDownload(){ saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++; file.close(); } + sync(); ui->ctrWjProcess->setValue(100); ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료")); QTimer::singleShot(1000,this,SLOT(close())); @@ -261,8 +264,85 @@ void FileProcessDlg::infodataDownload(){ } void FileProcessDlg::servicedataDownload(){ + QString strUsbPath; + QString strHeader = "no,name,time\n"; + QString strFile; + QFile file; + error_item *item; + uint32_t timetemp, totaltime=0; + int i = 1; + OvenStatistics *ovs = OvenStatistics::getInstance(); + if(FileProcessor::detectUSB(strUsbPath)){ + strFile = strUsbPath + SERVICE_DATA_FILE; + file.setFileName(strFile); + if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){ + QTextStream out(&file); + out.setCodec("UTF-8"); + out<< strHeader; + timetemp = ovs->srvdata->use_log.items.steam_heat/3600; + out << i++ << tr(",Steam Heating Time,") << timetemp << "h\n"; + timetemp = ovs->srvdata->use_log.items.dry_heat/3600; + out << i++ << tr(",Hot Air Heating Time,") << timetemp << "h\n"; + i=1;out<< strHeader; + timetemp = ovs->srvdata->use_log.items.cook_dry_mode/3600; + totaltime+= ovs->srvdata->use_log.items.cook_dry_mode; + out << i++ << tr(",Hot Air Mode,") << timetemp << "h\n"; + timetemp = ovs->srvdata->use_log.items.cook_steam_mode/3600; + totaltime += ovs->srvdata->use_log.items.cook_steam_mode; + out << i++ << tr(",Steam Mode,") << timetemp << "h\n"; + timetemp = ovs->srvdata->use_log.items.cook_combi_mode/3600; + totaltime += ovs->srvdata->use_log.items.cook_combi_mode; + out << i++ << tr(",Combi Mode,") << timetemp << "h\n"; + timetemp = ovs->srvdata->use_log.items.wash_mode_nocleanser/3600; + totaltime += ovs->srvdata->use_log.items.wash_mode_nocleanser; + out << i++ << tr(",세제없이 헹굼,").toUtf8() << timetemp << "h\n"; + timetemp = ovs->srvdata->use_log.items.wash_mode_simple/3600; + totaltime += ovs->srvdata->use_log.items.wash_mode_simple; + out << i++ << tr(",간이세척,").toUtf8() << timetemp << "h\n"; + timetemp = ovs->srvdata->use_log.items.wash_mode_standard/3600; + totaltime += ovs->srvdata->use_log.items.wash_mode_standard; + out << i++ << tr(",표준세척,").toUtf8() << timetemp << "h\n"; + timetemp = ovs->srvdata->use_log.items.wash_mode_strong/3600; + totaltime += ovs->srvdata->use_log.items.wash_mode_strong; + out << i++ << tr(",강세척").toUtf8() << timetemp << "h\n"; + timetemp = ovs->srvdata->use_log.items.wash_mode_speed/3600; + totaltime +=ovs->srvdata->use_log.items.wash_mode_speed; + out << i++ << tr(",고속세척,").toUtf8() << timetemp << "h\n"; + timetemp = ovs->srvdata->use_log.items.cooldown_mode/3600; + totaltime += ovs->srvdata->use_log.items.cooldown_mode; + out << i++ << tr(",쿨다운,").toUtf8() << timetemp << "h\n"; + timetemp = totaltime/3600; + out << i++ << tr(",전체작동시간,").toUtf8() << timetemp << "h\n"; + i=1;out<< strHeader; + timetemp = ovs->srvdata->use_log.items.door_open/60; + out << i++ << tr(",도어 Open,").toUtf8() << timetemp << "min\n"; + timetemp = ovs->srvdata->use_log.items.dv_open/60; + out << i++ << tr(",볼밸브 Open,").toUtf8() << timetemp << "min\n"; + timetemp = ovs->srvdata->use_log.items.ssv_open/60; + out << i++ << tr(",S/G 급수 솔레노이드,").toUtf8() << timetemp << "min\n"; + timetemp = ovs->srvdata->use_log.items.qnv_open/60; + out << i++ << tr(",퀀칭 솔레노이드,").toUtf8() << timetemp << "min\n"; + timetemp = ovs->srvdata->use_log.items.snv_open/60; + out << i++ << tr(",고내살수 노즐 솔레노이드 ,").toUtf8() << timetemp << "min\n"; + timetemp = 0; + out << i++ << tr(",호스릴 솔레노이드,").toUtf8() << timetemp << "min\n"; + timetemp = ovs->srvdata->use_log.items.ssp_open/60; + out << i++ << tr(",세제공급장치,").toUtf8() << timetemp << "min\n"; + timetemp = ovs->srvdata->use_log.items.hdm_open/60; + out << i++ << tr(",배습댐퍼,").toUtf8() << timetemp << "min\n"; + timetemp = ovs->srvdata->use_log.items.dp_open/60; + out << i++ << tr(",소형펌프모터,").toUtf8() << timetemp << "min\n"; + timetemp = ovs->srvdata->use_log.items.unp_open/60; + out << i++ << tr(",중형펌프모터,").toUtf8() << timetemp << "min\n"; + ui->ctrWjProcess->setValue(100); + ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료")); + file.close(); + sync(); + QTimer::singleShot(1000,this,SLOT(close())); + } + } } void FileProcessDlg::programDownload(){ @@ -278,44 +358,78 @@ void FileProcessDlg::configDownload(){ if(FileProcessor::detectUSB(strUsbPath)){ strUsbPath.append("/config.ini"); qDebug() << strUsbPath; + QFile file; + file.setFileName(strUsbPath); + if(file.exists()) file.remove(); if(QFile::copy("/prime/config/config.ini", strUsbPath)){ + sync(); + ui->ctrWjProcess->setValue(50); + ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초")); + } + else{ + ui->ctrLbRemainTime->setText(tr("설정 다운로드에 실패하였습니다.")); + QTimer::singleShot(1000,this,SLOT(close())); + return; + } + strUsbPath.replace("/config.ini","/favorite.ini"); + file.setFileName(strUsbPath); + if(file.exists()) file.remove(); + if(QFile::copy("/prime/config/favorite.ini", strUsbPath)){ + sync(); ui->ctrWjProcess->setValue(100); ui->ctrLbRemainTime->setText("남은 예상 시간 : 0초"); ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료")); QTimer::singleShot(1000,this,SLOT(close())); } else{ - ui->ctrLbRemainTime->setText(tr("다운로드에 실패하였습니다.")); + ui->ctrLbRemainTime->setText(tr("즐겨찾기 다운로드에 실패하였습니다.")); QTimer::singleShot(1000,this,SLOT(close())); } } else{ - ui->ctrLbRemainTime->setText(tr("다운로드에 실패하였습니다.")); + ui->ctrLbRemainTime->setText(tr("USB 인식을 실패하였습니다.")); QTimer::singleShot(1000,this,SLOT(close())); } } void FileProcessDlg::configUpload(){ QString strUsbPath; + Config *cfg = Config::getInstance(); if(FileProcessor::detectUSB(strUsbPath)){ strUsbPath.append("/config.ini"); qDebug() << strUsbPath; QFile file("/prime/config/config.ini"); file.remove(); if(QFile::copy( strUsbPath , "/prime/config/config.ini")){ - OvenStatistics* ovs = OvenStatistics::getInstance(); - ovs->srvdata->loadServiceData(); + sync(); + cfg->loadConfig(); + cfg->applyConfig(); + ui->ctrWjProcess->setValue(50); + ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초")); + } + else{ + ui->ctrLbRemainTime->setText(tr("설정 업로드에 실패하였습니다.")); + QTimer::singleShot(1000,this,SLOT(close())); + return; + } + QFile file2("/prime/config/favorite.ini"); + file2.remove(); + strUsbPath.replace("/config.ini", "/favorite.ini"); + qDebug() << strUsbPath; + if(QFile::copy( strUsbPath , "/prime/config/favorite.ini")){ + sync(); + cfg->loadFavorite(); ui->ctrWjProcess->setValue(100); ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료")); QTimer::singleShot(1000,this,SLOT(close())); } else{ - ui->ctrLbRemainTime->setText(tr("업로드에 실패하였습니다.")); + ui->ctrLbRemainTime->setText(tr("즐겨찾기 업로드에 실패하였습니다.")); QTimer::singleShot(1000,this,SLOT(close())); } } else{ - ui->ctrLbRemainTime->setText(tr("업로드에 실패하였습니다.")); + ui->ctrLbRemainTime->setText(tr("USB 인식을 실패하였습니다.")); QTimer::singleShot(1000,this,SLOT(close())); } }