equal
deleted
inserted
replaced
627 from plcopen.structures import IEC_KEYWORDS, TypeHierarchy_list |
627 from plcopen.structures import IEC_KEYWORDS, TypeHierarchy_list |
628 |
628 |
629 # Construct debugger natively supported types |
629 # Construct debugger natively supported types |
630 DebugTypes = [t for t in zip(*TypeHierarchy_list)[0] if not t.startswith("ANY")] + \ |
630 DebugTypes = [t for t in zip(*TypeHierarchy_list)[0] if not t.startswith("ANY")] + \ |
631 ["STEP","TRANSITION","ACTION"] |
631 ["STEP","TRANSITION","ACTION"] |
|
632 DebugTypesSize = {"BOOL" : 1, |
|
633 "STEP" : 1, |
|
634 "TRANSITION" : 1, |
|
635 "ACTION" : 1, |
|
636 "SINT" : 1, |
|
637 "USINT" : 1, |
|
638 "BYTE" : 1, |
|
639 "STRING" : 128, |
|
640 "INT" : 2, |
|
641 "UINT" : 2, |
|
642 "WORD" : 2, |
|
643 "WSTRING" : 0, #TODO |
|
644 "DINT" : 4, |
|
645 "UDINT" : 4, |
|
646 "DWORD" : 4, |
|
647 "LINT" : 4, |
|
648 "ULINT" : 8, |
|
649 "LWORD" : 8, |
|
650 "REAL" : 4, |
|
651 "LREAL" : 8, |
|
652 } |
632 |
653 |
633 import re |
654 import re |
634 import targets |
655 import targets |
635 import connectors |
656 import connectors |
636 from discovery import DiscoveryDialog |
657 from discovery import DiscoveryDialog |
1104 """ |
1125 """ |
1105 self.GetIECProgramsAndVariables() |
1126 self.GetIECProgramsAndVariables() |
1106 |
1127 |
1107 # prepare debug code |
1128 # prepare debug code |
1108 debug_code = targets.code("plc_debug") % { |
1129 debug_code = targets.code("plc_debug") % { |
|
1130 "buffer_size": reduce(lambda x, y: x + y, [DebugTypesSize.get(v["type"], 0) for v in self._VariablesList], 0), |
1109 "programs_declarations": |
1131 "programs_declarations": |
1110 "\n".join(["extern %(type)s %(C_path)s;"%p for p in self._ProgramList]), |
1132 "\n".join(["extern %(type)s %(C_path)s;"%p for p in self._ProgramList]), |
1111 "extern_variables_declarations":"\n".join([ |
1133 "extern_variables_declarations":"\n".join([ |
1112 {"PT":"extern %(type)s *%(C_path)s;", |
1134 {"PT":"extern %(type)s *%(C_path)s;", |
1113 "VAR":"extern %(type)s %(C_path)s;"}[v["vartype"]]%v |
1135 "VAR":"extern %(type)s %(C_path)s;"}[v["vartype"]]%v |
1243 # init/cleanup/retrieve/publish, run and align code |
1265 # init/cleanup/retrieve/publish, run and align code |
1244 (self.Generate_plc_common_main,"plc_common_main.c","Common runtime")]: |
1266 (self.Generate_plc_common_main,"plc_common_main.c","Common runtime")]: |
1245 try: |
1267 try: |
1246 # Do generate |
1268 # Do generate |
1247 code = generator() |
1269 code = generator() |
|
1270 if code is None: |
|
1271 raise |
1248 code_path = os.path.join(buildpath,filename) |
1272 code_path = os.path.join(buildpath,filename) |
1249 open(code_path, "w").write(code) |
1273 open(code_path, "w").write(code) |
1250 # Insert this file as first file to be compiled at root plugin |
1274 # Insert this file as first file to be compiled at root plugin |
1251 self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS)) |
1275 self.LocationCFilesAndCFLAGS[0][1].insert(0,(code_path, self.plcCFLAGS)) |
1252 except Exception, exc: |
1276 except Exception, exc: |