Support timedepth mode on UDCF import

Fixes #756

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-11-11 09:40:40 +08:00 committed by Dirk Hohndel
parent 01441ccb45
commit 116615857c

View file

@ -86,35 +86,78 @@
</cylinder> </cylinder>
</xsl:for-each> </xsl:for-each>
<xsl:variable name="delta" select="SAMPLES/DELTA|samples/delta"/> <xsl:choose>
<!-- gas change --> <!-- samples recorded at irregular internal, but storing time stamp -->
<xsl:for-each select="SAMPLES/SWITCH|samples/switch"> <xsl:when test="timedepthmode">
<event name="gaschange"> <!-- gas change -->
<xsl:variable name="timeSec" select="count(preceding-sibling::D|preceding-sibling::d) * $delta"/> <xsl:for-each select="SAMPLES/SWITCH|samples/switch">
<xsl:attribute name="time"> <event name="gaschange">
<xsl:value-of select="concat(floor($timeSec div 60), ':', <xsl:variable name="timeSec" select="following-sibling::T|following-sibling::t"/>
format-number(floor($timeSec mod 60), '00'), ' min')"/> <xsl:attribute name="time">
</xsl:attribute> <xsl:value-of select="concat(floor($timeSec div 60), ':',
<xsl:attribute name="value"> format-number(floor($timeSec mod 60), '00'), ' min')"/>
<xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2|ancestor::dive/gases/mix[mixname=current()]/o2 * 100" /> </xsl:attribute>
</xsl:attribute> <xsl:attribute name="value">
</event> <xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2|ancestor::dive/gases/mix[mixname=current()]/o2 * 100" />
</xsl:for-each> </xsl:attribute>
<!-- end gas change --> </event>
</xsl:for-each>
<!-- end gas change -->
<xsl:for-each select="SAMPLES/D|samples/d"> <!-- samples -->
<sample> <xsl:for-each select="SAMPLES/D|samples/d">
<xsl:variable name="timeSec" select="(position() - 1) * $delta"/> <sample>
<xsl:attribute name="time"> <xsl:variable name="timeSec" select="preceding-sibling::T[position()=1]|preceding-sibling::t[position()=1]"/>
<xsl:value-of select="concat(floor($timeSec div 60), ':', <xsl:attribute name="time">
format-number(floor($timeSec mod 60), '00'), ' min')"/> <xsl:value-of select="concat(floor($timeSec div 60), ':',
</xsl:attribute> format-number(floor($timeSec mod 60), '00'), ' min')"/>
<xsl:attribute name="depth"> </xsl:attribute>
<xsl:value-of select="concat(., ' m')"/> <xsl:attribute name="depth">
</xsl:attribute> <xsl:value-of select="concat(., ' m')"/>
</sample> </xsl:attribute>
</xsl:for-each> </sample>
</xsl:for-each>
<!-- end samples -->
</xsl:when>
<!-- sample recorded at even internals -->
<xsl:otherwise>
<xsl:variable name="delta" select="SAMPLES/DELTA|samples/delta"/>
<!-- gas change -->
<xsl:for-each select="SAMPLES/SWITCH|samples/switch">
<event name="gaschange">
<xsl:variable name="timeSec" select="count(preceding-sibling::D|preceding-sibling::d) * $delta"/>
<xsl:attribute name="time">
<xsl:value-of select="concat(floor($timeSec div 60), ':',
format-number(floor($timeSec mod 60), '00'), ' min')"/>
</xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="ancestor::DIVE/GASES/MIX[MIXNAME=current()]/O2|ancestor::dive/gases/mix[mixname=current()]/o2 * 100" />
</xsl:attribute>
</event>
</xsl:for-each>
<!-- end gas change -->
<!-- samples -->
<xsl:for-each select="SAMPLES/D|samples/d">
<sample>
<xsl:variable name="timeSec" select="(position() - 1) * $delta"/>
<xsl:attribute name="time">
<xsl:value-of select="concat(floor($timeSec div 60), ':',
format-number(floor($timeSec mod 60), '00'), ' min')"/>
</xsl:attribute>
<xsl:attribute name="depth">
<xsl:value-of select="concat(., ' m')"/>
</xsl:attribute>
</sample>
</xsl:for-each>
<!-- end samples -->
</xsl:otherwise>
</xsl:choose>
</dive> </dive>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>