On Sun, Oct 12, 2014 at 9:56 PM, Dirk Hohndel <[email protected]> wrote:

> On Sun, Oct 12, 2014 at 09:52:36PM +0300, Miika Turkia wrote:
> > > So the DLD Format just got a few new fields. Example attached. The
> > > <ADDITIONALTANKS> is completely optional and always additional to the
> main
> > > tank which continues to live directly in the <DIVELOGSDATA>.
> > > Also please note, that a new tag <HEPCT> for Helium percentage has been
> > > added to the main tank and all additional tanks.
> > >
> >
> > The import to Subsurface is now implemented. The export is a bit more
> > "interesting" as we do not have concept of main tank. I think to just use
> > the first in the XML as the main cylinder and the others as additional.
> > Does this make sense?
>
> We used to have code somewhere that said "if there's a gaschange event in
> the first 30 seconds (or maybe it was minute), then assume that's the main
> tank in use. For example the Cobalt always sends the first gas in use as
> part of the first sample...
> I've seen many instances where the main (only) gas in use is not the first
> one on the Cobalt.
>

Correct, the DLD export does indeed already have such a feature. Anyway
here is the export part.

miika
From 4875cb6b0212aca86ce0294271e7036e99d5979d Mon Sep 17 00:00:00 2001
From: Miika Turkia <[email protected]>
Date: Sun, 12 Oct 2014 22:19:26 +0300
Subject: [PATCH] Export additional tanks to divelogs.de

All recorded cylinders are exported to divelogs.de. This potentially
includes cylinders that have not been used.

The start and end pressure for additional cylinders is taken from the
cylinder information. Main tank gets this information from first and
last pressure reading or from the cylinder information if samples are
not available. This should be ok when there is only one cylinder with
pressure sensor, but does not probably work for people having multiple
sensors.

Signed-off-by: Miika Turkia <[email protected]>
---
 xslt/divelogs-export.xslt | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/xslt/divelogs-export.xslt b/xslt/divelogs-export.xslt
index ec39ba2..b3b8dfa 100644
--- a/xslt/divelogs-export.xslt
+++ b/xslt/divelogs-export.xslt
@@ -107,6 +107,49 @@
       </xsl:choose>
     </CYLINDERENDPRESSURE>
 
+    <ADDITIONALTANKS>
+      <xsl:for-each select="cylinder[position() != $cylinder]">
+          <xsl:variable name="cur_cyl">
+            <xsl:value-of select="position()"/>
+          </xsl:variable>
+
+          <TANK>
+            <CYLINDERDESCRIPTION>
+              <xsl:value-of select="@description"/>
+            </CYLINDERDESCRIPTION>
+
+            <xsl:variable name="dbl">
+              <xsl:choose>
+                <xsl:when test="substring(@description, 1, 1) = 'D' and substring-before(substring(@description, 2), ' ') * 2 = substring-before(@size, ' ')">
+                  <xsl:value-of select="'2'"/>
+                </xsl:when>
+                <xsl:otherwise>
+                  <xsl:value-of select="'1'"/>
+                </xsl:otherwise>
+              </xsl:choose>
+            </xsl:variable>
+            <DBLTANK>
+              <xsl:value-of select="$dbl - 1"/>
+            </DBLTANK>
+            <CYLINDERSIZE>
+              <xsl:value-of select="substring-before(@size, ' ') div $dbl"/>
+            </CYLINDERSIZE>
+            <CYLINDERSTARTPRESSURE>
+              <xsl:value-of select="@start"/>
+            </CYLINDERSTARTPRESSURE>
+            <CYLINDERENDPRESSURE>
+              <xsl:value-of select="@end"/>
+            </CYLINDERENDPRESSURE>
+            <O2PCT>
+              <xsl:value-of select="substring-before(@o2, '%')"/>
+            </O2PCT>
+            <HEPCT>
+              <xsl:value-of select="substring-before(@he, '%')"/>
+            </HEPCT>
+          </TANK>
+      </xsl:for-each>
+    </ADDITIONALTANKS>
+
     <WEIGHT>
       <xsl:call-template name="sum">
         <xsl:with-param name="values" select="weightsystem/@weight"/>
@@ -115,6 +158,9 @@
     <O2PCT>
       <xsl:value-of select="substring-before(cylinder[position() = $cylinder]/@o2, '%')"/>
     </O2PCT>
+    <HEPCT>
+      <xsl:value-of select="substring-before(cylinder[position() = $cylinder]/@he, '%')"/>
+    </HEPCT>
     <LOGNOTES>
       <xsl:value-of select="notes"/>
     </LOGNOTES>
-- 
1.9.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to