Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
authorEdouard Tisserant
Thu, 27 Mar 2014 10:06:30 +0100
changeset 1401 611fded24ce4
parent 1400 65a751cbb9b9
child 1402 49441045b192
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Beremiz.py
IDEFrame.py
ProjectController.py
tests/python/beremiz.xml
tests/python/c_code@c_ext/baseconfnode.xml
tests/python/c_code@c_ext/cfile.xml
tests/python/c_code@c_ext/confnode.xml
tests/python/plc.xml
tests/python/python@py_ext/baseconfnode.xml
tests/python/python@py_ext/pyfile.xml
--- a/Beremiz.py	Fri Mar 21 00:21:15 2014 +0100
+++ b/Beremiz.py	Thu Mar 27 10:06:30 2014 +0100
@@ -349,13 +349,6 @@
     
     def _init_coll_AddMenu_Items(self, parent):
         IDEFrame._init_coll_AddMenu_Items(self, parent, False)
-        
-        # Disable add resource until matiec is able to handle multiple ressource definition
-        #new_id = wx.NewId()
-        #AppendMenu(parent, help='', id=new_id,
-        #          kind=wx.ITEM_NORMAL, text=_(u'&Resource'))
-        #self.Bind(wx.EVT_MENU, self.AddResourceMenu, id=new_id)
-        
         self._RecursiveAddMenuItems(parent, GetAddMenuItems())
     
     def _init_coll_HelpMenu_Items(self, parent):
@@ -1010,10 +1003,11 @@
             confnode_menu.Destroy()
             
             event.Skip()
-        elif item_infos["type"] != ITEM_PROJECT:
+        elif item_infos["type"] == ITEM_RESOURCE:
+            # prevent last resource to be delted
             parent = self.ProjectTree.GetItemParent(item)
             parent_name = self.ProjectTree.GetItemText(parent)
-            if item_infos["type"] != ITEM_RESOURCE or parent_name == _("Resources"):
+            if parent_name == _("Resources"):
                 IDEFrame.OnProjectTreeRightUp(self, event)
         else:
             IDEFrame.OnProjectTreeRightUp(self, event)
--- a/IDEFrame.py	Fri Mar 21 00:21:15 2014 +0100
+++ b/IDEFrame.py	Thu Mar 27 10:06:30 2014 +0100
@@ -36,8 +36,8 @@
  ID_PLCOPENEDITOREDITMENUADDFUNCTION, ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK, 
  ID_PLCOPENEDITOREDITMENUADDPROGRAM, ID_PLCOPENEDITOREDITMENUADDCONFIGURATION,
  ID_PLCOPENEDITOREDITMENUFINDNEXT, ID_PLCOPENEDITOREDITMENUFINDPREVIOUS,
- ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, 
-] = [wx.NewId() for _init_coll_EditMenu_Items in range(9)]
+ ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, ID_PLCOPENEDITOREDITMENUADDRESOURCE
+] = [wx.NewId() for _init_coll_EditMenu_Items in range(10)]
 
 # Define PLCOpenEditor DisplayMenu extra items id
 [ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE, 
@@ -325,6 +325,8 @@
               kind=wx.ITEM_NORMAL, text=_(u'Function &Block'))
         AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDPROGRAM,
               kind=wx.ITEM_NORMAL, text=_(u'&Program'))
+        AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDRESOURCE,
+                  kind=wx.ITEM_NORMAL, text=_(u'&Resource'))
         if add_config:
             AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION,
                   kind=wx.ITEM_NORMAL, text=_(u'&Configuration'))
@@ -385,6 +387,8 @@
               id=ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK)
         self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("program"),
               id=ID_PLCOPENEDITOREDITMENUADDPROGRAM)
+        self.Bind(wx.EVT_MENU, self.AddResourceMenu, 
+              id=ID_PLCOPENEDITOREDITMENUADDRESOURCE)
         self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu,
               id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION)
         self.Bind(wx.EVT_MENU, self.OnSelectAllMenu, id=wx.ID_SELECTALL)
