Blame view

app/gui/oven_control/fileprocessdlg.cpp 37.5 KB
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
1
  #include <QTimer>
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
2
  #include <unistd.h>
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
3
  #include <QProcess>
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
4
5
6
7
  #include "fileprocessdlg.h"
  #include "ui_fileprocessdlg.h"
  #include "fileprocessor.h"
  #include "ovenstatics.h"
7fa4fdb0e   고영탁   인포 데이터 다운로드 기능 개발
8
  #include "stringer.h"
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
9
  #include "config.h"
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
10
  #include <QDebug>
7fa4fdb0e   고영탁   인포 데이터 다운로드 기능 개발
11
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
12
13
14
15
16
  #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"
7fa4fdb0e   고영탁   인포 데이터 다운로드 기능 개발
17
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  
  ProgramCopyWorker::ProgramCopyWorker(){
      m_bStop = false;
  }
  
  
  ProgramCopyWorker::ProgramCopyWorker(QString strDest){
      m_strDestDir = strDest;
  }
  
  void ProgramCopyWorker::setDestPath(QString strDest){
      m_strDestDir = strDest;
  }
  
  void ProgramCopyWorker::workerMain(){
      quint64 nTotalFileSize=0;
      quint64 nCpyFileSize=0;
      uint16_t nCurProgress=0;
      int nRemainSec = 0;
      QStringList strdirlist;
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
38
39
      QString srcFilepath;
      QString destFilePath;
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
40
      bool bRst=true;
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
41
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
42
43
44
45
46
47
      //make destination folder
      QDir destdir(m_strDestDir);
      if(!destdir.isRoot() && destdir.exists()==false){
          destdir.mkpath(m_strDestDir);
      }
      qDebug() << "Target Path is " << m_strDestDir;
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
48
49
      foreach(QString strinfo, m_arrSrcFileList){
          QString filepath = strinfo.left(strinfo.indexOf(',',0));
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
50
          QFileInfo finfo(filepath);
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
51
          nTotalFileSize+= finfo.size();        
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
52
      }
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
53
      qDebug() << "File List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize;
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
54
55
56
57
  
      foreach(QString srcpath, m_arrSrcDirList){
          nTotalFileSize += FileProcessor::getDirSize(srcpath);
      }
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
58
59
      qDebug() << " Dir List info : count = " << m_arrSrcFileList.size() << ", File Total Size = " << nTotalFileSize;
      if(nTotalFileSize <=0 ){
7835a6555   고영탁   파일 복사 기능 수정
60
          emit errorFired("SIZE ERROR ");
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
61
62
          QThread::currentThread()->msleep(1000);
          bRst = false;
7835a6555   고영탁   파일 복사 기능 수정
63
          emit progressed(0,0);
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
64
          emit finished();
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
65
66
          return;
      }
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
67
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
68
69
70
71
72
      foreach(QString strinfo, m_arrSrcFileList){
          QString filepath = strinfo.left(strinfo.indexOf(',',0));
          QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1));
          QDir destdir(destfiledir);
          if(destdir.exists() == false) destdir.mkpath(destfiledir);
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
73
74
          QFileInfo finfo(filepath);
          srcFilepath = filepath;
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
75
          destFilePath = QString("%1/%2").arg(destfiledir).arg(finfo.fileName());
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
76
77
78
          if(QFile::exists(destFilePath)){
              QFile::rename(destFilePath, QString("%1.bak").arg(destFilePath));
          }
7835a6555   고영탁   파일 복사 기능 수정
79
80
          if(QFile::copy(srcFilepath,destFilePath)==false){
              qDebug() << srcFilepath << " file copy fail!";
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
81
              bRst = false;
7835a6555   고영탁   파일 복사 기능 수정
82
83
84
85
              emit errorFired(finfo.fileName());
              QThread::currentThread()->msleep(5000);
              break;
          }
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
86
87
88
89
90
91
          nCpyFileSize += finfo.size();
          nCurProgress = (nCpyFileSize *100) / nTotalFileSize;
          nRemainSec = (nTotalFileSize-nCpyFileSize)/200000;
          emit progressed(nCurProgress,nRemainSec);
          if(QThread::currentThread()->isInterruptionRequested()){
              sync();
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
92
93
94
95
96
              QThread::currentThread()->quit();
              break;
          }
          QThread::currentThread()->msleep(10);
      }
