Import support for new Seabear format

This add support for Seabear's new import format that is used by H3 and
T1. In the future also the Hudc  should switch to the new format. The
main difference to the old one is that time stamps are no longer
recorded in the samples, but intervali is specified in the header.

The header contains other useful information as well that we should
build support for. E.g. surface pressure, gas mixes, GF, and mode might
be useful additions later on.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2015-03-22 17:13:47 +02:00 committed by Dirk Hohndel
parent cb49c37b31
commit 86ac7fdf47
5 changed files with 114 additions and 26 deletions

View file

@ -316,6 +316,7 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
ui->setupUi(this);
fileNames = fn;
column = 0;
delta = "0";
/* Add indexes of XSLTs requiring special handling to the list */
specialCSV << 3;
@ -375,7 +376,53 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
QString firstLine = f.readLine();
if (firstLine.contains("SEABEAR")) {
seabear = true;
firstLine = "Sample time;Sample depth;Sample NDL;Sample TTS;Sample stopdepth;Sample temperature;Sample pressure";
/*
* Parse header - currently only interested in sample
* interval, or if we have old format (if interval value
* is missing from the header).
*/
while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) {
if (firstLine.contains("//Log interval: "))
delta = firstLine.remove(QString::fromLatin1("//Log interval: ")).trimmed();
}
/*
* Parse CSV fields
* The pO2 values from CCR diving are ignored later on.
*/
firstLine = f.readLine().trimmed();
currColumns = firstLine.split(';');
Q_FOREACH (QString columnText, currColumns) {
if (columnText == "Time") {
headers.append("Sample time");
} else if (columnText == "Depth") {
headers.append("Sample depth");
} else if (columnText == "Temperature") {
headers.append("Sample temperature");
} else if (columnText == "NDT") {
headers.append("Sample NDL");
} else if (columnText == "TTS") {
headers.append("Sample TTS");
} else if (columnText == "pO2_1") {
headers.append("Sample pO2_1");
} else if (columnText == "pO2_2") {
headers.append("Sample pO2_2");
} else if (columnText == "pO2_3") {
headers.append("Sample pO2_3");
} else if (columnText == "Ceiling") {
headers.append("Sample ceiling");
} else {
// We do not know about this value
qDebug() << "Seabear import found an un-handled field: " << columnText;
headers.append("");
}
}
firstLine = headers.join(";");
blockSignals(true);
ui->knownImports->setCurrentText("Seabear CSV");
blockSignals(false);
@ -543,7 +590,8 @@ void DiveLogImportDialog::on_buttonBox_accepted()
r.indexOf(tr("Sample pressure")),
ui->CSVSeparator->currentIndex(),
specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
ui->CSVUnits->currentIndex()
ui->CSVUnits->currentIndex(),
delta.toUtf8().data()
) < 0)
return;