Fixed bugs in SFC when loading transition condition and referenced transition or action body
authorLaurent Bessard
Thu, 05 Dec 2013 20:06:19 +0100
changeset 1382 675a6229fc60
parent 1381 8b0a7eceb76d
child 1383 45935812f930
Fixed bugs in SFC when loading transition condition and referenced transition or action body
plcopen/plcopen.py
plcopen/pou_block_instances.xslt
plcopen/pou_block_instances.ysl2
--- a/plcopen/plcopen.py	Thu Dec 05 20:03:27 2013 +0100
+++ b/plcopen/plcopen.py	Thu Dec 05 20:06:19 2013 +0100
@@ -1333,7 +1333,7 @@
     setattr(cls, "getaction", getaction)
     
     def getactionList(self):
-        if self.actions:
+        if self.actions is not None:
             return self.actions.getaction()
         return []
     setattr(cls, "getactionList", getactionList)
--- a/plcopen/pou_block_instances.xslt	Thu Dec 05 20:03:27 2013 +0100
+++ b/plcopen/pou_block_instances.xslt	Thu Dec 05 20:06:19 2013 +0100
@@ -6,7 +6,7 @@
   <xsl:template match="text()">
     <xsl:param name="_indent" select="0"/>
   </xsl:template>
-  <xsl:template match="ppx:pou">
+  <xsl:template match="ppx:pou[ppx:body]|ppx:transition[ppx:body]|ppx:action[ppx:body]">
     <xsl:param name="_indent" select="0"/>
     <xsl:apply-templates select="ppx:body/*[self::ppx:FBD or self::ppx:LD or self::ppx:SFC]/*">
       <xsl:with-param name="_indent" select="$_indent + (1) * $autoindent"/>
@@ -331,11 +331,11 @@
     </xsl:variable>
     <xsl:variable name="condition">
       <xsl:choose>
-        <xsl:when test="ppx:reference">
+        <xsl:when test="ppx:condition/ppx:reference">
           <xsl:value-of select="ppx:condition/ppx:reference/@name"/>
         </xsl:when>
-        <xsl:when test="ppx:inline">
-          <xsl:value-of select="ppx:condition/ppx:inline/ppx:body/ppx:ST/xhtml:p/text()"/>
+        <xsl:when test="ppx:condition/ppx:inline">
+          <xsl:value-of select="ppx:condition/ppx:inline/ppx:ST/xhtml:p/text()"/>
         </xsl:when>
       </xsl:choose>
     </xsl:variable>
--- a/plcopen/pou_block_instances.ysl2	Thu Dec 05 20:03:27 2013 +0100
+++ b/plcopen/pou_block_instances.ysl2	Thu Dec 05 20:06:19 2013 +0100
@@ -7,7 +7,7 @@
     
     template "text()";
     
-    template "ppx:pou" {
+    template "ppx:pou[ppx:body]|ppx:transition[ppx:body]|ppx:action[ppx:body]" {
         apply "ppx:body/*[self::ppx:FBD or self::ppx:LD or self::ppx:SFC]/*";
     }
     
@@ -238,8 +238,8 @@
         }
         variable "condition" {
             choose {
-                when "ppx:reference" > «ppx:condition/ppx:reference/@name»
-                when "ppx:inline" > «ppx:condition/ppx:inline/ppx:body/ppx:ST/xhtml:p/text()»
+                when "ppx:condition/ppx:reference" > «ppx:condition/ppx:reference/@name»
+                when "ppx:condition/ppx:inline" > «ppx:condition/ppx:inline/ppx:ST/xhtml:p/text()»
             }
         }
         value "ns:SetSpecificValues($priority, $condition_type, $condition)";