7835a6555   고영탁   파일 복사 기능 수정
97
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
98
      qDebug() << "File List Copy Finished";
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
99
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
100
      if(QThread::currentThread()->isInterruptionRequested() == false || bRst == false){
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
101
102
103
104
          foreach(QString srcpath, m_arrSrcDirList){
              qDebug() << "src dir : " << srcpath;
  
              QDir srcdir(srcpath);
7835a6555   고영탁   파일 복사 기능 수정
105
106
              if(srcdir.exists() == false){
                  qDebug() << "Source Dir is not exist";
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
107
                  bRst = false;
7835a6555   고영탁   파일 복사 기능 수정
108
109
110
111
                  emit errorFired("DIR not exist");
                  QThread::currentThread()->msleep(5000);
                  break;
              }
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
112
113
114
115
116
117
118
119
120
              strdirlist.append(srcpath);
              FileProcessor::getAllDirList(srcdir, strdirlist);
              qDebug() << "dir size  : " <<strdirlist.size();
  
              QString targetpath =QString("%1%2").arg(m_strDestDir).arg(srcpath.mid(srcpath.lastIndexOf('/')));
              qDebug() << "target dir : " << targetpath;
  
              QDir destDir(targetpath);
              if(destDir.exists()) {
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
121
                  qDebug() << "rename target path";
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
122
123
124
125
126
127
                  QDir().rename(targetpath, QString("%1_").arg(targetpath));
              }
  
              foreach(QString strDir, strdirlist){
                  QDir srcItem(strDir);
                  srcItem.mkpath( QString(strDir).replace(srcpath,targetpath));
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
128
129
130
131
                  QFileInfoList strFileInfolist = srcItem.entryInfoList(QDir::Files |  QDir::NoSymLinks | QDir::NoDotAndDotDot);
                  foreach(QFileInfo finfo, strFileInfolist){
                      srcFilepath = finfo.absoluteFilePath();
                      destFilePath = QString("%1/%2").arg(QString(strDir).replace(srcpath,targetpath)).arg(finfo.fileName());
cc63fa9f8   고영탁   데모모드 삭제 및 파일 복사 기...
132
                      if(QFile::copy(srcFilepath, destFilePath)==false){
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
133
                          bRst = false;
7835a6555   고영탁   파일 복사 기능 수정
134
135
136
137
                          emit errorFired(finfo.fileName());
                          qDebug() << srcFilepath << " file copy fail!";
                          QThread::currentThread()->msleep(5000);
                          break;
cc63fa9f8   고영탁   데모모드 삭제 및 파일 복사 기...
138
                      }
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
139
140
141
                      nCpyFileSize += finfo.size();
                      nCurProgress = (nCpyFileSize *100) / nTotalFileSize;
                      nRemainSec = (nTotalFileSize-nCpyFileSize)/200000;
cc63fa9f8   고영탁   데모모드 삭제 및 파일 복사 기...
142
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
143
                      //qDebug() << srcFilepath << destFilePath << "total size " << nTotalFileSize << "nCpyFileSize " << nCpyFileSize;
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
144
145
146
                      emit progressed(nCurProgress,nRemainSec);
                      if(QThread::currentThread()->isInterruptionRequested()){
                          sync();
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
147
148
                          break;
                      }
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
149
                      //QThread::currentThread()->msleep(100);
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
150
                  }
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
151
                  if(QThread::currentThread()->isInterruptionRequested() || bRst == false) break;
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
152
153
154
155
156
              }
              strdirlist.clear();
              if(QThread::currentThread()->isInterruptionRequested()) break;
          }
      }
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
157
      qDebug() << "File Copy Complete! SRC File Size = " << nTotalFileSize << "DEST File Size = " << nCpyFileSize;
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
158
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
159
      if(QThread::currentThread()->isInterruptionRequested() || bRst == false){
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
160
161
162
          foreach(QString strinfo, m_arrSrcFileList){
              QString filepath = strinfo.left(strinfo.indexOf(',',0)+1);
              QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1));
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
163
164
              QFileInfo finfo(filepath);
              srcFilepath = filepath;
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
165
              destFilePath = QString("%1/%2").arg(destfiledir).arg(finfo.fileName());
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
              if(QFile::exists( QString("%1.bak").arg(destFilePath))){
                  QFile::remove(destFilePath);
                  QFile::rename(QString("%1.bak").arg(destFilePath), destFilePath);
                  nCpyFileSize -= finfo.size();
                  nCurProgress = (nCpyFileSize *100) / nTotalFileSize;
                  emit progressed(nCurProgress, nRemainSec);
              }
              QThread::currentThread()->msleep(1);
          }
          foreach(QString srcpath, m_arrSrcDirList){
              qDebug() << "src dir : " << srcpath;
  
              QDir srcdir(srcpath);
              QString targetpath =QString("%1%2").arg(m_strDestDir).arg(srcpath.mid(srcpath.lastIndexOf('/')));
              qDebug() << "target dir : " << targetpath;
  
              QDir destDir(targetpath);
              QDir renameDir(QString("%1_").arg(targetpath));
              if(renameDir.exists()) {
                  qDebug() << "remove target path";
                  destDir.removeRecursively();
                  QDir().rename(QString("%1_").arg(targetpath), targetpath);
              }
              emit progressed(0, 0);
          }
      }
      else{
cc63fa9f8   고영탁   데모모드 삭제 및 파일 복사 기...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
          sync();
          foreach(QString strinfo, m_arrSrcFileList){
              QString filepath = strinfo.left(strinfo.indexOf(',',0));
              QString destfiledir = strinfo.right(strinfo.size() - (strinfo.indexOf(',',0)+1));
              QDir destdir(destfiledir);
              QFileInfo finfo(filepath);
              srcFilepath = filepath;
              destFilePath = QString("%1/%2.bak").arg(destfiledir).arg(finfo.fileName());
              qDebug() << destFilePath;
              if(QFile::exists(destFilePath)){
                  if(QFile(destFilePath).remove()==false){
                      qDebug() << destFilePath << "delete fail";
                  }
              }
              else qDebug() << "file not found error";
          }
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
209
210
          foreach(QString srcpath, m_arrSrcDirList){
              qDebug() << "src dir : " << srcpath;
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
211
              QDir srcdir(srcpath);
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
212
213
              QString targetpath =QString("%1%2").arg(m_strDestDir).arg(srcpath.mid(srcpath.lastIndexOf('/')));
              qDebug() << "target dir : " << targetpath;
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
              QDir destDir(targetpath);
              QDir renameDir(QString("%1_").arg(targetpath));
              if(renameDir.exists()) {
                  renameDir.removeRecursively();
              }
              emit progressed(0, 0);
          }
      }
      sync();
      emit finished();
  }
  
  void ProgramCopyWorker::addSrcDir(QString strDirPath){
      m_arrSrcDirList.append(strDirPath);
  }
  
  void ProgramCopyWorker::addSrcFile(QString strfilename){
      m_arrSrcFileList.append(strfilename);
  }
  
  void ProgramCopyWorker::workerStop(){
      //QMutexLocker locker(&m_mutex);
     // qDebug() << "stop thread";
     m_bStop = true;
  }
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
239
240
241
242
243
244
245
246
  FileProcessDlg::FileProcessDlg(QWidget *parent, ConfigType type, bool isDown) :
      QDialog(parent),
      ui(new Ui::FileProcessDlg)
  {
      ui->setupUi(this);
      setAttribute(Qt::WA_DeleteOnClose);
      setAttribute(Qt::WA_TranslucentBackground);
      setWindowFlags(Qt::FramelessWindowHint);
40f5d047f   고영탁   엔코더 작업 진행 중
247
248
249
      qApp->setActiveWindow(this);
      this->setFocus();
      ui->ctrBtnCancel->setFocus();
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
250
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
251
252
      m_bRst = true;
      m_nCfgtype  = type;
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
253
254
255
256
257
258
259
260
261
262
      ui->ctrWjProcess->setMinimum(0);
      ui->ctrWjProcess->setMaximum(100);
  
      if(isDown){
          QPixmap pxmap;
          pxmap.load(":/images/config/102_usb_upload_icon.png");
          ui->label_2->setPixmap(pxmap);
      }
  
      switch(type){
663943a37   고영탁   설정 기능 마무리 진행 중
263
264
265
      case config_haccp_data_download:
          QTimer::singleShot(100,this,SLOT(haccpdataDownload()));
          break;
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
      case config_info_data_download:
          QTimer::singleShot(100,this,SLOT(infodataDownload()));
          break;
      case config_service_data_download:
          QTimer::singleShot(100,this,SLOT(servicedataDownload()));
          break;
      case config_program_download:
          QTimer::singleShot(100,this,SLOT(programDownload()));
          break;
      case config_program_upload:
          QTimer::singleShot(100,this,SLOT(programUpload()));
          break;
      case config_set_download:
          QTimer::singleShot(100,this,SLOT(configDownload()));
          break;
      case config_set_upload:
          QTimer::singleShot(100,this,SLOT(configUpload()));
          break;
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
284
285
286
      case config_standard_info_upload:
          QTimer::singleShot(100,this,SLOT(standardInfoUpload()));
          break;
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
287
288
289
290
291
292
293
294
295
296
297
298
299
      default:
          QTimer::singleShot(200,this,SLOT(deleteLater()));
          break;
      }
  }
  
  FileProcessDlg::~FileProcessDlg()
  {
      delete ui;
  }
  
  void FileProcessDlg::on_ctrBtnCancel_clicked()
  {
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
300
301
302
303
  
      //emit stopcopy();
      programCopyThd.requestInterruption();
      //close();
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
304
  }
