[Kst] branches/work/kst/portto4/kst/src/datasources/ascii
Barth Netterfield
netterfield at astro.utoronto.ca
Tue Apr 30 13:33:55 UTC 2013
SVN commit 1351676 by netterfield:
Configuration dialog mostly works, with these exceptions:
-Preview first 100 lines ins not enabled yet.
-I don't know what 'Always accept files matching' is supposed to do, and
I don't know if it does it.
-File date, at least under linux, is suspect. What we probably want is
file creation date/time, but that doesn't seem to (necessarily) exist.
What do we want to do here?
M +3 -6 asciiconfig.ui
M +26 -2 asciiconfigwidget.cpp
M +3 -0 asciiconfigwidget.h
M +31 -0 asciisource.cpp
M +1 -0 asciisource.h
M +0 -10 asciisourceconfig.cpp
M +0 -3 asciisourceconfig.h
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfig.ui #1351675:1351676
@@ -679,12 +679,6 @@
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
@@ -999,4 +993,7 @@
</hints>
</connection>
</connections>
+ <slots>
+ <slot>interpretationChanged()</slot>
+ </slots>
</ui>
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfigwidget.cpp #1351675:1351676
@@ -43,6 +43,11 @@
_showBeginning->setLineWrapMode(QPlainTextEdit::NoWrap);
_showBeginning->setMinimumSize(640, 100);
+ QObject::connect(_ctime, SIGNAL(toggled(bool)), this, SLOT(interpretationChanged(bool)));
+ QObject::connect(_seconds, SIGNAL(toggled(bool)), this, SLOT(interpretationChanged(bool)));
+ QObject::connect(_indexFreq, SIGNAL(toggled(bool)), this, SLOT(interpretationChanged(bool)));
+ QObject::connect(_formattedString, SIGNAL(toggled(bool)), this, SLOT(interpretationChanged(bool)));
+
}
@@ -77,6 +82,27 @@
_labelBeginning->setText(QString("First lines of file '%1'").arg(QFileInfo(_filename).fileName()));
}
+void AsciiConfigWidgetInternal::interpretationChanged(bool enabled) {
+ if (enabled) {
+ if (_ctime->isChecked()) {
+ _offsetDateTime->setEnabled(false);
+ _offsetFileDate->setEnabled(false);
+ _offsetRelative->setEnabled(true);
+ _offsetRelative->setChecked(true);
+ } else if (_formattedString->isChecked()) {
+ _offsetDateTime->setEnabled(true);
+ _offsetFileDate->setEnabled(true);
+ _offsetRelative->setEnabled(true);
+ } else {
+ _offsetDateTime->setEnabled(true);
+ _offsetFileDate->setEnabled(true);
+ _offsetRelative->setEnabled(false);
+ if (_offsetRelative->isChecked()) {
+ _offsetDateTime->setChecked(true);
+ }
+ }
+ }
+}
AsciiSourceConfig AsciiConfigWidgetInternal::config()
{
@@ -131,7 +157,6 @@
config._useThreads =_useThreads->isChecked();
config._timeAsciiFormatString = _timeAsciiFormatString->text();
config._dataRate = _dataRate->value();
- config._useOffset = _useOffset->isChecked();
config._offsetDateTime = _offsetDateTime->isChecked();
config._offsetFileDate = _offsetFileDate->isChecked();
config._offsetRelative = _offsetRelative->isChecked();
@@ -179,7 +204,6 @@
_useThreads->setChecked(config._useThreads);
_timeAsciiFormatString->setText(config._timeAsciiFormatString);
_dataRate->setValue(config._dataRate.value());
- _useOffset->setChecked(config._useOffset.value());
_offsetDateTime->setChecked(config._offsetDateTime.value());
_offsetFileDate->setChecked(config._offsetFileDate.value());
_offsetRelative->setChecked(config._offsetRelative.value());
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciiconfigwidget.h #1351675:1351676
@@ -34,6 +34,9 @@
private Q_SLOTS:
void showBeginning();
+ protected Q_SLOTS:
+ void interpretationChanged(bool enabled);
+
private:
const int _index_offset;
QString _filename;
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1351675:1351676
@@ -23,6 +23,7 @@
#include "measuretime.h"
#include <QFile>
+#include <QFileInfo>
#include <QMessageBox>
#include <QThread>
#include <QtConcurrentRun>
@@ -187,6 +188,7 @@
force_update = false;
}
_fileSize = file.size();
+ _fileCreationTime_t = QFileInfo(file).created().toTime_t();
bool new_data = _reader.findDataRows(read_completely, file, _fileSize);
@@ -227,6 +229,35 @@
{
int read = tryReadField(v, field, s, n);
+ if (isTime(field)) {
+ if (_config._indexInterpretation == AsciiSourceConfig::FixedRate ) {
+ double rate = _config._dataRate.value();
+ if (rate>0) {
+ rate = 1.0/rate;
+ } else {
+ rate = 1.0;
+ }
+
+ for (int i=0; i<read; i++) {
+ v[i] *= rate;
+ }
+ }
+
+ double dT = 0.0;
+ if (_config._offsetDateTime.value()) {
+ dT = (double)_config._dateTimeOffset.value().toTime_t();
+ } else if (_config._offsetRelative.value()) {
+ dT = _config._relativeOffset.value();
+ } else if (_config._offsetFileDate.value()) {
+ dT = _fileCreationTime_t;
+ }
+
+ for (int i=0; i<read; i++) {
+ v[i] += dT;
+ }
+
+ }
+
QString msg("%1 because not enough memory is available.\nTry setting a file buffer limit in the configuration options.");
if (read == n) {
return read;
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1351675:1351676
@@ -79,6 +79,7 @@
bool _haveHeader;
bool _fieldListComplete;
bool _haveWarned;
+ double _fileCreationTime_t;
QStringList _scalarList;
QMap<QString, QString> _strings;
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.cpp #1351675:1351676
@@ -61,8 +61,6 @@
const char AsciiSourceConfig::Tag_useThreads[] = "useThreads";
const char AsciiSourceConfig::Key_dataRate[] = "Data Rate for index";
const char AsciiSourceConfig::Tag_dataRate[] = "dataRate";
-const char AsciiSourceConfig::Key_useOffset[] = "Use time offset for interpreted time fields";
-const char AsciiSourceConfig::Tag_useOffset[] = "useOffset";
const char AsciiSourceConfig::Key_offsetDateTime[] = "use an explicit date/time offset";
const char AsciiSourceConfig::Tag_offsetDateTime[] = "offsetDateTime";
const char AsciiSourceConfig::Key_offsetFileDate[] = "use file time/date as offset";
@@ -94,7 +92,6 @@
_limitFileBufferSize(128),
_useThreads(false),
_dataRate(1.0),
- _useOffset(false),
_offsetDateTime(false),
_offsetFileDate(false),
_offsetRelative(true),
@@ -125,7 +122,6 @@
_useThreads >> cfg;
_timeAsciiFormatString >> cfg;
_dataRate >> cfg;
- _useOffset >> cfg;
_offsetDateTime >> cfg;
_offsetFileDate >> cfg;
_offsetRelative >> cfg;
@@ -167,7 +163,6 @@
_useThreads << cfg;
_timeAsciiFormatString << cfg;
_dataRate << cfg;
- _useOffset << cfg;
_offsetDateTime << cfg;
_offsetFileDate << cfg;
_offsetRelative << cfg;
@@ -216,7 +211,6 @@
_useThreads >> s;
_timeAsciiFormatString >> s;
_dataRate >> s;
- _useOffset >> s;
_offsetDateTime >> s;
_offsetFileDate >> s;
_offsetRelative >> s;
@@ -247,7 +241,6 @@
_useThreads << attributes;
_timeAsciiFormatString << attributes;
_dataRate << attributes;
- _useOffset << attributes;
_offsetDateTime << attributes;
_offsetFileDate << attributes;
_offsetRelative << attributes;
@@ -281,7 +274,6 @@
_useThreads << elem;
_timeAsciiFormatString << elem;
_dataRate << elem;
- _useOffset << elem;
_offsetDateTime << elem;
_offsetFileDate << elem;
_offsetRelative << elem;
@@ -315,7 +307,6 @@
_useThreads == rhs._useThreads &&
_timeAsciiFormatString == rhs._timeAsciiFormatString &&
_dataRate == rhs._dataRate &&
- _useOffset == rhs._useOffset &&
_offsetDateTime == rhs._offsetDateTime &&
_offsetFileDate == rhs._offsetFileDate &&
_offsetRelative == rhs._offsetRelative &&
@@ -347,7 +338,6 @@
_unitsLine != rhs._unitsLine ||
_timeAsciiFormatString != rhs._timeAsciiFormatString ||
_dataRate != rhs._dataRate ||
- _useOffset != rhs._useOffset ||
_offsetDateTime != rhs._offsetDateTime ||
_offsetFileDate != rhs._offsetFileDate ||
_offsetRelative != rhs._offsetRelative ||
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisourceconfig.h #1351675:1351676
@@ -60,8 +60,6 @@
static const char Tag_useThreads[];
static const char Key_dataRate[];
static const char Tag_dataRate[];
- static const char Key_useOffset[];
- static const char Tag_useOffset[];
static const char Key_offsetDateTime[];
static const char Tag_offsetDateTime[];
static const char Key_offsetFileDate[];
@@ -110,7 +108,6 @@
NamedParameter<int, Key_limitFileBufferSize, Tag_limitFileBufferSize> _limitFileBufferSize;
NamedParameter<int, Key_useThreads, Tag_useThreads> _useThreads;
NamedParameter<double, Key_dataRate, Tag_dataRate> _dataRate;
- NamedParameter<bool, Key_useOffset, Tag_useOffset> _useOffset;
NamedParameter<bool, Key_offsetDateTime, Tag_offsetDateTime> _offsetDateTime;
NamedParameter<bool, Key_offsetFileDate, Tag_offsetFileDate> _offsetFileDate;
NamedParameter<bool, Key_offsetRelative, Tag_offsetRelative> _offsetRelative;
More information about the Kst
mailing list