• 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

Revision9ae25e539b85b797a617b3cfe470e314b02dd8cb (tree)
Time2013-01-30 00:07:36
Authorarakaki <alucky4416@user...>
Commiterarakaki

Log Message

feature: log save interval 1minute. change log file each days.

Change Summary

Incremental Difference

--- a/logthread.cpp
+++ b/logthread.cpp
@@ -60,31 +60,37 @@ void LogThread::LogData(quint64 timestamp, double tmpr, double humid)
6060 void LogThread::run()
6161 {
6262
63- qDebug() << "logTh is started.";
63+ // qDebug() << "logTh is started.";
6464 EventData event;
6565 QFile csvfile;
6666 QTextStream out;
6767 QDateTime timestamp;
68+ int prev_Minute; // prev minutes for timestamp for 1 minutes interval
69+ int prev_Day; // prev Day for Change logfile.
70+
6871 while(!stopped) {
6972 if (EvtQue->isEmpty()) {
7073 msleep(100);
71- } else {
74+ } else {
7275 event = EvtQue->dequeue();
7376 if (!logging) { // idle
7477 if (event.id == Ev_Log_Start) {
7578 // then file open
76- logfilepath = logsavefolderpath + QDir::separator() + "USBRHLog_" + QDateTime::currentDateTime().toString("yyyyMMdd") + ".csv";
79+ prev_Minute = -1;
80+ QDateTime today = QDateTime::currentDateTime();
81+ logfilepath = logsavefolderpath + QDir::separator() + "USBRHLog_" + today.toString("yyyyMMdd") + ".csv";
7782 csvfile.setFileName(logfilepath);
7883 if (csvfile.open(QIODevice::WriteOnly | QIODevice::Append)) {
7984 logging = true;
8085 qDebug() << "logTh log started. logfilename is " << logfilepath;
81- out.flush();
86+ //out.flush();
8287 out.setDevice(&csvfile);
8388 out.setRealNumberNotation(QTextStream::FixedNotation);
8489 out.setRealNumberPrecision(2);
8590 if (csvfile.size() == 0) {
8691 out << "timestamp, tempr(C), humid(%)" << endl; // append header
8792 }
93+ prev_Day = today.date().day();
8894 emit LogStarted();
8995 } else {
9096 emit LogEnded(1);
@@ -104,8 +110,28 @@ void LogThread::run()
104110 } else if (event.id == Ev_Log_Data) {
105111 // if data; // write data to file.
106112 timestamp.setMSecsSinceEpoch(event.timestamp_ms);
107- qDebug() << "timestamp: " << timestamp.toString("yyyy/MM/dd hh:mm:ss") << "," << "tmpr = " << event.tmpr << ", humid = " << event.humid;
108- out << timestamp.toString("yyyy/MM/dd hh:mm:ss") << "," << event.tmpr << "," << event.humid << endl;
113+ if (timestamp.time().minute() != prev_Minute) { // save interval is 1 minute
114+ if (timestamp.date().day() != prev_Day) {
115+ out.flush();
116+ csvfile.close();
117+ logfilepath = logsavefolderpath + QDir::separator() + "USBRHLog_" + timestamp.toString("yyyyMMdd") + ".csv";
118+ csvfile.setFileName(logfilepath);
119+ if (csvfile.open(QIODevice::WriteOnly | QIODevice::Append)) {
120+ logging = true;
121+ qDebug() << "logTh log started. logfilename is " << logfilepath;
122+ out.setDevice(&csvfile);
123+ out.setRealNumberNotation(QTextStream::FixedNotation);
124+ out.setRealNumberPrecision(2);
125+ if (csvfile.size() == 0) {
126+ out << "timestamp, tempr(C), humid(%)" << endl; // append header
127+ }
128+ prev_Day = timestamp.date().day();
129+ }
130+ }
131+ // qDebug() << "timestamp: " << timestamp.toString("yyyy/MM/dd hh:mm:ss") << "," << "tmpr = " << event.tmpr << ", humid = " << event.humid;
132+ out << timestamp.toString("yyyy/MM/dd hh:mm") << ", " << event.tmpr << ", " << event.humid << endl;
133+ prev_Minute = timestamp.time().minute();
134+ }
109135 }
110136 }
111137 }
@@ -121,5 +147,5 @@ void LogThread::run()
121147 csvfile.close();
122148 }
123149
124- qDebug() << "logTh is stopped.";
150+ // qDebug() << "logTh is stopped.";
125151 }
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -28,6 +28,9 @@
2828 <pointsize>18</pointsize>
2929 </font>
3030 </property>
31+ <property name="segmentStyle">
32+ <enum>QLCDNumber::Flat</enum>
33+ </property>
3134 </widget>
3235 <widget class="QLCDNumber" name="lcdHumid">
3336 <property name="geometry">
@@ -43,6 +46,9 @@
4346 <pointsize>18</pointsize>
4447 </font>
4548 </property>
49+ <property name="segmentStyle">
50+ <enum>QLCDNumber::Flat</enum>
51+ </property>
4652 </widget>
4753 <widget class="QLabel" name="label">
4854 <property name="geometry">