7fa4fdb0e   고영탁   인포 데이터 다운로드 기능 개발
305
306
307
308
309
310
311
312
313
314
315
  void FileProcessDlg::saveHistoryLineData(QTextStream &out, uint16_t i,  uint16_t fired_cnt, time_t first_fired, time_t last_fried){
      QString strLine;
      QDateTime dt;
      //for(int i =0;i<m_arrErrorMaxIdx[(uint16_t)type];i++){
     //     err_item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[type][i]]);
          strLine = tr("erro%1,").arg(i);
          if(first_fired == 0){
              strLine += "-,0,-";
          }
          else{
              dt.setTime_t(first_fired);
0faa32511   김태훈   컴파일 경고 제거 및 리팩토링
316
              strLine+= Stringer::dateTime(dt,Stringer::OneLine) + ",";
7fa4fdb0e   고영탁   인포 데이터 다운로드 기능 개발
317
318
              strLine += QString("%1").arg(fired_cnt) + ",";
              dt.setTime_t(last_fried);
0faa32511   김태훈   컴파일 경고 제거 및 리팩토링
319
              strLine += Stringer::dateTime(dt,Stringer::OneLine) + ",";
7fa4fdb0e   고영탁   인포 데이터 다운로드 기능 개발
320
321
322
323
324
325
          }
          out << strLine << "
  ";
          qDebug() << strLine;
      //}
  }
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
326
  void FileProcessDlg::infodataDownload(){
7fa4fdb0e   고영탁   인포 데이터 다운로드 기능 개발
327
328
329
330
331
332
333
334
335
      QString strUsbPath;
      QString strFile;
      QFile file;
      error_item *item;
      OvenStatistics *ovenst = OvenStatistics::getInstance();
      time_t firsttimebuf=0,lasttimebuf=0;
      uint16_t firecntbuf=0;
      uint16_t erridx = 0;
      int i;
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
336
7fa4fdb0e   고영탁   인포 데이터 다운로드 기능 개발
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
      if(FileProcessor::detectUSB(strUsbPath)){
          //Top
          strFile = strUsbPath + ERROR_LOG_FILE_TOP;
          qDebug() << strUsbPath;
          file.setFileName(strFile);
          if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
              QTextStream out(&file);
              out << tr("Gas Error History
  ") << "Top Ignition Box" <<"
  ";
              out << tr("no,") << tr("First Appearance,") << tr("Counter,") << tr("Last Appearance
  ");
              for(i =0;i<m_arrErrorMaxIdx[ERROR_HISTORY_UPPERBUNNER];i++){
                  item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_UPPERBUNNER][i]]);
                  saveHistoryLineData(out,i+1,item->fired_cnt,item->first_fired,item->last_fried);
              }
              file.close();
          }
          ui->ctrWjProcess->setValue(25);
          ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초"));
          //Bottom
          strFile = strUsbPath + ERROR_LOG_FILE_BOTTOM;
          qDebug() << strUsbPath;
          file.setFileName(strFile);
          if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
              QTextStream out(&file);
              out << tr("Gas Error History
  ") << "Bottom Ignition Box" <<"
  ";
              out << tr("no,") << tr("First Appearance,") << tr("Counter,") << tr("Last Appearance
  ");
              for(i =0;i<m_arrErrorMaxIdx[ERROR_HISTORY_LOWERBUNNER];i++){
                  item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_LOWERBUNNER][i]]);
                  saveHistoryLineData(out,i+1,item->fired_cnt,item->first_fired,item->last_fried);
              }
              file.close();
          }
          ui->ctrWjProcess->setValue(50);
          ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초"));
          //Steam
          strFile = strUsbPath + ERROR_LOG_FILE_STEAM;
          qDebug() << strUsbPath;
          file.setFileName(strFile);
          if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
              QTextStream out(&file);
              out << tr("Gas Error History
  ") << "Steam Ignition Box" <<"
  ";
              out << tr("no,") << tr("First Appearance,") << tr("Counter,") << tr("Last Appearance
  ");
              for(i =0;i<m_arrErrorMaxIdx[ERROR_HISTORY_STEAMBUNNER];i++){
                  item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_STEAMBUNNER][i]]);
                  saveHistoryLineData(out,i+1,item->fired_cnt,item->first_fired,item->last_fried);
              }
              file.close();
          }
          ui->ctrWjProcess->setValue(75);
          ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초"));
          //Total
          strFile = strUsbPath + ERROR_LOG_FILE_TOTAL;
          qDebug() << strUsbPath;
          file.setFileName(strFile);
          if(file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){
              QTextStream out(&file);
              out << tr("Service Error History
  
  ");
              out << tr("no,") << tr("First Appearance,") << tr("Counter,") << tr("Last Appearance
  ");
              //01 상부 점화 장치 데이터 초기화
               firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              for(i=0;i<m_arrErrorMaxIdx[ERROR_HISTORY_UPPERBUNNER];i++){
                  item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_UPPERBUNNER][i]]);
                 if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
                 else{
                      if( (firsttimebuf > item->first_fired && item->first_fired != 0) || firsttimebuf == 0 ) firsttimebuf = item->first_fired;
                      if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
                      firecntbuf += item->fired_cnt;
                 }
              }
              saveHistoryLineData(out,erridx+1, firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              //02 스팀 점화 장치 데이터 초기화
              firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              for(i=0;i<m_arrErrorMaxIdx[ERROR_HISTORY_STEAMBUNNER];i++){
                  item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_STEAMBUNNER][i]]);
                 if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
                 else{
                      if((firsttimebuf > item->first_fired && item->first_fired != 0) || firsttimebuf == 0 ) firsttimebuf = item->first_fired;
                      if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
                      firecntbuf += item->fired_cnt;
                 }
              }
              saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              //03 하부 점화 장치 데이터 초기화
              firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              for(i=0;i<m_arrErrorMaxIdx[ERROR_HISTORY_LOWERBUNNER];i++){
                  item = &(ovenst->srvdata->err_log.values[m_arrErrorIdxs[ERROR_HISTORY_LOWERBUNNER][i]]);
                 if(i==0) {firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;}
                 else{
                      if((firsttimebuf > item->first_fired && item->first_fired != 0) || firsttimebuf == 0 ) firsttimebuf = item->first_fired;
                      if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
                      firecntbuf += item->fired_cnt;
                 }
              }
              saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              //04 WATER
              firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              item = &(ovenst->srvdata->err_log.items.inner_temp_fail);
              firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
              item = &(ovenst->srvdata->err_log.items.qunching_temp_fail);
              if( firsttimebuf > item->first_fired && item->first_fired != 0 ) firsttimebuf = item->first_fired;
              if( lasttimebuf < item->last_fried ) lasttimebuf = item->last_fried;
              firecntbuf += item->fired_cnt;
              saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              //05 구성품
              firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              //07 B1 센서 에러
              firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              item = &(ovenst->srvdata->err_log.items.inner_temp_high_alarm);
              firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
              saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              //08 B2 센서 에러
              firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              item = &(ovenst->srvdata->err_log.items.qunching_temp_high_alarm);
              saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              //10 B4 센서 에러
              firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              item = &(ovenst->srvdata->err_log.items.wall_temp1_high_alarm);
              firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
              saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              //11 B5 센서 에러
              firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              item = &(ovenst->srvdata->err_log.items.steam_gen_temp_high_alram);
              firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
              saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              firecntbuf = 0;firsttimebuf =  0; lasttimebuf=0;
              item = &(ovenst->srvdata->err_log.items.water_level_sensor_fail);
              firsttimebuf = item->first_fired;lasttimebuf = item->last_fried;firecntbuf=item->fired_cnt;
              saveHistoryLineData(out, erridx,firecntbuf,firsttimebuf,lasttimebuf);erridx++;
              file.close();
          }
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
479
          sync();
