30 from plcopen.structures import IEC_KEYWORDS |
30 from plcopen.structures import IEC_KEYWORDS |
31 from targets.typemapping import DebugTypesSize, LogLevelsCount, LogLevels |
31 from targets.typemapping import DebugTypesSize, LogLevelsCount, LogLevels |
32 from targets.typemapping import UnpackDebugBuffer |
32 from targets.typemapping import UnpackDebugBuffer |
33 from ConfigTreeNode import ConfigTreeNode, XSDSchemaErrorMessage |
33 from ConfigTreeNode import ConfigTreeNode, XSDSchemaErrorMessage |
34 |
34 |
35 base_folder = os.path.split(sys.path[0])[0] |
35 base_folder = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] |
36 |
36 |
37 MATIEC_ERROR_MODEL = re.compile(".*\.st:(\d+)-(\d+)\.\.(\d+)-(\d+): (?:error)|(?:warning) : (.*)$") |
37 MATIEC_ERROR_MODEL = re.compile(".*\.st:(\d+)-(\d+)\.\.(\d+)-(\d+): (?:error)|(?:warning) : (.*)$") |
38 |
38 |
39 ITEM_CONFNODE = 25 |
39 ITEM_CONFNODE = 25 |
40 |
40 |
606 return True |
606 return True |
607 |
607 |
608 def _Compile_ST_to_SoftPLC(self): |
608 def _Compile_ST_to_SoftPLC(self): |
609 self.logger.write(_("Compiling IEC Program into C code...\n")) |
609 self.logger.write(_("Compiling IEC Program into C code...\n")) |
610 buildpath = self._getBuildPath() |
610 buildpath = self._getBuildPath() |
611 |
611 buildcmd = "\"%s\" -f -l -p -I \"%s\" -T \"%s\" \"%s\""%( |
612 # Now compile IEC code into many C files |
|
613 # files are listed to stdout, and errors to stderr. |
|
614 status, result, err_result = ProcessLogger( |
|
615 self.logger, |
|
616 "\"%s\" -f -l -p -I \"%s\" -T \"%s\" \"%s\""%( |
|
617 self.iec2c_path, |
612 self.iec2c_path, |
618 self.ieclib_path, |
613 self.ieclib_path, |
619 buildpath, |
614 buildpath, |
620 self._getIECcodepath()), |
615 self._getIECcodepath()) |
621 no_stdout=True, no_stderr=True).spin() |
616 |
|
617 try: |
|
618 # Invoke compiler. Output files are listed to stdout, errors to stderr |
|
619 status, result, err_result = ProcessLogger(self.logger, buildcmd, |
|
620 no_stdout=True, no_stderr=True).spin() |
|
621 except Exception,e: |
|
622 self.logger.write_error(buildcmd + "\n") |
|
623 self.logger.write_error(repr(e) + "\n") |
|
624 return False |
|
625 |
622 if status: |
626 if status: |
623 # Failed ! |
627 # Failed ! |
624 |
628 |
625 # parse iec2c's error message. if it contains a line number, |
629 # parse iec2c's error message. if it contains a line number, |
626 # then print those lines from the generated IEC file. |
630 # then print those lines from the generated IEC file. |