--- a/ProjectController.py	Fri Mar 21 00:21:15 2014 +0100
+++ b/ProjectController.py	Thu Mar 27 10:06:30 2014 +0100
@@ -440,7 +440,7 @@
         if len(self.Libraries)==0:
             return [],[],()
         self.GetIECProgramsAndVariables()
-        LibIECCflags = '"-I%s"'%os.path.abspath(self.GetIECLibPath())
+        LibIECCflags = '"-I%s" -Wno-unused-function'%os.path.abspath(self.GetIECLibPath())
         LocatedCCodeAndFlags=[]
         Extras=[]
         for lib in self.Libraries:
@@ -668,7 +668,7 @@
         # Keep track of generated C files for later use by self.CTNGenerate_C
         self.PLCGeneratedCFiles = C_files
         # compute CFLAGS for plc
-        self.plcCFLAGS = '"-I%s"'%self.ieclib_path
+        self.plcCFLAGS = '"-I%s" -Wno-unused-function'%self.ieclib_path
         return True
 
     def GetBuilder(self):
--- a/tests/python/beremiz.xml	Fri Mar 21 00:21:15 2014 +0100
+++ b/tests/python/beremiz.xml	Thu Mar 27 10:06:30 2014 +0100
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version='1.0' encoding='utf-8'?>
 <BeremizRoot URI_location="LOCAL://">
   <TargetType/>
 </BeremizRoot>
--- a/tests/python/c_code@c_ext/baseconfnode.xml	Fri Mar 21 00:21:15 2014 +0100
+++ b/tests/python/c_code@c_ext/baseconfnode.xml	Thu Mar 27 10:06:30 2014 +0100
@@ -1,2 +1,2 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version='1.0' encoding='utf-8'?>
 <BaseParams Name="c_code" IEC_Channel="1"/>
--- a/tests/python/c_code@c_ext/cfile.xml	Fri Mar 21 00:21:15 2014 +0100
+++ b/tests/python/c_code@c_ext/cfile.xml	Thu Mar 27 10:06:30 2014 +0100
@@ -1,15 +1,15 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<CFile>
+<?xml version='1.0' encoding='utf-8'?>
+<CFile xmlns:xhtml="http://www.w3.org/1999/xhtml">
   <includes>
-<![CDATA[
-]]>
+    <xhtml:p><![CDATA[
+]]></xhtml:p>
   </includes>
   <variables>
     <variable name="TestInput" type="SINT" initial="0"/>
     <variable name="TestOutput" type="SINT"/>
   </variables>
   <globals>
-<![CDATA[
+    <xhtml:p><![CDATA[
 volatile long Lock=0;
 volatile char PtoC=1,CtoP=2;
 
@@ -48,26 +48,26 @@
   }
   return 0;
 }
-]]>
+]]></xhtml:p>
   </globals>
   <initFunction>
-<![CDATA[
-]]>
+    <xhtml:p><![CDATA[
+]]></xhtml:p>
   </initFunction>
   <cleanUpFunction>
-<![CDATA[
-]]>
+    <xhtml:p><![CDATA[
+]]></xhtml:p>
   </cleanUpFunction>
   <retrieveFunction>
-<![CDATA[
-]]>
+    <xhtml:p><![CDATA[
+]]></xhtml:p>
   </retrieveFunction>
   <publishFunction>