7fa4fdb0e   고영탁   인포 데이터 다운로드 기능 개발
480
481
482
483
          ui->ctrWjProcess->setValue(100);
          ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료"));
          QTimer::singleShot(1000,this,SLOT(close()));
      }
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
484
485
486
  }
  
  void FileProcessDlg::servicedataDownload(){
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
487
488
489
490
491
      QString strUsbPath;
      QString strHeader = "no,name,time
  ";
      QString strFile;
      QFile file;
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
      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
  ";
              timetemp = ovs->srvdata->use_log.items.dry_heat/3600;
              out << i++ << tr(",Hot Air Heating Time,") << timetemp << "h
  ";
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
508
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
              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
  ";
              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
  ";
              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
  ";
              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
  ";
              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
  ";
              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
  ";
              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
  ";
              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
  ";
              timetemp = ovs->srvdata->use_log.items.cooldown_mode/3600;
              totaltime += ovs->srvdata->use_log.items.cooldown_mode;
              out << i++ << tr(",쿨다운,").toUtf8() << timetemp << "h
  ";
              timetemp = totaltime/3600;
              out << i++ << tr(",전체작동시간,").toUtf8() << timetemp << "h
  ";
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
549
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
              i=1;out<< strHeader;
              timetemp = ovs->srvdata->use_log.items.door_open/60;
              out << i++ << tr(",도어 Open,").toUtf8() << timetemp << "min
  ";
              timetemp = ovs->srvdata->use_log.items.dv_open/60;
              out << i++ << tr(",볼밸브 Open,").toUtf8() << timetemp << "min
  ";
              timetemp = ovs->srvdata->use_log.items.ssv_open/60;
              out << i++ << tr(",S/G 급수 솔레노이드,").toUtf8() << timetemp << "min
  ";
              timetemp = ovs->srvdata->use_log.items.qnv_open/60;
              out << i++ << tr(",퀀칭 솔레노이드,").toUtf8() << timetemp << "min
  ";
              timetemp = ovs->srvdata->use_log.items.snv_open/60;
              out << i++ << tr(",고내살수 노즐 솔레노이드 ,").toUtf8() << timetemp << "min
  ";
              timetemp = 0;
              out << i++ << tr(",호스릴 솔레노이드,").toUtf8() << timetemp << "min
  ";
              timetemp = ovs->srvdata->use_log.items.ssp_open/60;
              out << i++ << tr(",세제공급장치,").toUtf8() << timetemp << "min
  ";
              timetemp = ovs->srvdata->use_log.items.hdm_open/60;
              out << i++ << tr(",배습댐퍼,").toUtf8() << timetemp << "min
  ";
              timetemp = ovs->srvdata->use_log.items.dp_open/60;
              out << i++ << tr(",소형펌프모터,").toUtf8() << timetemp << "min
  ";
              timetemp = ovs->srvdata->use_log.items.unp_open/60;
              out << i++ << tr(",중형펌프모터,").toUtf8() << timetemp << "min
  ";
              ui->ctrWjProcess->setValue(100);
              ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료"));
              file.close();
              sync();
              QTimer::singleShot(1000,this,SLOT(close()));
          }
      }
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
588
589
590
  }
  
  void FileProcessDlg::programDownload(){
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
591
592
593
594
      QString strDescPath;
      QString strSrcPath;
  
      if(FileProcessor::detectUSB(strDescPath)){
cc63fa9f8   고영탁   데모모드 삭제 및 파일 복사 기...
595
          worker.setDestPath(QString("%1/prime").arg(strDescPath));
7835a6555   고영탁   파일 복사 기능 수정
596
597
          worker.addSrcDir("/prime/history");
          worker.addSrcDir("/prime/program");
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
598
          worker.moveToThread(&programCopyThd);
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
599
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
600
601
          connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain()));
          connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int)));
7835a6555   고영탁   파일 복사 기능 수정
602
          connect(&worker, SIGNAL(errorFired(QString)), this, SLOT(onErrorFired(QString)));
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
          connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop()));
          connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit()));
          connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished()));
          //connect(ui->ctrBtnCancel, SIGNAL(clicked(bool)), &worker, SLOT(workerStop()));
  
          programCopyThd.start();
          qDebug() << "thread start";
      }
      else{
          ui->ctrLbRemainTime->setText(tr("USB 인식을 실패하였습니다."));
          QTimer::singleShot(1000,this,SLOT(close()));
      }
  }
  
  void FileProcessDlg::onProgressFinished(){
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
      QString strDescPath;
      QString strZipCmd;
      m_bRst = true;
      QProcess process;
  
      FileProcessor::detectUSB(strDescPath);
  
      strZipCmd = QString("sh -c \"unzip -P 1234 %1/prime/prime.zip -d /prime\"").arg(strDescPath);
      QFileInfo info(QString("%1/prime/prime.zip").arg(strDescPath));
  
  
      QDir cookbooksrc("/prime/cookbook");
      QDir cookBookback("/prime/cookbook_back");
      QDir multibooksrc("/prime/multi");
      QDir multibookback("/prime/multi_back");
  
      qDebug() << info.absoluteFilePath();
  
      if(m_nCfgtype == config_program_upload && m_bRst && info.exists()==true){
          if(cookbooksrc.exists()){
              if(cookBookback.exists()){
                  process.start("sh -c \"rm -r /prime/cookbook_back\"");
                  process.waitForFinished();
                  process.start("sync");
                  process.waitForFinished();
              }
              qDebug() << "cook book exists";
              process.start("sh -c \"mv /prime/cookbook /prime/cookbook_back\"");
              process.waitForFinished();
              process.start("sync");
              process.waitForFinished();
          }
  
          if(multibooksrc.exists()){
              if(multibookback.exists()){
                  process.start("sh -c \"rm -r /prime/multi_back\"");
                  process.waitForFinished();
                  process.start("sync");
                  process.waitForFinished();
              }
              qDebug() << "multi book exists";
              process.start("sh -c \"mv /prime/multi /prime/multi_back\"");
              process.waitForFinished();
              process.start("sync");
              process.waitForFinished();
          }
  
          qDebug() << "cook book upload";
          qDebug() << QTime::currentTime();
  
          process.start(strZipCmd);
          if(process.waitForFinished(120000)==false){
              ui->ctrLbRemainTime->setText("Cook book copy fail");
          }
          process.start("sync");
          process.waitForFinished();
          qDebug() << QTime::currentTime();
      }
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
676
677
678
      ui->ctrLbRemainTime->setText(tr("완료"));
      QTimer::singleShot(1000,this, SLOT(close()));
  }
