Fixed build of tests/python.
authorEdouard Tisserant
Wed, 25 Feb 2015 14:00:11 +0100
changeset 1452 7a2b344de8cf
parent 1451 94e620cbd9de
child 1453 f31353cac197
Fixed build of tests/python.
py_ext/PythonFileCTNMixin.py
tests/python/plc.xml
tests/python/py_ext_0@py_ext/pyfile.xml
--- a/py_ext/PythonFileCTNMixin.py	Wed Feb 25 13:59:01 2015 +0100
+++ b/py_ext/PythonFileCTNMixin.py	Wed Feb 25 14:00:11 2015 +0100
@@ -74,7 +74,7 @@
         pyextname = self.CTNName()
         varinfos = map(lambda variable : {
                     "name": variable.getname(),
-                    "desc" : repr(variable.getdesc()),   
+                    "desc" : repr(variable.getdesc()),
                     "onchangecode" : '"'+variable.getonchange()+\
                                          "('"+variable.getname()+"')\"" \
                                      if variable.getonchange() else '""',
@@ -102,7 +102,7 @@
     %(desc)s,
     %(onchange)s,
     %(opts)s))
-""" % varinfo 
+""" % varinfo
       for varinfo in varinfos])
 
         # Runtime calls (start, stop, init, and cleanup)
@@ -130,7 +130,7 @@
 import ctypes
 _%(pyextname)sGlobalsDesc = []
 __ext_name__ = "%(pyextname)s"
-PLCGlobalsDesc.append(( "_%(pyextname)s" , _%(pyextname)sGlobalsDesc ))
+PLCGlobalsDesc.append(( "%(pyextname)s" , _%(pyextname)sGlobalsDesc ))
 %(globalstubs)s
 
 ## User code in "global" scope
@@ -208,8 +208,8 @@
     __SET_VAR(__%(name)s_notifier->,TRIG,,__BOOL_LITERAL(TRUE));
     __SET_VAR(__%(name)s_notifier->,CODE,,__STRING_LITERAL(%(onchangelen)d,%(onchangecode)s));
 """
-        vardec = "\n".join([(vardecfmt + vardeconchangefmt 
-                             if varinfo["onchange"] else vardecfmt)% varinfo 
+        vardec = "\n".join([(vardecfmt + vardeconchangefmt
+                             if varinfo["onchange"] else vardecfmt)% varinfo
                             for varinfo in varinfos])
         varret = "\n".join([varretfmt % varinfo for varinfo in varinfos])
         varpub = "\n".join([(varpubonchangefmt if varinfo["onchange"] else
@@ -219,6 +219,9 @@
                                 onchangelen = len(varinfo["onchangecode"]),**varinfo)
                             for varinfo in varinfos if varinfo["onchange"]])
 
+        # TODO : use config name obtained from model instead of default
+        # "config.h". User cannot change config name, but project imported
+        # or created in older beremiz vesion could use different name.
         PyCFileContent = """\
 /*
  * Code generated by Beremiz py_ext confnode
--- a/tests/python/plc.xml	Wed Feb 25 13:59:01 2015 +0100
+++ b/tests/python/plc.xml	Wed Feb 25 14:00:11 2015 +0100
@@ -1,7 +1,7 @@
 <?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="2015-02-02T23:04:42">
+  <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2015-02-25T13:38:24">
     <coordinateInfo>
       <pageSize x="1024" y="1024"/>
       <fbd>
@@ -1297,7 +1297,7 @@
   </types>
   <instances>
     <configurations>
-      <configuration name="conf_pytest">
+      <configuration name="config">
         <resource name="res_pytest">
           <task name="pytest_task" interval="T#1ms" priority="0"/>
           <globalVars>
--- a/tests/python/py_ext_0@py_ext/pyfile.xml	Wed Feb 25 13:59:01 2015 +0100
+++ b/tests/python/py_ext_0@py_ext/pyfile.xml	Wed Feb 25 14:00:11 2015 +0100
@@ -6,12 +6,12 @@
   </variables>
   <globals>
     <xhtml:p><![CDATA[
+print "All python PLC globals variables :", PLCGlobalsDesc
+print "Current extention name :", __ext_name__
 ]]></xhtml:p>
   </globals>
   <init>
     <xhtml:p><![CDATA[
-print "Exposed variables :", _PySafePLCGlobals
-print "PyExtName :", _PyExtName
 ]]></xhtml:p>
   </init>
   <cleanup>