Try to detect first cylinder on divelogs.de export

Most dive computers start always with the first cylinder (and if not,
they give a gas switch in the first few seconds). Trying to follow this
principle on divelogs.de export.

The bug 626 sounds like a bit different case so a sample XML log would
be needed to ensure that use case gets fixed.

See #626

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2014-07-16 06:20:21 +03:00 committed by Dirk Hohndel
parent c02cc33fc8
commit 5a34261fec

View file

@ -38,11 +38,39 @@
<PARTNER> <PARTNER>
<xsl:value-of select="buddy"/> <xsl:value-of select="buddy"/>
</PARTNER> </PARTNER>
<!-- If there is a gas change event within the first few seconds
then we try to detect matching cylinder, otherwise the first
cylinder is used.
-->
<xsl:variable name="time">
<xsl:call-template name="time2sec">
<xsl:with-param name="time">
<xsl:value-of select="event[@name = 'gaschange']/@time"/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="mix">
<xsl:value-of select="concat(event[@name = 'gaschange']/@value, '.0%')"/>
</xsl:variable>
<xsl:variable name="cylinder">
<xsl:choose>
<xsl:when test="$time &lt; 60">
<xsl:value-of select="count(cylinder[@o2 = $mix]/preceding-sibling::cylinder) + 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<CYLINDERDESCRIPTION> <CYLINDERDESCRIPTION>
<xsl:value-of select="cylinder/@description"/> <xsl:value-of select="cylinder[position() = $cylinder]/@description"/>
</CYLINDERDESCRIPTION> </CYLINDERDESCRIPTION>
<CYLINDERSIZE> <CYLINDERSIZE>
<xsl:value-of select="substring-before(cylinder/@size, ' ')"/> <xsl:value-of select="substring-before(cylinder[position() = $cylinder]/@size, ' ')"/>
</CYLINDERSIZE> </CYLINDERSIZE>
<CYLINDERSTARTPRESSURE> <CYLINDERSTARTPRESSURE>
<xsl:choose> <xsl:choose>
@ -50,7 +78,7 @@
<xsl:value-of select="substring-before(node()/sample/@pressure, ' ')"/> <xsl:value-of select="substring-before(node()/sample/@pressure, ' ')"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="cylinder[1]/@start"/> <xsl:value-of select="cylinder[position() = $cylinder]/@start"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</CYLINDERSTARTPRESSURE> </CYLINDERSTARTPRESSURE>
@ -60,10 +88,11 @@
<xsl:value-of select="node()/sample[@pressure][last()]/@pressure"/> <xsl:value-of select="node()/sample[@pressure][last()]/@pressure"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="cylinder[1]/@end"/> <xsl:value-of select="cylinder[$cylinder]/@end"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</CYLINDERENDPRESSURE> </CYLINDERENDPRESSURE>
<WEIGHT> <WEIGHT>
<xsl:call-template name="sum"> <xsl:call-template name="sum">
<xsl:with-param name="values" select="weightsystem/@weight"/> <xsl:with-param name="values" select="weightsystem/@weight"/>