[PATCH] Fix event/alarm types in UDDF export.

Martin Long martin at longhome.co.uk
Sun Dec 14 15:23:49 PST 2014


UDDF only supports a specific set of alarms. Some events also don't map
to alarms but map to other types of elements in UDDF.

This patch adds a map of the accepted types. Where a map doesn't exist
the type will not be mapped to an alarm, the option then remains to
map it to another kind of element, in the same way that happened with
headings and gas switches.

This removes the need for the specific exclusion of heading and
gas switch, as they are now simply not included in the map.

Signed-off-by: Martin Long <martin at longhome.co.uk>
---
 xslt/uddf-export.xslt | 38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/xslt/uddf-export.xslt b/xslt/uddf-export.xslt
index 89bf6c1..f6f51cf 100644
--- a/xslt/uddf-export.xslt
+++ b/xslt/uddf-export.xslt
@@ -17,6 +17,24 @@
       </xsl:call-template>
     </xsl:for-each>
   </xsl:variable>
+  
+  <xsl:variable name="eventmap">
+    <!--entry key="safety stop (mandatory)"></entry-->
+    <!--entry key="deco"></entry-->
+    <entry key="ascent">ascent</entry><!--Not sure of definitions in our file. Ascent too fast??-->
+    <entry key="violation">deco</entry><!--Assume this is missed deco-->
+    <!--entry key="below floor">error</entry-->
+    <entry key="divetime">rbt</entry>
+    <!--entry key="maxdepth"></entry-->
+    <!--entry key="OLF"></entry-->
+    <!--entry key="PO2"></entry-->
+    <!--entry key="airtime"></entry-->
+    <entry key="ceiling">error</entry>
+    <!--entry key="heading"></entry-->
+    <entry key="surface">surface</entry>
+    <!--entry key="bookmark"></entry-->
+    <entry key="unknown">error</entry>
+  </xsl:variable>
 
 
   <xsl:template match="/divelog/settings"/>
@@ -348,9 +366,12 @@
 
               <xsl:if test="$timesecond != $time">
                 <waypoint>
-                  <xsl:if test="not(@name = 'heading') and not(@name = 'gaschange')">
+                  <xsl:variable name="name">
+                    <xsl:value-of select="@name"/>
+                  </xsl:variable>
+                  <xsl:if test="xt:node-set($eventmap)/entry[@key = $name]">
                     <alarm>
-                      <xsl:value-of select="@name"/>
+                      <xsl:value-of select="xt:node-set($eventmap)/entry[@key = $name]"/>
                     </alarm>
                   </xsl:if>
 
@@ -406,10 +427,15 @@
                   <xsl:value-of select="@time"/>
                 </xsl:variable>
 
-                <xsl:for-each select="preceding-sibling::event[@time = $time and not(@name='heading' or @name='gaschange')]/@name">
-                  <alarm>
-                    <xsl:value-of select="."/>
-                  </alarm>
+                <xsl:for-each select="preceding-sibling::event[@time = $time]">
+                  <xsl:variable name="name">
+                    <xsl:value-of select="@name"/>
+                  </xsl:variable>
+                  <xsl:if test="xt:node-set($eventmap)/entry[@key = $name]">
+                    <alarm>
+                      <xsl:value-of select="xt:node-set($eventmap)/entry[@key = $name]"/>
+                    </alarm>
+                  </xsl:if>
                 </xsl:for-each>
 
                 <depth>
-- 
1.9.1



More information about the subsurface mailing list