diff options
author | Suchita Lad | 2024-07-03 16:41:07 +0530 |
---|---|---|
committer | Suchita Lad | 2024-07-03 16:41:07 +0530 |
commit | d0ad318846b72c0b74b50e18ec93b4144256289b (patch) | |
tree | 82e07aeb05f93da25305f660b7a95da85c3b50df | |
parent | 61cccacc01ae379a9a258947012e4f07b5ce46e7 (diff) | |
download | Common-Interface-Project-d0ad318846b72c0b74b50e18ec93b4144256289b.tar.gz Common-Interface-Project-d0ad318846b72c0b74b50e18ec93b4144256289b.tar.bz2 Common-Interface-Project-d0ad318846b72c0b74b50e18ec93b4144256289b.zip |
Updated SUMMATION block file
-rw-r--r-- | blocks/Xcos/blocks/SUMMATION.py | 10 | ||||
-rw-r--r-- | blocks/xcos2xml/blocks/SUMMATION.xsl | 91 | ||||
-rw-r--r-- | blocks/xcos2xml/foot.xsl | 2 | ||||
-rw-r--r-- | blocks/xcos2xml/head.xsl | 6 | ||||
-rw-r--r-- | blocks/xcos2xml/ports/port.xsl | 113 |
5 files changed, 200 insertions, 22 deletions
diff --git a/blocks/Xcos/blocks/SUMMATION.py b/blocks/Xcos/blocks/SUMMATION.py index f94e2b70..04d36618 100644 --- a/blocks/Xcos/blocks/SUMMATION.py +++ b/blocks/Xcos/blocks/SUMMATION.py @@ -20,18 +20,22 @@ def SUMMATION(outroot, attribid, ordering, geometry, parameters): func_name, BLOCKTYPE_C, dependsOnU='1') - addExprsNode(outnode, TYPE_STRING, 1, parameters[1:]) + if len(parameters) == 1: + new_parameters = [1, parameters[0], 0] + else: + new_parameters = parameters + addExprsNode(outnode, TYPE_STRING, 3, new_parameters) addSciDBNode(outnode, TYPE_DOUBLE, AS_REAL_PARAM, 0, []) array = ['1', '-1'] addPrecNode(outnode, TYPE_INTEGER, AS_INT_PARAM, 2, array) - addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_OBJ_PARAM, parameters) + addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_OBJ_PARAM, []) array = ['0'] addPrecisionNode(outnode, TYPE_INTEGER, AS_NBZERO, 1, array) addPrecisionNode(outnode, TYPE_INTEGER, AS_NMODE, 1, array) addTypeNode(outnode, TYPE_DOUBLE, AS_STATE, 0, []) addTypeNode(outnode, TYPE_DOUBLE, AS_DSTATE, 0, []) - addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, parameters) + addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, []) addArrayNode(outnode, scilabClass="ScilabList", **{'as': 'equations'}) diff --git a/blocks/xcos2xml/blocks/SUMMATION.xsl b/blocks/xcos2xml/blocks/SUMMATION.xsl index c8b50c8b..209a7bd8 100644 --- a/blocks/xcos2xml/blocks/SUMMATION.xsl +++ b/blocks/xcos2xml/blocks/SUMMATION.xsl @@ -1,4 +1,50 @@ <xsl:template match="*[@interfaceFunctionName = 'SUMMATION']"> + <xsl:variable name="total" select="(*[@as='exprs']/data)" /> + <xsl:variable name="parameters1"> + <xsl:choose> + <xsl:when test="count($total) = 1">1</xsl:when> + <xsl:otherwise> + <xsl:value-of select="(*[@as='exprs']/data[1]/@value)" /> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="parameters2"> + <xsl:choose> + <xsl:when test="count($total) = 1"> + <xsl:value-of select="(*[@as='exprs']/data[1]/@value)" /> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="(*[@as='exprs']/data[2]/@value)" /> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="parameters3"> + <xsl:choose> + <xsl:when test="count($total) = 1">0</xsl:when> + <xsl:otherwise> + <xsl:value-of select="(*[@as='exprs']/data[3]/@value)" /> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <!-- <xsl:variable name="total1" select="(*[@as='exprs']/data)" /> --> + <!-- <xsl:variable name="value"> + <xsl:value-of select="parameter[1]" /> + </xsl:variable> --> + + <xsl:variable name="explicitInputPorts"> + + <!-- <xsl:variable name="count" select="string-length($parameters2) - string-length(translate($parameters2, ';,', '')) + 1" /> --> + <xsl:value-of select="string-length($parameters2) - string-length(translate($parameters2, ';,', '')) + 1" /> + </xsl:variable> + <xsl:variable name="implicitInputPorts">0</xsl:variable> + <xsl:variable name="explicitOutputPorts">1</xsl:variable> + <xsl:variable name="implicitOutputPorts">0</xsl:variable> + <xsl:variable name="controlPorts">0</xsl:variable> + <xsl:variable name="commandPorts">0</xsl:variable> + <xsl:element name="mxCell"> <xsl:attribute name="style"> <xsl:value-of select="@style" /> @@ -10,21 +56,6 @@ <xsl:attribute name="connectable">0</xsl:attribute> <xsl:attribute name="CellType">Component</xsl:attribute> <xsl:attribute name="blockprefix">XCOS</xsl:attribute> - <!-- <xsl:variable name="explicitInputPorts">2</xsl:variable> --> - <xsl:variable name="explicitInputPorts"> - <xsl:variable name="value" select="(*[@as='exprs']/data/@value)" /> - <xsl:variable name="count" select="string-length($value) - string-length(translate($value, ';,', '')) + 1" /> - <xsl:value-of select="$count" /> - </xsl:variable> - <xsl:variable name="implicitInputPorts">0</xsl:variable> - <xsl:variable name="explicitOutputPorts">1</xsl:variable> - <xsl:variable name="implicitOutputPorts">0</xsl:variable> - <xsl:variable name="controlPorts">0</xsl:variable> - <xsl:variable name="commandPorts">0</xsl:variable> - <xsl:variable name="inputPortNumber">0</xsl:variable> - <xsl:variable name="outputPortNumber">0</xsl:variable> - <xsl:variable name="controlPortNumber">0</xsl:variable> - <xsl:variable name="commandPortNumber">0</xsl:variable> <xsl:attribute name="explicitInputPorts"> <xsl:value-of select="$explicitInputPorts" /> </xsl:attribute> @@ -50,21 +81,43 @@ <xsl:attribute name="targetVertex">0</xsl:attribute> <xsl:attribute name="tarx">0</xsl:attribute> <xsl:attribute name="tary">0</xsl:attribute> + <xsl:apply-templates select="node()"/> <Object> <xsl:attribute name="display_parameter"> - <xsl:value-of select="*[@as='exprs']/data/@value"/> </xsl:attribute> <xsl:attribute name="as">displayProperties</xsl:attribute> </Object> <Object> - <xsl:attribute name="p000_value"> - <xsl:value-of select="*[@as='exprs']/data/@value"/> - </xsl:attribute> + + + <xsl:attribute name="{concat('p000', '_value')}"> + <xsl:value-of select="$parameters1"/> + </xsl:attribute> + <xsl:attribute name="{concat('p001', '_value')}"> + <xsl:value-of select="$parameters2"/> + </xsl:attribute> + <xsl:attribute name="{concat('p002', '_value')}"> + <xsl:value-of select="$parameters3"/> + </xsl:attribute> <xsl:attribute name="as">parameter_values</xsl:attribute> </Object> + </xsl:element> + + <xsl:call-template name="port"> + <xsl:with-param name="id" select="@id"/> + <xsl:with-param name="explicitInputPorts" select="$explicitInputPorts"/> + <xsl:with-param name="explicitOutputPorts" select="$explicitOutputPorts"/> + <xsl:with-param name="implicitInputPorts" select="$implicitInputPorts"/> + <xsl:with-param name="implicitOutputPorts" select="$implicitOutputPorts"/> + <xsl:with-param name="controlPorts" select="$controlPorts"/> + <xsl:with-param name="commandPorts" select="$commandPorts"/> + </xsl:call-template> </xsl:template> + + + diff --git a/blocks/xcos2xml/foot.xsl b/blocks/xcos2xml/foot.xsl index 8a62bcc6..25c82141 100644 --- a/blocks/xcos2xml/foot.xsl +++ b/blocks/xcos2xml/foot.xsl @@ -5,4 +5,6 @@ <xsl:template match="ScilabInteger" /> <xsl:template match="SuperBlockDiagram" /> <xsl:template match="ScilabString" /> + <xsl:template match="ExplicitInputPort" /> + <xsl:template match="ExplicitOutputPort" /> </xsl:stylesheet> diff --git a/blocks/xcos2xml/head.xsl b/blocks/xcos2xml/head.xsl index cb3c3949..926cd266 100644 --- a/blocks/xcos2xml/head.xsl +++ b/blocks/xcos2xml/head.xsl @@ -401,6 +401,12 @@ --> <xsl:output method="xml" indent="no" /> + <xsl:key name="k-in" match="ExplicitInputPort | ImplicitInputPort" use="@parent" /> + <xsl:key name="k-out" match="ExplicitOutputPort | ImplicitOutputPort" use="@parent" /> + <xsl:key name="k-command" match="CommandPort" use="@parent" /> + <xsl:key name="k-control" match="ControlPort" use="@parent" /> + <!-- kcommand kcontrol --> + <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> diff --git a/blocks/xcos2xml/ports/port.xsl b/blocks/xcos2xml/ports/port.xsl new file mode 100644 index 00000000..3aa5d4e1 --- /dev/null +++ b/blocks/xcos2xml/ports/port.xsl @@ -0,0 +1,113 @@ + <xsl:template name="port"> + <xsl:param name="id" /> + <xsl:param name="explicitInputPorts" /> + <xsl:param name="explicitOutputPorts" /> + <xsl:param name="implicitInputPorts" /> + <xsl:param name="implicitOutputPorts" /> + <xsl:param name="controlPorts" /> + <xsl:param name="commandPorts" /> +<xsl:for-each select="key('k-in', @id)"> + <xsl:element name="mxCell"> + <xsl:attribute name="style"> + <xsl:value-of select="name(.)" /> + </xsl:attribute> + <xsl:attribute name="id"> + <xsl:value-of select="@id" /> + </xsl:attribute> + <xsl:attribute name="vertex">1</xsl:attribute> + <xsl:attribute name="CellType">Pin</xsl:attribute> + <xsl:attribute name="ParentComponent"> + <xsl:value-of select="@parent" /> + </xsl:attribute> + <xsl:attribute name="sourceVertex">0</xsl:attribute> + <xsl:attribute name="targetVertex">0</xsl:attribute> + <xsl:attribute name="tarx">0</xsl:attribute> + <xsl:attribute name="tary">0</xsl:attribute> + <mxGeometry x="0" width="8" height="8" relative="1" as="geometry"> + <xsl:variable name="numerator" select="2 * (position() - 1) + 1" /> + <xsl:attribute name="y"> + <xsl:value-of select="$numerator div (2 * number($explicitInputPorts + $implicitInputPorts))"/> + </xsl:attribute> + <mxPoint x="-8" y="-4" as="offset"/> + </mxGeometry> + </xsl:element> + </xsl:for-each> + <xsl:for-each select="key('k-out', @id)"> + <xsl:element name="mxCell"> + <xsl:attribute name="style"> + <xsl:value-of select="name(.)" /> + </xsl:attribute> + <xsl:attribute name="id"> + <xsl:value-of select="@id" /> + </xsl:attribute> + <xsl:attribute name="vertex">1</xsl:attribute> + <xsl:attribute name="CellType">Pin</xsl:attribute> + <xsl:attribute name="ParentComponent"> + <xsl:value-of select="@parent" /> + </xsl:attribute> + <xsl:attribute name="sourceVertex">0</xsl:attribute> + <xsl:attribute name="targetVertex">0</xsl:attribute> + <xsl:attribute name="tarx">0</xsl:attribute> + <xsl:attribute name="tary">0</xsl:attribute> + <mxGeometry x="1" width="8" height="8" relative="1" as="geometry"> + <xsl:variable name="numerator" select="2 * (position() - 1) + 1" /> + <xsl:attribute name="y"> + <xsl:value-of select="$numerator div (2 * number($explicitOutputPorts + $implicitOutputPorts))"/> + </xsl:attribute> + <mxPoint x="0" y="-4" as="offset"/> + </mxGeometry> + </xsl:element> + </xsl:for-each> + <xsl:for-each select="key('k-command', @id)"> + <xsl:element name="mxCell"> + <xsl:attribute name="style"> + <xsl:value-of select="name(.)" /> + </xsl:attribute> + <xsl:attribute name="id"> + <xsl:value-of select="@id" /> + </xsl:attribute> + <xsl:attribute name="vertex">1</xsl:attribute> + <xsl:attribute name="CellType">Pin</xsl:attribute> + <xsl:attribute name="ParentComponent"> + <xsl:value-of select="@parent" /> + </xsl:attribute> + <xsl:attribute name="sourceVertex">0</xsl:attribute> + <xsl:attribute name="targetVertex">0</xsl:attribute> + <xsl:attribute name="tarx">0</xsl:attribute> + <xsl:attribute name="tary">0</xsl:attribute> + <mxGeometry x="0" width="8" height="8" relative="1" as="geometry"> + <xsl:variable name="numerator" select="2 * (position() - 1) + 1" /> + <xsl:attribute name="y"> + <xsl:value-of select="$numerator div (2 * number($commandPorts))"/> + </xsl:attribute> + <mxPoint x="-4" y="0" as="offset"/> + </mxGeometry> + </xsl:element> + </xsl:for-each> + <xsl:for-each select="key('k-control', @id)"> + <xsl:element name="mxCell"> + <xsl:attribute name="style"> + <xsl:value-of select="name(.)" /> + </xsl:attribute> + <xsl:attribute name="id"> + <xsl:value-of select="@id" /> + </xsl:attribute> + <xsl:attribute name="vertex">1</xsl:attribute> + <xsl:attribute name="CellType">Pin</xsl:attribute> + <xsl:attribute name="ParentComponent"> + <xsl:value-of select="@parent" /> + </xsl:attribute> + <xsl:attribute name="sourceVertex">0</xsl:attribute> + <xsl:attribute name="targetVertex">0</xsl:attribute> + <xsl:attribute name="tarx">0</xsl:attribute> + <xsl:attribute name="tary">0</xsl:attribute> + <mxGeometry x="0" width="8" height="8" relative="1" as="geometry"> + <xsl:variable name="numerator" select="2 * (position() - 1) + 1" /> + <xsl:attribute name="y"> + <xsl:value-of select="$numerator div (2 * number($controlPorts))"/> + </xsl:attribute> + <mxPoint x="-4" y="-8" as="offset"/> + </mxGeometry> + </xsl:element> + </xsl:for-each> +</xsl:template>
\ No newline at end of file |