]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Multiple cylinder support for JDiveLog import
authorMiika Turkia <miika.turkia@gmail.com>
Sun, 18 Dec 2011 12:36:28 +0000 (14:36 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 18 Dec 2011 19:56:26 +0000 (11:56 -0800)
Support for multiple cylinders and gas change events when Importing
JDiveLog logs to Subsurface. This is tested with manually crafted data
and not real data (originating from dive computer).

NOTE: Subsurface does not handle importing multiple cylinders
correctly but imports only the first cylinder. However, manually
converting data to a file and opening that in Subsurface works
correctly.
 (xsltproc jdivelog2subsurface.xslt jdivelog-gas.jlb > gas.xml)

Some minor tweaking on importing JDiveLog specific fields to notes
fields in Subsurface is also included.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
xslt/jdivelog2subsurface.xslt

index 73b4590fbb6b163c54f0f500917161ea0f8e6905..e2f40c560c5d7fcc4eb135781835d8cbecc39cc6 100644 (file)
 
       <notes>
         <xsl:if test="DiveActivity != ''">
-          <xsl:value-of select="DiveActivity"/>
+Diveactivity: <xsl:value-of select="DiveActivity"/>
         </xsl:if>
-        <xsl:if test="Comment != ''">
-          <xsl:if test="DiveActivity != ''">
-            <xsl:value-of select="': '"/>
-          </xsl:if>
-          <xsl:value-of select="Comment"/>
+        <xsl:if test="DiveType != ''">
+Divetype: <xsl:value-of select="DiveType"/>
         </xsl:if>
         <xsl:if test="Equipment/Visibility != ''">
 Visibility: <xsl:value-of select="Equipment/Visibility"/>
@@ -86,41 +83,51 @@ Gloves: <xsl:value-of select="Equipment/Gloves"/>
         <xsl:if test="Equipment/Weight != ''">
 Weight: <xsl:value-of select="Equipment/Weight"/>
         </xsl:if>
+        <xsl:if test="Comment != ''">
+Comment: <xsl:value-of select="Comment"/>
+        </xsl:if>
       </notes>
 
       <!-- cylinder -->
-      <xsl:variable name="o2">
-        <xsl:choose>
-          <xsl:when test="DIVE/GASES/MIX/O2 != ''">
-            <xsl:value-of select="concat(DIVE/GASES/MIX/O2*100, '%')"/>
-          </xsl:when>
-          <xsl:otherwise>21.0%</xsl:otherwise>
-        </xsl:choose>
-      </xsl:variable>
-      <xsl:variable name="size">
-        <xsl:choose>
-          <xsl:when test="Equipment/Tanks/Tank/MIX/TANK/TANKVOLUME != ''">
-            <xsl:value-of select="concat(Equipment/Tanks/Tank/MIX/TANK/TANKVOLUME * 1000, ' l')"/>
-          </xsl:when>
-          <xsl:otherwise>0 l</xsl:otherwise>
-        </xsl:choose>
-      </xsl:variable>
-      <xsl:variable name="start">
-        <xsl:variable name="number" select="Equipment/Tanks/Tank/MIX/TANK/PSTART"/>
-        <xsl:call-template name="pressure">
-          <xsl:with-param name="number" select="$number"/>
-          <xsl:with-param name="units" select="$units"/>
-        </xsl:call-template>
-      </xsl:variable>
-      <xsl:variable name="end">
-        <xsl:variable name="number" select="Equipment/Tanks/Tank/MIX/TANK/PEND"/>
-        <xsl:call-template name="pressure">
-          <xsl:with-param name="number" select="$number"/>
-          <xsl:with-param name="units" select="$units"/>
-        </xsl:call-template>
-      </xsl:variable>
-
-      <cylinder o2="{$o2}" size="{$size}" start="{$start}" end="{$end}"/>
+      <xsl:for-each select="Equipment/Tanks/Tank">
+        <cylinder>
+          <xsl:attribute name="o2">
+            <xsl:choose>
+              <xsl:when test="MIX/O2 != ''">
+                <xsl:value-of select="concat(MIX/O2*100, '%')"/>
+              </xsl:when>
+              <xsl:otherwise>21.0%</xsl:otherwise>
+            </xsl:choose>
+          </xsl:attribute>
+          <xsl:if test="MIX/HE != '0.0'">
+            <xsl:attribute name="he">
+              <xsl:value-of select="concat(MIX/HE*100, '%')"/>
+            </xsl:attribute>
+          </xsl:if>
+          <xsl:attribute name="size">
+            <xsl:choose>
+              <xsl:when test="MIX/TANK/TANKVOLUME != ''">
+                <xsl:value-of select="concat(MIX/TANK/TANKVOLUME * 1000, ' l')"/>
+              </xsl:when>
+              <xsl:otherwise>0 l</xsl:otherwise>
+            </xsl:choose>
+          </xsl:attribute>
+          <xsl:attribute name="start">
+            <xsl:variable name="number" select="MIX/TANK/PSTART"/>
+            <xsl:call-template name="pressure">
+              <xsl:with-param name="number" select="$number"/>
+              <xsl:with-param name="units" select="$units"/>
+            </xsl:call-template>
+          </xsl:attribute>
+          <xsl:attribute name="end">
+            <xsl:variable name="number" select="MIX/TANK/PEND"/>
+            <xsl:call-template name="pressure">
+              <xsl:with-param name="number" select="$number"/>
+              <xsl:with-param name="units" select="$units"/>
+            </xsl:call-template>
+          </xsl:attribute>
+        </cylinder>
+      </xsl:for-each>
       <!-- end cylinder -->
 
       <!-- DELTA is the sample interval -->
@@ -156,6 +163,22 @@ Weight: <xsl:value-of select="Equipment/Weight"/>
       </xsl:for-each>
       <!-- end events -->
 
+      <!-- gas change -->
+      <xsl:for-each select="DIVE/SAMPLES/SWITCH">
+        <event name="gaschange">
+          <xsl:attribute name="time">
+            <xsl:call-template name="timeConvert">
+              <xsl:with-param name="timeSec" select="count(preceding-sibling::D) * $delta"/>
+              <xsl:with-param name="units" select="'si'"/>
+            </xsl:call-template>
+          </xsl:attribute>
+          <xsl:attribute name="value">
+            <xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2 * 100" />
+          </xsl:attribute>
+        </event>
+      </xsl:for-each>
+      <!-- end gas change -->
+
       <!-- dive sample - all the depth and temp readings -->
       <xsl:for-each select="DIVE/SAMPLES/D">
         <xsl:variable name="timeSec" select="(position() - 1) * $delta"/>