Desktop: Fix the Generation of <switchmix> Elements in the UDDF Export.

Fix the generation of <switchmix> elements in the UDDF export.
Also change the ids of gasmixes to include the helium fraction, and
fractions of a percent, in order to make UDDF export suitable for
technical diving.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2024-01-24 00:41:07 +13:00 committed by Dirk Hohndel
parent 6318a983eb
commit 94a7ba9097
2 changed files with 96 additions and 31 deletions

View file

@ -1,3 +1,4 @@
desktop: fix gas switches in UDDF exports
core: allow of up to 6 O2 sensors (and corresponding voting logic) core: allow of up to 6 O2 sensors (and corresponding voting logic)
desktop: add divemode as a possible dive list column desktop: add divemode as a possible dive list column
profile-widget: Now zomed in profiles can be panned with horizontal scroll. profile-widget: Now zomed in profiles can be panned with horizontal scroll.

View file

@ -5,7 +5,7 @@
<xsl:output method="xml" encoding="utf-8" indent="yes"/> <xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:param name="units" select="units"/> <xsl:param name="units" select="units"/>
<xsl:key name="gases" match="cylinder" use="concat(substring-before(@o2, '.'), '/', substring-before(@he, '.'))" /> <xsl:key name="gases" match="cylinder" use="concat(number(substring-before(@o2, '%')), '/', number(substring-before(@he, '%')))" />
<xsl:key name="images" match="picture" use="concat(../../dive/@number|../dive/@number, ':', @filename, '@', @offset)" /> <xsl:key name="images" match="picture" use="concat(../../dive/@number|../dive/@number, ':', @filename, '@', @offset)" />
<xsl:key name="divecomputer" match="divecomputer" use="@deviceid" /> <xsl:key name="divecomputer" match="divecomputer" use="@deviceid" />
@ -134,15 +134,15 @@
<!-- Define all the unique gases found in the dive log --> <!-- Define all the unique gases found in the dive log -->
<gasdefinitions> <gasdefinitions>
<!-- Get unique gas mixes from all the recorded dives --> <!-- Get unique gas mixes from all the recorded dives -->
<xsl:for-each select="//dive/cylinder[generate-id() = generate-id(key('gases', concat(substring-before(@o2, '.'), '/', substring-before(@he, '.')))[1])]"> <xsl:for-each select="//dive/cylinder[generate-id() = generate-id(key('gases', concat(number(substring-before(@o2, '%')), '/', number(substring-before(@he, '%'))))[1])]">
<xsl:variable name="o2"> <xsl:variable name="o2">
<xsl:choose> <xsl:choose>
<xsl:when test="@o2 != ''"> <xsl:when test="@o2 != ''">
<xsl:value-of select="substring-before(@o2, '.')"/> <xsl:value-of select="number(substring-before(@o2, '%'))"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="'21'"/> <xsl:value-of select="21"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
@ -150,10 +150,10 @@
<xsl:variable name="he"> <xsl:variable name="he">
<xsl:choose> <xsl:choose>
<xsl:when test="@he != ''"> <xsl:when test="@he != ''">
<xsl:value-of select="substring-before(@he, '.')"/> <xsl:value-of select="number(substring-before(@he, '%'))"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="'0'"/> <xsl:value-of select="0"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
@ -163,9 +163,25 @@
just use the same references used internally on just use the same references used internally on
Subsurface. Subsurface.
--> -->
<mix id="mix{$o2}"> <mix id="mix({$o2}/{$he})">
<name> <name>
<xsl:value-of select="concat($o2, '/', $he)"/> <xsl:choose>
<xsl:when test="$he + $o2 &gt; 100">
<xsl:value-of select="concat('Impossible mix: ', $o2, '/', $he)"/>
</xsl:when>
<xsl:when test="$he &gt; 0">
<xsl:value-of select="concat('TMx ', $o2, '/', $he)"/>
</xsl:when>
<xsl:when test="$o2 = 21">
<xsl:value-of select="'air'"/>
</xsl:when>
<xsl:when test="$o2 = 100">
<xsl:value-of select="'oxygen'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('EANx ', $o2)"/>
</xsl:otherwise>
</xsl:choose>
</name> </name>
<o2> <o2>
<xsl:value-of select="format-number($o2 div 100, '0.00')"/> <xsl:value-of select="format-number($o2 div 100, '0.00')"/>
@ -334,19 +350,31 @@
</informationbeforedive> </informationbeforedive>
<xsl:for-each select="cylinder"> <xsl:for-each select="cylinder">
<xsl:variable name="o2">
<xsl:choose>
<xsl:when test="@o2 != ''">
<xsl:value-of select="number(substring-before(@o2, '%'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="21"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="he">
<xsl:choose>
<xsl:when test="@he != ''">
<xsl:value-of select="number(substring-before(@he, '%'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="0"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<tankdata> <tankdata>
<link> <link ref="mix({$o2}/{$he})"/>
<xsl:attribute name="ref">
<xsl:choose>
<xsl:when test="@o2 != ''">
<xsl:value-of select="concat('mix', substring-before(@o2, '.'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'mix21'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</link>
<xsl:if test="@size"> <xsl:if test="@size">
@ -501,11 +529,29 @@
<divetime><xsl:value-of select="$time"/></divetime> <divetime><xsl:value-of select="$time"/></divetime>
<xsl:if test="@name = 'gaschange'"> <xsl:if test="@name = 'gaschange'">
<switchmix> <xsl:variable name="o2">
<xsl:attribute name="ref"> <xsl:choose>
<xsl:value-of select="concat('mix', @value)"/> <xsl:when test="@o2 != ''">
</xsl:attribute> <xsl:value-of select="number(substring-before(@o2, '%'))"/>
</switchmix> </xsl:when>
<xsl:otherwise>
<xsl:value-of select="21"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="he">
<xsl:choose>
<xsl:when test="@he != ''">
<xsl:value-of select="number(substring-before(@he, '%'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="0"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<switchmix ref="mix({$o2}/{$he})"/>
</xsl:if> </xsl:if>
<xsl:if test="@name = 'heading'"> <xsl:if test="@name = 'heading'">
@ -555,12 +601,30 @@
</heading> </heading>
</xsl:for-each> </xsl:for-each>
<xsl:for-each select="preceding-sibling::event[@time = $time and @name='gaschange']/@value"> <xsl:for-each select="preceding-sibling::event[@time = $time and @name='gaschange']">
<switchmix> <xsl:variable name="o2">
<xsl:attribute name="ref"> <xsl:choose>
<xsl:value-of select="concat('mix', .)"/> <xsl:when test="@o2 != ''">
</xsl:attribute> <xsl:value-of select="number(substring-before(@o2, '%'))"/>
</switchmix> </xsl:when>
<xsl:otherwise>
<xsl:value-of select="21"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="he">
<xsl:choose>
<xsl:when test="@he != ''">
<xsl:value-of select="number(substring-before(@he, '%'))"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="0"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<switchmix ref="mix({$o2}/{$he})"/>
</xsl:for-each> </xsl:for-each>
<xsl:if test="./@pressure != ''"> <xsl:if test="./@pressure != ''">