1076 " variable_table[%(num)s].type = %(type)s_ENUM;\n"%v |
1076 " variable_table[%(num)s].type = %(type)s_ENUM;\n"%v |
1077 for v in self._VariablesList if v["vartype"] != "FB" and v["type"] in DebugTypes ])} |
1077 for v in self._VariablesList if v["vartype"] != "FB" and v["type"] in DebugTypes ])} |
1078 |
1078 |
1079 return debug_code |
1079 return debug_code |
1080 |
1080 |
|
1081 def Generate_plc_python(self): |
|
1082 """ |
|
1083 Generate trace/debug code out of PLC variable list |
|
1084 """ |
|
1085 self.GetIECProgramsAndVariables() |
|
1086 |
|
1087 python_eval_fb_list = [] |
|
1088 for v in self._VariablesList : |
|
1089 if v["vartype"] == "FB" and v["type"] == "PYTHON_EVAL": |
|
1090 python_eval_fb_list.append(v) |
|
1091 python_eval_fb_count = len(python_eval_fb_list) |
|
1092 |
|
1093 # prepare debug code |
|
1094 python_code = targets.code("plc_python") % { |
|
1095 "python_eval_fb_count": python_eval_fb_count} |
|
1096 return python_code |
|
1097 |
1081 def Generate_plc_common_main(self): |
1098 def Generate_plc_common_main(self): |
1082 """ |
1099 """ |
1083 Use plugins layout given in LocationCFilesAndCFLAGS to |
1100 Use plugins layout given in LocationCFilesAndCFLAGS to |
1084 generate glue code that dispatch calls to all plugins |
1101 generate glue code that dispatch calls to all plugins |
1085 """ |
1102 """ |
1173 # Template based part of C code generation |
1190 # Template based part of C code generation |
1174 # files are stacked at the beginning, as files of plugin tree root |
1191 # files are stacked at the beginning, as files of plugin tree root |
1175 for generator, filename, name in [ |
1192 for generator, filename, name in [ |
1176 # debugger code |
1193 # debugger code |
1177 (self.Generate_plc_debugger, "plc_debugger.c", "Debugger"), |
1194 (self.Generate_plc_debugger, "plc_debugger.c", "Debugger"), |
|
1195 # IEC<->python gateway code |
|
1196 (self.Generate_plc_python, "plc_python.c", "IEC-Python gateway"), |
1178 # init/cleanup/retrieve/publish, run and align code |
1197 # init/cleanup/retrieve/publish, run and align code |
1179 (self.Generate_plc_common_main,"plc_common_main.c","Common runtime")]: |
1198 (self.Generate_plc_common_main,"plc_common_main.c","Common runtime")]: |
1180 try: |
1199 try: |
1181 # Do generate |
1200 # Do generate |
1182 code = generator() |
1201 code = generator() |
1406 #print weakcallable, value, args, kwargs |
1425 #print weakcallable, value, args, kwargs |
1407 wx.CallAfter(weakcallable.SetValue, value, *args, **kwargs) |
1426 wx.CallAfter(weakcallable.SetValue, value, *args, **kwargs) |
1408 # This will block thread if more than one call is waiting |
1427 # This will block thread if more than one call is waiting |
1409 elif debug_vars is not None: |
1428 elif debug_vars is not None: |
1410 wx.CallAfter(self.logger.write_warning, |
1429 wx.CallAfter(self.logger.write_warning, |
1411 "debug data not coherent %d != %d"%(len(debug_vars), len(self.TracedIECPath))) |
1430 "Debug data not coherent %d != %d\n"%(len(debug_vars), len(self.TracedIECPath))) |
1412 elif debug_tick == -1: |
1431 elif debug_tick == -1: |
1413 #wx.CallAfter(self.logger.write, "Debugger unavailable\n") |
1432 #wx.CallAfter(self.logger.write, "Debugger unavailable\n") |
1414 pass |
1433 pass |
1415 else: |
1434 else: |
1416 wx.CallAfter(self.logger.write, "Debugger disabled\n") |
1435 wx.CallAfter(self.logger.write, "Debugger disabled\n") |