7835a6555   고영탁   파일 복사 기능 수정
679
680
  void FileProcessDlg::onErrorFired(QString Desc)
  {
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
681
      m_bRst = false;
7835a6555   고영탁   파일 복사 기능 수정
682
683
684
      ui->ctrLbRemainTime->setText(QString("%1 %2").arg(Desc).arg(tr("에러 발생으로 종료합니다.")));
      //QTimer::singleShot(1000,this, SLOT(close()));
  }
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
685
686
687
688
689
690
691
  void FileProcessDlg::onProgressed(int progress, int sec){
      int min, _sec;
      QString strTemp;
      ui->ctrWjProcess->setValue(progress);
      min = sec/60;
      _sec = sec%60;
      if(min >0){
0faa32511   김태훈   컴파일 경고 제거 및 리팩토링
692
          strTemp = tr("남은 예상 시간 : %1분 %2초").arg(min).arg(_sec);
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
693
694
695
          ui->ctrLbRemainTime->setText(strTemp);
      }
      else{
0faa32511   김태훈   컴파일 경고 제거 및 리팩토링
696
          strTemp = tr("남은 예상 시간 : %1초").arg(_sec);
7a3fdac0e   고영탁   설정 프로그램 다운로드 기능 개발
697
698
          ui->ctrLbRemainTime->setText(strTemp);
      }
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
699
700
701
  }
  
  void FileProcessDlg::programUpload(){
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
702
703
      QString strDescPath;
      QString strSrcPath;
9a0a0882e   고영탁   쿡북 파일 압축 암호화 기능 추가
704
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
705
      if(FileProcessor::detectUSB(strSrcPath)){
1c53b45b7   고영탁   프로그램 업로드 기능 수정
706
707
708
709
710
711
712
713
714
715
          worker.addSrcFile(QString("%1/prime/superdaemon,/prime").arg(strSrcPath));
          worker.addSrcFile(QString("%1/prime/superdaemon.ini,/prime").arg(strSrcPath));
          worker.addSrcFile(QString("%1/prime/app-prime-gui,/prime").arg(strSrcPath));
          worker.addSrcFile(QString("%1/prime/app-prime-modbus,/prime").arg(strSrcPath));
          worker.addSrcFile(QString("%1/prime/service-web,/prime").arg(strSrcPath));
          worker.addSrcFile(QString("%1/prime/app-prime-gui.md5,/prime").arg(strSrcPath));
          worker.addSrcFile(QString("%1/prime/app-prime-modbus.md5,/prime").arg(strSrcPath));
          worker.addSrcFile(QString("%1/prime/superdaemon.ini.md5,/prime").arg(strSrcPath));
          worker.addSrcFile(QString("%1/prime/superdaemon.md5,/prime").arg(strSrcPath));
          worker.setDestPath("/prime");
7835a6555   고영탁   파일 복사 기능 수정
716
          //worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/cookbook")); //쿡북 복사 삭제
1c53b45b7   고영탁   프로그램 업로드 기능 수정
717
718
          worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/templates"));
          worker.addSrcDir(QString("%1/%2").arg(strSrcPath,"prime/sounds"));
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
719
720
721
722
          worker.moveToThread(&programCopyThd);
  
          connect(&programCopyThd,SIGNAL(started()), &worker, SLOT(workerMain()));
          connect(&worker, SIGNAL(progressed(int,int)), this, SLOT(onProgressed(int,int)));
7835a6555   고영탁   파일 복사 기능 수정
723
          connect(&worker,SIGNAL(errorFired(QString)),this,SLOT(onErrorFired(QString)));
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
724
725
726
727
          connect(this, SIGNAL(stopcopy()), &worker, SLOT(workerStop()));
          connect(&worker, SIGNAL(finished()), &programCopyThd,SLOT(quit()));
          connect(&programCopyThd, SIGNAL(finished()), this, SLOT(onProgressFinished()));
          //connect(ui->ctrBtnCancel, SIGNAL(clicked(bool)), &worker, SLOT(workerStop()));
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
728
c3b0bdeac   고영탁   설정 프로그램 업로드 버그 수정
729
730
731
732
733
734
735
          programCopyThd.start();
          qDebug() << "thread start";
      }
      else{
          ui->ctrLbRemainTime->setText(tr("USB 인식을 실패하였습니다."));
          QTimer::singleShot(1000,this,SLOT(close()));
      }
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
736
737
738
739
  }
  
  void FileProcessDlg::configDownload(){
      QString strUsbPath;
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
740
      QString strSrcPath;
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
741
      if(FileProcessor::detectUSB(strUsbPath)){
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
742
743
744
745
          strSrcPath = QString("%1/%2").arg(strUsbPath).arg(CONFIG_FILE_NAME);
          QFileInfo finfo(strSrcPath);
          QDir fdir = finfo.absoluteDir();
          if(finfo.absoluteDir().exists() == false) fdir.mkpath(finfo.absolutePath());
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
746
          QFile file;
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
747
          file.setFileName(strSrcPath);
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
748
          if(file.exists()) file.remove();
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
749
          if(QFile::copy(CONFIG_FILE_NAME, strSrcPath)){
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
750
751
752
753
754
755
756
757
758
              sync();
              ui->ctrWjProcess->setValue(50);
              ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1초"));
          }
          else{
              ui->ctrLbRemainTime->setText(tr("설정 다운로드에 실패하였습니다."));
              QTimer::singleShot(1000,this,SLOT(close()));
              return;
          }
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
759
760
          strSrcPath = QString("%1/%2").arg(strUsbPath).arg(FAVORITE_FILE_NAME);
          file.setFileName(strSrcPath);
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
761
          if(file.exists()) file.remove();
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
762
          if(QFile::copy(FAVORITE_FILE_NAME, strSrcPath)){
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
763
              sync();
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
764
              ui->ctrWjProcess->setValue(100);
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
765
766
767
768
              ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료"));
              QTimer::singleShot(1000,this,SLOT(close()));
          }
          else{
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
769
              ui->ctrLbRemainTime->setText(tr("즐겨찾기 다운로드에 실패하였습니다."));
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
770
771
772
773
              QTimer::singleShot(1000,this,SLOT(close()));
          }
      }
      else{
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
774
          ui->ctrLbRemainTime->setText(tr("USB 인식을 실패하였습니다."));
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
775
776
777
778
779
          QTimer::singleShot(1000,this,SLOT(close()));
      }
  }
  
  void FileProcessDlg::configUpload(){
4c8eff382   김태훈   더 적절한 해결 방법으로 변경
780
      uint8_t buff[sizeof(config_lists)+1];
878f5d85f   고영탁   가스식 rpm 설정 기능 추가
781
      qint64 readlen;
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
782
      QString strUsbPath;
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
783
      QString strSrcPath;
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
784
      Config *cfg = Config::getInstance();
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
785
      if(FileProcessor::detectUSB(strUsbPath)){
6c2810f46   고영탁   프로그램 업로드시 모델 정보 변...
786
          strSrcPath = QString("%1%2").arg(strUsbPath).arg(CONFIG_FILE_NAME);
878f5d85f   고영탁   가스식 rpm 설정 기능 추가
787
788
          QFile srcFile(strSrcPath);
          //Check Source File is valid this machine
6c2810f46   고영탁   프로그램 업로드시 모델 정보 변...
789
          if(srcFile.open(QIODevice::ReadOnly)){
4c8eff382   김태훈   더 적절한 해결 방법으로 변경
790
              readlen = srcFile.read((char *) buff,sizeof(config_lists)+1);
6c2810f46   고영탁   프로그램 업로드시 모델 정보 변...
791
792
793
794
795
796
797
              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;
              }
4c8eff382   김태훈   더 적절한 해결 방법으로 변경
798
              if(buff[sizeof(config_lists)] != 0x9C){
6c2810f46   고영탁   프로그램 업로드시 모델 정보 변...
799
800
801
802
803
                  qDebug() << "SRC config.ini file check fail";
                  ui->ctrLbRemainTime->setText(tr("설정 업로드에 실패하였습니다."));
                  QTimer::singleShot(1000,this,SLOT(close()));
                  return;
              }
4c8eff382   김태훈   더 적절한 해결 방법으로 변경
804
              cfg->copyConfigArea((char *) buff);
6c2810f46   고영탁   프로그램 업로드시 모델 정보 변...
805
              cfg->saveConfig();
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
806
              cfg->applyConfig();
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
807
808
          }
          else{
6c2810f46   고영탁   프로그램 업로드시 모델 정보 변...
809
              qDebug() << "SRC config.ini file open fail";
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
810
811
812
813
              ui->ctrLbRemainTime->setText(tr("설정 업로드에 실패하였습니다."));
              QTimer::singleShot(1000,this,SLOT(close()));
              return;
          }
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
814
          strSrcPath = QString("%1/%2").arg(strUsbPath).arg(FAVORITE_FILE_NAME);
6c2810f46   고영탁   프로그램 업로드시 모델 정보 변...
815
          QFile file(FAVORITE_FILE_NAME);
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
816
817
          file.remove();
          if(QFile::copy( strSrcPath , FAVORITE_FILE_NAME)){
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
818
819
              sync();
              cfg->loadFavorite();
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
820
821
822
823
824
              ui->ctrWjProcess->setValue(100);
              ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료"));
              QTimer::singleShot(1000,this,SLOT(close()));
          }
          else{
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
825
              ui->ctrLbRemainTime->setText(tr("즐겨찾기 업로드에 실패하였습니다."));
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
826
827
828
829
              QTimer::singleShot(1000,this,SLOT(close()));
          }
      }
      else{
1fe2b9973   고영탁   시스템 관리 기능 버그 수정
830
          ui->ctrLbRemainTime->setText(tr("USB 인식을 실패하였습니다."));
1f685a2a5   고영탁   설정 시스템 관리 기능 개발
831
832
833
          QTimer::singleShot(1000,this,SLOT(close()));
      }
  }
