summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuchita Lad2024-07-26 10:54:51 +0530
committerSuchita Lad2024-08-27 13:01:05 +0530
commit4fb4460557cee7b3e2c673df20090b3efc4fee98 (patch)
treeec3e3e838d51d5faa42c98b5b1c82e9148fd081b
parentf86295f41e93313e96cb321ddc07a4d37e58f9e3 (diff)
downloadCommon-Interface-Project-4fb4460557cee7b3e2c673df20090b3efc4fee98.tar.gz
Common-Interface-Project-4fb4460557cee7b3e2c673df20090b3efc4fee98.tar.bz2
Common-Interface-Project-4fb4460557cee7b3e2c673df20090b3efc4fee98.zip
updated files
-rwxr-xr-xblocks/Xcos/MxGraphParser.py30
-rw-r--r--blocks/xcos2xml/links/CommandControlLink.xsl22
-rw-r--r--blocks/xcos2xml/links/ExplicitLink.xsl2
-rw-r--r--blocks/xcos2xml/links/ImplicitLink.xsl22
-rw-r--r--blocks/xcos2xml/ports/port.xsl8
-rw-r--r--blocks/xcos2xml/split.xsl40
6 files changed, 53 insertions, 71 deletions
diff --git a/blocks/Xcos/MxGraphParser.py b/blocks/Xcos/MxGraphParser.py
index 46bf4945..94f2aefe 100755
--- a/blocks/Xcos/MxGraphParser.py
+++ b/blocks/Xcos/MxGraphParser.py
@@ -59,6 +59,7 @@ for root in model:
edgeDict = {}
edgeDict2 = {}
splitList = []
+ mxPointList = {}
for cell in list(root):
try:
attrib = cell.attrib
@@ -78,7 +79,7 @@ for root in model:
continue
cell_type = attrib['CellType']
-
+
if cell_type == 'Component':
style = attrib['style']
componentGeometry = {}
@@ -144,11 +145,24 @@ for root in model:
ordering = len(styleArray)
IDLIST[attribid] = style
globals()[style](outroot, attribid, ParentComponent, ordering, geometry)
+ print("Testing Value: ", attribid, ordering, ParentComponent,geometry)
elif 'edge' in attrib:
+ print(attrib)
+ mxGeometry = cell.find('mxGeometry')
+ print(mxGeometry)
+ array = mxGeometry.find('Array')
+ celid = cell.attrib.get('id')
+ mxPointList[celid] = array
+ print(mxPointList)
+ for points in mxPointList:
+ value = mxPointList[points]
+
+
sourceVertex = attrib['sourceVertex']
targetVertex = attrib['targetVertex']
sourceType = IDLIST[sourceVertex]
targetType = IDLIST[targetVertex]
+ # print("SV:", sourceVertex, "TV:", targetVertex, "ST:", sourceType, "TT:",targetType)
# switch vertices if required
if sourceType in ['ExplicitInputPort', 'ImplicitInputPort', 'ControlPort'] and targetType in ['ExplicitOutputPort', 'ExplicitLink', 'ImplicitOutputPort', 'ImplicitLink', 'CommandPort', 'CommandControlLink']:
@@ -185,22 +199,34 @@ for root in model:
IDLIST[attribid] = style
if addSplit:
+ for a in cell.attrib:
+ print(a, cell.attrib.get(a) )
mxGeometry = cell.find('mxGeometry')
if mxGeometry is not None:
+ for a in mxGeometry.attrib:
+ print(a, mxGeometry.attrib.get(a) )
+ for child in mxGeometry:
+ print(child)
mxPoint = mxGeometry.find('mxPoint')
if mxPoint is not None:
+ for b in mxPoint.attrib:
+ print(b, mxPoint.attrib.get(b))
+ for child in mxPoint:
+ print(child)
geometry = {}
geometry['width'] = mxPoint.attrib.get('width', '7')
geometry['height'] = mxPoint.attrib.get('height', '7')
geometry['x'] = mxPoint.attrib.get('x', '0')
geometry['y'] = mxPoint.attrib.get('y', '0')
-
+ print("Testing Value1: ", geometry)
splitList.append((attribid, sourceVertex, targetVertex, sourceType, targetType, geometry))
try:
+ print("Source",edgeDict[sourceVertex])
del edgeDict[sourceVertex]
except KeyError:
pass
try:
+ print("target",edgeDict[targetVertex])
del edgeDict[targetVertex]
except KeyError:
pass
diff --git a/blocks/xcos2xml/links/CommandControlLink.xsl b/blocks/xcos2xml/links/CommandControlLink.xsl
deleted file mode 100644
index 3433c5d9..00000000
--- a/blocks/xcos2xml/links/CommandControlLink.xsl
+++ /dev/null
@@ -1,22 +0,0 @@
- <xsl:template match="CommandControlLink">
- <xsl:element name="mxCell">
- <xsl:attribute name="id">
- <xsl:value-of select="@id" />
- </xsl:attribute>
- <xsl:attribute name="edge">1</xsl:attribute>
- <xsl:attribute name="sourceVertex">
- <xsl:value-of select="@source" />
- </xsl:attribute>
- <xsl:attribute name="targetVertex">
- <xsl:value-of select="@target" />
- </xsl:attribute>
- <xsl:attribute name="node">.null</xsl:attribute>
- <xsl:attribute name="CellType">Unknown</xsl:attribute>
- <xsl:attribute name="tarx">0</xsl:attribute>
- <xsl:attribute name="tary">0</xsl:attribute>
- <xsl:apply-templates select="node()"/>
- <xsl:apply-templates />
- <Object as="parameter_values"/>
- <Object as="displayProperties"/>
- </xsl:element>
- </xsl:template>
diff --git a/blocks/xcos2xml/links/ExplicitLink.xsl b/blocks/xcos2xml/links/ExplicitLink.xsl
index e1e8d8a1..d7c85dd2 100644
--- a/blocks/xcos2xml/links/ExplicitLink.xsl
+++ b/blocks/xcos2xml/links/ExplicitLink.xsl
@@ -1,4 +1,4 @@
-<xsl:template match="ExplicitLink">
+<xsl:template match="ExplicitLink | CommandControlLink">
<xsl:variable name="sourceId" select="@source" />
<xsl:variable name="sourceParentId" select="//*[@id = $sourceId]/@parent" />
<xsl:variable name="sourceParentName" select="name(//*[@id = $sourceParentId])" />
diff --git a/blocks/xcos2xml/links/ImplicitLink.xsl b/blocks/xcos2xml/links/ImplicitLink.xsl
deleted file mode 100644
index 13c5e046..00000000
--- a/blocks/xcos2xml/links/ImplicitLink.xsl
+++ /dev/null
@@ -1,22 +0,0 @@
- <xsl:template match="ImplicitLink">
- <xsl:element name="mxCell">
- <xsl:attribute name="id">
- <xsl:value-of select="@id" />
- </xsl:attribute>
- <xsl:attribute name="edge">1</xsl:attribute>
- <xsl:attribute name="sourceVertex">
- <xsl:value-of select="@source" />
- </xsl:attribute>
- <xsl:attribute name="targetVertex">
- <xsl:value-of select="@target" />
- </xsl:attribute>
- <xsl:attribute name="node">.null</xsl:attribute>
- <xsl:attribute name="CellType">Unknown</xsl:attribute>
- <xsl:attribute name="tarx">0</xsl:attribute>
- <xsl:attribute name="tary">0</xsl:attribute>
- <xsl:apply-templates select="node()"/>
- <xsl:apply-templates />
- <Object as="parameter_values"/>
- <Object as="displayProperties"/>
- </xsl:element>
- </xsl:template>
diff --git a/blocks/xcos2xml/ports/port.xsl b/blocks/xcos2xml/ports/port.xsl
index 0754d9e1..f6a5422d 100644
--- a/blocks/xcos2xml/ports/port.xsl
+++ b/blocks/xcos2xml/ports/port.xsl
@@ -24,7 +24,7 @@
<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:variable name="numerator" select="2 * number($explicitInputPorts + $implicitInputPorts) - (2 * (position() - 1) + 1)" />
<xsl:attribute name="y">
<xsl:value-of select="$numerator div (2 * number($explicitInputPorts + $implicitInputPorts))"/>
</xsl:attribute>
@@ -52,7 +52,7 @@
<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:variable name="numerator" select="2 * number($explicitOutputPorts + $implicitOutputPorts) - (2 * (position() - 1) + 1)" />
<xsl:attribute name="y">
<xsl:value-of select="$numerator div (2 * number($explicitOutputPorts + $implicitOutputPorts))"/>
</xsl:attribute>
@@ -80,7 +80,7 @@
<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:variable name="numerator" select="2 * number($commandPorts) - (2 * (position() - 1) + 1)" />
<xsl:attribute name="y">
<xsl:value-of select="$numerator div (2 * number($commandPorts))"/>
</xsl:attribute>
@@ -108,7 +108,7 @@
<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:variable name="numerator" select="2 * number($controlPorts) - (2 * (position() - 1) + 1)" />
<xsl:attribute name="y">
<xsl:value-of select="$numerator div (2 * number($controlPorts))"/>
</xsl:attribute>
diff --git a/blocks/xcos2xml/split.xsl b/blocks/xcos2xml/split.xsl
index ba3ef4df..cefd4d58 100644
--- a/blocks/xcos2xml/split.xsl
+++ b/blocks/xcos2xml/split.xsl
@@ -1,7 +1,7 @@
-<xsl:key name="k-input" match="ExplicitInputPort" use="@parent" />
-<xsl:key name="k-output" match="ExplicitOutputPort" use="@parent" />
-<xsl:key name="k-srclink" match="ExplicitLink" use="@source" />
-<xsl:key name="k-tgtlink" match="ExplicitLink" use="@target" />
+<xsl:key name="k-input" match="ExplicitInputPort | ControlPort" use="@parent" />
+<xsl:key name="k-output" match="ExplicitOutputPort | CommandPort" use="@parent" />
+<xsl:key name="k-srclink" match="ExplicitLink | CommandControlLink" use="@source" />
+<xsl:key name="k-tgtlink" match="ExplicitLink | CommandControlLink" use="@target" />
<xsl:template match="SplitBlock">
@@ -18,8 +18,20 @@
<xsl:variable name="geometry" select="mxGeometry" />
<xsl:variable name="x" select="$geometry/@x" />
<xsl:variable name="y" select="$geometry/@y" />
+ <!-- <xsl:variable name="h" select="$geometry/@height" />
+ <xsl:variable name="w" select="$geometry/@width" />
+ <xsl:value-of select="$x" />
+ <xsl:value-of select="$y" />
+ <xsl:value-of select="$h" />
+ <xsl:value-of select="$w" /> -->
<xsl:element name="mxCell">
+ <!-- <xsl:attribute name="test0">
+ <xsl:value-of select="$x" />
+ </xsl:attribute>
+ <xsl:attribute name="test1">
+ <xsl:value-of select="$y" />
+ </xsl:attribute> -->
<xsl:attribute name="id">
<xsl:value-of select="$newidone" />
</xsl:attribute>
@@ -34,12 +46,6 @@
<xsl:attribute name="CellType">Unknown</xsl:attribute>
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
- <xsl:attribute name="testabc">
- <xsl:value-of select="$InputPorts" />
- </xsl:attribute>
- <xsl:attribute name="testabc1">
- <xsl:value-of select="$OutputPorts" />
- </xsl:attribute>
<!-- <xsl:apply-templates select="node()"/> -->
<!-- <xsl:apply-templates /> -->
<mxGeometry relative="1" as="geometry">
@@ -49,10 +55,10 @@
</xsl:for-each>
<xsl:element name="mxPoint">
<xsl:attribute name="x">
- <xsl:value-of select="$x - 4" />
+ <xsl:value-of select="$x" />
</xsl:attribute>
<xsl:attribute name="y">
- <xsl:value-of select="$y - 4" />
+ <xsl:value-of select="$y" />
</xsl:attribute>
</xsl:element>
@@ -71,9 +77,6 @@
<xsl:variable name="sourcetwoid" select="$OutputtwoPort/@id" />
<xsl:variable name="sourcetwolink" select="key('k-srclink', $sourcetwoid)" />
<xsl:element name="mxCell">
- <xsl:attribute name="test0">
- <xsl:value-of select="$sourcetwoid" />
- </xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="generate-id($targetonelink)" />
</xsl:attribute>
@@ -100,9 +103,6 @@
<xsl:variable name="targettwoid" select="$InputtwoPort/@id" />
<xsl:variable name="targettwolink" select="key('k-tgtlink', $targettwoid)" />
<xsl:element name="mxCell">
- <xsl:attribute name="test1">
- <xsl:value-of select="$InputtwoPort/@id" />
- </xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="generate-id($sourceonelink)" />
</xsl:attribute>
@@ -136,7 +136,7 @@
</xsl:choose>
</xsl:template>
- <xsl:template match="ExplicitLink">
+ <xsl:template match="ExplicitLink | CommandControlLink">
<xsl:variable name="sourceId" select="@source"/>
<xsl:variable name="sourceElement" select="//*[@id = $sourceId]"/>
<xsl:variable name="sourceElemId" select="$sourceElement/@parent"/>
@@ -156,7 +156,7 @@
</xsl:choose>
</xsl:template>
- <xsl:template match="ExplicitInputPort | ExplicitOutputPort">
+ <xsl:template match="ExplicitInputPort | ExplicitOutputPort | ControlPort | CommandPort">
<xsl:variable name="parentId" select="@parent"/>
<xsl:variable name="parentElement" select="//*[@id = $parentId]"/>
<xsl:choose>