• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisione3a845c5d63f23707e64906a2d5b65f124ac38b8 (tree)
Time2013-01-31 00:49:32
Authoralucky4416 <alucky4416@user...>
Commiteralucky4416

Log Message

feature: add display lapsed time, logfile name.

Change Summary

Incremental Difference

--- a/daqthread.cpp
+++ b/daqthread.cpp
@@ -21,6 +21,8 @@ DAQThread::DAQThread(QObject *parent) :
2121 this, SLOT(slotLogStarted()));
2222 connect(logTh, SIGNAL(LogEnded(int)),
2323 this, SLOT(slotLogEnded(int)));
24+ connect(logTh, SIGNAL(ChangeLogFilename(QString)),
25+ this, SIGNAL(ChangeLogFilename(QString)));
2426
2527 // logTh start
2628 logTh->start();
--- a/daqthread.h
+++ b/daqthread.h
@@ -18,6 +18,7 @@ signals:
1818 void LogStart(QString logfolderpath);
1919 void LogStop();
2020 void GetData(QDateTime timestamp, double tmpr, double humid);
21+ void ChangeLogFilename(QString filename);
2122 void LogStarted();
2223 void LogEnded(int status); // status 0 is success, !0 is Fail
2324
--- a/logthread.cpp
+++ b/logthread.cpp
@@ -92,6 +92,7 @@ void LogThread::run()
9292 }
9393 prev_Day = today.date().day();
9494 emit LogStarted();
95+ emit ChangeLogFilename(logfilepath);
9596 } else {
9697 emit LogEnded(1);
9798 qDebug() << "open error";
@@ -126,6 +127,7 @@ void LogThread::run()
126127 out << "timestamp, tempr(C), humid(%)" << endl; // append header
127128 }
128129 prev_Day = timestamp.date().day();
130+ emit ChangeLogFilename(logfilepath);
129131 }
130132 }
131133 // qDebug() << "timestamp: " << timestamp.toString("yyyy/MM/dd hh:mm:ss") << "," << "tmpr = " << event.tmpr << ", humid = " << event.humid;
--- a/logthread.h
+++ b/logthread.h
@@ -26,6 +26,7 @@ public:
2626 signals:
2727 void LogStarted();
2828 void LogEnded(int status); // status 0 is success, !0 is Fail
29+ void ChangeLogFilename(QString filename);
2930
3031 public slots:
3132 void slotLogStart(QString logfolderpath);
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -26,6 +26,10 @@ MainWindow::MainWindow(QWidget *parent) :
2626 ui->lcdTempr->display(0.0);
2727 ui->lcdHumid->display(0.0);
2828
29+ ui->label_LogLapsedTime->setText(""); // "Lapsed Time: "
30+// ui->label_LogLapsedTime->hide(); // hidden label_LogLapsedTime
31+
32+
2933 logging = false;
3034
3135 tmpr_max = -1000.0;
@@ -46,6 +50,8 @@ MainWindow::MainWindow(QWidget *parent) :
4650 this, SLOT(slotLogEnded(int)));
4751 connect(daqTh, SIGNAL(GetData(QDateTime, double, double)),
4852 this, SLOT(slotGetData(QDateTime, double, double)));
53+ connect(daqTh, SIGNAL(ChangeLogFilename(QString)),
54+ this, SLOT(slotChangeLogFilename(QString)));
4955 // DaqTh start
5056 daqTh->start();
5157
@@ -91,6 +97,23 @@ void MainWindow::slotGetData(QDateTime timestamp, double tmpr, double humid)
9197 }
9298 ui->label_Max->setText(QString("Max: %1 'C at ").arg(tmpr_max) + time_max.toString("yyyy/MM/dd hh:mm:ss"));
9399 ui->label_Min->setText(QString("Min: %1 'C at ").arg(tmpr_min) + time_min.toString("yyyy/MM/dd hh:mm:ss"));
100+
101+ if (logging) {
102+ int lapsed_time = (QDateTime::currentMSecsSinceEpoch() - logstart_time.toMSecsSinceEpoch()) / 1000;
103+ if (lapsed_time < 60) { // 1 minute
104+ ui->label_LogLapsedTime->setText(QString("Lapsed Time: %1 sec").arg(lapsed_time));
105+ } else if (lapsed_time < 3600) { // 1 hour
106+ ui->label_LogLapsedTime->setText(QString("Lapsed Time: %1 min").arg(lapsed_time/60));
107+ } else if (lapsed_time < 86400) { // 1 day
108+ ui->label_LogLapsedTime->setText(QString("Lapsed Time: %1 hour").arg(lapsed_time/3600));
109+ } else { // over 1 day
110+ ui->label_LogLapsedTime->setText(QString("Lapsed Time: %1 day").arg(lapsed_time/86400));
111+ }
112+ }
113+}
114+void MainWindow::slotChangeLogFilename(QString filename)
115+{
116+ ui->statusBar->showMessage(QString("logfile: %1").arg(filename));
94117 }
95118
96119 void MainWindow::slotLogStarted()
@@ -122,7 +145,7 @@ void MainWindow::on_pushButton_LogStart_clicked()
122145 logging = false;
123146 ui->pushButton_LogStart->setText("Log Start");
124147 ui->label_LogState->setText("LogEnded: " + QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss"));
125-
148+ ui->label_LogLapsedTime->setText("");
126149 } else {
127150 // now idle..
128151 LogStartDialog *dlg = new LogStartDialog(logpath, this);
@@ -134,7 +157,8 @@ void MainWindow::on_pushButton_LogStart_clicked()
134157
135158 logging = true;
136159 ui->pushButton_LogStart->setText("Log Stop");
137- ui->label_LogState->setText("LogStarted: " + QDateTime::currentDateTime().toString("yyyy/MM/dd hh:mm:ss"));
160+ logstart_time = QDateTime::currentDateTime();
161+ ui->label_LogState->setText("LogStarted: " + logstart_time.toString("yyyy/MM/dd hh:mm:ss"));
138162
139163 // reset Max/Min
140164 tmpr_max = -1000.0;
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -24,6 +24,7 @@ signals:
2424
2525 private slots:
2626 void slotGetData(QDateTime, double, double);
27+ void slotChangeLogFilename(QString);
2728 void slotLogStarted();
2829 void slotLogEnded(int status);
2930
@@ -49,6 +50,8 @@ private:
4950 double tmpr_min;
5051 QDateTime time_max;
5152 QDateTime time_min;
53+
54+ QDateTime logstart_time; // for lapsed time
5255 };
5356
5457 #endif // MAINWINDOW_H
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -138,9 +138,9 @@
138138 <property name="geometry">
139139 <rect>
140140 <x>50</x>
141- <y>220</y>
141+ <y>230</y>
142142 <width>161</width>
143- <height>41</height>
143+ <height>61</height>
144144 </rect>
145145 </property>
146146 <property name="font">
@@ -198,7 +198,7 @@
198198 <property name="geometry">
199199 <rect>
200200 <x>230</x>
201- <y>230</y>
201+ <y>220</y>
202202 <width>381</width>
203203 <height>31</height>
204204 </rect>
@@ -215,6 +215,27 @@
215215 <string>Idle...</string>
216216 </property>
217217 </widget>
218+ <widget class="QLabel" name="label_LogLapsedTime">
219+ <property name="geometry">
220+ <rect>
221+ <x>230</x>
222+ <y>260</y>
223+ <width>381</width>
224+ <height>31</height>
225+ </rect>
226+ </property>
227+ <property name="font">
228+ <font>
229+ <pointsize>12</pointsize>
230+ </font>
231+ </property>
232+ <property name="frameShape">
233+ <enum>QFrame::StyledPanel</enum>
234+ </property>
235+ <property name="text">
236+ <string>Lapsed time: </string>
237+ </property>
238+ </widget>
218239 </widget>
219240 <widget class="QMenuBar" name="menuBar">
220241 <property name="geometry">