ProjectController.py
changeset 1515 da8bf5aa275f
parent 1511 91538d0c242c
child 1517 30692ab8b5c7
equal deleted inserted replaced
1514:968e7898d66b 1515:da8bf5aa275f
   139         self.DebugTicks = []
   139         self.DebugTicks = []
   140         self.SetAppFrame(frame, logger)
   140         self.SetAppFrame(frame, logger)
   141 
   141 
   142         self.iec2c_path = os.path.join(base_folder, "matiec", "iec2c"+(".exe" if wx.Platform == '__WXMSW__' else ""))
   142         self.iec2c_path = os.path.join(base_folder, "matiec", "iec2c"+(".exe" if wx.Platform == '__WXMSW__' else ""))
   143         self.ieclib_path = os.path.join(base_folder, "matiec", "lib")
   143         self.ieclib_path = os.path.join(base_folder, "matiec", "lib")
   144         self.ieclib_c_path = os.path.join(base_folder, "matiec", "lib", "C")
   144         self.ieclib_c_path = self._getMatIecCPath()
   145 
   145 
   146         # Setup debug information
   146         # Setup debug information
   147         self.IECdebug_datas = {}
   147         self.IECdebug_datas = {}
   148         self.IECdebug_lock = Lock()
   148         self.IECdebug_lock = Lock()
   149 
   149 
   627         plc_file = open(self._getIECcodepath(), "a")
   627         plc_file = open(self._getIECcodepath(), "a")
   628         plc_file.write(open(self._getIECgeneratedcodepath(), "r").read())
   628         plc_file.write(open(self._getIECgeneratedcodepath(), "r").read())
   629         plc_file.close()
   629         plc_file.close()
   630         return True
   630         return True
   631 
   631 
       
   632 
       
   633     def _getMatIecCPath(self):
       
   634         path=''
       
   635         paths=[
       
   636             os.path.join(base_folder, "matiec", "lib", "C"),
       
   637             os.path.join(base_folder, "matiec", "lib") ]
       
   638         for p in paths:
       
   639             filename=os.path.join(p, "iec_types.h")
       
   640             if (os.path.isfile(filename)):
       
   641                 path = p
       
   642                 break
       
   643         return path
       
   644 
       
   645     def _getMatIecOptions(self):
       
   646         buildpath = self._getBuildPath()
       
   647         buildcmd = "\"%s\" -h"%(self.iec2c_path)
       
   648         options =["-f", "-l", "-p"]
       
   649 
       
   650         buildopt = ""
       
   651         try:
       
   652             # Invoke compiler. Output files are listed to stdout, errors to stderr
       
   653             status, result, err_result = ProcessLogger(self.logger, buildcmd,
       
   654                 no_stdout=True, no_stderr=True).spin()
       
   655         except Exception,e:
       
   656             return buildopt
       
   657 
       
   658         for opt in options:
       
   659             if opt in result:
       
   660                 buildopt = buildopt + " " + opt
       
   661         return buildopt
       
   662 
   632     def _Compile_ST_to_SoftPLC(self):
   663     def _Compile_ST_to_SoftPLC(self):
   633         self.logger.write(_("Compiling IEC Program into C code...\n"))
   664         self.logger.write(_("Compiling IEC Program into C code...\n"))
   634         buildpath = self._getBuildPath()
   665         buildpath = self._getBuildPath()
   635         buildcmd = "\"%s\" -f -l -p -I \"%s\" -T \"%s\" \"%s\""%(
   666         buildcmd = "\"%s\" %s -I \"%s\" -T \"%s\" \"%s\""%(
   636                          self.iec2c_path,
   667                          self.iec2c_path,
       
   668                          self._getMatIecOptions(),
   637                          self.ieclib_path,
   669                          self.ieclib_path,
   638                          buildpath,
   670                          buildpath,
   639                          self._getIECcodepath())
   671                          self._getIECcodepath())
   640 
   672 
   641         try:
   673         try: