diff options
author | Sunil Shetye | 2024-09-30 23:10:42 +0530 |
---|---|---|
committer | Sunil Shetye | 2024-09-30 23:10:42 +0530 |
commit | 42f3949786bc931f4096126d2e3d7e240ff75112 (patch) | |
tree | 747c70cea81379de7ce7446454d745239ac9c3dc | |
parent | 4b458d5ca463af2393d4c3a53b52e740b27b8c44 (diff) | |
download | Common-Interface-Project-42f3949786bc931f4096126d2e3d7e240ff75112.tar.gz Common-Interface-Project-42f3949786bc931f4096126d2e3d7e240ff75112.tar.bz2 Common-Interface-Project-42f3949786bc931f4096126d2e3d7e240ff75112.zip |
cleanup xsl code
-rw-r--r-- | blocks/Xcos/blocks/ANDBLK.py | 2 | ||||
-rw-r--r-- | blocks/eda-frontend/public/splitblock.xsl | 106 | ||||
-rw-r--r-- | blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js | 2 | ||||
-rw-r--r-- | blocks/xcos2xml/head.xsl | 2 | ||||
-rw-r--r-- | blocks/xcos2xml/ports/port.xsl | 2 |
5 files changed, 56 insertions, 58 deletions
diff --git a/blocks/Xcos/blocks/ANDBLK.py b/blocks/Xcos/blocks/ANDBLK.py index b5136f17..c80ef06b 100644 --- a/blocks/Xcos/blocks/ANDBLK.py +++ b/blocks/Xcos/blocks/ANDBLK.py @@ -96,7 +96,7 @@ def ANDBLK(outroot, attribid, ordering, geometry, parameters): dataLines="-1", initialState="0.0", style="CommandPort", value="") - CLKOUT_f(root, block_id[4], ordering, geometry, ['2']) + CLKOUT_f(root, block_id[4], ordering, geometry, ['1']) addPort(root, TYPE_CNTRL, id=port_id[4], parent=block_id[4], ordering="1", diff --git a/blocks/eda-frontend/public/splitblock.xsl b/blocks/eda-frontend/public/splitblock.xsl index 79e00460..405ccd63 100644 --- a/blocks/eda-frontend/public/splitblock.xsl +++ b/blocks/eda-frontend/public/splitblock.xsl @@ -30,22 +30,25 @@ <xsl:param name="y" /> <xsl:param name="parent" /> - <xsl:variable name="newidone" select="generate-id()" /> <xsl:variable name="newidtwo" select="generate-id($targetonelink)" /> <xsl:element name="{$linktype}"> <xsl:attribute name="id"> - <xsl:value-of select="$newidone" /> + <xsl:value-of select="$newidone" /> + </xsl:attribute> + <xsl:attribute name="parent"> + <xsl:value-of select="$parent" /> </xsl:attribute> - <xsl:attribute name="parent"><xsl:value-of select="$parent" /></xsl:attribute> <xsl:attribute name="source"> <xsl:value-of select="$targetonelink/@source" /> </xsl:attribute> <xsl:attribute name="target"> <xsl:value-of select="$sourceonelink/@target" /> </xsl:attribute> - <xsl:attribute name="style">ExplicitLink</xsl:attribute> + <xsl:attribute name="style"> + <xsl:value-of select="$linktype" /> + </xsl:attribute> <xsl:attribute name="value"></xsl:attribute> <mxGeometry relative="1" as="geometry"> <Array as="points"> @@ -63,14 +66,18 @@ <xsl:attribute name="id"> <xsl:value-of select="$newidtwo" /> </xsl:attribute> - <xsl:attribute name="parent"><xsl:value-of select="$parent" /></xsl:attribute> + <xsl:attribute name="parent"> + <xsl:value-of select="$parent" /> + </xsl:attribute> <xsl:attribute name="source"> <xsl:value-of select="$sourcetwolink/@target" /> </xsl:attribute> <xsl:attribute name="target"> <xsl:value-of select="$newidone" /> </xsl:attribute> - <xsl:attribute name="style">ExplicitLink</xsl:attribute> + <xsl:attribute name="style"> + <xsl:value-of select="$linktype" /> + </xsl:attribute> <xsl:attribute name="value"></xsl:attribute> <mxGeometry relative="1" as="geometry"> <mxPoint> @@ -90,32 +97,28 @@ </mxGeometry> </xsl:element> <!-- foreach loop, link copy, source change --> - <xsl:for-each select="$sourceonesecondlink"> + <xsl:for-each select="$targetonesecondlink"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:attribute name="target"> <xsl:value-of select="$newidone" /> </xsl:attribute> - - </xsl:copy> </xsl:for-each> - <xsl:for-each select="$sourcetwosecondlink"> + <xsl:for-each select="$sourceonesecondlink"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:attribute name="target"> - <xsl:value-of select="$newidtwo" /> + <xsl:value-of select="$newidone" /> </xsl:attribute> - </xsl:copy> </xsl:for-each> - <xsl:for-each select="$targetonesecondlink"> + <xsl:for-each select="$sourcetwosecondlink"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:attribute name="target"> - <xsl:value-of select="$newidone" /> + <xsl:value-of select="$newidtwo" /> </xsl:attribute> - </xsl:copy> </xsl:for-each> </xsl:template> @@ -133,18 +136,10 @@ <xsl:variable name="x" select="$geometry/@x" /> <xsl:variable name="y" select="$geometry/@y" /> <xsl:variable name="parent" select="@parent" /> - <xsl:element name="TEST"> - <xsl:attribute name="ABC1"> - <xsl:value-of select="$x" /> - </xsl:attribute> - <xsl:attribute name="ABC2"> - <xsl:value-of select="$y" /> - </xsl:attribute> - </xsl:element> - <xsl:choose> <xsl:when test="count($InputPort) >= 1 and count($OutputPort) >= 2"> + <xsl:variable name="linktype">ExplicitLink</xsl:variable> <xsl:variable name="targetoneid" select="$InputPort[position()=1]/@id" /> <xsl:variable name="sourceoneid" select="$OutputPort[position()=1]/@id" /> <xsl:variable name="sourcetwoid" select="$OutputPort[position()=2]/@id" /> @@ -154,7 +149,6 @@ <xsl:variable name="targetonesecondlink" select="key('k-srclink', $targetonelink/@id)" /> <xsl:variable name="sourceonesecondlink" select="key('k-tgtlink', $sourceonelink/@id)" /> <xsl:variable name="sourcetwosecondlink" select="key('k-tgtlink', $sourcetwolink/@id)" /> - <xsl:variable name="linktype">ExplicitLink</xsl:variable> <xsl:call-template name="links"> <xsl:with-param name="linktype" select="$linktype"/> @@ -167,24 +161,29 @@ <xsl:with-param name="x" select="$x"/> <xsl:with-param name="y" select="$y"/> <xsl:with-param name="parent" select="$parent"/> - - </xsl:call-template> </xsl:when> <xsl:when test="count($ControlPort) >= 1 and count($CommandPort) >= 2"> + <xsl:variable name="linktype">ImplicitLink</xsl:variable> <xsl:variable name="targetcommandoneid" select="$ControlPort[position()=1]/@id" /> <xsl:variable name="sourcecommandoneid" select="$CommandPort[position()=1]/@id" /> <xsl:variable name="sourcecommandtwoid" select="$CommandPort[position()=2]/@id" /> <xsl:variable name="targetcommandonelink" select="key('k-commandtgtlink', $targetcommandoneid)" /> <xsl:variable name="sourcecommandonelink" select="key('k-commandsrclink', $sourcecommandoneid)" /> <xsl:variable name="sourcecommandtwolink" select="key('k-commandsrclink', $sourcecommandtwoid)" /> + <xsl:variable name="targetonesecondlink" select="key('k-commandsrclink', $targetcommandonelink/@id)" /> + <xsl:variable name="sourceonesecondlink" select="key('k-commandtgtlink', $sourcecommandonelink/@id)" /> + <xsl:variable name="sourcetwosecondlink" select="key('k-commandtgtlink', $sourcecommandtwolink/@id)" /> <xsl:call-template name="links"> - <xsl:with-param name="linktype" select="ImplicitLink"/> + <xsl:with-param name="linktype" select="$linktype"/> <xsl:with-param name="targetonelink" select="$targetcommandonelink"/> <xsl:with-param name="sourceonelink" select="$sourcecommandonelink"/> <xsl:with-param name="sourcetwolink" select="$sourcecommandtwolink"/> + <xsl:with-param name="targetonesecondlink" select="$targetonesecondlink"/> + <xsl:with-param name="sourceonesecondlink" select="$sourceonesecondlink"/> + <xsl:with-param name="sourcetwosecondlink" select="$sourcetwosecondlink"/> <xsl:with-param name="x" select="$x"/> <xsl:with-param name="y" select="$y"/> <xsl:with-param name="parent" select="$parent"/> @@ -192,18 +191,25 @@ </xsl:when> <xsl:when test="count($ImplicitPort) >= 3"> + <xsl:variable name="linktype">CommandControlLink</xsl:variable> <xsl:variable name="targetimplicitoneid" select="$ImplicitPort[position()=1]/@id" /> <xsl:variable name="sourceimplicitoneid" select="$ImplicitPort[position()=2]/@id" /> <xsl:variable name="sourceimplicittwoid" select="$ImplicitPort[position()=3]/@id" /> <xsl:variable name="targetimplicitonelink" select="key('k-implicitsrclink', $targetimplicitoneid)" /> <xsl:variable name="sourceimplicitonelink" select="key('k-implicitsrclink', $sourceimplicitoneid)" /> <xsl:variable name="sourceimplicittwolink" select="key('k-implicitsrclink', $sourceimplicittwoid)" /> + <xsl:variable name="targetonesecondlink" select="key('k-implicitsrclink', $targetimplicitonelink/@id)" /> + <xsl:variable name="sourceonesecondlink" select="key('k-implicitsrclink', $sourceimplicitonelink/@id)" /> + <xsl:variable name="sourcetwosecondlink" select="key('k-implicitsrclink', $sourceimplicittwolink/@id)" /> <xsl:call-template name="links"> - <xsl:with-param name="linktype" select="CommandControlLink"/> + <xsl:with-param name="linktype" select="$linktype"/> <xsl:with-param name="targetonelink" select="$targetimplicitonelink"/> <xsl:with-param name="sourceonelink" select="$sourceimplicitonelink"/> <xsl:with-param name="sourcetwolink" select="$sourceimplicittwolink"/> + <xsl:with-param name="targetonesecondlink" select="$targetonesecondlink"/> + <xsl:with-param name="sourceonesecondlink" select="$sourceonesecondlink"/> + <xsl:with-param name="sourcetwosecondlink" select="$sourcetwosecondlink"/> <xsl:with-param name="x" select="$x"/> <xsl:with-param name="y" select="$y"/> <xsl:with-param name="parent" select="$parent"/> @@ -212,7 +218,18 @@ </xsl:choose> </xsl:template> - + <xsl:template match="ExplicitInputPort | ExplicitOutputPort | ImplicitInputPort | ImplicitOutputPort | ControlPort | CommandPort"> + <xsl:variable name="parentId" select="@parent"/> + <xsl:variable name="SPLIT" select="//SplitBlock[position() = 1]"/> + + <xsl:choose> + <xsl:when test="$parentId != $SPLIT/@id" > + <xsl:copy> + <xsl:copy-of select="@*"/> + </xsl:copy> + </xsl:when> + </xsl:choose> + </xsl:template> <xsl:template match="ExplicitLink | CommandControlLink | ImplicitLink"> <xsl:variable name="sourceId" select="@source"/> @@ -227,37 +244,18 @@ <xsl:variable name="tgtsrc" select="//*[@id = $targetElement/@source]"/> <xsl:variable name="tgtsrcid" select="$tgtsrc/@parent"/> <xsl:element name="DEF"> - <xsl:attribute name="TESTABC"> - <xsl:value-of select="$tgtsrcid" /> - </xsl:attribute> + <xsl:attribute name="TESTABC"> + <xsl:value-of select="$tgtsrcid" /> + </xsl:attribute> </xsl:element> <xsl:choose> <xsl:when test="$sourceElemId != $SPLITLINK/@id and $targetElemId != $SPLITLINK/@id and $tgtsrcid != $SPLITLINK/@id"> - <!-- Copy the link element and its attributes only if it should not be removed --> - <xsl:copy> - <xsl:copy-of select="@*"/> - <xsl:copy-of select="node()"/> - </xsl:copy> - </xsl:when> - </xsl:choose> - </xsl:template> - - <xsl:template match="ExplicitInputPort | ExplicitOutputPort | ImplicitInputPort | ImplicitOutputPort | ControlPort | CommandPort"> - <xsl:variable name="parentId" select="@parent"/> - <xsl:variable name="parentElement" select="//*[@id = $parentId]"/> - <xsl:variable name="PortId" select="@id"/> - <xsl:variable name="SPLIT" select="//SplitBlock[position() = 1]"/> - - <xsl:choose> - <xsl:when test="$parentId != $SPLIT/@id" > - + <!-- Copy the link element and its attributes only if it should not be removed --> <xsl:copy> <xsl:copy-of select="@*"/> + <xsl:copy-of select="node()"/> </xsl:copy> </xsl:when> </xsl:choose> - </xsl:template> - - </xsl:stylesheet> diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js index fc42b313..ee8f5dbc 100644 --- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js +++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js @@ -412,7 +412,7 @@ function parseXmlToGraph (xmlDoc, graph) { v1.implicitOutputPorts = 0 v1.controlPorts = 0 v1.commandPorts = 0 - v1.simulationFunction = cellAttrs.simulationFunction.value + v1.simulationFunction = cellAttrs.simulationFunction?.value } else if (cellAttrs.CellType?.value === 'Pin') { const style = cellAttrs.style.value.replace(/;.*/, '') const vertexId = cellAttrs.id.value diff --git a/blocks/xcos2xml/head.xsl b/blocks/xcos2xml/head.xsl index 24fa4566..b06416da 100644 --- a/blocks/xcos2xml/head.xsl +++ b/blocks/xcos2xml/head.xsl @@ -405,7 +405,7 @@ <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" /> - + <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 index 31016a5e..08bfa0ad 100644 --- a/blocks/xcos2xml/ports/port.xsl +++ b/blocks/xcos2xml/ports/port.xsl @@ -37,7 +37,7 @@ <Object as="parameter_values"/> <Object as="displayProperties"/> </xsl:element> - </xsl:for-each> + </xsl:for-each> <xsl:for-each select="key('k-out', $id)"> <xsl:element name="mxCell"> <xsl:attribute name="style"> |