Skip to content

Commit

Permalink
Merge pull request #276 from suchitalad/xcosblocks
Browse files Browse the repository at this point in the history
Updated xcos blocks files for step function
  • Loading branch information
sunilshetye authored Jan 8, 2025
2 parents 99bd66c + d4e1b60 commit 300edc2
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 7 deletions.
2 changes: 1 addition & 1 deletion blocks/Xcos/blocks/CLOCK_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def CLOCK_c(outroot, attribid, ordering, geometry, parameters, parent=1, style=N
dataLines="-1", initialState="0.0",
style="ControlPort", value="")

EVTDLY_c(root, block_id[3], ordering, geometry, parameters, parent=block_id[1])
EVTDLY_c(root, block_id[3], ordering, geometry, ['0.0001', '0'], parent=block_id[1])

addPort(root, TYPE_CNTRL, id=port_id[1],
parent=block_id[3], ordering="1",
Expand Down
2 changes: 1 addition & 1 deletion blocks/Xcos/blocks/DELAY_f.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def DELAY_f(outroot, attribid, ordering, geometry, parameters, parent=1, style=N
style="ExplicitOutputPort;align=right;verticalAlign=middle;spacing=10.0;rotation=0",
value="")

OUT_f(root, block_id[3], ordering, geometry, parameters)
OUT_f(root, block_id[3], ordering, geometry, ['1'])

REGISTER_f(root, block_id[4], ordering, geometry, parameters)

Expand Down
2 changes: 1 addition & 1 deletion blocks/Xcos/blocks/OUT_f.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def OUT_f(outroot, attribid, ordering, geometry, parameters, parent=1, style=Non
style, BLOCKTYPE_C, dependsOnU='0',
dependsOnT='0')

addExprsNode(outnode, TYPE_STRING, 1, parameters[0])
addExprsNode(outnode, TYPE_STRING, 1, parameters)
addTypeNode(outnode, TYPE_DOUBLE, AS_REAL_PARAM, 0,
[])
array = ['1']
Expand Down
2 changes: 1 addition & 1 deletion blocks/Xcos/blocks/STEP.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def STEP(outroot, attribid, ordering, geometry, parameters, parent=1, style=None

addExprsNode(outnode, TYPE_STRING, 3, parameters)
addSciDBNode(outnode, TYPE_DOUBLE, AS_REAL_PARAM,
2, realParts=[0.0, 1.0])
2, realParts=[parameters[1], parameters[2]])
addTypeNode(outnode, TYPE_DOUBLE, AS_INT_PARAM, 0, [])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_OBJ_PARAM, parameters)
array = ['0']
Expand Down
2 changes: 1 addition & 1 deletion blocks/Xcos/blocks/STEP_FUNCTION.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def STEP_FUNCTION(outroot, attribid, ordering, geometry, parameters, parent=1, s
dataLines="-1", initialState="0.005",
style="CommandPort", value="")

OUT_f(root, block_id[3], ordering, geometry, parameters, parent=block_id[1])
OUT_f(root, block_id[3], ordering, geometry, ['1'], parent=block_id[1])

adPort(root, TYPE_EXPLICITINPORT, id=port_id[3],
parent=block_id[3], ordering="1",
Expand Down
39 changes: 38 additions & 1 deletion blocks/xcos2xml/blocks/CLOCK_c.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,45 @@
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
<xsl:apply-templates select="node()"/>

<xsl:variable name="value1">
<xsl:choose>
<xsl:when test="SuperBlockDiagram">
<xsl:value-of select="SuperBlockDiagram/mxGraphModel/root
/BasicBlock[@style='EVTDLY_c']
/ScilabString[@height='2' and @width='1']
/data[@column='0' and @line='0']/@value"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="Array[@as='realParameters']
/Array[@scilabClass='ScilabList']
/Array[@scilabClass='ScilabMList']
/Array[@scilabClass='ScilabMList']
/ScilabString[@height='2' and @width='1']
/data[@column='0' and @line='0']/@value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="value2">
<xsl:choose>
<xsl:when test="SuperBlockDiagram">
<xsl:value-of select="SuperBlockDiagram/mxGraphModel/root
/BasicBlock[@style='EVTDLY_c']
/ScilabString[@height='2' and @width='1']
/data[@column='0' and @line='1']/@value"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="Array[@as='realParameters']
/Array[@scilabClass='ScilabList']
/Array[@scilabClass='ScilabMList']
/Array[@scilabClass='ScilabMList']
/ScilabString[@height='2' and @width='1']
/data[@column='0' and @line='1']/@value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<Object display_parameter="" as="displayProperties"/>
<Object p000_value="0.1" p001_value="0.1" as="parameter_values"/>
<Object p000_value="{$value1}" p001_value="{$value2}" as="parameter_values"/>
</xsl:element>
<xsl:call-template name="port">
<xsl:with-param name="id" select="@id"/>
Expand Down
58 changes: 57 additions & 1 deletion blocks/xcos2xml/blocks/STEP_FUNCTION.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,64 @@
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
<xsl:apply-templates select="node()"/>

<xsl:variable name="value1">
<xsl:choose>
<xsl:when test="SuperBlockDiagram">
<xsl:value-of select="SuperBlockDiagram/mxGraphModel/root
/BasicBlock[@style='STEP']
/ScilabString[@height='3' and @width='1']
/data[@column='0' and @line='0']/@value"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="Array[@as='realParameters']
/Array[@scilabClass='ScilabList']
/Array[@scilabClass='ScilabMList']
/Array[@scilabClass='ScilabMList']
/ScilabString[@height='3' and @width='1']
/data[@column='0' and @line='0']/@value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="value2">
<xsl:choose>
<xsl:when test="SuperBlockDiagram">
<xsl:value-of select="SuperBlockDiagram/mxGraphModel/root
/BasicBlock[@style='STEP']
/ScilabString[@height='3' and @width='1']
/data[@column='0' and @line='1']/@value"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="Array[@as='realParameters']
/Array[@scilabClass='ScilabList']
/Array[@scilabClass='ScilabMList']
/Array[@scilabClass='ScilabMList']
/ScilabString[@height='3' and @width='1']
/data[@column='0' and @line='1']/@value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="value3">
<xsl:choose>
<xsl:when test="SuperBlockDiagram">
<xsl:value-of select="SuperBlockDiagram/mxGraphModel/root
/BasicBlock[@style='STEP']
/ScilabString[@height='3' and @width='1']
/data[@column='0' and @line='2']/@value"/>
</xsl:when>

<xsl:otherwise>
<xsl:value-of select="Array[@as='realParameters']
/Array[@scilabClass='ScilabList']
/Array[@scilabClass='ScilabMList']
/Array[@scilabClass='ScilabMList']
/ScilabString[@height='3' and @width='1']
/data[@column='0' and @line='2']/@value"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<Object display_parameter="" as="displayProperties"/>
<Object p000_value="1" p001_value="0" p002_value="1" as="parameter_values"/>
<Object p000_value="{$value1}" p001_value="{$value2}" p002_value="{$value3}" as="parameter_values"/>
</xsl:element>
<xsl:call-template name="port">
<xsl:with-param name="id" select="@id"/>
Expand Down

0 comments on commit 300edc2

Please sign in to comment.