-<![CDATA[
+    <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	Fri Mar 21 00:21:15 2014 +0100
+++ b/tests/python/c_code@c_ext/confnode.xml	Thu Mar 27 10:06:30 2014 +0100
@@ -1,2 +1,2 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version='1.0' encoding='utf-8'?>
 <CExtension CFLAGS="" LDFLAGS=""/>
--- a/tests/python/plc.xml	Fri Mar 21 00:21:15 2014 +0100
+++ b/tests/python/plc.xml	Thu Mar 27 10:06:30 2014 +0100
@@ -1,14 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://www.plcopen.org/xml/tc6.xsd"
-         xsi:schemaLocation="http://www.plcopen.org/xml/tc6.xsd"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xmlns:xhtml="http://www.w3.org/1999/xhtml">
-  <fileHeader companyName=""
-              productName="Beremiz"
-              productVersion="0.0"
-              creationDateTime="2008-12-14T16:21:19"/>
-  <contentHeader name="Beremiz Python Support Tests"
-                 modificationDateTime="2013-05-15T18:19:52">
+<?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"/>
+  <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2014-03-27T09:15:55">
     <coordinateInfo>
       <pageSize x="1024" y="1024"/>
       <fbd>
@@ -428,7 +421,7 @@
             <comment localId="16" height="90" width="680">
               <position x="50" y="25"/>
               <content>
-<![CDATA[This 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><![CDATA[This 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">
@@ -674,32 +667,32 @@
             <comment localId="30" height="90" width="405">
               <position x="245" y="825"/>
               <content>
-<![CDATA[You will be ready to use beremiz with C and Python when you will understand why "FromInput" is equal  to 75.
-Enjoy. ]]>
+                <xhtml:p><![CDATA[You will be ready to use beremiz with C and Python when you will understand why "FromInput" is equal  to 75.
+Enjoy. ]]></xhtml:p>
               </content>
             </comment>
             <comment localId="31" height="60" width="345">
               <position x="295" y="265"/>
               <content>
-<![CDATA[Sleep here is bad. It blocks other py_eval instances. Whith a wxGlade GUI, GUI freeze for a second.]]>
+                <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="60" width="345">
               <position x="295" y="380"/>
               <content>
-<![CDATA[Prints FBID to stdout of PLC runtime. FBID is a unique reference to py_eval instance.]]>
+                <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="60" width="345">
               <position x="295" y="500"/>
               <content>
-<![CDATA[Simple_C_Call is declared in C_File "1.x:c_code". See python ctypes manual for details on typing.]]>
+                <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="105" width="235">
               <position x="25" y="285"/>
               <content>
-<![CDATA[Fast clock, at least faster that sleep(1). See what happens when python takes time to answer : PLC continues.]]>
+                <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="130">
@@ -889,23 +882,19 @@
                 </variable>
               </outputVariables>
             </block>
-            <inVariable localId="50" height="30" width="105">
+            <inVariable localId="50" height="30" width="105" executionOrderId="0" negated="false">
               <position x="200" y="1085"/>
               <connectionPointOut>
                 <relPosition x="105" y="15"/>
               </connectionPointOut>
               <expression>Global_RS.Q1</expression>
             </inVariable>
-            <block localId="51" width="70" height="85" typeName="AND">
+            <block localId="51" width="70" height="85" typeName="AND" executionOrderId="0">
               <position x="365" y="1065"/>
               <inputVariables>
                 <variable formalParameter="IN1" negated="true">
                   <connectionPointIn>
                     <relPosition x="0" y="35"/>
-                    <connection refLocalId="50">
-                      <position x="365" y="1100"/>
-                      <position x="305" y="1100"/>
-                    </connection>
                   </connectionPointIn>
                 </variable>
                 <variable formalParameter="IN2">
@@ -934,45 +923,33 @@
               </connectionPointOut>
               <expression>BOOL#TRUE</expression>
             </inVariable>
-            <outVariable localId="13" height="30" width="105">
+            <outVariable localId="13" height="30" width="105" executionOrderId="0" negated="false">
               <position x="510" y="1085"/>
               <connectionPointIn>
                 <relPosition x="0" y="15"/>
-                <connection refLocalId="51" formalParameter="OUT">
-                  <position x="510" y="1100"/>
-                  <position x="435" y="1100"/>
-                </connection>
               </connectionPointIn>
               <expression>Global_RS.S</expression>
             </outVariable>
-            <outVariable localId="20" height="30" width="105">
+            <outVariable localId="20" height="30" width="105" executionOrderId="0" negated="false">
               <position x="510" y="1200"/>
               <connectionPointIn>
                 <relPosition x="0" y="15"/>
-                <connection refLocalId="41" formalParameter="OUT">
-                  <position x="510" y="1215"/>
-                  <position x="435" y="1215"/>
-                </connection>
               </connectionPointIn>
               <expression>Global_RS.R1</expression>
             </outVariable>
-            <inVariable localId="24" height="30" width="105">
+            <inVariable localId="24" height="30" width="105" executionOrderId="0" negated="false">
               <position x="200" y="1200"/>
               <connectionPointOut>
                 <relPosition x="105" y="15"/>
               </connectionPointOut>
               <expression>Global_RS.Q1</expression>
             </inVariable>
-            <block localId="41" width="70" height="85" typeName="OR">
+            <block localId="41" width="70" height="85" typeName="OR" executionOrderId="0">
               <position x="365" y="1180"/>
               <inputVariables>
                 <variable formalParameter="IN1">
                   <connectionPointIn>
                     <relPosition x="0" y="35"/>
-                    <connection refLocalId="24">
-                      <position x="365" y="1215"/>
-                      <position x="305" y="1215"/>
-                    </connection>
                   </connectionPointIn>
                 </variable>
                 <variable formalParameter="IN2">
@@ -1117,6 +1094,12 @@
               </connectionPointOut>
               <expression>23</expression>
             </inVariable>
+            <comment localId="60" height="40" width="500">
+              <position x="120" y="1020"/>
+              <content>
+                <xhtml:p><![CDATA[Test for access to Gobal FB variables is disabled, as broken in matiec]]></xhtml:p>
+              </content>
+            </comment>
           </FBD>
         </body>
       </pou>
@@ -1185,7 +1168,7 @@
         </interface>
         <body>
           <ST>
-<![CDATA[(* hereafter is a C pragma accessing FB interface in a clean way *)
+            <xhtml:p><![CDATA[(* hereafter is a C pragma accessing FB interface in a clean way *)
 {{
   char toPLC;
   char fromPLC = GetFbVar(IN);
@@ -1202,7 +1185,7 @@
 }}
 (* If you do not use __GET_VAR and _SET_VAR macro, expect unexpected *)
 Global_RS();
-]]>
+]]></xhtml:p>
           </ST>
         </body>
       </pou>
@@ -1226,7 +1209,7 @@
         </interface>
         <body>
           <ST>
-<![CDATA[NORM := SQRT(IN1 * IN1 + IN2 * IN2);]]>
+            <xhtml:p><![CDATA[NORM := SQRT(IN1 * IN1 + IN2 * IN2);]]></xhtml:p>
           </ST>
         </body>
       </pou>
--- a/tests/python/python@py_ext/baseconfnode.xml	Fri Mar 21 00:21:15 2014 +0100
+++ b/tests/python/python@py_ext/baseconfnode.xml	Thu Mar 27 10:06:30 2014 +0100
@@ -1,2 +1,2 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version='1.0' encoding='utf-8'?>
 <BaseParams Name="python" IEC_Channel="0"/>
--- a/tests/python/python@py_ext/pyfile.xml	Fri Mar 21 00:21:15 2014 +0100
+++ b/tests/python/python@py_ext/pyfile.xml	Thu Mar 27 10:06:30 2014 +0100
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<PyFile>
+<?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>
-<![CDATA[
+    <xhtml:p><![CDATA[
 import time,sys,ctypes
 Python_to_C_Call = PLCBinary.Python_to_C_Call
 Python_to_C_Call.restype = ctypes.c_int
@@ -39,30 +39,30 @@
 b = Timer(6, badaboomwx)
 b.start()
 """
-]]>
+]]></xhtml:p>
   </globals>
   <init>
-<![CDATA[
+    <xhtml:p><![CDATA[
 global x, y
 x = 2
 y = 5
 print "py_runtime init:", x, ",", y
-]]>
+]]></xhtml:p>
   </init>
   <cleanup>
-<![CDATA[
+    <xhtml:p><![CDATA[
 print "py_runtime cleanup"
-]]>
+]]></xhtml:p>
   </cleanup>
   <start>
-<![CDATA[
+    <xhtml:p><![CDATA[
 global x, y
 print "py_runtime start", x * x + y * y
-]]>
+]]></xhtml:p>
   </start>
   <stop>
-<![CDATA[
+    <xhtml:p><![CDATA[
 print "py_runtime stop"
-]]>
+]]></xhtml:p>
   </stop>
 </PyFile>