IDE: Add a "Tutorials and Examples" sub menu to "File" menu to directly open projects in /exemples directory. Move 'python' and 'first_steps' projecvts from /tests to /exemple
--- a/.hgignore Mon Sep 13 17:57:47 2021 +0200
+++ b/.hgignore Mon Sep 13 22:23:14 2021 +0200
@@ -9,6 +9,7 @@
syntax: regexp
^tests/.*/build$
+^exemples/.*/build$
^.idea/.*
syntax: regexp
^.*\.pyc$
--- a/BeremizIDE.py Mon Sep 13 17:57:47 2021 +0200
+++ b/BeremizIDE.py Mon Sep 13 22:23:14 2021 +0200
@@ -241,6 +241,7 @@
def _init_utils(self):
self.ConfNodeMenu = wx.Menu(title='')
self.RecentProjectsMenu = wx.Menu(title='')
+ self.TutorialsProjectsMenu = wx.Menu(title='')
IDEFrame._init_utils(self)
@@ -251,6 +252,28 @@
kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O')
parent.AppendMenu(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu)
parent.AppendSeparator()
+ parent.Append(wx.ID_ANY, _("&Tutorials and Examples"), self.TutorialsProjectsMenu)
+
+ exemples_dir = Bpath("exemples")
+ project_list = sorted(os.listdir(exemples_dir))
+
+ for idx, dirname in enumerate(project_list):
+ text = u'&%d: %s' % (idx + 1, dirname)
+
+ item = self.TutorialsProjectsMenu.Append(wx.ID_ANY, text, '')
+
+ projectpath = os.path.join(exemples_dir, dirname)
+
+ def OpenExemple(event):
+ if self.CTR is not None and not self.CheckSaveBeforeClosing():
+ return
+
+ self.OpenProject(projectpath)
+ if not self.CTR.CheckProjectPathPerm():
+ self.ResetView()
+
+ self.Bind(wx.EVT_MENU, OpenExemple, item)
+ parent.AppendSeparator()
AppendMenu(parent, help='', id=wx.ID_SAVE,
kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S')
AppendMenu(parent, help='', id=wx.ID_SAVEAS,
--- a/ConfigTreeNode.py Mon Sep 13 17:57:47 2021 +0200
+++ b/ConfigTreeNode.py Mon Sep 13 22:23:14 2021 +0200
@@ -194,7 +194,7 @@
os.mkdir(self.CTNPath())
def CTNRequestSave(self, from_project_path=None):
- if self.GetCTRoot().CheckProjectPathPerm(False):
+ if self.GetCTRoot().CheckProjectPathPerm():
# If confnode do not have corresponding directory
ctnpath = self.CTNPath()
if not os.path.isdir(ctnpath):
--- a/ProjectController.py Mon Sep 13 17:57:47 2021 +0200
+++ b/ProjectController.py Mon Sep 13 22:23:14 2021 +0200
@@ -402,7 +402,7 @@
return res
# helper func to check project path write permission
- def CheckProjectPathPerm(self, dosave=True):
+ def CheckProjectPathPerm(self):
if CheckPathPerm(self.ProjectPath):
return True
if self.AppFrame is not None:
@@ -577,7 +577,7 @@
return True
def SaveProject(self, from_project_path=None):
- if self.CheckProjectPathPerm(False):
+ if self.CheckProjectPathPerm():
if from_project_path is not None:
old_projectfiles_path = self._getProjectFilesPath(
from_project_path)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/first_steps/beremiz.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,5 @@
+<?xml version='1.0' encoding='utf-8'?>
+<BeremizRoot xmlns:xsd="http://www.w3.org/2001/XMLSchema" URI_location="LOCAL://">
+ <TargetType/>
+ <Libraries Enable_Python_Library="false"/>
+</BeremizRoot>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/first_steps/plc.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,1160 @@
+<?xml version='1.0' encoding='utf-8'?>
+<project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
+ <fileHeader companyName="Beremiz" productName="Beremiz" productVersion="1" creationDateTime="2016-10-24T18:09:22"/>
+ <contentHeader name="First Steps" modificationDateTime="2018-09-26T12:52:51">
+ <coordinateInfo>
+ <fbd>
+ <scaling x="0" y="0"/>
+ </fbd>
+ <ld>
+ <scaling x="0" y="0"/>
+ </ld>
+ <sfc>
+ <scaling x="0" y="0"/>
+ </sfc>
+ </coordinateInfo>
+ </contentHeader>
+ <types>
+ <dataTypes/>
+ <pous>
+ <pou name="AverageVal" pouType="function">
+ <interface>
+ <returnType>
+ <REAL/>
+ </returnType>
+ <inputVars>
+ <variable name="Cnt1">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Cnt2">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Cnt3">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Cnt4">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Cnt5">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </inputVars>
+ <localVars>
+ <variable name="InputsNumber">
+ <type>
+ <REAL/>
+ </type>
+ <initialValue>
+ <simpleValue value="5.0"/>
+ </initialValue>
+ <documentation>
+ <xhtml:p><![CDATA[Количество входных значений]]></xhtml:p>
+ </documentation>
+ </variable>
+ </localVars>
+ </interface>
+ <body>
+ <ST>
+ <xhtml:p><![CDATA[AverageVal := INT_TO_REAL(Cnt1+Cnt2+Cnt3+Cnt4+Cnt5)/InputsNumber;]]></xhtml:p>
+ </ST>
+ </body>
+ </pou>
+ <pou name="plc_prg" pouType="program">
+ <interface>
+ <inputVars>
+ <variable name="Reset">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ </inputVars>
+ <outputVars>
+ <variable name="Cnt1">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Cnt2">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Cnt3">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Cnt4">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Cnt5">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </outputVars>
+ <localVars>
+ <variable name="CounterST0">
+ <type>
+ <derived name="CounterST"/>
+ </type>
+ </variable>
+ <variable name="CounterFBD0">
+ <type>
+ <derived name="CounterFBD"/>
+ </type>
+ </variable>
+ <variable name="CounterSFC0">
+ <type>
+ <derived name="CounterSFC"/>
+ </type>
+ </variable>
+ <variable name="CounterIL0">
+ <type>
+ <derived name="CounterIL"/>
+ </type>
+ </variable>
+ <variable name="CounterLD0">
+ <type>
+ <derived name="CounterLD"/>
+ </type>
+ </variable>
+ <variable name="AVCnt">
+ <type>
+ <REAL/>
+ </type>
+ </variable>
+ </localVars>
+ </interface>
+ <body>
+ <FBD>
+ <block localId="1" typeName="CounterST" instanceName="CounterST0" executionOrderId="0" height="60" width="125">
+ <position x="207" y="53"/>
+ <inputVariables>
+ <variable formalParameter="Reset">
+ <connectionPointIn>
+ <relPosition x="0" y="40"/>
+ <connection refLocalId="2">
+ <position x="207" y="93"/>
+ <position x="114" y="93"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="125" y="40"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="2" executionOrderId="0" height="30" width="79" negated="false">
+ <position x="35" y="78"/>
+ <connectionPointOut>
+ <relPosition x="79" y="15"/>
+ </connectionPointOut>
+ <expression>Reset</expression>
+ </inVariable>
+ <block localId="4" typeName="CounterFBD" instanceName="CounterFBD0" executionOrderId="0" height="54" width="121">
+ <position x="211" y="146"/>
+ <inputVariables>
+ <variable formalParameter="Reset">
+ <connectionPointIn>
+ <relPosition x="0" y="37"/>
+ <connection refLocalId="13">
+ <position x="211" y="183"/>
+ <position x="115" y="183"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="121" y="37"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <comment localId="6" height="365" width="569">
+ <position x="620" y="130"/>
+ <content>
+ <xhtml:p><![CDATA[In this example function block with the same functionality
+is created using all five IEC 61131-3 programing languages:
+- IL;
+- FBD;
+- LD;
+- ST;
+- SFC.
+
+
+
+
+Function block is a counter with reset control input.
+If reset is True counter value is reset to the value defined by
+global configuration constant ResetCounterValue.
+If reset is False, counter is incremented every cycle.
+]]></xhtml:p>
+ </content>
+ </comment>
+ <block localId="7" typeName="CounterSFC" instanceName="CounterSFC0" executionOrderId="0" height="52" width="121">
+ <position x="211" y="237"/>
+ <inputVariables>
+ <variable formalParameter="Reset">
+ <connectionPointIn>
+ <relPosition x="0" y="36"/>
+ <connection refLocalId="12">
+ <position x="211" y="273"/>
+ <position x="103" y="273"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="121" y="36"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <block localId="9" typeName="CounterIL" instanceName="CounterIL0" executionOrderId="0" height="62" width="121">
+ <position x="211" y="322"/>
+ <inputVariables>
+ <variable formalParameter="Reset">
+ <connectionPointIn>
+ <relPosition x="0" y="41"/>
+ <connection refLocalId="10">
+ <position x="211" y="363"/>
+ <position x="101" y="363"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="121" y="41"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="10" executionOrderId="0" height="30" width="67" negated="false">
+ <position x="34" y="348"/>
+ <connectionPointOut>
+ <relPosition x="67" y="15"/>
+ </connectionPointOut>
+ <expression>Reset</expression>
+ </inVariable>
+ <inVariable localId="12" executionOrderId="0" height="30" width="67" negated="false">
+ <position x="36" y="258"/>
+ <connectionPointOut>
+ <relPosition x="67" y="15"/>
+ </connectionPointOut>
+ <expression>Reset</expression>
+ </inVariable>
+ <inVariable localId="13" executionOrderId="0" height="30" width="79" negated="false">
+ <position x="36" y="168"/>
+ <connectionPointOut>
+ <relPosition x="79" y="15"/>
+ </connectionPointOut>
+ <expression>Reset</expression>
+ </inVariable>
+ <block localId="14" typeName="CounterLD" instanceName="CounterLD0" executionOrderId="0" height="62" width="124">
+ <position x="210" y="412"/>
+ <inputVariables>
+ <variable formalParameter="Reset">
+ <connectionPointIn>
+ <relPosition x="0" y="41"/>
+ <connection refLocalId="16">
+ <position x="210" y="453"/>
+ <position x="100" y="453"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="Out">
+ <connectionPointOut>
+ <relPosition x="124" y="41"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="16" executionOrderId="0" height="30" width="64" negated="false">
+ <position x="36" y="438"/>
+ <connectionPointOut>
+ <relPosition x="64" y="15"/>
+ </connectionPointOut>
+ <expression>Reset</expression>
+ </inVariable>
+ <block localId="17" typeName="AverageVal" executionOrderId="0" height="470" width="100">
+ <position x="514" y="28"/>
+ <inputVariables>
+ <variable formalParameter="Cnt1">
+ <connectionPointIn>
+ <relPosition x="0" y="65"/>
+ <connection refLocalId="3">
+ <position x="514" y="93"/>
+ <position x="474" y="93"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="Cnt2">
+ <connectionPointIn>
+ <relPosition x="0" y="155"/>
+ <connection refLocalId="5">
+ <position x="514" y="183"/>
+ <position x="473" y="183"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="Cnt3">
+ <connectionPointIn>
+ <relPosition x="0" y="245"/>
+ <connection refLocalId="8">
+ <position x="514" y="273"/>
+ <position x="472" y="273"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="Cnt4">
+ <connectionPointIn>
+ <relPosition x="0" y="335"/>
+ <connection refLocalId="11">
+ <position x="514" y="363"/>
+ <position x="469" y="363"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="Cnt5">
+ <connectionPointIn>
+ <relPosition x="0" y="425"/>
+ <connection refLocalId="15">
+ <position x="514" y="453"/>
+ <position x="469" y="453"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="100" y="65"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <outVariable localId="18" executionOrderId="0" height="30" width="55" negated="false">
+ <position x="649" y="78"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="17" formalParameter="OUT">
+ <position x="649" y="93"/>
+ <position x="614" y="93"/>
+ </connection>
+ </connectionPointIn>
+ <expression>AVCnt</expression>
+ </outVariable>
+ <inOutVariable localId="3" executionOrderId="0" height="30" width="106" negatedOut="false" negatedIn="false">
+ <position x="368" y="78"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="1" formalParameter="OUT">
+ <position x="368" y="93"/>
+ <position x="332" y="93"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="106" y="15"/>
+ </connectionPointOut>
+ <expression>Cnt1</expression>
+ </inOutVariable>
+ <inOutVariable localId="5" executionOrderId="0" height="30" width="103" negatedOut="false" negatedIn="false">
+ <position x="370" y="168"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="4" formalParameter="OUT">
+ <position x="370" y="183"/>
+ <position x="332" y="183"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="103" y="15"/>
+ </connectionPointOut>
+ <expression>Cnt2</expression>
+ </inOutVariable>
+ <inOutVariable localId="8" executionOrderId="0" height="30" width="97" negatedOut="false" negatedIn="false">
+ <position x="375" y="258"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="7" formalParameter="OUT">
+ <position x="375" y="273"/>
+ <position x="332" y="273"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="97" y="15"/>
+ </connectionPointOut>
+ <expression>Cnt3</expression>
+ </inOutVariable>
+ <inOutVariable localId="11" executionOrderId="0" height="30" width="91" negatedOut="false" negatedIn="false">
+ <position x="378" y="348"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="9" formalParameter="OUT">
+ <position x="378" y="363"/>
+ <position x="332" y="363"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="91" y="15"/>
+ </connectionPointOut>
+ <expression>Cnt4</expression>
+ </inOutVariable>
+ <inOutVariable localId="15" executionOrderId="0" height="30" width="88" negatedOut="false" negatedIn="false">
+ <position x="381" y="438"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="14" formalParameter="Out">
+ <position x="381" y="453"/>
+ <position x="334" y="453"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="88" y="15"/>
+ </connectionPointOut>
+ <expression>Cnt5</expression>
+ </inOutVariable>
+ </FBD>
+ </body>
+ </pou>
+ <pou name="CounterST" pouType="functionBlock">
+ <interface>
+ <inputVars>
+ <variable name="Reset">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ </inputVars>
+ <localVars>
+ <variable name="Cnt">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </localVars>
+ <outputVars>
+ <variable name="OUT">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </outputVars>
+ <externalVars constant="true">
+ <variable name="ResetCounterValue">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </externalVars>
+ </interface>
+ <body>
+ <ST>
+ <xhtml:p><![CDATA[IF Reset THEN
+ Cnt := ResetCounterValue;
+ELSE
+ Cnt := Cnt + 1;
+END_IF;
+
+Out := Cnt;]]></xhtml:p>
+ </ST>
+ </body>
+ </pou>
+ <pou name="CounterFBD" pouType="functionBlock">
+ <interface>
+ <inputVars>
+ <variable name="Reset">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ </inputVars>
+ <outputVars>
+ <variable name="OUT">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </outputVars>
+ <localVars>
+ <variable name="Cnt">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </localVars>
+ <externalVars constant="true">
+ <variable name="ResetCounterValue">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </externalVars>
+ </interface>
+ <body>
+ <FBD>
+ <inVariable localId="1" executionOrderId="0" height="30" width="61" negated="false">
+ <position x="321" y="58"/>
+ <connectionPointOut>
+ <relPosition x="61" y="15"/>
+ </connectionPointOut>
+ <expression>Reset</expression>
+ </inVariable>
+ <outVariable localId="2" executionOrderId="0" height="30" width="39" negated="false">
+ <position x="675" y="137"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="3">
+ <position x="675" y="152"/>
+ <position x="589" y="152"/>
+ </connection>
+ </connectionPointIn>
+ <expression>OUT</expression>
+ </outVariable>
+ <inOutVariable localId="3" executionOrderId="0" height="30" width="37" negatedOut="false" negatedIn="false">
+ <position x="557" y="137"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="7" formalParameter="OUT">
+ <position x="557" y="152"/>
+ <position x="527" y="152"/>
+ <position x="527" y="130"/>
+ <position x="517" y="130"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="37" y="15"/>
+ </connectionPointOut>
+ <expression>Cnt</expression>
+ </inOutVariable>
+ <block localId="4" typeName="ADD" executionOrderId="0" height="80" width="69">
+ <position x="328" y="115"/>
+ <inputVariables>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="35"/>
+ <connection refLocalId="6">
+ <position x="328" y="150"/>
+ <position x="275" y="150"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="65"/>
+ <connection refLocalId="3">
+ <position x="328" y="180"/>
+ <position x="317" y="180"/>
+ <position x="317" y="213"/>
+ <position x="604" y="213"/>
+ <position x="604" y="152"/>
+ <position x="594" y="152"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="69" y="35"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="5" executionOrderId="0" height="30" width="163" negated="false">
+ <position x="222" y="256"/>
+ <connectionPointOut>
+ <relPosition x="163" y="15"/>
+ </connectionPointOut>
+ <expression>ResetCounterValue</expression>
+ </inVariable>
+ <inVariable localId="6" executionOrderId="0" height="30" width="21" negated="false">
+ <position x="254" y="135"/>
+ <connectionPointOut>
+ <relPosition x="21" y="15"/>
+ </connectionPointOut>
+ <expression>1</expression>
+ </inVariable>
+ <block localId="7" typeName="SEL" executionOrderId="0" height="80" width="69">
+ <position x="448" y="100"/>
+ <inputVariables>
+ <variable formalParameter="G">
+ <connectionPointIn>
+ <relPosition x="0" y="30"/>
+ <connection refLocalId="1">
+ <position x="448" y="130"/>
+ <position x="415" y="130"/>
+ <position x="415" y="73"/>
+ <position x="382" y="73"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN0">
+ <connectionPointIn>
+ <relPosition x="0" y="50"/>
+ <connection refLocalId="4" formalParameter="OUT">
+ <position x="448" y="150"/>
+ <position x="397" y="150"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="70"/>
+ <connection refLocalId="5">
+ <position x="448" y="170"/>
+ <position x="414" y="170"/>
+ <position x="414" y="271"/>
+ <position x="385" y="271"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="69" y="30"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ </FBD>
+ </body>
+ </pou>
+ <pou name="CounterSFC" pouType="functionBlock">
+ <interface>
+ <inputVars>
+ <variable name="Reset">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ </inputVars>
+ <outputVars>
+ <variable name="OUT">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </outputVars>
+ <localVars>
+ <variable name="Cnt">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </localVars>
+ <externalVars constant="true">
+ <variable name="ResetCounterValue">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </externalVars>
+ </interface>
+ <actions/>
+ <body>
+ <SFC>
+ <step localId="1" name="Start" initialStep="true" height="34" width="90">
+ <position x="241" y="14"/>
+ <connectionPointOut formalParameter="">
+ <relPosition x="45" y="34"/>
+ </connectionPointOut>
+ </step>
+ <selectionDivergence localId="2" height="1" width="431">
+ <position x="70" y="86"/>
+ <connectionPointIn>
+ <relPosition x="216" y="0"/>
+ <connection refLocalId="1">
+ <position x="286" y="86"/>
+ <position x="286" y="42"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut formalParameter="">
+ <relPosition x="0" y="1"/>
+ </connectionPointOut>
+ <connectionPointOut formalParameter="">
+ <relPosition x="431" y="1"/>
+ </connectionPointOut>
+ </selectionDivergence>
+ <transition localId="3" height="2" width="20">
+ <position x="491" y="132"/>
+ <connectionPointIn>
+ <relPosition x="10" y="0"/>
+ <connection refLocalId="2">
+ <position x="501" y="132"/>
+ <position x="501" y="87"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="10" y="2"/>
+ </connectionPointOut>
+ <condition>
+ <inline name="">
+ <ST>
+ <xhtml:p><![CDATA[Reset]]></xhtml:p>
+ </ST>
+ </inline>
+ </condition>
+ </transition>
+ <transition localId="4" height="2" width="20" executionOrderId="0">
+ <position x="60" y="135"/>
+ <connectionPointIn>
+ <relPosition x="10" y="0"/>
+ <connection refLocalId="2">
+ <position x="70" y="135"/>
+ <position x="70" y="87"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="10" y="2"/>
+ </connectionPointOut>
+ <condition>
+ <inline name="">
+ <ST>
+ <xhtml:p><![CDATA[NOT Reset]]></xhtml:p>
+ </ST>
+ </inline>
+ </condition>
+ </transition>
+ <step localId="5" name="ResetCounter" initialStep="false" height="30" width="134">
+ <position x="434" y="190"/>
+ <connectionPointIn>
+ <relPosition x="67" y="0"/>
+ <connection refLocalId="3">
+ <position x="501" y="190"/>
+ <position x="501" y="134"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut formalParameter="">
+ <relPosition x="67" y="30"/>
+ </connectionPointOut>
+ <connectionPointOutAction formalParameter="">
+ <relPosition x="134" y="15"/>
+ </connectionPointOutAction>
+ </step>
+ <actionBlock localId="6" height="63" width="254">
+ <position x="641" y="190"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="5">
+ <position x="641" y="205"/>
+ <position x="568" y="205"/>
+ </connection>
+ </connectionPointIn>
+ <action localId="0">
+ <relPosition x="0" y="0"/>
+ <inline>
+ <ST>
+ <xhtml:p><![CDATA[Cnt := ResetCounterValue;]]></xhtml:p>
+ </ST>
+ </inline>
+ </action>
+ <action localId="0">
+ <relPosition x="0" y="0"/>
+ <inline>
+ <ST>
+ <xhtml:p><![CDATA[OUT := Cnt;]]></xhtml:p>
+ </ST>
+ </inline>
+ </action>
+ </actionBlock>
+ <step localId="7" name="Count" initialStep="false" height="30" width="85" executionOrderId="0">
+ <position x="28" y="191"/>
+ <connectionPointIn>
+ <relPosition x="42" y="0"/>
+ <connection refLocalId="4">
+ <position x="70" y="191"/>
+ <position x="70" y="137"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut formalParameter="">
+ <relPosition x="42" y="30"/>
+ </connectionPointOut>
+ <connectionPointOutAction formalParameter="">
+ <relPosition x="85" y="15"/>
+ </connectionPointOutAction>
+ </step>
+ <actionBlock localId="8" height="52" width="164" executionOrderId="0">
+ <position x="154" y="191"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="7">
+ <position x="154" y="206"/>
+ <position x="113" y="206"/>
+ </connection>
+ </connectionPointIn>
+ <action localId="0">
+ <relPosition x="0" y="0"/>
+ <inline>
+ <ST>
+ <xhtml:p><![CDATA[Cnt := Cnt + 1;]]></xhtml:p>
+ </ST>
+ </inline>
+ </action>
+ <action localId="0">
+ <relPosition x="0" y="0"/>
+ <inline>
+ <ST>
+ <xhtml:p><![CDATA[OUT := Cnt;]]></xhtml:p>
+ </ST>
+ </inline>
+ </action>
+ </actionBlock>
+ <selectionConvergence localId="10" height="1" width="431">
+ <position x="70" y="273"/>
+ <connectionPointIn>
+ <relPosition x="0" y="0"/>
+ <connection refLocalId="13">
+ <position x="70" y="273"/>
+ <position x="70" y="244"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointIn>
+ <relPosition x="431" y="0"/>
+ <connection refLocalId="14">
+ <position x="501" y="273"/>
+ <position x="501" y="250"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="216" y="1"/>
+ </connectionPointOut>
+ </selectionConvergence>
+ <jumpStep localId="12" targetName="Start" height="13" width="12">
+ <position x="280" y="317"/>
+ <connectionPointIn>
+ <relPosition x="6" y="0"/>
+ <connection refLocalId="10">
+ <position x="286" y="317"/>
+ <position x="286" y="274"/>
+ </connection>
+ </connectionPointIn>
+ </jumpStep>
+ <transition localId="13" height="2" width="20" executionOrderId="0">
+ <position x="60" y="242"/>
+ <connectionPointIn>
+ <relPosition x="10" y="0"/>
+ <connection refLocalId="7">
+ <position x="70" y="242"/>
+ <position x="70" y="215"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="10" y="2"/>
+ </connectionPointOut>
+ <condition>
+ <inline name="">
+ <ST>
+ <xhtml:p><![CDATA[Reset]]></xhtml:p>
+ </ST>
+ </inline>
+ </condition>
+ </transition>
+ <transition localId="14" height="2" width="20" executionOrderId="0">
+ <position x="491" y="248"/>
+ <connectionPointIn>
+ <relPosition x="10" y="0"/>
+ <connection refLocalId="5">
+ <position x="501" y="248"/>
+ <position x="501" y="220"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="10" y="2"/>
+ </connectionPointOut>
+ <condition>
+ <inline name="">
+ <ST>
+ <xhtml:p><![CDATA[NOT Reset]]></xhtml:p>
+ </ST>
+ </inline>
+ </condition>
+ </transition>
+ </SFC>
+ </body>
+ </pou>
+ <pou name="CounterIL" pouType="functionBlock">
+ <interface>
+ <localVars>
+ <variable name="Cnt">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </localVars>
+ <inputVars>
+ <variable name="Reset">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ </inputVars>
+ <outputVars>
+ <variable name="OUT">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </outputVars>
+ <externalVars constant="true">
+ <variable name="ResetCounterValue">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </externalVars>
+ </interface>
+ <body>
+ <IL>
+ <xhtml:p><![CDATA[LD Reset
+JMPC ResetCnt
+
+(* increment counter *)
+LD Cnt
+ADD 1
+JMP QuitFb
+
+ResetCnt:
+(* reset counter *)
+LD ResetCounterValue
+
+QuitFb:
+(* save results *)
+ST Cnt
+ST Out
+]]></xhtml:p>
+ </IL>
+ </body>
+ </pou>
+ <pou name="CounterLD" pouType="functionBlock">
+ <interface>
+ <inputVars>
+ <variable name="Reset">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ </inputVars>
+ <outputVars>
+ <variable name="Out">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </outputVars>
+ <localVars>
+ <variable name="Cnt">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </localVars>
+ <externalVars constant="true">
+ <variable name="ResetCounterValue">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </externalVars>
+ </interface>
+ <body>
+ <LD>
+ <outVariable localId="2" executionOrderId="0" height="30" width="34" negated="false">
+ <position x="527" y="87"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="3">
+ <position x="527" y="102"/>
+ <position x="443" y="102"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Out</expression>
+ </outVariable>
+ <inOutVariable localId="3" executionOrderId="0" height="30" width="34" negatedOut="false" negatedIn="false">
+ <position x="409" y="87"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="7" formalParameter="OUT">
+ <position x="409" y="102"/>
+ <position x="367" y="102"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="34" y="15"/>
+ </connectionPointOut>
+ <expression>Cnt</expression>
+ </inOutVariable>
+ <block localId="4" typeName="ADD" executionOrderId="0" height="80" width="67">
+ <position x="180" y="87"/>
+ <inputVariables>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="35"/>
+ <connection refLocalId="6">
+ <position x="180" y="122"/>
+ <position x="127" y="122"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="65"/>
+ <connection refLocalId="3">
+ <position x="180" y="152"/>
+ <position x="169" y="152"/>
+ <position x="169" y="185"/>
+ <position x="453" y="185"/>
+ <position x="453" y="102"/>
+ <position x="443" y="102"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="67" y="35"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="5" executionOrderId="0" height="30" width="158" negated="false">
+ <position x="74" y="228"/>
+ <connectionPointOut>
+ <relPosition x="158" y="15"/>
+ </connectionPointOut>
+ <expression>ResetCounterValue</expression>
+ </inVariable>
+ <inVariable localId="6" executionOrderId="0" height="30" width="21" negated="false">
+ <position x="106" y="107"/>
+ <connectionPointOut>
+ <relPosition x="21" y="15"/>
+ </connectionPointOut>
+ <expression>1</expression>
+ </inVariable>
+ <block localId="7" typeName="SEL" executionOrderId="0" height="80" width="67">
+ <position x="300" y="72"/>
+ <inputVariables>
+ <variable formalParameter="G">
+ <connectionPointIn>
+ <relPosition x="0" y="30"/>
+ <connection refLocalId="9">
+ <position x="300" y="102"/>
+ <position x="266" y="102"/>
+ <position x="266" y="62"/>
+ <position x="134" y="62"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN0">
+ <connectionPointIn>
+ <relPosition x="0" y="50"/>
+ <connection refLocalId="4" formalParameter="OUT">
+ <position x="300" y="122"/>
+ <position x="247" y="122"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="70"/>
+ <connection refLocalId="5">
+ <position x="300" y="142"/>
+ <position x="266" y="142"/>
+ <position x="266" y="243"/>
+ <position x="232" y="243"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="67" y="30"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <leftPowerRail localId="8" height="40" width="3">
+ <position x="46" y="42"/>
+ <connectionPointOut formalParameter="">
+ <relPosition x="3" y="20"/>
+ </connectionPointOut>
+ </leftPowerRail>
+ <contact localId="9" height="15" width="21" negated="false">
+ <position x="113" y="54"/>
+ <connectionPointIn>
+ <relPosition x="0" y="8"/>
+ <connection refLocalId="8">
+ <position x="113" y="62"/>
+ <position x="49" y="62"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="21" y="8"/>
+ </connectionPointOut>
+ <variable>Reset</variable>
+ </contact>
+ </LD>
+ </body>
+ </pou>
+ </pous>
+ </types>
+ <instances>
+ <configurations>
+ <configuration name="config">
+ <resource name="resource1">
+ <task name="plc_task" priority="1" interval="T#100ms">
+ <pouInstance name="plc_task_instance" typeName="plc_prg"/>
+ </task>
+ </resource>
+ <globalVars constant="true">
+ <variable name="ResetCounterValue">
+ <type>
+ <INT/>
+ </type>
+ <initialValue>
+ <simpleValue value="17"/>
+ </initialValue>
+ </variable>
+ </globalVars>
+ </configuration>
+ </configurations>
+ </instances>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/python/beremiz.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,5 @@
+<?xml version='1.0' encoding='utf-8'?>
+<BeremizRoot URI_location="LOCAL://">
+ <TargetType/>
+ <Libraries Enable_Python_Library="true"/>
+</BeremizRoot>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/python/c_code@c_ext/baseconfnode.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='utf-8'?>
+<BaseParams Name="c_code" IEC_Channel="1"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/python/c_code@c_ext/cfile.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,75 @@
+<?xml version='1.0' encoding='utf-8'?>
+<CFile xmlns:xhtml="http://www.w3.org/1999/xhtml">
+ <includes>
+ <xhtml:p><![CDATA[
+]]></xhtml:p>
+ </includes>
+ <variables>
+ <variable name="TestInput" type="SINT" initial="0"/>
+ <variable name="TestOutput" type="SINT"/>
+ </variables>
+ <globals>
+ <xhtml:p><![CDATA[
+volatile long Lock=0;
+volatile char PtoC=1,CtoP=2;
+
+extern long AtomicCompareExchange(long*,long, long);
+extern char *PLC_ID;
+
+int Simple_C_Call(int val){
+ return val+1;
+}
+
+int Python_to_C_Call(char toC, char *fromC){
+ /* Code called by python should never touch to
+ variables modified by PLC thread directly
+
+ AtomicCompareExchange comes from
+ beremiz' runtime implementation */
+
+ int res = 0;
+ if(!AtomicCompareExchange((long*)&Lock, 0, 1)){
+ PtoC=toC;
+ *fromC=CtoP;
+ AtomicCompareExchange((long*)&Lock, 1, 0);
+ res=1;
+ }
+ printf("C code called by Python: toC %d fromC %d\n",toC,*fromC);
+ printf("PLC_ID id %s\n",PLC_ID);
+ return res;
+}
+
+int PLC_C_Call(char fromPLC, char *toPLC){
+ /* PLC also have to be realy carefull not to
+ conflict with asynchronous python access */
+ if(!AtomicCompareExchange((long*)&Lock, 0, 1)){
+ CtoP = fromPLC;
+ *toPLC = PtoC;
+ AtomicCompareExchange((long*)&Lock, 1, 0);
+ return 1;
+ }
+ return 0;
+}
+]]></xhtml:p>
+ </globals>
+ <initFunction>
+ <xhtml:p><![CDATA[
+]]></xhtml:p>
+ </initFunction>
+ <cleanUpFunction>
+ <xhtml:p><![CDATA[
+]]></xhtml:p>
+ </cleanUpFunction>
+ <retrieveFunction>
+ <xhtml:p><![CDATA[
+]]></xhtml:p>
+ </retrieveFunction>
+ <publishFunction>
+ <xhtml:p><![CDATA[
+if(!AtomicCompareExchange((long*)&Lock, 0, 1)){
+ TestInput = CtoP + PtoC + TestOutput;
+ AtomicCompareExchange((long*)&Lock, 1, 0);
+}
+]]></xhtml:p>
+ </publishFunction>
+</CFile>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/python/c_code@c_ext/confnode.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='utf-8'?>
+<CExtension CFLAGS="" LDFLAGS=""/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/python/plc.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,1644 @@
+<?xml version='1.0' encoding='utf-8'?>
+<project xmlns="http://www.plcopen.org/xml/tc6_0201" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.plcopen.org/xml/tc6_0201">
+ <fileHeader companyName="" productName="Beremiz" productVersion="0.0" creationDateTime="2008-12-14T16:21:19" contentDescription="This example shows many features in Beremiz: 1. How to implement python extensions. 2. How to implement basic C extension. 3. How to use C code in IEC POUs. 4. How to call C functions from python code. 5. How to avoid race conditions between IEC, C and python code. 6. How to convert betweet different IEC types. "/>
+ <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2020-10-19T23:53:08">
+ <coordinateInfo>
+ <pageSize x="1024" y="1024"/>
+ <fbd>
+ <scaling x="5" y="5"/>
+ </fbd>
+ <ld>
+ <scaling x="5" y="5"/>
+ </ld>
+ <sfc>
+ <scaling x="5" y="5"/>
+ </sfc>
+ </coordinateInfo>
+ </contentHeader>
+ <types>
+ <dataTypes>
+ <dataType name="CPLX_TYPE">
+ <baseType>
+ <struct>
+ <variable name="FIRSTBYTE">
+ <type>
+ <SINT/>
+ </type>
+ </variable>
+ <variable name="SECONDBYTE">
+ <type>
+ <SINT/>
+ </type>
+ </variable>
+ </struct>
+ </baseType>
+ </dataType>
+ <dataType name="StateMachine">
+ <baseType>
+ <enum>
+ <values>
+ <value name="STANDBY"/>
+ <value name="START"/>
+ <value name="STOP"/>
+ </values>
+ </enum>
+ </baseType>
+ </dataType>
+ <dataType name="datatype0">
+ <baseType>
+ <BOOL/>
+ </baseType>
+ </dataType>
+ <dataType name="blups">
+ <baseType>
+ <array>
+ <dimension lower="0" upper="31"/>
+ <baseType>
+ <derived name="CPLX_TYPE"/>
+ </baseType>
+ </array>
+ </baseType>
+ </dataType>
+ </dataTypes>
+ <pous>
+ <pou name="main_pytest" pouType="program">
+ <interface>
+ <localVars>
+ <variable name="mux1_sel">
+ <type>
+ <INT/>
+ </type>
+ <initialValue>
+ <simpleValue value="3"/>
+ </initialValue>
+ <documentation>
+ <xhtml:p><![CDATA[blah]]></xhtml:p>
+ </documentation>
+ </variable>
+ <variable name="mux2_sel">
+ <type>
+ <INT/>
+ </type>
+ <initialValue>
+ <simpleValue value="3"/>
+ </initialValue>
+ </variable>
+ <variable name="pytest_var1">
+ <type>
+ <string/>
+ </type>
+ </variable>
+ <variable name="fefvsd">
+ <type>
+ <derived name="datatype0"/>
+ </type>
+ </variable>
+ <variable name="pytest_var2">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ <variable name="py1">
+ <type>
+ <derived name="python_eval"/>
+ </type>
+ </variable>
+ <variable name="Block1">
+ <type>
+ <derived name="python_eval"/>
+ </type>
+ </variable>
+ <variable name="Block2">
+ <type>
+ <derived name="python_eval"/>
+ </type>
+ </variable>
+ <variable name="Block3">
+ <type>
+ <derived name="python_eval"/>
+ </type>
+ </variable>
+ <variable name="pytest_var3">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ <variable name="FromC">
+ <type>
+ <SINT/>
+ </type>
+ </variable>
+ <variable name="C_Pragma0">
+ <type>
+ <derived name="C_Pragma"/>
+ </type>
+ </variable>
+ </localVars>
+ <externalVars>
+ <variable name="TestInput">
+ <type>
+ <SINT/>
+ </type>
+ </variable>
+ <variable name="TestOutput">
+ <type>
+ <SINT/>
+ </type>
+ </variable>
+ </externalVars>
+ <localVars>
+ <variable name="FromInput">
+ <type>
+ <SINT/>
+ </type>
+ </variable>
+ <variable name="Test_BCD">
+ <type>
+ <WORD/>
+ </type>
+ <initialValue>
+ <simpleValue value="151"/>
+ </initialValue>
+ </variable>
+ <variable name="Test_BCD_WRONG">
+ <type>
+ <WORD/>
+ </type>
+ <initialValue>
+ <simpleValue value="154"/>
+ </initialValue>
+ </variable>
+ <variable name="Test_BCD_CONVERTED">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ <variable name="Test_BCD_RESULT">
+ <type>
+ <UINT/>
+ </type>
+ </variable>
+ <variable name="Test_BCD_WRONG_RESULT">
+ <type>
+ <UINT/>
+ </type>
+ </variable>
+ <variable name="Test_DT">
+ <type>
+ <DT/>
+ </type>
+ <initialValue>
+ <simpleValue value="DT#2013-02-23-22:35:46"/>
+ </initialValue>
+ </variable>
+ <variable name="Test_TOD">
+ <type>
+ <TOD/>
+ </type>
+ </variable>
+ <variable name="Test_TOD_STRING">
+ <type>
+ <string/>
+ </type>
+ </variable>
+ <variable name="Test_Date">
+ <type>
+ <DATE/>
+ </type>
+ </variable>
+ <variable name="Test_String">
+ <type>
+ <string/>
+ </type>
+ <initialValue>
+ <simpleValue value="test"/>
+ </initialValue>
+ </variable>
+ <variable name="Test_Bool">
+ <type>
+ <BOOL/>
+ </type>
+ </variable>
+ </localVars>
+ <externalVars>
+ <variable name="Global_RS">
+ <type>
+ <derived name="RS"/>
+ </type>
+ </variable>
+ <variable name="TUTU">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="TOTO">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Test_Python_Var">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Second_Python_Var">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ <variable name="Grumpf">
+ <type>
+ <string/>
+ </type>
+ </variable>
+ </externalVars>
+ <localVars>
+ <variable name="RTC0">
+ <type>
+ <derived name="RTC"/>
+ </type>
+ </variable>
+ </localVars>
+ <externalVars>
+ <variable name="SomeVarName">
+ <type>
+ <DINT/>
+ </type>
+ </variable>
+ </externalVars>
+ </interface>
+ <body>
+ <FBD>
+ <inVariable localId="4" height="30" width="160" executionOrderId="0" negated="false">
+ <position x="295" y="450"/>
+ <connectionPointOut>
+ <relPosition x="160" y="15"/>
+ </connectionPointOut>
+ <expression>'666'</expression>
+ </inVariable>
+ <block localId="5" width="125" height="80" typeName="python_eval" instanceName="py1" executionOrderId="0">
+ <position x="686" y="400"/>
+ <inputVariables>
+ <variable formalParameter="TRIG">
+ <connectionPointIn>
+ <relPosition x="0" y="35"/>
+ <connection refLocalId="7" formalParameter="OUT">
+ <position x="686" y="435"/>
+ <position x="285" y="435"/>
+ <position x="285" y="480"/>
+ <position x="250" y="480"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="CODE">
+ <connectionPointIn>
+ <relPosition x="0" y="65"/>
+ <connection refLocalId="4">
+ <position x="686" y="465"/>
+ <position x="455" y="465"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="ACK">
+ <connectionPointOut>
+ <relPosition x="125" y="35"/>
+ </connectionPointOut>
+ </variable>
+ <variable formalParameter="RESULT">
+ <connectionPointOut>
+ <relPosition x="125" y="65"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <block localId="7" width="70" height="45" typeName="NOT" executionOrderId="0">
+ <position x="180" y="450"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="30"/>
+ <connection refLocalId="3">
+ <position x="180" y="480"/>
+ <position x="155" y="480"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="70" y="30"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inOutVariable localId="3" height="30" width="120" executionOrderId="0" negatedOut="false" negatedIn="false">
+ <position x="35" y="465"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="7" formalParameter="OUT">
+ <position x="35" y="480"/>
+ <position x="25" y="480"/>
+ <position x="25" y="440"/>
+ <position x="270" y="440"/>
+ <position x="270" y="480"/>
+ <position x="250" y="480"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="120" y="15"/>
+ </connectionPointOut>
+ <expression>pytest_var2</expression>
+ </inOutVariable>
+ <block localId="8" width="125" height="80" typeName="python_eval" instanceName="Block1" executionOrderId="0">
+ <position x="686" y="545"/>
+ <inputVariables>
+ <variable formalParameter="TRIG">
+ <connectionPointIn>
+ <relPosition x="0" y="35"/>
+ <connection refLocalId="7" formalParameter="OUT">
+ <position x="686" y="580"/>
+ <position x="285" y="580"/>
+ <position x="285" y="480"/>
+ <position x="250" y="480"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="CODE">
+ <connectionPointIn>
+ <relPosition x="0" y="65"/>
+ <connection refLocalId="9">
+ <position x="686" y="610"/>
+ <position x="665" y="610"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="ACK">
+ <connectionPointOut>
+ <relPosition x="125" y="35"/>
+ </connectionPointOut>
+ </variable>
+ <variable formalParameter="RESULT">
+ <connectionPointOut>
+ <relPosition x="125" y="65"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="9" height="30" width="370" executionOrderId="0" negated="false">
+ <position x="295" y="595"/>
+ <connectionPointOut>
+ <relPosition x="370" y="15"/>
+ </connectionPointOut>
+ <expression>'sys.stdout.write("FBID :"+str(FBID)+"\n")'</expression>
+ </inVariable>
+ <inVariable localId="11" height="30" width="290" executionOrderId="0" negated="false">
+ <position x="295" y="735"/>
+ <connectionPointOut>
+ <relPosition x="290" y="15"/>
+ </connectionPointOut>
+ <expression>'PLCBinary.Simple_C_Call(5678)'</expression>
+ </inVariable>
+ <block localId="12" width="125" height="80" typeName="python_eval" instanceName="Block2" executionOrderId="0">
+ <position x="686" y="687"/>
+ <inputVariables>
+ <variable formalParameter="TRIG">
+ <connectionPointIn>
+ <relPosition x="0" y="33"/>
+ <connection refLocalId="7" formalParameter="OUT">
+ <position x="686" y="720"/>
+ <position x="285" y="720"/>
+ <position x="285" y="480"/>
+ <position x="250" y="480"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="CODE">
+ <connectionPointIn>
+ <relPosition x="0" y="63"/>
+ <connection refLocalId="11">
+ <position x="686" y="750"/>
+ <position x="585" y="750"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="ACK">
+ <connectionPointOut>
+ <relPosition x="125" y="33"/>
+ </connectionPointOut>
+ </variable>
+ <variable formalParameter="RESULT">
+ <connectionPointOut>
+ <relPosition x="125" y="63"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="14" height="30" width="290" executionOrderId="0" negated="false">
+ <position x="290" y="885"/>
+ <connectionPointOut>
+ <relPosition x="290" y="15"/>
+ </connectionPointOut>
+ <expression>'MyPythonFunc(42)'</expression>
+ </inVariable>
+ <block localId="15" width="125" height="80" typeName="python_eval" instanceName="Block3" executionOrderId="0">
+ <position x="686" y="837"/>
+ <inputVariables>
+ <variable formalParameter="TRIG">
+ <connectionPointIn>
+ <relPosition x="0" y="33"/>
+ <connection refLocalId="7" formalParameter="OUT">
+ <position x="686" y="870"/>
+ <position x="285" y="870"/>
+ <position x="285" y="480"/>
+ <position x="250" y="480"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="CODE">
+ <connectionPointIn>
+ <relPosition x="0" y="63"/>
+ <connection refLocalId="14">
+ <position x="686" y="900"/>
+ <position x="580" y="900"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="ACK">
+ <connectionPointOut>
+ <relPosition x="125" y="33"/>
+ </connectionPointOut>
+ </variable>
+ <variable formalParameter="RESULT">
+ <connectionPointOut>
+ <relPosition x="125" y="63"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <comment localId="16" height="90" width="680">
+ <position x="35" y="275"/>
+ <content>
+ <xhtml:p><![CDATA[This part of the example test that, despite of 2T period clock stimulating TRIG pin of pyth_eval blocks, blocks keep executing one after the other, in respect of execution order.]]></xhtml:p>
+ </content>
+ </comment>
+ <block localId="17" width="80" height="120" typeName="MUX" executionOrderId="0">
+ <position x="1101" y="790"/>
+ <inputVariables>
+ <variable formalParameter="K">
+ <connectionPointIn>
+ <relPosition x="0" y="30"/>
+ <connection refLocalId="18">
+ <position x="1101" y="820"/>
+ <position x="1076" y="820"/>
+ <position x="1076" y="810"/>
+ <position x="1060" y="810"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN0">
+ <connectionPointIn>
+ <relPosition x="0" y="50"/>
+ <connection refLocalId="5" formalParameter="RESULT">
+ <position x="1101" y="840"/>
+ <position x="941" y="840"/>
+ <position x="941" y="465"/>
+ <position x="811" y="465"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="70"/>
+ <connection refLocalId="8" formalParameter="RESULT">
+ <position x="1101" y="860"/>
+ <position x="926" y="860"/>
+ <position x="926" y="610"/>
+ <position x="811" y="610"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="90"/>
+ <connection refLocalId="12" formalParameter="RESULT">
+ <position x="1101" y="880"/>
+ <position x="911" y="880"/>
+ <position x="911" y="750"/>
+ <position x="811" y="750"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN3">
+ <connectionPointIn>
+ <relPosition x="0" y="110"/>
+ <connection refLocalId="15" formalParameter="RESULT">
+ <position x="1101" y="900"/>
+ <position x="811" y="900"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="80" y="30"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <outVariable localId="19" height="35" width="125" executionOrderId="0" negated="false">
+ <position x="1271" y="805"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="17" formalParameter="OUT">
+ <position x="1271" y="820"/>
+ <position x="1181" y="820"/>
+ </connection>
+ </connectionPointIn>
+ <expression>pytest_var1</expression>
+ </outVariable>
+ <block localId="21" width="80" height="120" typeName="MUX" executionOrderId="0">
+ <position x="1106" y="385"/>
+ <inputVariables>
+ <variable formalParameter="K">
+ <connectionPointIn>
+ <relPosition x="0" y="30"/>
+ <connection refLocalId="22">
+ <position x="1106" y="415"/>
+ <position x="1076" y="415"/>
+ <position x="1076" y="405"/>
+ <position x="1055" y="405"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN0">
+ <connectionPointIn>
+ <relPosition x="0" y="50"/>
+ <connection refLocalId="5" formalParameter="ACK">
+ <position x="1106" y="435"/>
+ <position x="811" y="435"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="70"/>
+ <connection refLocalId="8" formalParameter="ACK">
+ <position x="1106" y="455"/>
+ <position x="841" y="455"/>
+ <position x="841" y="580"/>
+ <position x="811" y="580"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="90"/>
+ <connection refLocalId="12" formalParameter="ACK">
+ <position x="1106" y="475"/>
+ <position x="856" y="475"/>
+ <position x="856" y="720"/>
+ <position x="811" y="720"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN3">
+ <connectionPointIn>
+ <relPosition x="0" y="110"/>
+ <connection refLocalId="15" formalParameter="ACK">
+ <position x="1106" y="495"/>
+ <position x="871" y="495"/>
+ <position x="871" y="870"/>
+ <position x="811" y="870"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="80" y="30"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="22" height="30" width="74" executionOrderId="0" negated="false">
+ <position x="981" y="390"/>
+ <connectionPointOut>
+ <relPosition x="74" y="15"/>
+ </connectionPointOut>
+ <expression>mux1_sel</expression>
+ </inVariable>
+ <outVariable localId="23" height="35" width="125" executionOrderId="0" negated="false">
+ <position x="1271" y="400"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="21" formalParameter="OUT">
+ <position x="1271" y="415"/>
+ <position x="1186" y="415"/>
+ </connection>
+ </connectionPointIn>
+ <expression>pytest_var3</expression>
+ </outVariable>
+ <outVariable localId="25" height="30" width="60" executionOrderId="0" negated="false">
+ <position x="320" y="1075"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="26" formalParameter="OUT">
+ <position x="320" y="1090"/>
+ <position x="265" y="1090"/>
+ </connection>
+ </connectionPointIn>
+ <expression>FromC</expression>
+ </outVariable>
+ <inVariable localId="1" height="30" width="30" executionOrderId="0" negated="false">
+ <position x="105" y="1075"/>
+ <connectionPointOut>
+ <relPosition x="30" y="15"/>
+ </connectionPointOut>
+ <expression>23</expression>
+ </inVariable>
+ <block localId="26" width="80" height="45" typeName="C_Pragma" instanceName="C_Pragma0" executionOrderId="0">
+ <position x="185" y="1060"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="30"/>
+ <connection refLocalId="1">
+ <position x="185" y="1090"/>
+ <position x="135" y="1090"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="80" y="30"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="27" height="30" width="90" executionOrderId="0" negated="false">
+ <position x="100" y="1190"/>
+ <connectionPointOut>
+ <relPosition x="90" y="15"/>
+ </connectionPointOut>
+ <expression>TestInput</expression>
+ </inVariable>
+ <outVariable localId="28" height="30" width="105" executionOrderId="0" negated="false">
+ <position x="195" y="1125"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="2">
+ <position x="195" y="1140"/>
+ <position x="140" y="1140"/>
+ </connection>
+ </connectionPointIn>
+ <expression>TestOutput</expression>
+ </outVariable>
+ <outVariable localId="29" height="30" width="85" executionOrderId="0" negated="false">
+ <position x="215" y="1190"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="27">
+ <position x="215" y="1205"/>
+ <position x="190" y="1205"/>
+ </connection>
+ </connectionPointIn>
+ <expression>FromInput</expression>
+ </outVariable>
+ <inVariable localId="2" height="30" width="30" executionOrderId="0" negated="false">
+ <position x="110" y="1125"/>
+ <connectionPointOut>
+ <relPosition x="30" y="15"/>
+ </connectionPointOut>
+ <expression>10</expression>
+ </inVariable>
+ <comment localId="30" height="105" width="465">
+ <position x="50" y="925"/>
+ <content>
+ <xhtml:p><![CDATA[You will be ready to use beremiz with C and Python when you will understand why "FromInput" is equal to 75.
+Happy hacking! ]]></xhtml:p>
+ </content>
+ </comment>
+ <comment localId="31" height="90" width="345">
+ <position x="295" y="485"/>
+ <content>
+ <xhtml:p><![CDATA[Sleep here is bad. It blocks other py_eval instances. Whith a wxGlade GUI, GUI freeze for a second.]]></xhtml:p>
+ </content>
+ </comment>
+ <comment localId="6" height="80" width="345">
+ <position x="295" y="630"/>
+ <content>
+ <xhtml:p><![CDATA[Prints FBID to stdout of PLC runtime. FBID is a unique reference to py_eval instance.]]></xhtml:p>
+ </content>
+ </comment>
+ <comment localId="10" height="85" width="345">
+ <position x="295" y="770"/>
+ <content>
+ <xhtml:p><![CDATA[Simple_C_Call is declared in C_File "1.x:c_code". See python ctypes manual for details on typing.]]></xhtml:p>
+ </content>
+ </comment>
+ <comment localId="32" height="145" width="235">
+ <position x="25" y="505"/>
+ <content>
+ <xhtml:p><![CDATA[Fast clock, at least faster that sleep(1). See what happens when python takes time to answer : PLC continues.]]></xhtml:p>
+ </content>
+ </comment>
+ <outVariable localId="33" height="30" width="133" executionOrderId="0" negated="false">
+ <position x="580" y="1564"/>
+ <connectionPointIn>
+ <relPosition x="0" y="16"/>
+ <connection refLocalId="35" formalParameter="OUT">
+ <position x="580" y="1580"/>
+ <position x="371" y="1580"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Test_BCD_RESULT</expression>
+ </outVariable>
+ <inVariable localId="34" height="30" width="75" executionOrderId="0" negated="false">
+ <position x="60" y="1564"/>
+ <connectionPointOut>
+ <relPosition x="75" y="16"/>
+ </connectionPointOut>
+ <expression>Test_BCD</expression>
+ </inVariable>
+ <block localId="35" width="106" height="60" typeName="BCD_TO_UINT" executionOrderId="0">
+ <position x="265" y="1539"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="41"/>
+ <connection refLocalId="34">
+ <position x="265" y="1580"/>
+ <position x="135" y="1580"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="106" y="41"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="36" height="30" width="66" executionOrderId="0" negated="false">
+ <position x="60" y="1774"/>
+ <connectionPointOut>
+ <relPosition x="66" y="16"/>
+ </connectionPointOut>
+ <expression>Test_DT</expression>
+ </inVariable>
+ <block localId="37" width="255" height="45" typeName="DATE_AND_TIME_TO_TIME_OF_DAY" executionOrderId="0">
+ <position x="265" y="1759"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="31"/>
+ <connection refLocalId="36">
+ <position x="265" y="1790"/>
+ <position x="125" y="1790"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="255" y="31"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <block localId="38" width="195" height="45" typeName="DATE_AND_TIME_TO_DATE" executionOrderId="0">
+ <position x="265" y="1834"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="31"/>
+ <connection refLocalId="36">
+ <position x="265" y="1865"/>
+ <position x="242" y="1865"/>
+ <position x="242" y="1790"/>
+ <position x="125" y="1790"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="195" y="31"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <outVariable localId="40" height="30" width="82" executionOrderId="0" negated="false">
+ <position x="580" y="1849"/>
+ <connectionPointIn>
+ <relPosition x="0" y="16"/>
+ <connection refLocalId="38" formalParameter="OUT">
+ <position x="580" y="1865"/>
+ <position x="460" y="1865"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Test_Date</expression>
+ </outVariable>
+ <outVariable localId="42" height="30" width="98" executionOrderId="0" negated="false">
+ <position x="465" y="1944"/>
+ <connectionPointIn>
+ <relPosition x="0" y="16"/>
+ <connection refLocalId="46" formalParameter="OUT">
+ <position x="465" y="1960"/>
+ <position x="395" y="1960"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Test_String</expression>
+ </outVariable>
+ <outVariable localId="43" height="30" width="82" executionOrderId="0" negated="false">
+ <position x="465" y="2014"/>
+ <connectionPointIn>
+ <relPosition x="0" y="16"/>
+ <connection refLocalId="44" formalParameter="OUT">
+ <position x="465" y="2030"/>
+ <position x="400" y="2030"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Test_Bool</expression>
+ </outVariable>
+ <block localId="44" width="135" height="45" typeName="STRING_TO_BOOL" executionOrderId="0">
+ <position x="265" y="1999"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="31"/>
+ <connection refLocalId="45">
+ <position x="265" y="2030"/>
+ <position x="115" y="2030"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="135" y="31"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="45" height="30" width="58" executionOrderId="0" negated="false">
+ <position x="60" y="2014"/>
+ <connectionPointOut>
+ <relPosition x="58" y="16"/>
+ </connectionPointOut>
+ <expression>'True'</expression>
+ </inVariable>
+ <block localId="46" width="130" height="45" typeName="INT_TO_STRING" executionOrderId="0">
+ <position x="265" y="1929"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="31"/>
+ <connection refLocalId="58">
+ <position x="265" y="1960"/>
+ <position x="205" y="1960"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="130" y="31"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="50" height="30" width="106" executionOrderId="0" negated="false">
+ <position x="75" y="2275"/>
+ <connectionPointOut>
+ <relPosition x="106" y="15"/>
+ </connectionPointOut>
+ <expression>Global_RS.Q1</expression>
+ </inVariable>
+ <block localId="51" width="70" height="85" typeName="AND" executionOrderId="0">
+ <position x="240" y="2255"/>
+ <inputVariables>
+ <variable formalParameter="IN1" negated="true">
+ <connectionPointIn>
+ <relPosition x="0" y="35"/>
+ <connection refLocalId="50">
+ <position x="240" y="2290"/>
+ <position x="180" y="2290"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="70"/>
+ <connection refLocalId="52">
+ <position x="240" y="2325"/>
+ <position x="180" y="2325"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="70" y="35"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="52" height="30" width="105" executionOrderId="0" negated="false">
+ <position x="75" y="2310"/>
+ <connectionPointOut>
+ <relPosition x="105" y="15"/>
+ </connectionPointOut>
+ <expression>BOOL#TRUE</expression>
+ </inVariable>
+ <outVariable localId="13" height="30" width="105" executionOrderId="0" negated="false">
+ <position x="385" y="2275"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="51" formalParameter="OUT">
+ <position x="385" y="2290"/>
+ <position x="310" y="2290"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Global_RS.S</expression>
+ </outVariable>
+ <outVariable localId="20" height="30" width="106" executionOrderId="0" negated="false">
+ <position x="385" y="2390"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="41" formalParameter="OUT">
+ <position x="385" y="2405"/>
+ <position x="310" y="2405"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Global_RS.R1</expression>
+ </outVariable>
+ <inVariable localId="24" height="30" width="106" executionOrderId="0" negated="false">
+ <position x="75" y="2390"/>
+ <connectionPointOut>
+ <relPosition x="106" y="15"/>
+ </connectionPointOut>
+ <expression>Global_RS.Q1</expression>
+ </inVariable>
+ <block localId="41" width="70" height="85" typeName="OR" executionOrderId="0">
+ <position x="240" y="2370"/>
+ <inputVariables>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="35"/>
+ <connection refLocalId="24">
+ <position x="240" y="2405"/>
+ <position x="180" y="2405"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="70"/>
+ <connection refLocalId="48">
+ <position x="240" y="2440"/>
+ <position x="180" y="2440"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="70" y="35"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="48" height="30" width="105" executionOrderId="0" negated="false">
+ <position x="75" y="2425"/>
+ <connectionPointOut>
+ <relPosition x="105" y="15"/>
+ </connectionPointOut>
+ <expression>BOOL#FALSE</expression>
+ </inVariable>
+ <outVariable localId="54" height="30" width="135" executionOrderId="0" negated="false">
+ <position x="930" y="1774"/>
+ <connectionPointIn>
+ <relPosition x="0" y="16"/>
+ <connection refLocalId="55" formalParameter="OUT">
+ <position x="930" y="1790"/>
+ <position x="855" y="1790"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Test_TOD_STRING</expression>
+ </outVariable>
+ <block localId="55" width="125" height="45" typeName="TOD_TO_STRING" executionOrderId="0">
+ <position x="730" y="1759"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="31"/>
+ <connection refLocalId="39">
+ <position x="730" y="1790"/>
+ <position x="655" y="1790"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="125" y="31"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inOutVariable localId="39" height="30" width="75" executionOrderId="0" negatedOut="false" negatedIn="false">
+ <position x="580" y="1774"/>
+ <connectionPointIn>
+ <relPosition x="0" y="16"/>
+ <connection refLocalId="37" formalParameter="OUT">
+ <position x="580" y="1790"/>
+ <position x="520" y="1790"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="75" y="16"/>
+ </connectionPointOut>
+ <expression>Test_TOD</expression>
+ </inOutVariable>
+ <inVariable localId="49" height="30" width="30" executionOrderId="0" negated="false">
+ <position x="160" y="2510"/>
+ <connectionPointOut>
+ <relPosition x="30" y="15"/>
+ </connectionPointOut>
+ <expression>42</expression>
+ </inVariable>
+ <outVariable localId="57" height="30" width="50" executionOrderId="0" negated="false">
+ <position x="240" y="2510"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="49">
+ <position x="240" y="2525"/>
+ <position x="190" y="2525"/>
+ </connection>
+ </connectionPointIn>
+ <expression>TOTO</expression>
+ </outVariable>
+ <outVariable localId="56" height="30" width="50" executionOrderId="0" negated="false">
+ <position x="240" y="2550"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="49">
+ <position x="240" y="2565"/>
+ <position x="215" y="2565"/>
+ <position x="215" y="2525"/>
+ <position x="190" y="2525"/>
+ </connection>
+ </connectionPointIn>
+ <expression>TUTU</expression>
+ </outVariable>
+ <inVariable localId="58" height="30" width="146" executionOrderId="0" negated="false">
+ <position x="60" y="1944"/>
+ <connectionPointOut>
+ <relPosition x="146" y="16"/>
+ </connectionPointOut>
+ <expression>Second_Python_Var</expression>
+ </inVariable>
+ <inVariable localId="59" height="30" width="30" executionOrderId="0" negated="false">
+ <position x="100" y="1385"/>
+ <connectionPointOut>
+ <relPosition x="30" y="15"/>
+ </connectionPointOut>
+ <expression>1</expression>
+ </inVariable>
+ <block localId="61" typeName="function0" executionOrderId="0" height="45" width="111">
+ <position x="760" y="1170"/>
+ <inputVariables>
+ <variable formalParameter="LocalVar0">
+ <connectionPointIn>
+ <relPosition x="0" y="30"/>
+ <connection refLocalId="62">
+ <position x="760" y="1200"/>
+ <position x="723" y="1200"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="111" y="30"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <inVariable localId="62" executionOrderId="0" height="30" width="58" negated="false">
+ <position x="665" y="1185"/>
+ <connectionPointOut>
+ <relPosition x="58" y="15"/>
+ </connectionPointOut>
+ <expression>fefvsd</expression>
+ </inVariable>
+ <outVariable localId="63" executionOrderId="0" height="30" width="58" negated="false">
+ <position x="905" y="1185"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="61" formalParameter="OUT">
+ <position x="905" y="1200"/>
+ <position x="871" y="1200"/>
+ </connection>
+ </connectionPointIn>
+ <expression>fefvsd</expression>
+ </outVariable>
+ <comment localId="53" height="80" width="420">
+ <position x="75" y="2160"/>
+ <content>
+ <xhtml:p><![CDATA[Shows global variables access from resource configuration (res_pytest) and from project's configuration.]]></xhtml:p>
+ </content>
+ </comment>
+ <inVariable localId="18" height="30" width="74" executionOrderId="0" negated="false">
+ <position x="986" y="795"/>
+ <connectionPointOut>
+ <relPosition x="74" y="15"/>
+ </connectionPointOut>
+ <expression>mux2_sel</expression>
+ </inVariable>
+ <comment localId="60" height="45" width="930">
+ <position x="60" y="1480"/>
+ <content>
+ <xhtml:p><![CDATA[Here is shown how to convert values between different types (BCD, DT, TOD, STRING and others) using standard functions.]]></xhtml:p>
+ </content>
+ </comment>
+ <comment localId="64" height="55" width="300">
+ <position x="665" y="1095"/>
+ <content>
+ <xhtml:p><![CDATA[Example of usage of user-defined function.]]></xhtml:p>
+ </content>
+ </comment>
+ <comment localId="65" height="45" width="410">
+ <position x="55" y="1315"/>
+ <content>
+ <xhtml:p><![CDATA[Shows access variable defined in python extension. ]]></xhtml:p>
+ </content>
+ </comment>
+ <inVariable localId="66" height="30" width="137" executionOrderId="0" negated="false">
+ <position x="60" y="1685"/>
+ <connectionPointOut>
+ <relPosition x="137" y="15"/>
+ </connectionPointOut>
+ <expression>Test_BCD_WRONG</expression>
+ </inVariable>
+ <block localId="67" width="106" height="100" typeName="BCD_TO_UINT" executionOrderId="0">
+ <position x="265" y="1620"/>
+ <inputVariables>
+ <variable formalParameter="EN">
+ <connectionPointIn>
+ <relPosition x="0" y="40"/>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="80"/>
+ <connection refLocalId="66">
+ <position x="265" y="1700"/>
+ <position x="255" y="1700"/>
+ <position x="255" y="1700"/>
+ <position x="345" y="1700"/>
+ <position x="345" y="1700"/>
+ <position x="197" y="1700"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="ENO">
+ <connectionPointOut>
+ <relPosition x="106" y="40"/>
+ </connectionPointOut>
+ </variable>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="106" y="80"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <outVariable localId="68" height="30" width="196" executionOrderId="0" negated="false">
+ <position x="580" y="1685"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="67" formalParameter="OUT">
+ <position x="580" y="1700"/>
+ <position x="371" y="1700"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Test_BCD_WRONG_RESULT</expression>
+ </outVariable>
+ <comment localId="69" height="165" width="375">
+ <position x="795" y="1590"/>
+ <content>
+ <xhtml:p><![CDATA[Incorrect BCD number is not converted to UINT.
+
+151 (16#97) is good BCD number , but
+154 (16#9A) is not.
+
+Try this out and look at value of Test_BCD_CONVERTED variable.
+
+
+]]></xhtml:p>
+ </content>
+ </comment>
+ <outVariable localId="70" height="30" width="185" executionOrderId="0" negated="false">
+ <position x="580" y="1645"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="67" formalParameter="ENO">
+ <position x="580" y="1660"/>
+ <position x="370" y="1660"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Test_BCD_CONVERTED</expression>
+ </outVariable>
+ <comment localId="71" height="215" width="680">
+ <position x="35" y="30"/>
+ <content>
+ <xhtml:p><![CDATA[This example shows many features in Beremiz:
+
+ 1. How to implement python extensions.
+ 2. How to implement basic C extension.
+ 3. How to use C code in IEC POUs.
+ 4. How to call C functions from python code.
+ 5. How to avoid race conditions between IEC, C and python code.
+ 6. How to convert betweet different IEC types.
+]]></xhtml:p>
+ </content>
+ </comment>
+ <outVariable localId="72" executionOrderId="0" height="30" width="60" negated="false">
+ <position x="1065" y="1970"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="76" formalParameter="OUT">
+ <position x="1065" y="1985"/>
+ <position x="1025" y="1985"/>
+ <position x="1025" y="1995"/>
+ <position x="985" y="1995"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Grumpf</expression>
+ </outVariable>
+ <inVariable localId="73" executionOrderId="0" height="30" width="85" negated="false">
+ <position x="625" y="1940"/>
+ <connectionPointOut>
+ <relPosition x="85" y="15"/>
+ </connectionPointOut>
+ <expression>BOOL#TRUE</expression>
+ </inVariable>
+ <inVariable localId="74" executionOrderId="0" height="30" width="70" negated="false">
+ <position x="625" y="1975"/>
+ <connectionPointOut>
+ <relPosition x="70" y="15"/>
+ </connectionPointOut>
+ <expression>Test_DT</expression>
+ </inVariable>
+ <block localId="75" typeName="RTC" instanceName="RTC0" executionOrderId="0" height="90" width="65">
+ <position x="760" y="1925"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="35"/>
+ <connection refLocalId="73">
+ <position x="760" y="1960"/>
+ <position x="735" y="1960"/>
+ <position x="735" y="1955"/>
+ <position x="710" y="1955"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="PDT">
+ <connectionPointIn>
+ <relPosition x="0" y="70"/>
+ <connection refLocalId="74">
+ <position x="760" y="1995"/>
+ <position x="727" y="1995"/>
+ <position x="727" y="1990"/>
+ <position x="695" y="1990"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="Q">
+ <connectionPointOut>
+ <relPosition x="65" y="35"/>
+ </connectionPointOut>
+ </variable>
+ <variable formalParameter="CDT">
+ <connectionPointOut>
+ <relPosition x="65" y="70"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <block localId="76" typeName="DT_TO_STRING" executionOrderId="0" height="40" width="110">
+ <position x="875" y="1965"/>
+ <inputVariables>
+ <variable formalParameter="IN">
+ <connectionPointIn>
+ <relPosition x="0" y="30"/>
+ <connection refLocalId="75" formalParameter="CDT">
+ <position x="875" y="1995"/>
+ <position x="825" y="1995"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="110" y="30"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <block localId="77" typeName="ADD" executionOrderId="0" height="60" width="65">
+ <position x="170" y="1370"/>
+ <inputVariables>
+ <variable formalParameter="IN1">
+ <connectionPointIn>
+ <relPosition x="0" y="30"/>
+ <connection refLocalId="59">
+ <position x="170" y="1400"/>
+ <position x="130" y="1400"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ <variable formalParameter="IN2">
+ <connectionPointIn>
+ <relPosition x="0" y="50"/>
+ <connection refLocalId="78">
+ <position x="170" y="1420"/>
+ <position x="160" y="1420"/>
+ <position x="160" y="1450"/>
+ <position x="390" y="1450"/>
+ <position x="390" y="1400"/>
+ <position x="380" y="1400"/>
+ </connection>
+ </connectionPointIn>
+ </variable>
+ </inputVariables>
+ <inOutVariables/>
+ <outputVariables>
+ <variable formalParameter="OUT">
+ <connectionPointOut>
+ <relPosition x="65" y="30"/>
+ </connectionPointOut>
+ </variable>
+ </outputVariables>
+ </block>
+ <outVariable localId="47" executionOrderId="0" height="30" width="130" negated="false">
+ <position x="625" y="1335"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="79">
+ <position x="625" y="1350"/>
+ <position x="590" y="1350"/>
+ </connection>
+ </connectionPointIn>
+ <expression>Test_Python_Var</expression>
+ </outVariable>
+ <inVariable localId="79" executionOrderId="0" height="25" width="30" negated="false">
+ <position x="560" y="1340"/>
+ <connectionPointOut>
+ <relPosition x="30" y="10"/>
+ </connectionPointOut>
+ <expression>23</expression>
+ </inVariable>
+ <inOutVariable localId="78" executionOrderId="0" height="30" width="100" negatedOut="false" negatedIn="false">
+ <position x="280" y="1385"/>
+ <connectionPointIn>
+ <relPosition x="0" y="15"/>
+ <connection refLocalId="77" formalParameter="OUT">
+ <position x="280" y="1400"/>
+ <position x="235" y="1400"/>
+ </connection>
+ </connectionPointIn>
+ <connectionPointOut>
+ <relPosition x="100" y="15"/>
+ </connectionPointOut>
+ <expression>SomeVarName</expression>
+ </inOutVariable>
+ </FBD>
+ </body>
+ </pou>
+ <pou name="C_Pragma" pouType="functionBlock">
+ <interface>
+ <outputVars>
+ <variable name="OUT">
+ <type>
+ <SINT/>
+ </type>
+ </variable>
+ </outputVars>
+ <inputVars>
+ <variable name="IN">
+ <type>
+ <SINT/>
+ </type>
+ </variable>
+ </inputVars>
+ <localVars>
+ <variable name="COORDS">
+ <type>
+ <array>
+ <dimension lower="0" upper="5"/>
+ <baseType>
+ <SINT/>
+ </baseType>
+ </array>
+ </type>
+ <initialValue>
+ <arrayValue>
+ <value>
+ <simpleValue value="54"/>
+ </value>
+ <value>
+ <simpleValue value="55"/>
+ </value>
+ <value>
+ <simpleValue value="56"/>
+ </value>
+ <value>
+ <simpleValue value="57"/>
+ </value>
+ <value>
+ <simpleValue value="58"/>
+ </value>
+ <value>
+ <simpleValue value="59"/>
+ </value>
+ </arrayValue>
+ </initialValue>
+ </variable>
+ <variable name="SMURF">
+ <type>
+ <derived name="CPLX_TYPE"/>
+ </type>
+ </variable>
+ </localVars>
+ <externalVars>
+ <variable name="Global_RS">
+ <type>
+ <derived name="RS"/>
+ </type>
+ </variable>
+ <variable name="Dudiduda">
+ <type>
+ <derived name="blups"/>
+ </type>
+ </variable>
+ </externalVars>
+ </interface>
+ <body>
+ <ST>
+ <xhtml:p><![CDATA[(* hereafter is a C pragma accessing FB interface in a clean way *)
+{{
+ char toPLC;
+ char fromPLC = GetFbVar(IN);
+ extern int PLC_C_Call(char, char *);
+ if(PLC_C_Call(fromPLC, &toPLC)){
+ SetFbVar(OUT, toPLC);
+ }
+ if(0){
+ /* that code demonstrate C access to complex types */
+ char somebyte = GetFbVar(COORDS, .table[3]);
+ SetFbVar(SMURF, somebyte, .FIRSTBYTE);
+ SetFbVar(COORDS, somebyte, .table[4]);
+ }
+}}
+(* If you do not use GetFbVar and SetFbVar macros, expect unexpected behaviour*)
+Global_RS();
+
+(* testing access to global struct array *)
+Dudiduda[2].FIRSTBYTE := 0;
+]]></xhtml:p>
+ </ST>
+ </body>
+ </pou>
+ <pou name="norm" pouType="function">
+ <interface>
+ <returnType>
+ <REAL/>
+ </returnType>
+ <inputVars>
+ <variable name="IN1">
+ <type>
+ <REAL/>
+ </type>
+ </variable>
+ <variable name="IN2">
+ <type>
+ <REAL/>
+ </type>
+ </variable>
+ </inputVars>
+ </interface>
+ <body>
+ <ST>
+ <xhtml:p><![CDATA[NORM := SQRT(IN1 * IN1 + IN2 * IN2);]]></xhtml:p>
+ </ST>
+ </body>
+ </pou>
+ <pou name="function0" pouType="function">
+ <interface>
+ <returnType>
+ <derived name="datatype0"/>
+ </returnType>
+ <inputVars>
+ <variable name="LocalVar0">
+ <type>
+ <derived name="datatype0"/>
+ </type>
+ </variable>
+ </inputVars>
+ </interface>
+ <body>
+ <ST>
+ <xhtml:p><![CDATA[function0 := LocalVar0;
+]]></xhtml:p>
+ </ST>
+ </body>
+ </pou>
+ </pous>
+ </types>
+ <instances>
+ <configurations>
+ <configuration name="config">
+ <resource name="res_pytest">
+ <task name="pytest_task" priority="0" interval="T#500ms"/>
+ <globalVars>
+ <variable name="TOTO">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </globalVars>
+ <pouInstance name="pytest_instance" typeName="main_pytest"/>
+ </resource>
+ <globalVars>
+ <variable name="Global_RS">
+ <type>
+ <derived name="RS"/>
+ </type>
+ </variable>
+ <variable name="Dudiduda">
+ <type>
+ <derived name="blups"/>
+ </type>
+ </variable>
+ <variable name="TUTU">
+ <type>
+ <INT/>
+ </type>
+ </variable>
+ </globalVars>
+ </configuration>
+ </configurations>
+ </instances>
+</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/python/py_ext_0@py_ext/baseconfnode.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='utf-8'?>
+<BaseParams xmlns:xsd="http://www.w3.org/2001/XMLSchema" IEC_Channel="2" Name="py_ext_0"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/python/py_ext_0@py_ext/pyfile.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,42 @@
+<?xml version='1.0' encoding='utf-8'?>
+<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <variables>
+ <variable name="SomeVarName" type="DINT" onchange="MyFunc, SomeChange"/>
+ <variable name="Grumpf" type="STRING" initial="'mhoo'" onchange="MyFunc, MyOtherFunc"/>
+ </variables>
+ <globals>
+ <xhtml:p><![CDATA[
+print "All python PLC globals variables :", PLCGlobalsDesc
+print "Current extention name :", __ext_name__
+
+def MyFunc(*args):
+ print args
+
+def MyOtherFunc(*args):
+ print "other", args
+
+def SomeChange(*args):
+ print "count",OnChange.SomeVarName.count
+ print "first",OnChange.SomeVarName.first
+ print "last",OnChange.SomeVarName.last
+
+
+]]></xhtml:p>
+ </globals>
+ <init>
+ <xhtml:p><![CDATA[
+]]></xhtml:p>
+ </init>
+ <cleanup>
+ <xhtml:p><![CDATA[
+]]></xhtml:p>
+ </cleanup>
+ <start>
+ <xhtml:p><![CDATA[
+]]></xhtml:p>
+ </start>
+ <stop>
+ <xhtml:p><![CDATA[
+]]></xhtml:p>
+ </stop>
+</PyFile>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/python/python@py_ext/baseconfnode.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='utf-8'?>
+<BaseParams Name="python" IEC_Channel="0"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exemples/python/python@py_ext/pyfile.xml Mon Sep 13 22:23:14 2021 +0200
@@ -0,0 +1,69 @@
+<?xml version='1.0' encoding='utf-8'?>
+<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml">
+ <variables>
+ <variable name="Test_Python_Var" type="INT" initial="4"/>
+ <variable name="Second_Python_Var" type="INT" initial="5"/>
+ </variables>
+ <globals>
+ <xhtml:p><![CDATA[
+import time,sys,ctypes
+Python_to_C_Call = PLCBinary.Python_to_C_Call
+Python_to_C_Call.restype = ctypes.c_int
+Python_to_C_Call.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)]
+
+def MyPythonFunc(arg):
+ i = ctypes.c_int()
+ if(Python_to_C_Call(arg, i)):
+ res = i.value
+ print "toC:", arg, "from C:", res, "FBID:", FBID
+ else:
+ print "Failed Python_to_C_Call failed"
+ res = None
+ print "Python read PLC global :",PLCGlobals.Test_Python_Var
+ print "Python read PLC global Grumpf :",PLCGlobals.Grumpf
+ PLCGlobals.Second_Python_Var = 789
+ sys.stdout.flush()
+ return res
+
+async_error_test_code = """
+def badaboom():
+ tuple()[0]
+
+import wx
+def badaboomwx():
+ wx.CallAfter(badaboom)
+
+from threading import Timer
+a = Timer(3, badaboom)
+a.start()
+
+b = Timer(6, badaboomwx)
+b.start()
+"""
+]]></xhtml:p>
+ </globals>
+ <init>
+ <xhtml:p><![CDATA[
+global x, y
+x = 2
+y = 5
+print "py_runtime init:", x, ",", y
+]]></xhtml:p>
+ </init>
+ <cleanup>
+ <xhtml:p><![CDATA[
+print "py_runtime cleanup"
+]]></xhtml:p>
+ </cleanup>
+ <start>
+ <xhtml:p><![CDATA[
+global x, y
+print "py_runtime start", x * x + y * y
+]]></xhtml:p>
+ </start>
+ <stop>
+ <xhtml:p><![CDATA[
+print "py_runtime stop"
+]]></xhtml:p>
+ </stop>
+</PyFile>
--- a/tests/first_steps/beremiz.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<BeremizRoot xmlns:xsd="http://www.w3.org/2001/XMLSchema" URI_location="LOCAL://">
- <TargetType/>
- <Libraries Enable_Python_Library="false"/>
-</BeremizRoot>
--- a/tests/first_steps/plc.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1160 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<project xmlns:ns1="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.plcopen.org/xml/tc6_0201">
- <fileHeader companyName="Beremiz" productName="Beremiz" productVersion="1" creationDateTime="2016-10-24T18:09:22"/>
- <contentHeader name="First Steps" modificationDateTime="2018-09-26T12:52:51">
- <coordinateInfo>
- <fbd>
- <scaling x="0" y="0"/>
- </fbd>
- <ld>
- <scaling x="0" y="0"/>
- </ld>
- <sfc>
- <scaling x="0" y="0"/>
- </sfc>
- </coordinateInfo>
- </contentHeader>
- <types>
- <dataTypes/>
- <pous>
- <pou name="AverageVal" pouType="function">
- <interface>
- <returnType>
- <REAL/>
- </returnType>
- <inputVars>
- <variable name="Cnt1">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Cnt2">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Cnt3">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Cnt4">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Cnt5">
- <type>
- <INT/>
- </type>
- </variable>
- </inputVars>
- <localVars>
- <variable name="InputsNumber">
- <type>
- <REAL/>
- </type>
- <initialValue>
- <simpleValue value="5.0"/>
- </initialValue>
- <documentation>
- <xhtml:p><![CDATA[Количество входных значений]]></xhtml:p>
- </documentation>
- </variable>
- </localVars>
- </interface>
- <body>
- <ST>
- <xhtml:p><![CDATA[AverageVal := INT_TO_REAL(Cnt1+Cnt2+Cnt3+Cnt4+Cnt5)/InputsNumber;]]></xhtml:p>
- </ST>
- </body>
- </pou>
- <pou name="plc_prg" pouType="program">
- <interface>
- <inputVars>
- <variable name="Reset">
- <type>
- <BOOL/>
- </type>
- </variable>
- </inputVars>
- <outputVars>
- <variable name="Cnt1">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Cnt2">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Cnt3">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Cnt4">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Cnt5">
- <type>
- <INT/>
- </type>
- </variable>
- </outputVars>
- <localVars>
- <variable name="CounterST0">
- <type>
- <derived name="CounterST"/>
- </type>
- </variable>
- <variable name="CounterFBD0">
- <type>
- <derived name="CounterFBD"/>
- </type>
- </variable>
- <variable name="CounterSFC0">
- <type>
- <derived name="CounterSFC"/>
- </type>
- </variable>
- <variable name="CounterIL0">
- <type>
- <derived name="CounterIL"/>
- </type>
- </variable>
- <variable name="CounterLD0">
- <type>
- <derived name="CounterLD"/>
- </type>
- </variable>
- <variable name="AVCnt">
- <type>
- <REAL/>
- </type>
- </variable>
- </localVars>
- </interface>
- <body>
- <FBD>
- <block localId="1" typeName="CounterST" instanceName="CounterST0" executionOrderId="0" height="60" width="125">
- <position x="207" y="53"/>
- <inputVariables>
- <variable formalParameter="Reset">
- <connectionPointIn>
- <relPosition x="0" y="40"/>
- <connection refLocalId="2">
- <position x="207" y="93"/>
- <position x="114" y="93"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="125" y="40"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="2" executionOrderId="0" height="30" width="79" negated="false">
- <position x="35" y="78"/>
- <connectionPointOut>
- <relPosition x="79" y="15"/>
- </connectionPointOut>
- <expression>Reset</expression>
- </inVariable>
- <block localId="4" typeName="CounterFBD" instanceName="CounterFBD0" executionOrderId="0" height="54" width="121">
- <position x="211" y="146"/>
- <inputVariables>
- <variable formalParameter="Reset">
- <connectionPointIn>
- <relPosition x="0" y="37"/>
- <connection refLocalId="13">
- <position x="211" y="183"/>
- <position x="115" y="183"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="121" y="37"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <comment localId="6" height="365" width="569">
- <position x="620" y="130"/>
- <content>
- <xhtml:p><![CDATA[In this example function block with the same functionality
-is created using all five IEC 61131-3 programing languages:
-- IL;
-- FBD;
-- LD;
-- ST;
-- SFC.
-
-
-
-
-Function block is a counter with reset control input.
-If reset is True counter value is reset to the value defined by
-global configuration constant ResetCounterValue.
-If reset is False, counter is incremented every cycle.
-]]></xhtml:p>
- </content>
- </comment>
- <block localId="7" typeName="CounterSFC" instanceName="CounterSFC0" executionOrderId="0" height="52" width="121">
- <position x="211" y="237"/>
- <inputVariables>
- <variable formalParameter="Reset">
- <connectionPointIn>
- <relPosition x="0" y="36"/>
- <connection refLocalId="12">
- <position x="211" y="273"/>
- <position x="103" y="273"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="121" y="36"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <block localId="9" typeName="CounterIL" instanceName="CounterIL0" executionOrderId="0" height="62" width="121">
- <position x="211" y="322"/>
- <inputVariables>
- <variable formalParameter="Reset">
- <connectionPointIn>
- <relPosition x="0" y="41"/>
- <connection refLocalId="10">
- <position x="211" y="363"/>
- <position x="101" y="363"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="121" y="41"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="10" executionOrderId="0" height="30" width="67" negated="false">
- <position x="34" y="348"/>
- <connectionPointOut>
- <relPosition x="67" y="15"/>
- </connectionPointOut>
- <expression>Reset</expression>
- </inVariable>
- <inVariable localId="12" executionOrderId="0" height="30" width="67" negated="false">
- <position x="36" y="258"/>
- <connectionPointOut>
- <relPosition x="67" y="15"/>
- </connectionPointOut>
- <expression>Reset</expression>
- </inVariable>
- <inVariable localId="13" executionOrderId="0" height="30" width="79" negated="false">
- <position x="36" y="168"/>
- <connectionPointOut>
- <relPosition x="79" y="15"/>
- </connectionPointOut>
- <expression>Reset</expression>
- </inVariable>
- <block localId="14" typeName="CounterLD" instanceName="CounterLD0" executionOrderId="0" height="62" width="124">
- <position x="210" y="412"/>
- <inputVariables>
- <variable formalParameter="Reset">
- <connectionPointIn>
- <relPosition x="0" y="41"/>
- <connection refLocalId="16">
- <position x="210" y="453"/>
- <position x="100" y="453"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="Out">
- <connectionPointOut>
- <relPosition x="124" y="41"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="16" executionOrderId="0" height="30" width="64" negated="false">
- <position x="36" y="438"/>
- <connectionPointOut>
- <relPosition x="64" y="15"/>
- </connectionPointOut>
- <expression>Reset</expression>
- </inVariable>
- <block localId="17" typeName="AverageVal" executionOrderId="0" height="470" width="100">
- <position x="514" y="28"/>
- <inputVariables>
- <variable formalParameter="Cnt1">
- <connectionPointIn>
- <relPosition x="0" y="65"/>
- <connection refLocalId="3">
- <position x="514" y="93"/>
- <position x="474" y="93"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="Cnt2">
- <connectionPointIn>
- <relPosition x="0" y="155"/>
- <connection refLocalId="5">
- <position x="514" y="183"/>
- <position x="473" y="183"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="Cnt3">
- <connectionPointIn>
- <relPosition x="0" y="245"/>
- <connection refLocalId="8">
- <position x="514" y="273"/>
- <position x="472" y="273"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="Cnt4">
- <connectionPointIn>
- <relPosition x="0" y="335"/>
- <connection refLocalId="11">
- <position x="514" y="363"/>
- <position x="469" y="363"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="Cnt5">
- <connectionPointIn>
- <relPosition x="0" y="425"/>
- <connection refLocalId="15">
- <position x="514" y="453"/>
- <position x="469" y="453"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="100" y="65"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <outVariable localId="18" executionOrderId="0" height="30" width="55" negated="false">
- <position x="649" y="78"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="17" formalParameter="OUT">
- <position x="649" y="93"/>
- <position x="614" y="93"/>
- </connection>
- </connectionPointIn>
- <expression>AVCnt</expression>
- </outVariable>
- <inOutVariable localId="3" executionOrderId="0" height="30" width="106" negatedOut="false" negatedIn="false">
- <position x="368" y="78"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="1" formalParameter="OUT">
- <position x="368" y="93"/>
- <position x="332" y="93"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="106" y="15"/>
- </connectionPointOut>
- <expression>Cnt1</expression>
- </inOutVariable>
- <inOutVariable localId="5" executionOrderId="0" height="30" width="103" negatedOut="false" negatedIn="false">
- <position x="370" y="168"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="4" formalParameter="OUT">
- <position x="370" y="183"/>
- <position x="332" y="183"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="103" y="15"/>
- </connectionPointOut>
- <expression>Cnt2</expression>
- </inOutVariable>
- <inOutVariable localId="8" executionOrderId="0" height="30" width="97" negatedOut="false" negatedIn="false">
- <position x="375" y="258"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="7" formalParameter="OUT">
- <position x="375" y="273"/>
- <position x="332" y="273"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="97" y="15"/>
- </connectionPointOut>
- <expression>Cnt3</expression>
- </inOutVariable>
- <inOutVariable localId="11" executionOrderId="0" height="30" width="91" negatedOut="false" negatedIn="false">
- <position x="378" y="348"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="9" formalParameter="OUT">
- <position x="378" y="363"/>
- <position x="332" y="363"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="91" y="15"/>
- </connectionPointOut>
- <expression>Cnt4</expression>
- </inOutVariable>
- <inOutVariable localId="15" executionOrderId="0" height="30" width="88" negatedOut="false" negatedIn="false">
- <position x="381" y="438"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="14" formalParameter="Out">
- <position x="381" y="453"/>
- <position x="334" y="453"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="88" y="15"/>
- </connectionPointOut>
- <expression>Cnt5</expression>
- </inOutVariable>
- </FBD>
- </body>
- </pou>
- <pou name="CounterST" pouType="functionBlock">
- <interface>
- <inputVars>
- <variable name="Reset">
- <type>
- <BOOL/>
- </type>
- </variable>
- </inputVars>
- <localVars>
- <variable name="Cnt">
- <type>
- <INT/>
- </type>
- </variable>
- </localVars>
- <outputVars>
- <variable name="OUT">
- <type>
- <INT/>
- </type>
- </variable>
- </outputVars>
- <externalVars constant="true">
- <variable name="ResetCounterValue">
- <type>
- <INT/>
- </type>
- </variable>
- </externalVars>
- </interface>
- <body>
- <ST>
- <xhtml:p><![CDATA[IF Reset THEN
- Cnt := ResetCounterValue;
-ELSE
- Cnt := Cnt + 1;
-END_IF;
-
-Out := Cnt;]]></xhtml:p>
- </ST>
- </body>
- </pou>
- <pou name="CounterFBD" pouType="functionBlock">
- <interface>
- <inputVars>
- <variable name="Reset">
- <type>
- <BOOL/>
- </type>
- </variable>
- </inputVars>
- <outputVars>
- <variable name="OUT">
- <type>
- <INT/>
- </type>
- </variable>
- </outputVars>
- <localVars>
- <variable name="Cnt">
- <type>
- <INT/>
- </type>
- </variable>
- </localVars>
- <externalVars constant="true">
- <variable name="ResetCounterValue">
- <type>
- <INT/>
- </type>
- </variable>
- </externalVars>
- </interface>
- <body>
- <FBD>
- <inVariable localId="1" executionOrderId="0" height="30" width="61" negated="false">
- <position x="321" y="58"/>
- <connectionPointOut>
- <relPosition x="61" y="15"/>
- </connectionPointOut>
- <expression>Reset</expression>
- </inVariable>
- <outVariable localId="2" executionOrderId="0" height="30" width="39" negated="false">
- <position x="675" y="137"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="3">
- <position x="675" y="152"/>
- <position x="589" y="152"/>
- </connection>
- </connectionPointIn>
- <expression>OUT</expression>
- </outVariable>
- <inOutVariable localId="3" executionOrderId="0" height="30" width="37" negatedOut="false" negatedIn="false">
- <position x="557" y="137"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="7" formalParameter="OUT">
- <position x="557" y="152"/>
- <position x="527" y="152"/>
- <position x="527" y="130"/>
- <position x="517" y="130"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="37" y="15"/>
- </connectionPointOut>
- <expression>Cnt</expression>
- </inOutVariable>
- <block localId="4" typeName="ADD" executionOrderId="0" height="80" width="69">
- <position x="328" y="115"/>
- <inputVariables>
- <variable formalParameter="IN1">
- <connectionPointIn>
- <relPosition x="0" y="35"/>
- <connection refLocalId="6">
- <position x="328" y="150"/>
- <position x="275" y="150"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN2">
- <connectionPointIn>
- <relPosition x="0" y="65"/>
- <connection refLocalId="3">
- <position x="328" y="180"/>
- <position x="317" y="180"/>
- <position x="317" y="213"/>
- <position x="604" y="213"/>
- <position x="604" y="152"/>
- <position x="594" y="152"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="69" y="35"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="5" executionOrderId="0" height="30" width="163" negated="false">
- <position x="222" y="256"/>
- <connectionPointOut>
- <relPosition x="163" y="15"/>
- </connectionPointOut>
- <expression>ResetCounterValue</expression>
- </inVariable>
- <inVariable localId="6" executionOrderId="0" height="30" width="21" negated="false">
- <position x="254" y="135"/>
- <connectionPointOut>
- <relPosition x="21" y="15"/>
- </connectionPointOut>
- <expression>1</expression>
- </inVariable>
- <block localId="7" typeName="SEL" executionOrderId="0" height="80" width="69">
- <position x="448" y="100"/>
- <inputVariables>
- <variable formalParameter="G">
- <connectionPointIn>
- <relPosition x="0" y="30"/>
- <connection refLocalId="1">
- <position x="448" y="130"/>
- <position x="415" y="130"/>
- <position x="415" y="73"/>
- <position x="382" y="73"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN0">
- <connectionPointIn>
- <relPosition x="0" y="50"/>
- <connection refLocalId="4" formalParameter="OUT">
- <position x="448" y="150"/>
- <position x="397" y="150"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN1">
- <connectionPointIn>
- <relPosition x="0" y="70"/>
- <connection refLocalId="5">
- <position x="448" y="170"/>
- <position x="414" y="170"/>
- <position x="414" y="271"/>
- <position x="385" y="271"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="69" y="30"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- </FBD>
- </body>
- </pou>
- <pou name="CounterSFC" pouType="functionBlock">
- <interface>
- <inputVars>
- <variable name="Reset">
- <type>
- <BOOL/>
- </type>
- </variable>
- </inputVars>
- <outputVars>
- <variable name="OUT">
- <type>
- <INT/>
- </type>
- </variable>
- </outputVars>
- <localVars>
- <variable name="Cnt">
- <type>
- <INT/>
- </type>
- </variable>
- </localVars>
- <externalVars constant="true">
- <variable name="ResetCounterValue">
- <type>
- <INT/>
- </type>
- </variable>
- </externalVars>
- </interface>
- <actions/>
- <body>
- <SFC>
- <step localId="1" name="Start" initialStep="true" height="34" width="90">
- <position x="241" y="14"/>
- <connectionPointOut formalParameter="">
- <relPosition x="45" y="34"/>
- </connectionPointOut>
- </step>
- <selectionDivergence localId="2" height="1" width="431">
- <position x="70" y="86"/>
- <connectionPointIn>
- <relPosition x="216" y="0"/>
- <connection refLocalId="1">
- <position x="286" y="86"/>
- <position x="286" y="42"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut formalParameter="">
- <relPosition x="0" y="1"/>
- </connectionPointOut>
- <connectionPointOut formalParameter="">
- <relPosition x="431" y="1"/>
- </connectionPointOut>
- </selectionDivergence>
- <transition localId="3" height="2" width="20">
- <position x="491" y="132"/>
- <connectionPointIn>
- <relPosition x="10" y="0"/>
- <connection refLocalId="2">
- <position x="501" y="132"/>
- <position x="501" y="87"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="10" y="2"/>
- </connectionPointOut>
- <condition>
- <inline name="">
- <ST>
- <xhtml:p><![CDATA[Reset]]></xhtml:p>
- </ST>
- </inline>
- </condition>
- </transition>
- <transition localId="4" height="2" width="20" executionOrderId="0">
- <position x="60" y="135"/>
- <connectionPointIn>
- <relPosition x="10" y="0"/>
- <connection refLocalId="2">
- <position x="70" y="135"/>
- <position x="70" y="87"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="10" y="2"/>
- </connectionPointOut>
- <condition>
- <inline name="">
- <ST>
- <xhtml:p><![CDATA[NOT Reset]]></xhtml:p>
- </ST>
- </inline>
- </condition>
- </transition>
- <step localId="5" name="ResetCounter" initialStep="false" height="30" width="134">
- <position x="434" y="190"/>
- <connectionPointIn>
- <relPosition x="67" y="0"/>
- <connection refLocalId="3">
- <position x="501" y="190"/>
- <position x="501" y="134"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut formalParameter="">
- <relPosition x="67" y="30"/>
- </connectionPointOut>
- <connectionPointOutAction formalParameter="">
- <relPosition x="134" y="15"/>
- </connectionPointOutAction>
- </step>
- <actionBlock localId="6" height="63" width="254">
- <position x="641" y="190"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="5">
- <position x="641" y="205"/>
- <position x="568" y="205"/>
- </connection>
- </connectionPointIn>
- <action localId="0">
- <relPosition x="0" y="0"/>
- <inline>
- <ST>
- <xhtml:p><![CDATA[Cnt := ResetCounterValue;]]></xhtml:p>
- </ST>
- </inline>
- </action>
- <action localId="0">
- <relPosition x="0" y="0"/>
- <inline>
- <ST>
- <xhtml:p><![CDATA[OUT := Cnt;]]></xhtml:p>
- </ST>
- </inline>
- </action>
- </actionBlock>
- <step localId="7" name="Count" initialStep="false" height="30" width="85" executionOrderId="0">
- <position x="28" y="191"/>
- <connectionPointIn>
- <relPosition x="42" y="0"/>
- <connection refLocalId="4">
- <position x="70" y="191"/>
- <position x="70" y="137"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut formalParameter="">
- <relPosition x="42" y="30"/>
- </connectionPointOut>
- <connectionPointOutAction formalParameter="">
- <relPosition x="85" y="15"/>
- </connectionPointOutAction>
- </step>
- <actionBlock localId="8" height="52" width="164" executionOrderId="0">
- <position x="154" y="191"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="7">
- <position x="154" y="206"/>
- <position x="113" y="206"/>
- </connection>
- </connectionPointIn>
- <action localId="0">
- <relPosition x="0" y="0"/>
- <inline>
- <ST>
- <xhtml:p><![CDATA[Cnt := Cnt + 1;]]></xhtml:p>
- </ST>
- </inline>
- </action>
- <action localId="0">
- <relPosition x="0" y="0"/>
- <inline>
- <ST>
- <xhtml:p><![CDATA[OUT := Cnt;]]></xhtml:p>
- </ST>
- </inline>
- </action>
- </actionBlock>
- <selectionConvergence localId="10" height="1" width="431">
- <position x="70" y="273"/>
- <connectionPointIn>
- <relPosition x="0" y="0"/>
- <connection refLocalId="13">
- <position x="70" y="273"/>
- <position x="70" y="244"/>
- </connection>
- </connectionPointIn>
- <connectionPointIn>
- <relPosition x="431" y="0"/>
- <connection refLocalId="14">
- <position x="501" y="273"/>
- <position x="501" y="250"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="216" y="1"/>
- </connectionPointOut>
- </selectionConvergence>
- <jumpStep localId="12" targetName="Start" height="13" width="12">
- <position x="280" y="317"/>
- <connectionPointIn>
- <relPosition x="6" y="0"/>
- <connection refLocalId="10">
- <position x="286" y="317"/>
- <position x="286" y="274"/>
- </connection>
- </connectionPointIn>
- </jumpStep>
- <transition localId="13" height="2" width="20" executionOrderId="0">
- <position x="60" y="242"/>
- <connectionPointIn>
- <relPosition x="10" y="0"/>
- <connection refLocalId="7">
- <position x="70" y="242"/>
- <position x="70" y="215"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="10" y="2"/>
- </connectionPointOut>
- <condition>
- <inline name="">
- <ST>
- <xhtml:p><![CDATA[Reset]]></xhtml:p>
- </ST>
- </inline>
- </condition>
- </transition>
- <transition localId="14" height="2" width="20" executionOrderId="0">
- <position x="491" y="248"/>
- <connectionPointIn>
- <relPosition x="10" y="0"/>
- <connection refLocalId="5">
- <position x="501" y="248"/>
- <position x="501" y="220"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="10" y="2"/>
- </connectionPointOut>
- <condition>
- <inline name="">
- <ST>
- <xhtml:p><![CDATA[NOT Reset]]></xhtml:p>
- </ST>
- </inline>
- </condition>
- </transition>
- </SFC>
- </body>
- </pou>
- <pou name="CounterIL" pouType="functionBlock">
- <interface>
- <localVars>
- <variable name="Cnt">
- <type>
- <INT/>
- </type>
- </variable>
- </localVars>
- <inputVars>
- <variable name="Reset">
- <type>
- <BOOL/>
- </type>
- </variable>
- </inputVars>
- <outputVars>
- <variable name="OUT">
- <type>
- <INT/>
- </type>
- </variable>
- </outputVars>
- <externalVars constant="true">
- <variable name="ResetCounterValue">
- <type>
- <INT/>
- </type>
- </variable>
- </externalVars>
- </interface>
- <body>
- <IL>
- <xhtml:p><![CDATA[LD Reset
-JMPC ResetCnt
-
-(* increment counter *)
-LD Cnt
-ADD 1
-JMP QuitFb
-
-ResetCnt:
-(* reset counter *)
-LD ResetCounterValue
-
-QuitFb:
-(* save results *)
-ST Cnt
-ST Out
-]]></xhtml:p>
- </IL>
- </body>
- </pou>
- <pou name="CounterLD" pouType="functionBlock">
- <interface>
- <inputVars>
- <variable name="Reset">
- <type>
- <BOOL/>
- </type>
- </variable>
- </inputVars>
- <outputVars>
- <variable name="Out">
- <type>
- <INT/>
- </type>
- </variable>
- </outputVars>
- <localVars>
- <variable name="Cnt">
- <type>
- <INT/>
- </type>
- </variable>
- </localVars>
- <externalVars constant="true">
- <variable name="ResetCounterValue">
- <type>
- <INT/>
- </type>
- </variable>
- </externalVars>
- </interface>
- <body>
- <LD>
- <outVariable localId="2" executionOrderId="0" height="30" width="34" negated="false">
- <position x="527" y="87"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="3">
- <position x="527" y="102"/>
- <position x="443" y="102"/>
- </connection>
- </connectionPointIn>
- <expression>Out</expression>
- </outVariable>
- <inOutVariable localId="3" executionOrderId="0" height="30" width="34" negatedOut="false" negatedIn="false">
- <position x="409" y="87"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="7" formalParameter="OUT">
- <position x="409" y="102"/>
- <position x="367" y="102"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="34" y="15"/>
- </connectionPointOut>
- <expression>Cnt</expression>
- </inOutVariable>
- <block localId="4" typeName="ADD" executionOrderId="0" height="80" width="67">
- <position x="180" y="87"/>
- <inputVariables>
- <variable formalParameter="IN1">
- <connectionPointIn>
- <relPosition x="0" y="35"/>
- <connection refLocalId="6">
- <position x="180" y="122"/>
- <position x="127" y="122"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN2">
- <connectionPointIn>
- <relPosition x="0" y="65"/>
- <connection refLocalId="3">
- <position x="180" y="152"/>
- <position x="169" y="152"/>
- <position x="169" y="185"/>
- <position x="453" y="185"/>
- <position x="453" y="102"/>
- <position x="443" y="102"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="67" y="35"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="5" executionOrderId="0" height="30" width="158" negated="false">
- <position x="74" y="228"/>
- <connectionPointOut>
- <relPosition x="158" y="15"/>
- </connectionPointOut>
- <expression>ResetCounterValue</expression>
- </inVariable>
- <inVariable localId="6" executionOrderId="0" height="30" width="21" negated="false">
- <position x="106" y="107"/>
- <connectionPointOut>
- <relPosition x="21" y="15"/>
- </connectionPointOut>
- <expression>1</expression>
- </inVariable>
- <block localId="7" typeName="SEL" executionOrderId="0" height="80" width="67">
- <position x="300" y="72"/>
- <inputVariables>
- <variable formalParameter="G">
- <connectionPointIn>
- <relPosition x="0" y="30"/>
- <connection refLocalId="9">
- <position x="300" y="102"/>
- <position x="266" y="102"/>
- <position x="266" y="62"/>
- <position x="134" y="62"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN0">
- <connectionPointIn>
- <relPosition x="0" y="50"/>
- <connection refLocalId="4" formalParameter="OUT">
- <position x="300" y="122"/>
- <position x="247" y="122"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN1">
- <connectionPointIn>
- <relPosition x="0" y="70"/>
- <connection refLocalId="5">
- <position x="300" y="142"/>
- <position x="266" y="142"/>
- <position x="266" y="243"/>
- <position x="232" y="243"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="67" y="30"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <leftPowerRail localId="8" height="40" width="3">
- <position x="46" y="42"/>
- <connectionPointOut formalParameter="">
- <relPosition x="3" y="20"/>
- </connectionPointOut>
- </leftPowerRail>
- <contact localId="9" height="15" width="21" negated="false">
- <position x="113" y="54"/>
- <connectionPointIn>
- <relPosition x="0" y="8"/>
- <connection refLocalId="8">
- <position x="113" y="62"/>
- <position x="49" y="62"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="21" y="8"/>
- </connectionPointOut>
- <variable>Reset</variable>
- </contact>
- </LD>
- </body>
- </pou>
- </pous>
- </types>
- <instances>
- <configurations>
- <configuration name="config">
- <resource name="resource1">
- <task name="plc_task" priority="1" interval="T#100ms">
- <pouInstance name="plc_task_instance" typeName="plc_prg"/>
- </task>
- </resource>
- <globalVars constant="true">
- <variable name="ResetCounterValue">
- <type>
- <INT/>
- </type>
- <initialValue>
- <simpleValue value="17"/>
- </initialValue>
- </variable>
- </globalVars>
- </configuration>
- </configurations>
- </instances>
-</project>
--- a/tests/python/beremiz.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<BeremizRoot URI_location="LOCAL://">
- <TargetType/>
- <Libraries Enable_Python_Library="true"/>
-</BeremizRoot>
--- a/tests/python/c_code@c_ext/baseconfnode.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<BaseParams Name="c_code" IEC_Channel="1"/>
--- a/tests/python/c_code@c_ext/cfile.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<CFile xmlns:xhtml="http://www.w3.org/1999/xhtml">
- <includes>
- <xhtml:p><![CDATA[
-]]></xhtml:p>
- </includes>
- <variables>
- <variable name="TestInput" type="SINT" initial="0"/>
- <variable name="TestOutput" type="SINT"/>
- </variables>
- <globals>
- <xhtml:p><![CDATA[
-volatile long Lock=0;
-volatile char PtoC=1,CtoP=2;
-
-extern long AtomicCompareExchange(long*,long, long);
-extern char *PLC_ID;
-
-int Simple_C_Call(int val){
- return val+1;
-}
-
-int Python_to_C_Call(char toC, char *fromC){
- /* Code called by python should never touch to
- variables modified by PLC thread directly
-
- AtomicCompareExchange comes from
- beremiz' runtime implementation */
-
- int res = 0;
- if(!AtomicCompareExchange((long*)&Lock, 0, 1)){
- PtoC=toC;
- *fromC=CtoP;
- AtomicCompareExchange((long*)&Lock, 1, 0);
- res=1;
- }
- printf("C code called by Python: toC %d fromC %d\n",toC,*fromC);
- printf("PLC_ID id %s\n",PLC_ID);
- return res;
-}
-
-int PLC_C_Call(char fromPLC, char *toPLC){
- /* PLC also have to be realy carefull not to
- conflict with asynchronous python access */
- if(!AtomicCompareExchange((long*)&Lock, 0, 1)){
- CtoP = fromPLC;
- *toPLC = PtoC;
- AtomicCompareExchange((long*)&Lock, 1, 0);
- return 1;
- }
- return 0;
-}
-]]></xhtml:p>
- </globals>
- <initFunction>
- <xhtml:p><![CDATA[
-]]></xhtml:p>
- </initFunction>
- <cleanUpFunction>
- <xhtml:p><![CDATA[
-]]></xhtml:p>
- </cleanUpFunction>
- <retrieveFunction>
- <xhtml:p><![CDATA[
-]]></xhtml:p>
- </retrieveFunction>
- <publishFunction>
- <xhtml:p><![CDATA[
-if(!AtomicCompareExchange((long*)&Lock, 0, 1)){
- TestInput = CtoP + PtoC + TestOutput;
- AtomicCompareExchange((long*)&Lock, 1, 0);
-}
-]]></xhtml:p>
- </publishFunction>
-</CFile>
--- a/tests/python/c_code@c_ext/confnode.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<CExtension CFLAGS="" LDFLAGS=""/>
--- a/tests/python/plc.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1644 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<project xmlns="http://www.plcopen.org/xml/tc6_0201" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.plcopen.org/xml/tc6_0201">
- <fileHeader companyName="" productName="Beremiz" productVersion="0.0" creationDateTime="2008-12-14T16:21:19" contentDescription="This example shows many features in Beremiz: 1. How to implement python extensions. 2. How to implement basic C extension. 3. How to use C code in IEC POUs. 4. How to call C functions from python code. 5. How to avoid race conditions between IEC, C and python code. 6. How to convert betweet different IEC types. "/>
- <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2020-10-19T23:53:08">
- <coordinateInfo>
- <pageSize x="1024" y="1024"/>
- <fbd>
- <scaling x="5" y="5"/>
- </fbd>
- <ld>
- <scaling x="5" y="5"/>
- </ld>
- <sfc>
- <scaling x="5" y="5"/>
- </sfc>
- </coordinateInfo>
- </contentHeader>
- <types>
- <dataTypes>
- <dataType name="CPLX_TYPE">
- <baseType>
- <struct>
- <variable name="FIRSTBYTE">
- <type>
- <SINT/>
- </type>
- </variable>
- <variable name="SECONDBYTE">
- <type>
- <SINT/>
- </type>
- </variable>
- </struct>
- </baseType>
- </dataType>
- <dataType name="StateMachine">
- <baseType>
- <enum>
- <values>
- <value name="STANDBY"/>
- <value name="START"/>
- <value name="STOP"/>
- </values>
- </enum>
- </baseType>
- </dataType>
- <dataType name="datatype0">
- <baseType>
- <BOOL/>
- </baseType>
- </dataType>
- <dataType name="blups">
- <baseType>
- <array>
- <dimension lower="0" upper="31"/>
- <baseType>
- <derived name="CPLX_TYPE"/>
- </baseType>
- </array>
- </baseType>
- </dataType>
- </dataTypes>
- <pous>
- <pou name="main_pytest" pouType="program">
- <interface>
- <localVars>
- <variable name="mux1_sel">
- <type>
- <INT/>
- </type>
- <initialValue>
- <simpleValue value="3"/>
- </initialValue>
- <documentation>
- <xhtml:p><![CDATA[blah]]></xhtml:p>
- </documentation>
- </variable>
- <variable name="mux2_sel">
- <type>
- <INT/>
- </type>
- <initialValue>
- <simpleValue value="3"/>
- </initialValue>
- </variable>
- <variable name="pytest_var1">
- <type>
- <string/>
- </type>
- </variable>
- <variable name="fefvsd">
- <type>
- <derived name="datatype0"/>
- </type>
- </variable>
- <variable name="pytest_var2">
- <type>
- <BOOL/>
- </type>
- </variable>
- <variable name="py1">
- <type>
- <derived name="python_eval"/>
- </type>
- </variable>
- <variable name="Block1">
- <type>
- <derived name="python_eval"/>
- </type>
- </variable>
- <variable name="Block2">
- <type>
- <derived name="python_eval"/>
- </type>
- </variable>
- <variable name="Block3">
- <type>
- <derived name="python_eval"/>
- </type>
- </variable>
- <variable name="pytest_var3">
- <type>
- <BOOL/>
- </type>
- </variable>
- <variable name="FromC">
- <type>
- <SINT/>
- </type>
- </variable>
- <variable name="C_Pragma0">
- <type>
- <derived name="C_Pragma"/>
- </type>
- </variable>
- </localVars>
- <externalVars>
- <variable name="TestInput">
- <type>
- <SINT/>
- </type>
- </variable>
- <variable name="TestOutput">
- <type>
- <SINT/>
- </type>
- </variable>
- </externalVars>
- <localVars>
- <variable name="FromInput">
- <type>
- <SINT/>
- </type>
- </variable>
- <variable name="Test_BCD">
- <type>
- <WORD/>
- </type>
- <initialValue>
- <simpleValue value="151"/>
- </initialValue>
- </variable>
- <variable name="Test_BCD_WRONG">
- <type>
- <WORD/>
- </type>
- <initialValue>
- <simpleValue value="154"/>
- </initialValue>
- </variable>
- <variable name="Test_BCD_CONVERTED">
- <type>
- <BOOL/>
- </type>
- </variable>
- <variable name="Test_BCD_RESULT">
- <type>
- <UINT/>
- </type>
- </variable>
- <variable name="Test_BCD_WRONG_RESULT">
- <type>
- <UINT/>
- </type>
- </variable>
- <variable name="Test_DT">
- <type>
- <DT/>
- </type>
- <initialValue>
- <simpleValue value="DT#2013-02-23-22:35:46"/>
- </initialValue>
- </variable>
- <variable name="Test_TOD">
- <type>
- <TOD/>
- </type>
- </variable>
- <variable name="Test_TOD_STRING">
- <type>
- <string/>
- </type>
- </variable>
- <variable name="Test_Date">
- <type>
- <DATE/>
- </type>
- </variable>
- <variable name="Test_String">
- <type>
- <string/>
- </type>
- <initialValue>
- <simpleValue value="test"/>
- </initialValue>
- </variable>
- <variable name="Test_Bool">
- <type>
- <BOOL/>
- </type>
- </variable>
- </localVars>
- <externalVars>
- <variable name="Global_RS">
- <type>
- <derived name="RS"/>
- </type>
- </variable>
- <variable name="TUTU">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="TOTO">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Test_Python_Var">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Second_Python_Var">
- <type>
- <INT/>
- </type>
- </variable>
- <variable name="Grumpf">
- <type>
- <string/>
- </type>
- </variable>
- </externalVars>
- <localVars>
- <variable name="RTC0">
- <type>
- <derived name="RTC"/>
- </type>
- </variable>
- </localVars>
- <externalVars>
- <variable name="SomeVarName">
- <type>
- <DINT/>
- </type>
- </variable>
- </externalVars>
- </interface>
- <body>
- <FBD>
- <inVariable localId="4" height="30" width="160" executionOrderId="0" negated="false">
- <position x="295" y="450"/>
- <connectionPointOut>
- <relPosition x="160" y="15"/>
- </connectionPointOut>
- <expression>'666'</expression>
- </inVariable>
- <block localId="5" width="125" height="80" typeName="python_eval" instanceName="py1" executionOrderId="0">
- <position x="686" y="400"/>
- <inputVariables>
- <variable formalParameter="TRIG">
- <connectionPointIn>
- <relPosition x="0" y="35"/>
- <connection refLocalId="7" formalParameter="OUT">
- <position x="686" y="435"/>
- <position x="285" y="435"/>
- <position x="285" y="480"/>
- <position x="250" y="480"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="CODE">
- <connectionPointIn>
- <relPosition x="0" y="65"/>
- <connection refLocalId="4">
- <position x="686" y="465"/>
- <position x="455" y="465"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="ACK">
- <connectionPointOut>
- <relPosition x="125" y="35"/>
- </connectionPointOut>
- </variable>
- <variable formalParameter="RESULT">
- <connectionPointOut>
- <relPosition x="125" y="65"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <block localId="7" width="70" height="45" typeName="NOT" executionOrderId="0">
- <position x="180" y="450"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="30"/>
- <connection refLocalId="3">
- <position x="180" y="480"/>
- <position x="155" y="480"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="70" y="30"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inOutVariable localId="3" height="30" width="120" executionOrderId="0" negatedOut="false" negatedIn="false">
- <position x="35" y="465"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="7" formalParameter="OUT">
- <position x="35" y="480"/>
- <position x="25" y="480"/>
- <position x="25" y="440"/>
- <position x="270" y="440"/>
- <position x="270" y="480"/>
- <position x="250" y="480"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="120" y="15"/>
- </connectionPointOut>
- <expression>pytest_var2</expression>
- </inOutVariable>
- <block localId="8" width="125" height="80" typeName="python_eval" instanceName="Block1" executionOrderId="0">
- <position x="686" y="545"/>
- <inputVariables>
- <variable formalParameter="TRIG">
- <connectionPointIn>
- <relPosition x="0" y="35"/>
- <connection refLocalId="7" formalParameter="OUT">
- <position x="686" y="580"/>
- <position x="285" y="580"/>
- <position x="285" y="480"/>
- <position x="250" y="480"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="CODE">
- <connectionPointIn>
- <relPosition x="0" y="65"/>
- <connection refLocalId="9">
- <position x="686" y="610"/>
- <position x="665" y="610"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="ACK">
- <connectionPointOut>
- <relPosition x="125" y="35"/>
- </connectionPointOut>
- </variable>
- <variable formalParameter="RESULT">
- <connectionPointOut>
- <relPosition x="125" y="65"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="9" height="30" width="370" executionOrderId="0" negated="false">
- <position x="295" y="595"/>
- <connectionPointOut>
- <relPosition x="370" y="15"/>
- </connectionPointOut>
- <expression>'sys.stdout.write("FBID :"+str(FBID)+"\n")'</expression>
- </inVariable>
- <inVariable localId="11" height="30" width="290" executionOrderId="0" negated="false">
- <position x="295" y="735"/>
- <connectionPointOut>
- <relPosition x="290" y="15"/>
- </connectionPointOut>
- <expression>'PLCBinary.Simple_C_Call(5678)'</expression>
- </inVariable>
- <block localId="12" width="125" height="80" typeName="python_eval" instanceName="Block2" executionOrderId="0">
- <position x="686" y="687"/>
- <inputVariables>
- <variable formalParameter="TRIG">
- <connectionPointIn>
- <relPosition x="0" y="33"/>
- <connection refLocalId="7" formalParameter="OUT">
- <position x="686" y="720"/>
- <position x="285" y="720"/>
- <position x="285" y="480"/>
- <position x="250" y="480"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="CODE">
- <connectionPointIn>
- <relPosition x="0" y="63"/>
- <connection refLocalId="11">
- <position x="686" y="750"/>
- <position x="585" y="750"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="ACK">
- <connectionPointOut>
- <relPosition x="125" y="33"/>
- </connectionPointOut>
- </variable>
- <variable formalParameter="RESULT">
- <connectionPointOut>
- <relPosition x="125" y="63"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="14" height="30" width="290" executionOrderId="0" negated="false">
- <position x="290" y="885"/>
- <connectionPointOut>
- <relPosition x="290" y="15"/>
- </connectionPointOut>
- <expression>'MyPythonFunc(42)'</expression>
- </inVariable>
- <block localId="15" width="125" height="80" typeName="python_eval" instanceName="Block3" executionOrderId="0">
- <position x="686" y="837"/>
- <inputVariables>
- <variable formalParameter="TRIG">
- <connectionPointIn>
- <relPosition x="0" y="33"/>
- <connection refLocalId="7" formalParameter="OUT">
- <position x="686" y="870"/>
- <position x="285" y="870"/>
- <position x="285" y="480"/>
- <position x="250" y="480"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="CODE">
- <connectionPointIn>
- <relPosition x="0" y="63"/>
- <connection refLocalId="14">
- <position x="686" y="900"/>
- <position x="580" y="900"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="ACK">
- <connectionPointOut>
- <relPosition x="125" y="33"/>
- </connectionPointOut>
- </variable>
- <variable formalParameter="RESULT">
- <connectionPointOut>
- <relPosition x="125" y="63"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <comment localId="16" height="90" width="680">
- <position x="35" y="275"/>
- <content>
- <xhtml:p><![CDATA[This part of the example test that, despite of 2T period clock stimulating TRIG pin of pyth_eval blocks, blocks keep executing one after the other, in respect of execution order.]]></xhtml:p>
- </content>
- </comment>
- <block localId="17" width="80" height="120" typeName="MUX" executionOrderId="0">
- <position x="1101" y="790"/>
- <inputVariables>
- <variable formalParameter="K">
- <connectionPointIn>
- <relPosition x="0" y="30"/>
- <connection refLocalId="18">
- <position x="1101" y="820"/>
- <position x="1076" y="820"/>
- <position x="1076" y="810"/>
- <position x="1060" y="810"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN0">
- <connectionPointIn>
- <relPosition x="0" y="50"/>
- <connection refLocalId="5" formalParameter="RESULT">
- <position x="1101" y="840"/>
- <position x="941" y="840"/>
- <position x="941" y="465"/>
- <position x="811" y="465"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN1">
- <connectionPointIn>
- <relPosition x="0" y="70"/>
- <connection refLocalId="8" formalParameter="RESULT">
- <position x="1101" y="860"/>
- <position x="926" y="860"/>
- <position x="926" y="610"/>
- <position x="811" y="610"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN2">
- <connectionPointIn>
- <relPosition x="0" y="90"/>
- <connection refLocalId="12" formalParameter="RESULT">
- <position x="1101" y="880"/>
- <position x="911" y="880"/>
- <position x="911" y="750"/>
- <position x="811" y="750"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN3">
- <connectionPointIn>
- <relPosition x="0" y="110"/>
- <connection refLocalId="15" formalParameter="RESULT">
- <position x="1101" y="900"/>
- <position x="811" y="900"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="80" y="30"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <outVariable localId="19" height="35" width="125" executionOrderId="0" negated="false">
- <position x="1271" y="805"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="17" formalParameter="OUT">
- <position x="1271" y="820"/>
- <position x="1181" y="820"/>
- </connection>
- </connectionPointIn>
- <expression>pytest_var1</expression>
- </outVariable>
- <block localId="21" width="80" height="120" typeName="MUX" executionOrderId="0">
- <position x="1106" y="385"/>
- <inputVariables>
- <variable formalParameter="K">
- <connectionPointIn>
- <relPosition x="0" y="30"/>
- <connection refLocalId="22">
- <position x="1106" y="415"/>
- <position x="1076" y="415"/>
- <position x="1076" y="405"/>
- <position x="1055" y="405"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN0">
- <connectionPointIn>
- <relPosition x="0" y="50"/>
- <connection refLocalId="5" formalParameter="ACK">
- <position x="1106" y="435"/>
- <position x="811" y="435"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN1">
- <connectionPointIn>
- <relPosition x="0" y="70"/>
- <connection refLocalId="8" formalParameter="ACK">
- <position x="1106" y="455"/>
- <position x="841" y="455"/>
- <position x="841" y="580"/>
- <position x="811" y="580"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN2">
- <connectionPointIn>
- <relPosition x="0" y="90"/>
- <connection refLocalId="12" formalParameter="ACK">
- <position x="1106" y="475"/>
- <position x="856" y="475"/>
- <position x="856" y="720"/>
- <position x="811" y="720"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN3">
- <connectionPointIn>
- <relPosition x="0" y="110"/>
- <connection refLocalId="15" formalParameter="ACK">
- <position x="1106" y="495"/>
- <position x="871" y="495"/>
- <position x="871" y="870"/>
- <position x="811" y="870"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="80" y="30"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="22" height="30" width="74" executionOrderId="0" negated="false">
- <position x="981" y="390"/>
- <connectionPointOut>
- <relPosition x="74" y="15"/>
- </connectionPointOut>
- <expression>mux1_sel</expression>
- </inVariable>
- <outVariable localId="23" height="35" width="125" executionOrderId="0" negated="false">
- <position x="1271" y="400"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="21" formalParameter="OUT">
- <position x="1271" y="415"/>
- <position x="1186" y="415"/>
- </connection>
- </connectionPointIn>
- <expression>pytest_var3</expression>
- </outVariable>
- <outVariable localId="25" height="30" width="60" executionOrderId="0" negated="false">
- <position x="320" y="1075"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="26" formalParameter="OUT">
- <position x="320" y="1090"/>
- <position x="265" y="1090"/>
- </connection>
- </connectionPointIn>
- <expression>FromC</expression>
- </outVariable>
- <inVariable localId="1" height="30" width="30" executionOrderId="0" negated="false">
- <position x="105" y="1075"/>
- <connectionPointOut>
- <relPosition x="30" y="15"/>
- </connectionPointOut>
- <expression>23</expression>
- </inVariable>
- <block localId="26" width="80" height="45" typeName="C_Pragma" instanceName="C_Pragma0" executionOrderId="0">
- <position x="185" y="1060"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="30"/>
- <connection refLocalId="1">
- <position x="185" y="1090"/>
- <position x="135" y="1090"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="80" y="30"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="27" height="30" width="90" executionOrderId="0" negated="false">
- <position x="100" y="1190"/>
- <connectionPointOut>
- <relPosition x="90" y="15"/>
- </connectionPointOut>
- <expression>TestInput</expression>
- </inVariable>
- <outVariable localId="28" height="30" width="105" executionOrderId="0" negated="false">
- <position x="195" y="1125"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="2">
- <position x="195" y="1140"/>
- <position x="140" y="1140"/>
- </connection>
- </connectionPointIn>
- <expression>TestOutput</expression>
- </outVariable>
- <outVariable localId="29" height="30" width="85" executionOrderId="0" negated="false">
- <position x="215" y="1190"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="27">
- <position x="215" y="1205"/>
- <position x="190" y="1205"/>
- </connection>
- </connectionPointIn>
- <expression>FromInput</expression>
- </outVariable>
- <inVariable localId="2" height="30" width="30" executionOrderId="0" negated="false">
- <position x="110" y="1125"/>
- <connectionPointOut>
- <relPosition x="30" y="15"/>
- </connectionPointOut>
- <expression>10</expression>
- </inVariable>
- <comment localId="30" height="105" width="465">
- <position x="50" y="925"/>
- <content>
- <xhtml:p><![CDATA[You will be ready to use beremiz with C and Python when you will understand why "FromInput" is equal to 75.
-Happy hacking! ]]></xhtml:p>
- </content>
- </comment>
- <comment localId="31" height="90" width="345">
- <position x="295" y="485"/>
- <content>
- <xhtml:p><![CDATA[Sleep here is bad. It blocks other py_eval instances. Whith a wxGlade GUI, GUI freeze for a second.]]></xhtml:p>
- </content>
- </comment>
- <comment localId="6" height="80" width="345">
- <position x="295" y="630"/>
- <content>
- <xhtml:p><![CDATA[Prints FBID to stdout of PLC runtime. FBID is a unique reference to py_eval instance.]]></xhtml:p>
- </content>
- </comment>
- <comment localId="10" height="85" width="345">
- <position x="295" y="770"/>
- <content>
- <xhtml:p><![CDATA[Simple_C_Call is declared in C_File "1.x:c_code". See python ctypes manual for details on typing.]]></xhtml:p>
- </content>
- </comment>
- <comment localId="32" height="145" width="235">
- <position x="25" y="505"/>
- <content>
- <xhtml:p><![CDATA[Fast clock, at least faster that sleep(1). See what happens when python takes time to answer : PLC continues.]]></xhtml:p>
- </content>
- </comment>
- <outVariable localId="33" height="30" width="133" executionOrderId="0" negated="false">
- <position x="580" y="1564"/>
- <connectionPointIn>
- <relPosition x="0" y="16"/>
- <connection refLocalId="35" formalParameter="OUT">
- <position x="580" y="1580"/>
- <position x="371" y="1580"/>
- </connection>
- </connectionPointIn>
- <expression>Test_BCD_RESULT</expression>
- </outVariable>
- <inVariable localId="34" height="30" width="75" executionOrderId="0" negated="false">
- <position x="60" y="1564"/>
- <connectionPointOut>
- <relPosition x="75" y="16"/>
- </connectionPointOut>
- <expression>Test_BCD</expression>
- </inVariable>
- <block localId="35" width="106" height="60" typeName="BCD_TO_UINT" executionOrderId="0">
- <position x="265" y="1539"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="41"/>
- <connection refLocalId="34">
- <position x="265" y="1580"/>
- <position x="135" y="1580"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="106" y="41"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="36" height="30" width="66" executionOrderId="0" negated="false">
- <position x="60" y="1774"/>
- <connectionPointOut>
- <relPosition x="66" y="16"/>
- </connectionPointOut>
- <expression>Test_DT</expression>
- </inVariable>
- <block localId="37" width="255" height="45" typeName="DATE_AND_TIME_TO_TIME_OF_DAY" executionOrderId="0">
- <position x="265" y="1759"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="31"/>
- <connection refLocalId="36">
- <position x="265" y="1790"/>
- <position x="125" y="1790"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="255" y="31"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <block localId="38" width="195" height="45" typeName="DATE_AND_TIME_TO_DATE" executionOrderId="0">
- <position x="265" y="1834"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="31"/>
- <connection refLocalId="36">
- <position x="265" y="1865"/>
- <position x="242" y="1865"/>
- <position x="242" y="1790"/>
- <position x="125" y="1790"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="195" y="31"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <outVariable localId="40" height="30" width="82" executionOrderId="0" negated="false">
- <position x="580" y="1849"/>
- <connectionPointIn>
- <relPosition x="0" y="16"/>
- <connection refLocalId="38" formalParameter="OUT">
- <position x="580" y="1865"/>
- <position x="460" y="1865"/>
- </connection>
- </connectionPointIn>
- <expression>Test_Date</expression>
- </outVariable>
- <outVariable localId="42" height="30" width="98" executionOrderId="0" negated="false">
- <position x="465" y="1944"/>
- <connectionPointIn>
- <relPosition x="0" y="16"/>
- <connection refLocalId="46" formalParameter="OUT">
- <position x="465" y="1960"/>
- <position x="395" y="1960"/>
- </connection>
- </connectionPointIn>
- <expression>Test_String</expression>
- </outVariable>
- <outVariable localId="43" height="30" width="82" executionOrderId="0" negated="false">
- <position x="465" y="2014"/>
- <connectionPointIn>
- <relPosition x="0" y="16"/>
- <connection refLocalId="44" formalParameter="OUT">
- <position x="465" y="2030"/>
- <position x="400" y="2030"/>
- </connection>
- </connectionPointIn>
- <expression>Test_Bool</expression>
- </outVariable>
- <block localId="44" width="135" height="45" typeName="STRING_TO_BOOL" executionOrderId="0">
- <position x="265" y="1999"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="31"/>
- <connection refLocalId="45">
- <position x="265" y="2030"/>
- <position x="115" y="2030"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="135" y="31"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="45" height="30" width="58" executionOrderId="0" negated="false">
- <position x="60" y="2014"/>
- <connectionPointOut>
- <relPosition x="58" y="16"/>
- </connectionPointOut>
- <expression>'True'</expression>
- </inVariable>
- <block localId="46" width="130" height="45" typeName="INT_TO_STRING" executionOrderId="0">
- <position x="265" y="1929"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="31"/>
- <connection refLocalId="58">
- <position x="265" y="1960"/>
- <position x="205" y="1960"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="130" y="31"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="50" height="30" width="106" executionOrderId="0" negated="false">
- <position x="75" y="2275"/>
- <connectionPointOut>
- <relPosition x="106" y="15"/>
- </connectionPointOut>
- <expression>Global_RS.Q1</expression>
- </inVariable>
- <block localId="51" width="70" height="85" typeName="AND" executionOrderId="0">
- <position x="240" y="2255"/>
- <inputVariables>
- <variable formalParameter="IN1" negated="true">
- <connectionPointIn>
- <relPosition x="0" y="35"/>
- <connection refLocalId="50">
- <position x="240" y="2290"/>
- <position x="180" y="2290"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN2">
- <connectionPointIn>
- <relPosition x="0" y="70"/>
- <connection refLocalId="52">
- <position x="240" y="2325"/>
- <position x="180" y="2325"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="70" y="35"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="52" height="30" width="105" executionOrderId="0" negated="false">
- <position x="75" y="2310"/>
- <connectionPointOut>
- <relPosition x="105" y="15"/>
- </connectionPointOut>
- <expression>BOOL#TRUE</expression>
- </inVariable>
- <outVariable localId="13" height="30" width="105" executionOrderId="0" negated="false">
- <position x="385" y="2275"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="51" formalParameter="OUT">
- <position x="385" y="2290"/>
- <position x="310" y="2290"/>
- </connection>
- </connectionPointIn>
- <expression>Global_RS.S</expression>
- </outVariable>
- <outVariable localId="20" height="30" width="106" executionOrderId="0" negated="false">
- <position x="385" y="2390"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="41" formalParameter="OUT">
- <position x="385" y="2405"/>
- <position x="310" y="2405"/>
- </connection>
- </connectionPointIn>
- <expression>Global_RS.R1</expression>
- </outVariable>
- <inVariable localId="24" height="30" width="106" executionOrderId="0" negated="false">
- <position x="75" y="2390"/>
- <connectionPointOut>
- <relPosition x="106" y="15"/>
- </connectionPointOut>
- <expression>Global_RS.Q1</expression>
- </inVariable>
- <block localId="41" width="70" height="85" typeName="OR" executionOrderId="0">
- <position x="240" y="2370"/>
- <inputVariables>
- <variable formalParameter="IN1">
- <connectionPointIn>
- <relPosition x="0" y="35"/>
- <connection refLocalId="24">
- <position x="240" y="2405"/>
- <position x="180" y="2405"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN2">
- <connectionPointIn>
- <relPosition x="0" y="70"/>
- <connection refLocalId="48">
- <position x="240" y="2440"/>
- <position x="180" y="2440"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="70" y="35"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="48" height="30" width="105" executionOrderId="0" negated="false">
- <position x="75" y="2425"/>
- <connectionPointOut>
- <relPosition x="105" y="15"/>
- </connectionPointOut>
- <expression>BOOL#FALSE</expression>
- </inVariable>
- <outVariable localId="54" height="30" width="135" executionOrderId="0" negated="false">
- <position x="930" y="1774"/>
- <connectionPointIn>
- <relPosition x="0" y="16"/>
- <connection refLocalId="55" formalParameter="OUT">
- <position x="930" y="1790"/>
- <position x="855" y="1790"/>
- </connection>
- </connectionPointIn>
- <expression>Test_TOD_STRING</expression>
- </outVariable>
- <block localId="55" width="125" height="45" typeName="TOD_TO_STRING" executionOrderId="0">
- <position x="730" y="1759"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="31"/>
- <connection refLocalId="39">
- <position x="730" y="1790"/>
- <position x="655" y="1790"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="125" y="31"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inOutVariable localId="39" height="30" width="75" executionOrderId="0" negatedOut="false" negatedIn="false">
- <position x="580" y="1774"/>
- <connectionPointIn>
- <relPosition x="0" y="16"/>
- <connection refLocalId="37" formalParameter="OUT">
- <position x="580" y="1790"/>
- <position x="520" y="1790"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="75" y="16"/>
- </connectionPointOut>
- <expression>Test_TOD</expression>
- </inOutVariable>
- <inVariable localId="49" height="30" width="30" executionOrderId="0" negated="false">
- <position x="160" y="2510"/>
- <connectionPointOut>
- <relPosition x="30" y="15"/>
- </connectionPointOut>
- <expression>42</expression>
- </inVariable>
- <outVariable localId="57" height="30" width="50" executionOrderId="0" negated="false">
- <position x="240" y="2510"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="49">
- <position x="240" y="2525"/>
- <position x="190" y="2525"/>
- </connection>
- </connectionPointIn>
- <expression>TOTO</expression>
- </outVariable>
- <outVariable localId="56" height="30" width="50" executionOrderId="0" negated="false">
- <position x="240" y="2550"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="49">
- <position x="240" y="2565"/>
- <position x="215" y="2565"/>
- <position x="215" y="2525"/>
- <position x="190" y="2525"/>
- </connection>
- </connectionPointIn>
- <expression>TUTU</expression>
- </outVariable>
- <inVariable localId="58" height="30" width="146" executionOrderId="0" negated="false">
- <position x="60" y="1944"/>
- <connectionPointOut>
- <relPosition x="146" y="16"/>
- </connectionPointOut>
- <expression>Second_Python_Var</expression>
- </inVariable>
- <inVariable localId="59" height="30" width="30" executionOrderId="0" negated="false">
- <position x="100" y="1385"/>
- <connectionPointOut>
- <relPosition x="30" y="15"/>
- </connectionPointOut>
- <expression>1</expression>
- </inVariable>
- <block localId="61" typeName="function0" executionOrderId="0" height="45" width="111">
- <position x="760" y="1170"/>
- <inputVariables>
- <variable formalParameter="LocalVar0">
- <connectionPointIn>
- <relPosition x="0" y="30"/>
- <connection refLocalId="62">
- <position x="760" y="1200"/>
- <position x="723" y="1200"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="111" y="30"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <inVariable localId="62" executionOrderId="0" height="30" width="58" negated="false">
- <position x="665" y="1185"/>
- <connectionPointOut>
- <relPosition x="58" y="15"/>
- </connectionPointOut>
- <expression>fefvsd</expression>
- </inVariable>
- <outVariable localId="63" executionOrderId="0" height="30" width="58" negated="false">
- <position x="905" y="1185"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="61" formalParameter="OUT">
- <position x="905" y="1200"/>
- <position x="871" y="1200"/>
- </connection>
- </connectionPointIn>
- <expression>fefvsd</expression>
- </outVariable>
- <comment localId="53" height="80" width="420">
- <position x="75" y="2160"/>
- <content>
- <xhtml:p><![CDATA[Shows global variables access from resource configuration (res_pytest) and from project's configuration.]]></xhtml:p>
- </content>
- </comment>
- <inVariable localId="18" height="30" width="74" executionOrderId="0" negated="false">
- <position x="986" y="795"/>
- <connectionPointOut>
- <relPosition x="74" y="15"/>
- </connectionPointOut>
- <expression>mux2_sel</expression>
- </inVariable>
- <comment localId="60" height="45" width="930">
- <position x="60" y="1480"/>
- <content>
- <xhtml:p><![CDATA[Here is shown how to convert values between different types (BCD, DT, TOD, STRING and others) using standard functions.]]></xhtml:p>
- </content>
- </comment>
- <comment localId="64" height="55" width="300">
- <position x="665" y="1095"/>
- <content>
- <xhtml:p><![CDATA[Example of usage of user-defined function.]]></xhtml:p>
- </content>
- </comment>
- <comment localId="65" height="45" width="410">
- <position x="55" y="1315"/>
- <content>
- <xhtml:p><![CDATA[Shows access variable defined in python extension. ]]></xhtml:p>
- </content>
- </comment>
- <inVariable localId="66" height="30" width="137" executionOrderId="0" negated="false">
- <position x="60" y="1685"/>
- <connectionPointOut>
- <relPosition x="137" y="15"/>
- </connectionPointOut>
- <expression>Test_BCD_WRONG</expression>
- </inVariable>
- <block localId="67" width="106" height="100" typeName="BCD_TO_UINT" executionOrderId="0">
- <position x="265" y="1620"/>
- <inputVariables>
- <variable formalParameter="EN">
- <connectionPointIn>
- <relPosition x="0" y="40"/>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="80"/>
- <connection refLocalId="66">
- <position x="265" y="1700"/>
- <position x="255" y="1700"/>
- <position x="255" y="1700"/>
- <position x="345" y="1700"/>
- <position x="345" y="1700"/>
- <position x="197" y="1700"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="ENO">
- <connectionPointOut>
- <relPosition x="106" y="40"/>
- </connectionPointOut>
- </variable>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="106" y="80"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <outVariable localId="68" height="30" width="196" executionOrderId="0" negated="false">
- <position x="580" y="1685"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="67" formalParameter="OUT">
- <position x="580" y="1700"/>
- <position x="371" y="1700"/>
- </connection>
- </connectionPointIn>
- <expression>Test_BCD_WRONG_RESULT</expression>
- </outVariable>
- <comment localId="69" height="165" width="375">
- <position x="795" y="1590"/>
- <content>
- <xhtml:p><![CDATA[Incorrect BCD number is not converted to UINT.
-
-151 (16#97) is good BCD number , but
-154 (16#9A) is not.
-
-Try this out and look at value of Test_BCD_CONVERTED variable.
-
-
-]]></xhtml:p>
- </content>
- </comment>
- <outVariable localId="70" height="30" width="185" executionOrderId="0" negated="false">
- <position x="580" y="1645"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="67" formalParameter="ENO">
- <position x="580" y="1660"/>
- <position x="370" y="1660"/>
- </connection>
- </connectionPointIn>
- <expression>Test_BCD_CONVERTED</expression>
- </outVariable>
- <comment localId="71" height="215" width="680">
- <position x="35" y="30"/>
- <content>
- <xhtml:p><![CDATA[This example shows many features in Beremiz:
-
- 1. How to implement python extensions.
- 2. How to implement basic C extension.
- 3. How to use C code in IEC POUs.
- 4. How to call C functions from python code.
- 5. How to avoid race conditions between IEC, C and python code.
- 6. How to convert betweet different IEC types.
-]]></xhtml:p>
- </content>
- </comment>
- <outVariable localId="72" executionOrderId="0" height="30" width="60" negated="false">
- <position x="1065" y="1970"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="76" formalParameter="OUT">
- <position x="1065" y="1985"/>
- <position x="1025" y="1985"/>
- <position x="1025" y="1995"/>
- <position x="985" y="1995"/>
- </connection>
- </connectionPointIn>
- <expression>Grumpf</expression>
- </outVariable>
- <inVariable localId="73" executionOrderId="0" height="30" width="85" negated="false">
- <position x="625" y="1940"/>
- <connectionPointOut>
- <relPosition x="85" y="15"/>
- </connectionPointOut>
- <expression>BOOL#TRUE</expression>
- </inVariable>
- <inVariable localId="74" executionOrderId="0" height="30" width="70" negated="false">
- <position x="625" y="1975"/>
- <connectionPointOut>
- <relPosition x="70" y="15"/>
- </connectionPointOut>
- <expression>Test_DT</expression>
- </inVariable>
- <block localId="75" typeName="RTC" instanceName="RTC0" executionOrderId="0" height="90" width="65">
- <position x="760" y="1925"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="35"/>
- <connection refLocalId="73">
- <position x="760" y="1960"/>
- <position x="735" y="1960"/>
- <position x="735" y="1955"/>
- <position x="710" y="1955"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="PDT">
- <connectionPointIn>
- <relPosition x="0" y="70"/>
- <connection refLocalId="74">
- <position x="760" y="1995"/>
- <position x="727" y="1995"/>
- <position x="727" y="1990"/>
- <position x="695" y="1990"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="Q">
- <connectionPointOut>
- <relPosition x="65" y="35"/>
- </connectionPointOut>
- </variable>
- <variable formalParameter="CDT">
- <connectionPointOut>
- <relPosition x="65" y="70"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <block localId="76" typeName="DT_TO_STRING" executionOrderId="0" height="40" width="110">
- <position x="875" y="1965"/>
- <inputVariables>
- <variable formalParameter="IN">
- <connectionPointIn>
- <relPosition x="0" y="30"/>
- <connection refLocalId="75" formalParameter="CDT">
- <position x="875" y="1995"/>
- <position x="825" y="1995"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="110" y="30"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <block localId="77" typeName="ADD" executionOrderId="0" height="60" width="65">
- <position x="170" y="1370"/>
- <inputVariables>
- <variable formalParameter="IN1">
- <connectionPointIn>
- <relPosition x="0" y="30"/>
- <connection refLocalId="59">
- <position x="170" y="1400"/>
- <position x="130" y="1400"/>
- </connection>
- </connectionPointIn>
- </variable>
- <variable formalParameter="IN2">
- <connectionPointIn>
- <relPosition x="0" y="50"/>
- <connection refLocalId="78">
- <position x="170" y="1420"/>
- <position x="160" y="1420"/>
- <position x="160" y="1450"/>
- <position x="390" y="1450"/>
- <position x="390" y="1400"/>
- <position x="380" y="1400"/>
- </connection>
- </connectionPointIn>
- </variable>
- </inputVariables>
- <inOutVariables/>
- <outputVariables>
- <variable formalParameter="OUT">
- <connectionPointOut>
- <relPosition x="65" y="30"/>
- </connectionPointOut>
- </variable>
- </outputVariables>
- </block>
- <outVariable localId="47" executionOrderId="0" height="30" width="130" negated="false">
- <position x="625" y="1335"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="79">
- <position x="625" y="1350"/>
- <position x="590" y="1350"/>
- </connection>
- </connectionPointIn>
- <expression>Test_Python_Var</expression>
- </outVariable>
- <inVariable localId="79" executionOrderId="0" height="25" width="30" negated="false">
- <position x="560" y="1340"/>
- <connectionPointOut>
- <relPosition x="30" y="10"/>
- </connectionPointOut>
- <expression>23</expression>
- </inVariable>
- <inOutVariable localId="78" executionOrderId="0" height="30" width="100" negatedOut="false" negatedIn="false">
- <position x="280" y="1385"/>
- <connectionPointIn>
- <relPosition x="0" y="15"/>
- <connection refLocalId="77" formalParameter="OUT">
- <position x="280" y="1400"/>
- <position x="235" y="1400"/>
- </connection>
- </connectionPointIn>
- <connectionPointOut>
- <relPosition x="100" y="15"/>
- </connectionPointOut>
- <expression>SomeVarName</expression>
- </inOutVariable>
- </FBD>
- </body>
- </pou>
- <pou name="C_Pragma" pouType="functionBlock">
- <interface>
- <outputVars>
- <variable name="OUT">
- <type>
- <SINT/>
- </type>
- </variable>
- </outputVars>
- <inputVars>
- <variable name="IN">
- <type>
- <SINT/>
- </type>
- </variable>
- </inputVars>
- <localVars>
- <variable name="COORDS">
- <type>
- <array>
- <dimension lower="0" upper="5"/>
- <baseType>
- <SINT/>
- </baseType>
- </array>
- </type>
- <initialValue>
- <arrayValue>
- <value>
- <simpleValue value="54"/>
- </value>
- <value>
- <simpleValue value="55"/>
- </value>
- <value>
- <simpleValue value="56"/>
- </value>
- <value>
- <simpleValue value="57"/>
- </value>
- <value>
- <simpleValue value="58"/>
- </value>
- <value>
- <simpleValue value="59"/>
- </value>
- </arrayValue>
- </initialValue>
- </variable>
- <variable name="SMURF">
- <type>
- <derived name="CPLX_TYPE"/>
- </type>
- </variable>
- </localVars>
- <externalVars>
- <variable name="Global_RS">
- <type>
- <derived name="RS"/>
- </type>
- </variable>
- <variable name="Dudiduda">
- <type>
- <derived name="blups"/>
- </type>
- </variable>
- </externalVars>
- </interface>
- <body>
- <ST>
- <xhtml:p><![CDATA[(* hereafter is a C pragma accessing FB interface in a clean way *)
-{{
- char toPLC;
- char fromPLC = GetFbVar(IN);
- extern int PLC_C_Call(char, char *);
- if(PLC_C_Call(fromPLC, &toPLC)){
- SetFbVar(OUT, toPLC);
- }
- if(0){
- /* that code demonstrate C access to complex types */
- char somebyte = GetFbVar(COORDS, .table[3]);
- SetFbVar(SMURF, somebyte, .FIRSTBYTE);
- SetFbVar(COORDS, somebyte, .table[4]);
- }
-}}
-(* If you do not use GetFbVar and SetFbVar macros, expect unexpected behaviour*)
-Global_RS();
-
-(* testing access to global struct array *)
-Dudiduda[2].FIRSTBYTE := 0;
-]]></xhtml:p>
- </ST>
- </body>
- </pou>
- <pou name="norm" pouType="function">
- <interface>
- <returnType>
- <REAL/>
- </returnType>
- <inputVars>
- <variable name="IN1">
- <type>
- <REAL/>
- </type>
- </variable>
- <variable name="IN2">
- <type>
- <REAL/>
- </type>
- </variable>
- </inputVars>
- </interface>
- <body>
- <ST>
- <xhtml:p><![CDATA[NORM := SQRT(IN1 * IN1 + IN2 * IN2);]]></xhtml:p>
- </ST>
- </body>
- </pou>
- <pou name="function0" pouType="function">
- <interface>
- <returnType>
- <derived name="datatype0"/>
- </returnType>
- <inputVars>
- <variable name="LocalVar0">
- <type>
- <derived name="datatype0"/>
- </type>
- </variable>
- </inputVars>
- </interface>
- <body>
- <ST>
- <xhtml:p><![CDATA[function0 := LocalVar0;
-]]></xhtml:p>
- </ST>
- </body>
- </pou>
- </pous>
- </types>
- <instances>
- <configurations>
- <configuration name="config">
- <resource name="res_pytest">
- <task name="pytest_task" priority="0" interval="T#500ms"/>
- <globalVars>
- <variable name="TOTO">
- <type>
- <INT/>
- </type>
- </variable>
- </globalVars>
- <pouInstance name="pytest_instance" typeName="main_pytest"/>
- </resource>
- <globalVars>
- <variable name="Global_RS">
- <type>
- <derived name="RS"/>
- </type>
- </variable>
- <variable name="Dudiduda">
- <type>
- <derived name="blups"/>
- </type>
- </variable>
- <variable name="TUTU">
- <type>
- <INT/>
- </type>
- </variable>
- </globalVars>
- </configuration>
- </configurations>
- </instances>
-</project>
--- a/tests/python/py_ext_0@py_ext/baseconfnode.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<BaseParams xmlns:xsd="http://www.w3.org/2001/XMLSchema" IEC_Channel="2" Name="py_ext_0"/>
--- a/tests/python/py_ext_0@py_ext/pyfile.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <variables>
- <variable name="SomeVarName" type="DINT" onchange="MyFunc, SomeChange"/>
- <variable name="Grumpf" type="STRING" initial="'mhoo'" onchange="MyFunc, MyOtherFunc"/>
- </variables>
- <globals>
- <xhtml:p><![CDATA[
-print "All python PLC globals variables :", PLCGlobalsDesc
-print "Current extention name :", __ext_name__
-
-def MyFunc(*args):
- print args
-
-def MyOtherFunc(*args):
- print "other", args
-
-def SomeChange(*args):
- print "count",OnChange.SomeVarName.count
- print "first",OnChange.SomeVarName.first
- print "last",OnChange.SomeVarName.last
-
-
-]]></xhtml:p>
- </globals>
- <init>
- <xhtml:p><![CDATA[
-]]></xhtml:p>
- </init>
- <cleanup>
- <xhtml:p><![CDATA[
-]]></xhtml:p>
- </cleanup>
- <start>
- <xhtml:p><![CDATA[
-]]></xhtml:p>
- </start>
- <stop>
- <xhtml:p><![CDATA[
-]]></xhtml:p>
- </stop>
-</PyFile>
--- a/tests/python/python@py_ext/baseconfnode.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<BaseParams Name="python" IEC_Channel="0"/>
--- a/tests/python/python@py_ext/pyfile.xml Mon Sep 13 17:57:47 2021 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<PyFile xmlns:xhtml="http://www.w3.org/1999/xhtml">
- <variables>
- <variable name="Test_Python_Var" type="INT" initial="4"/>
- <variable name="Second_Python_Var" type="INT" initial="5"/>
- </variables>
- <globals>
- <xhtml:p><![CDATA[
-import time,sys,ctypes
-Python_to_C_Call = PLCBinary.Python_to_C_Call
-Python_to_C_Call.restype = ctypes.c_int
-Python_to_C_Call.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)]
-
-def MyPythonFunc(arg):
- i = ctypes.c_int()
- if(Python_to_C_Call(arg, i)):
- res = i.value
- print "toC:", arg, "from C:", res, "FBID:", FBID
- else:
- print "Failed Python_to_C_Call failed"
- res = None
- print "Python read PLC global :",PLCGlobals.Test_Python_Var
- print "Python read PLC global Grumpf :",PLCGlobals.Grumpf
- PLCGlobals.Second_Python_Var = 789
- sys.stdout.flush()
- return res
-
-async_error_test_code = """
-def badaboom():
- tuple()[0]
-
-import wx
-def badaboomwx():
- wx.CallAfter(badaboom)
-
-from threading import Timer
-a = Timer(3, badaboom)
-a.start()
-
-b = Timer(6, badaboomwx)
-b.start()
-"""
-]]></xhtml:p>
- </globals>
- <init>
- <xhtml:p><![CDATA[
-global x, y
-x = 2
-y = 5
-print "py_runtime init:", x, ",", y
-]]></xhtml:p>
- </init>
- <cleanup>
- <xhtml:p><![CDATA[
-print "py_runtime cleanup"
-]]></xhtml:p>
- </cleanup>
- <start>
- <xhtml:p><![CDATA[
-global x, y
-print "py_runtime start", x * x + y * y
-]]></xhtml:p>
- </start>
- <stop>
- <xhtml:p><![CDATA[
-print "py_runtime stop"
-]]></xhtml:p>
- </stop>
-</PyFile>