663943a37   고영탁   설정 기능 마무리 진행 중
834
835
836
837
838
839
  
  void FileProcessDlg::haccpdataDownload(){
      ui->ctrWjProcess->setValue(100);
      ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료"));
      QTimer::singleShot(1000,this,SLOT(close()));
  }
40f5d047f   고영탁   엔코더 작업 진행 중
840
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
841
842
843
844
  void FileProcessDlg::standardInfoUpload()
  {
      QString strUsbPath;
      QString strSrcPath;
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
845
      if(FileProcessor::detectUSB(strUsbPath)){
1c53b45b7   고영탁   프로그램 업로드 기능 수정
846
847
          strSrcPath = QString("%1%2").arg(strUsbPath).arg(MODEL_INFO_FILE_NAME);
          qDebug() <<strSrcPath;
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
848
849
          QFile file(MODEL_INFO_FILE_NAME);
          file.remove();
1c53b45b7   고영탁   프로그램 업로드 기능 수정
850
          sync();
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
851
852
853
854
855
856
857
858
859
860
861
862
863
          if(QFile::copy( strSrcPath ,MODEL_INFO_FILE_NAME)){
              sync();
              ui->ctrWjProcess->setValue(40);
              ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 2초"));
          }
          else{
              ui->ctrLbRemainTime->setText(tr("모델 정보 업로드에 실패하였습니다."));
              QTimer::singleShot(1000,this,SLOT(close()));
              return;
          }
          //QThread::msleep(800);
          file.setFileName(CHEF_INFO_FILE_NAME);
          file.remove();
1c53b45b7   고영탁   프로그램 업로드 기능 수정
864
865
          sync();
          strSrcPath = QString("%1%2").arg(strUsbPath).arg(CHEF_INFO_FILE_NAME);
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
866
867
868
869
870
871
872
873
874
875
876
877
878
879
          qDebug() << strSrcPath;
          if(QFile::copy( strSrcPath ,CHEF_INFO_FILE_NAME)){
              sync();
              ui->ctrWjProcess->setValue(70);
              ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 1"));
              QTimer::singleShot(1000,this,SLOT(close()));
          }
          else{
              ui->ctrLbRemainTime->setText(tr("핫라인 쉐프 정보 업로드에 실패하였습니다."));
              QTimer::singleShot(1000,this,SLOT(close()));
          }
          //QThread::msleep(800);
          file.setFileName(SERVICE_INFO_FILE_NAME);
          file.remove();
1c53b45b7   고영탁   프로그램 업로드 기능 수정
880
881
          sync();
          strSrcPath = QString("%1%2").arg(strUsbPath).arg(SERVICE_INFO_FILE_NAME);
cb1e6464c   고영탁   제품 정보 변경 기능 추가 및 ...
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
          qDebug() << strSrcPath;
          if(QFile::copy( strSrcPath ,SERVICE_INFO_FILE_NAME)){
              sync();
              ui->ctrWjProcess->setValue(100);
              ui->ctrLbRemainTime->setText(tr("남은 예상 시간 : 완료"));
              qDebug() << "standard upload success";
              QTimer::singleShot(1000,this,SLOT(close()));
          }
          else{
              ui->ctrLbRemainTime->setText(tr("핫라인 서비스 정보 업로드에 실패하였습니다."));
              QTimer::singleShot(1000,this,SLOT(close()));
          }
      }
      else{
          ui->ctrLbRemainTime->setText(tr("USB 인식을 실패하였습니다."));
          QTimer::singleShot(1000,this,SLOT(close()));
      }
  }
0faa32511   김태훈   컴파일 경고 제거 및 리팩토링
900
  void FileProcessDlg::keyPressEvent(QKeyEvent */*event*/){
40f5d047f   고영탁   엔코더 작업 진행 중
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
  
  }
  
  void FileProcessDlg::keyReleaseEvent(QKeyEvent *event){
      switch (event->key())
      {
      case 0x01000031:    // Push
      {
          QPushButton *btn = qobject_cast<QPushButton*>(focusWidget());
          if(btn != NULL){
              btn->click();
          }
          break;
      }
      }
  }