Commit c3b0bdeacf14f54bca6db3e4ea00b377681f2890
1 parent
1f78015ebd
Exists in
master
and in
2 other branches
설정 프로그램 업로드 버그 수정
- 파일 목록 리스트 복사 루틴 디버그
Showing
2 changed files
with
60 additions
and
23 deletions
 
Show diff stats
app/gui/oven_control/fileprocessdlg.cpp
| @@ -48,20 +48,32 @@ void ProgramCopyWorker::workerMain(){ | @@ -48,20 +48,32 @@ void ProgramCopyWorker::workerMain(){ | ||
| 48 | qDebug() << "Target Path is " << m_strDestDir; | 48 | qDebug() << "Target Path is " << m_strDestDir; | 
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | - foreach(QString filepath, m_arrSrcFileList){ | 51 | + foreach(QString strinfo, m_arrSrcFileList){ | 
| 52 | + QString filepath = strinfo.left(strinfo.indexOf(',',0)); | ||
| 52 | QFileInfo finfo(filepath); | 53 | QFileInfo finfo(filepath); | 
| 53 | - nTotalFileSize+= finfo.size(); | 54 | + nTotalFileSize+= finfo.size(); | 
| 54 | } | 55 | } | 
| 56 | + qDebug() << "File List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize; | ||
| 55 | 57 | ||
| 56 | foreach(QString srcpath, m_arrSrcDirList){ | 58 | foreach(QString srcpath, m_arrSrcDirList){ | 
| 57 | nTotalFileSize += FileProcessor::getDirSize(srcpath); | 59 | nTotalFileSize += FileProcessor::getDirSize(srcpath); | 
| 58 | } | 60 | } | 
| 59 | - qDebug()<<"Total Size : " << nTotalFileSize; | 61 | + qDebug() << " Dir List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize; | 
| 62 | + if(nTotalFileSize <=0 ){ | ||
| 63 | + emit finished(); | ||
| 64 | + progressed(0,0); | ||
| 65 | + return; | ||
| 66 | + } | ||
| 67 | + | ||
| 60 | 68 | ||
| 61 | - foreach(QString filepath, m_arrSrcFileList){ | 69 | + foreach(QString strinfo, m_arrSrcFileList){ | 
| 70 | + QString filepath = strinfo.left(strinfo.indexOf(',',0)); | ||
| 71 | + QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1)); | ||
| 72 | + QDir destdir(destfiledir); | ||
| 73 | + if(destdir.exists() == false) destdir.mkpath(destfiledir); | ||
| 62 | QFileInfo finfo(filepath); | 74 | QFileInfo finfo(filepath); | 
| 63 | srcFilepath = filepath; | 75 | srcFilepath = filepath; | 
| 64 | - destFilePath = QString("%1/%2").arg(m_strDestDir).arg(finfo.fileName()); | 76 | + destFilePath = QString("%1/%2").arg(destfiledir).arg(finfo.fileName()); | 
| 65 | if(QFile::exists(destFilePath)){ | 77 | if(QFile::exists(destFilePath)){ | 
| 66 | QFile::rename(destFilePath, QString("%1.bak").arg(destFilePath)); | 78 | QFile::rename(destFilePath, QString("%1.bak").arg(destFilePath)); | 
| 67 | } | 79 | } | 
| @@ -72,12 +84,12 @@ void ProgramCopyWorker::workerMain(){ | @@ -72,12 +84,12 @@ void ProgramCopyWorker::workerMain(){ | ||
| 72 | emit progressed(nCurProgress,nRemainSec); | 84 | emit progressed(nCurProgress,nRemainSec); | 
| 73 | if(QThread::currentThread()->isInterruptionRequested()){ | 85 | if(QThread::currentThread()->isInterruptionRequested()){ | 
| 74 | sync(); | 86 | sync(); | 
| 75 | - emit finished(); | ||
| 76 | QThread::currentThread()->quit(); | 87 | QThread::currentThread()->quit(); | 
| 77 | break; | 88 | break; | 
| 78 | } | 89 | } | 
| 79 | QThread::currentThread()->msleep(10); | 90 | QThread::currentThread()->msleep(10); | 
| 80 | } | 91 | } | 
| 92 | + qDebug() << "File List Copy Finished"; | ||
| 81 | 93 | ||
| 82 | if(QThread::currentThread()->isInterruptionRequested() == false){ | 94 | if(QThread::currentThread()->isInterruptionRequested() == false){ | 
| 83 | foreach(QString srcpath, m_arrSrcDirList){ | 95 | foreach(QString srcpath, m_arrSrcDirList){ | 
| @@ -93,31 +105,27 @@ void ProgramCopyWorker::workerMain(){ | @@ -93,31 +105,27 @@ void ProgramCopyWorker::workerMain(){ | ||
| 93 | 105 | ||
| 94 | QDir destDir(targetpath); | 106 | QDir destDir(targetpath); | 
| 95 | if(destDir.exists()) { | 107 | if(destDir.exists()) { | 
| 96 | - qDebug() << "remove target path"; | 108 | + qDebug() << "rename target path"; | 
| 97 | QDir().rename(targetpath, QString("%1_").arg(targetpath)); | 109 | QDir().rename(targetpath, QString("%1_").arg(targetpath)); | 
| 98 | } | 110 | } | 
| 99 | 111 | ||
| 100 | foreach(QString strDir, strdirlist){ | 112 | foreach(QString strDir, strdirlist){ | 
| 101 | QDir srcItem(strDir); | 113 | QDir srcItem(strDir); | 
| 102 | srcItem.mkpath( QString(strDir).replace(srcpath,targetpath)); | 114 | srcItem.mkpath( QString(strDir).replace(srcpath,targetpath)); | 
| 103 | - qDebug() << "make path : " << QString(strDir).replace(srcpath,targetpath); | ||
| 104 | - strFilelist = srcItem.entryList(QDir::NoDotAndDotDot | QDir::Files ); | ||
| 105 | - foreach(QString filename, strFilelist){ | ||
| 106 | - srcFilepath = QString("%1/%2").arg(strDir).arg(filename); | ||
| 107 | - destFilePath = QString("%1/%2").arg(QString(strDir).replace(srcpath,targetpath)).arg(filename); | ||
| 108 | - QFile::copy(srcFilepath, destFilePath); | ||
| 109 | - qDebug() << srcFilepath << destFilePath; | ||
| 110 | - QFileInfo finfo(srcFilepath); | 115 | + QFileInfoList strFileInfolist = srcItem.entryInfoList(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot); | 
| 116 | + foreach(QFileInfo finfo, strFileInfolist){ | ||
| 117 | + srcFilepath = finfo.absoluteFilePath(); | ||
| 118 | + destFilePath = QString("%1/%2").arg(QString(strDir).replace(srcpath,targetpath)).arg(finfo.fileName()); | ||
| 111 | nCpyFileSize += finfo.size(); | 119 | nCpyFileSize += finfo.size(); | 
| 112 | nCurProgress = (nCpyFileSize *100) / nTotalFileSize; | 120 | nCurProgress = (nCpyFileSize *100) / nTotalFileSize; | 
| 113 | nRemainSec = (nTotalFileSize-nCpyFileSize)/200000; | 121 | nRemainSec = (nTotalFileSize-nCpyFileSize)/200000; | 
| 122 | + //qDebug() << srcFilepath << destFilePath << "total size " << nTotalFileSize << "nCpyFileSize " << nCpyFileSize; | ||
| 114 | emit progressed(nCurProgress,nRemainSec); | 123 | emit progressed(nCurProgress,nRemainSec); | 
| 115 | if(QThread::currentThread()->isInterruptionRequested()){ | 124 | if(QThread::currentThread()->isInterruptionRequested()){ | 
| 116 | sync(); | 125 | sync(); | 
| 117 | - emit finished(); | ||
| 118 | break; | 126 | break; | 
| 119 | } | 127 | } | 
| 120 | - QThread::currentThread()->msleep(100); | 128 | + //QThread::currentThread()->msleep(100); | 
| 121 | } | 129 | } | 
| 122 | if(QThread::currentThread()->isInterruptionRequested()) break; | 130 | if(QThread::currentThread()->isInterruptionRequested()) break; | 
| 123 | } | 131 | } | 
| @@ -125,12 +133,15 @@ void ProgramCopyWorker::workerMain(){ | @@ -125,12 +133,15 @@ void ProgramCopyWorker::workerMain(){ | ||
| 125 | if(QThread::currentThread()->isInterruptionRequested()) break; | 133 | if(QThread::currentThread()->isInterruptionRequested()) break; | 
| 126 | } | 134 | } | 
| 127 | } | 135 | } | 
| 136 | + qDebug() << "File Copy Complete! SRC File Size = " << nTotalFileSize << "DEST File Size = " << nCpyFileSize; | ||
| 128 | 137 | ||
| 129 | if(QThread::currentThread()->isInterruptionRequested()){ | 138 | if(QThread::currentThread()->isInterruptionRequested()){ | 
| 130 | - foreach(QString filepath, m_arrSrcFileList){ | 139 | + foreach(QString strinfo, m_arrSrcFileList){ | 
| 140 | + QString filepath = strinfo.left(strinfo.indexOf(',',0)+1); | ||
| 141 | + QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1)); | ||
| 131 | QFileInfo finfo(filepath); | 142 | QFileInfo finfo(filepath); | 
| 132 | srcFilepath = filepath; | 143 | srcFilepath = filepath; | 
| 133 | - destFilePath = QString("%1/%2").arg(m_strDestDir).arg(finfo.fileName()); | 144 | + destFilePath = QString("%1/%2").arg(destfiledir).arg(finfo.fileName()); | 
| 134 | if(QFile::exists( QString("%1.bak").arg(destFilePath))){ | 145 | if(QFile::exists( QString("%1.bak").arg(destFilePath))){ | 
| 135 | QFile::remove(destFilePath); | 146 | QFile::remove(destFilePath); | 
| 136 | QFile::rename(QString("%1.bak").arg(destFilePath), destFilePath); | 147 | QFile::rename(QString("%1.bak").arg(destFilePath), destFilePath); | 
| @@ -160,12 +171,9 @@ void ProgramCopyWorker::workerMain(){ | @@ -160,12 +171,9 @@ void ProgramCopyWorker::workerMain(){ | ||
| 160 | else{ | 171 | else{ | 
| 161 | foreach(QString srcpath, m_arrSrcDirList){ | 172 | foreach(QString srcpath, m_arrSrcDirList){ | 
| 162 | qDebug() << "src dir : " << srcpath; | 173 | qDebug() << "src dir : " << srcpath; | 
| 163 | - | ||
| 164 | QDir srcdir(srcpath); | 174 | QDir srcdir(srcpath); | 
| 165 | - | ||
| 166 | QString targetpath =QString("%1%2").arg(m_strDestDir).arg(srcpath.mid(srcpath.lastIndexOf('/'))); | 175 | QString targetpath =QString("%1%2").arg(m_strDestDir).arg(srcpath.mid(srcpath.lastIndexOf('/'))); | 
| 167 | qDebug() << "target dir : " << targetpath; | 176 | qDebug() << "target dir : " << targetpath; | 
| 168 | - | ||
| 169 | QDir destDir(targetpath); | 177 | QDir destDir(targetpath); | 
| 170 | QDir renameDir(QString("%1_").arg(targetpath)); | 178 | QDir renameDir(QString("%1_").arg(targetpath)); | 
| 171 | if(renameDir.exists()) { | 179 | if(renameDir.exists()) { | 
| @@ -576,7 +584,36 @@ void FileProcessDlg::onProgressed(int progress, int sec){ | @@ -576,7 +584,36 @@ void FileProcessDlg::onProgressed(int progress, int sec){ | ||
| 576 | } | 584 | } | 
| 577 | 585 | ||
| 578 | void FileProcessDlg::programUpload(){ | 586 | void FileProcessDlg::programUpload(){ | 
| 587 | + QString strDescPath; | ||
| 588 | + QString strSrcPath; | ||
| 589 | + | ||
| 590 | + if(FileProcessor::detectUSB(strSrcPath)){ | ||
| 591 | + worker.addSrcFile(QString("%1/prime/falinux/run.sh,/falinux").arg(strSrcPath)); | ||
| 592 | + worker.addSrcFile(QString("%1/prime/falinux/app-prime-modbus,/falinux").arg(strSrcPath)); | ||
| 593 | + worker.addSrcFile(QString("%1/prime/falinux/app-prime-gui,/falinux").arg(strSrcPath)); | ||
| 594 | + worker.addSrcFile(QString("%1/prime/falinux/service-web,/falinux").arg(strSrcPath)); | ||
| 595 | + worker.addSrcFile(QString("%1/prime/falinux/templates/main.tmpl,/falinux/templates").arg(strSrcPath)); | ||
| 596 | + worker.addSrcFile(QString("%1/prime/falinux/system.ini,/falinux").arg(strSrcPath)); | ||
| 597 | + //worker.addSrcFile(QString("%1/prime/falinux/superdaemon,/falinux").arg(strSrcPath)); | ||
| 598 | + //worker.addSrcFile(QString("%1/prime/falinux/superdaemon.ini,/falinux").arg(strSrcPath)); | ||
| 599 | + worker.setDestPath("/prime"); | ||
| 600 | + worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"cookbook")); | ||
| 601 | + worker.moveToThread(&programCopyThd); | ||
| 602 | + | ||
| 603 | + connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain())); | ||
| 604 | + connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int))); | ||
| 605 | + connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop())); | ||
| 606 | + connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit())); | ||
| 607 | + connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished())); | ||
| 608 | + //connect(ui->ctrBtnCancel, SIGNAL(clicked(bool)), &worker, SLOT(workerStop())); | ||
| 579 | 609 | ||
| 610 | + programCopyThd.start(); | ||
| 611 | + qDebug() << "thread start"; | ||
| 612 | + } | ||
| 613 | + else{ | ||
| 614 | + ui->ctrLbRemainTime->setText(tr("USB 인식을 실패하였습니다.")); | ||
| 615 | + QTimer::singleShot(1000,this,SLOT(close())); | ||
| 616 | + } | ||
| 580 | } | 617 | } | 
| 581 | 618 | ||
| 582 | void FileProcessDlg::configDownload(){ | 619 | void FileProcessDlg::configDownload(){ | 
app/gui/oven_control/fileprocessor.cpp
| @@ -65,7 +65,7 @@ quint64 FileProcessor::getDirSize(const QString &str){ | @@ -65,7 +65,7 @@ quint64 FileProcessor::getDirSize(const QString &str){ | ||
| 65 | sizex += getDirSize(fileInfo.absoluteFilePath()); | 65 | sizex += getDirSize(fileInfo.absoluteFilePath()); | 
| 66 | } | 66 | } | 
| 67 | else{ | 67 | else{ | 
| 68 | - qDebug() << fileInfo.absoluteFilePath() << fileInfo.size(); | 68 | + //qDebug() << fileInfo.absoluteFilePath() << fileInfo.size(); | 
| 69 | sizex += fileInfo.size(); | 69 | sizex += fileInfo.size(); | 
| 70 | } | 70 | } | 
| 71 | } | 71 | } |