22 # You should have received a copy of the GNU General Public License |
22 # You should have received a copy of the GNU General Public License |
23 # along with this program; if not, write to the Free Software |
23 # along with this program; if not, write to the Free Software |
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
25 |
25 |
26 |
26 |
27 from __future__ import absolute_import |
27 |
28 import os |
28 import os |
29 import re |
29 import re |
30 from builtins import str as text |
30 from builtins import str as text |
31 |
31 |
32 import util.paths as paths |
32 import util.paths as paths |
132 def _onchange(var): |
132 def _onchange(var): |
133 content = self.GetVarOnChangeContent(var) |
133 content = self.GetVarOnChangeContent(var) |
134 return repr(content) if content else None |
134 return repr(content) if content else None |
135 |
135 |
136 pyextname = self.CTNName() |
136 pyextname = self.CTNName() |
137 varinfos = map( |
137 varinfos = [{ |
138 lambda variable: { |
|
139 "name": variable.getname(), |
138 "name": variable.getname(), |
140 "desc": repr(variable.getdesc()), |
139 "desc": repr(variable.getdesc()), |
141 "onchangecode": _onchangecode(variable), |
140 "onchangecode": _onchangecode(variable), |
142 "onchange": _onchange(variable), |
141 "onchange": _onchange(variable), |
143 "opts": repr(variable.getopts()), |
142 "opts": repr(variable.getopts()), |
144 "configname": configname.upper(), |
143 "configname": configname.upper(), |
145 "uppername": variable.getname().upper(), |
144 "uppername": variable.getname().upper(), |
146 "IECtype": self.GetCTRoot().GetBaseType(variable.gettype()), |
145 "IECtype": self.GetCTRoot().GetBaseType(variable.gettype()), |
147 "initial": repr(variable.getinitial()), |
146 "initial": repr(variable.getinitial()), |
148 "pyextname": pyextname |
147 "pyextname": pyextname |
149 }, |
148 } for variable in self.CodeFile.variables.variable] |
150 self.CodeFile.variables.variable) |
|
151 |
149 |
152 onchange_var_count = len([None for varinfo in varinfos if varinfo["onchange"]]) |
150 onchange_var_count = len([None for varinfo in varinfos if varinfo["onchange"]]) |
153 |
151 |
154 # python side PLC global variables access stub |
152 # python side PLC global variables access stub |
155 globalstubs = "\n".join([ |
153 globalstubs = "\n".join([ |