From 6c2810f46afcaa3f2ea906aab8262fd9d721022c Mon Sep 17 00:00:00 2001 From: byloveletter Date: Fri, 30 Jun 2017 11:11:32 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=A8=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=EC=8B=9C=20=EB=AA=A8=EB=8D=B8=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EB=B3=80=EA=B2=BD=20=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 파일 복사가 아닌 환경 설정 영역만 복사하도록 수정 - 업로드시 파일 검증 루틴 추가 --- app/gui/oven_control/config.cpp | 13 +++++++++ app/gui/oven_control/config.h | 1 + app/gui/oven_control/fileprocessdlg.cpp | 42 ++++++++++++++---------------- app/gui/oven_control/functiontestwindow.ui | 2 +- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/app/gui/oven_control/config.cpp b/app/gui/oven_control/config.cpp index fbd5cd2..64aa4d9 100644 --- a/app/gui/oven_control/config.cpp +++ b/app/gui/oven_control/config.cpp @@ -411,6 +411,19 @@ bool Config::saveFavorite(void){ return false; } +//Sytem Config Area Copy +void Config::copyConfigArea(const char *buff) +{ + config_item* end = &configlist.items.model; + config_item *start = &configlist.values[0]; + + uint32_t size = end - start; + + qDebug() << "size is "<< size; + + memcpy(&configlist.data[0], buff, sizeof(config_item)*size); +} + void Config::insertFavorite(Define::ConfigType idx){ m_setFavorite.insert((uint32_t)idx); } diff --git a/app/gui/oven_control/config.h b/app/gui/oven_control/config.h index 7fd63be..7586a6b 100644 --- a/app/gui/oven_control/config.h +++ b/app/gui/oven_control/config.h @@ -433,6 +433,7 @@ public: QList getConstSortedFavorite(); bool loadFavorite(void); bool saveFavorite(void); + void copyConfigArea(const char* buff); void insertFavorite(Define::ConfigType idx); void removeFavorite(Define::ConfigType idx); static QString getDateTimeString(uint32_t sec); diff --git a/app/gui/oven_control/fileprocessdlg.cpp b/app/gui/oven_control/fileprocessdlg.cpp index f457e96..7309744 100644 --- a/app/gui/oven_control/fileprocessdlg.cpp +++ b/app/gui/oven_control/fileprocessdlg.cpp @@ -696,38 +696,36 @@ void FileProcessDlg::configUpload(){ QString strSrcPath; Config *cfg = Config::getInstance(); if(FileProcessor::detectUSB(strUsbPath)){ - strSrcPath = QString("%1/%2").arg(strUsbPath).arg(CONFIG_FILE_NAME); + strSrcPath = QString("%1%2").arg(strUsbPath).arg(CONFIG_FILE_NAME); QFile srcFile(strSrcPath); //Check Source File is valid this machine - readlen = srcFile.read(buff,sizeof(config_lists)+1); - if(readlen != (sizeof(config_lists)+1)) { - qDebug() << "SRC config.ini file size wrong"; - ui->ctrLbRemainTime->setText(tr("설정 업로드에 실패하였습니다.")); - QTimer::singleShot(1000,this,SLOT(close())); - return; - } - if(buff[sizeof(config_lists)] != 0x9C){ - qDebug() << "SRC config.ini file check fail"; - ui->ctrLbRemainTime->setText(tr("설정 업로드에 실패하였습니다.")); - QTimer::singleShot(1000,this,SLOT(close())); - return; - } - QFile file(CONFIG_FILE_NAME); - file.remove(); - if(QFile::copy( strSrcPath , CONFIG_FILE_NAME)){ - sync(); - cfg->loadConfig(); + if(srcFile.open(QIODevice::ReadOnly)){ + readlen = srcFile.read(buff,sizeof(config_lists)+1); + srcFile.close(); + if(readlen != (sizeof(config_lists)+1)) { + qDebug() << "SRC config.ini file size wrong"; + ui->ctrLbRemainTime->setText(tr("설정 업로드에 실패하였습니다.")); + QTimer::singleShot(1000,this,SLOT(close())); + return; + } + if(buff[sizeof(config_lists)] != 0x9C){ + qDebug() << "SRC config.ini file check fail"; + ui->ctrLbRemainTime->setText(tr("설정 업로드에 실패하였습니다.")); + QTimer::singleShot(1000,this,SLOT(close())); + return; + } + cfg->copyConfigArea(buff); + cfg->saveConfig(); cfg->applyConfig(); - ui->ctrWjProcess->setValue(50); - ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초")); } else{ + qDebug() << "SRC config.ini file open fail"; ui->ctrLbRemainTime->setText(tr("설정 업로드에 실패하였습니다.")); QTimer::singleShot(1000,this,SLOT(close())); return; } strSrcPath = QString("%1/%2").arg(strUsbPath).arg(FAVORITE_FILE_NAME); - file.setFileName(FAVORITE_FILE_NAME); + QFile file(FAVORITE_FILE_NAME); file.remove(); if(QFile::copy( strSrcPath , FAVORITE_FILE_NAME)){ sync(); diff --git a/app/gui/oven_control/functiontestwindow.ui b/app/gui/oven_control/functiontestwindow.ui index 24a7aa0..d5f0d1d 100644 --- a/app/gui/oven_control/functiontestwindow.ui +++ b/app/gui/oven_control/functiontestwindow.ui @@ -579,7 +579,7 @@ QPushButton:pressed, QPushButton:focus { border-image: url(:/images/bottom_bar/b 100 - 1210 + 1209 30 1 -- 2.1.4