plugger.py
changeset 202 cd81a7a6e55c
parent 199 aa5f43bafad4
child 203 cb9901076a21
equal deleted inserted replaced
201:520d2416ff4d 202:cd81a7a6e55c
   590 from datetime import datetime
   590 from datetime import datetime
   591 # import necessary stuff from PLCOpenEditor
   591 # import necessary stuff from PLCOpenEditor
   592 from PLCControler import PLCControler
   592 from PLCControler import PLCControler
   593 from PLCOpenEditor import PLCOpenEditor, ProjectDialog
   593 from PLCOpenEditor import PLCOpenEditor, ProjectDialog
   594 from TextViewer import TextViewer
   594 from TextViewer import TextViewer
   595 from plcopen.structures import IEC_KEYWORDS, AddPluginBlockList, ClearPluginTypes, PluginTypes
   595 from plcopen.structures import IEC_KEYWORDS
   596 import runtime
   596 import runtime
   597 import re
   597 import re
   598 
   598 
   599 class PluginsRoot(PlugTemplate, PLCControler):
   599 class PluginsRoot(PlugTemplate, PLCControler):
   600     """
   600     """
   812         self.PluggedChilds = {}
   812         self.PluggedChilds = {}
   813     
   813     
   814     # Update PLCOpenEditor Plugin Block types from loaded plugins
   814     # Update PLCOpenEditor Plugin Block types from loaded plugins
   815     def RefreshPluginsBlockLists(self):
   815     def RefreshPluginsBlockLists(self):
   816         if getattr(self, "PluggedChilds", None) is not None:
   816         if getattr(self, "PluggedChilds", None) is not None:
   817             ClearPluginTypes()
   817             self.ClearPluginTypes()
   818             AddPluginBlockList(self.BlockTypesFactory())
   818             self.AddPluginBlockList(self.BlockTypesFactory())
   819             for child in self.IterChilds():
   819             for child in self.IterChilds():
   820                 AddPluginBlockList(child.BlockTypesFactory())
   820                 self.AddPluginBlockList(child.BlockTypesFactory())
   821         if self.PLCEditor is not None:
   821         if self.PLCEditor is not None:
   822             self.PLCEditor.RefreshEditor()
   822             self.PLCEditor.RefreshEditor()
   823     
   823     
   824     def PlugPath(self, PlugName=None):
   824     def PlugPath(self, PlugName=None):
   825         return self.ProjectPath
   825         return self.ProjectPath
   904         logger.write("Compiling IEC Program in to C code...\n")
   904         logger.write("Compiling IEC Program in to C code...\n")
   905         # Now compile IEC code into many C files
   905         # Now compile IEC code into many C files
   906         # files are listed to stdout, and errors to stderr. 
   906         # files are listed to stdout, and errors to stderr. 
   907         status, result, err_result = ProcessLogger(
   907         status, result, err_result = ProcessLogger(
   908                logger,
   908                logger,
   909                "\"%s\" \"%s\" -I \"%s\" \"%s\""%(
   909                "\"%s\" -f \"%s\" -I \"%s\" \"%s\""%(
   910                          iec2c_path,
   910                          iec2c_path,
   911                          self._getIECcodepath(),
   911                          self._getIECcodepath(),
   912                          ieclib_path, buildpath),
   912                          ieclib_path, buildpath),
   913                no_stdout=True).spin()
   913                no_stdout=True).spin()
   914         if status:
   914         if status:
   935 
   935 
   936     def _build(self, logger):
   936     def _build(self, logger):
   937         """
   937         """
   938         Method called by user to (re)build SoftPLC and plugin tree
   938         Method called by user to (re)build SoftPLC and plugin tree
   939         """
   939         """
       
   940         if self.PLCEditor is not None:
       
   941             self.PLCEditor.ClearErrors()
       
   942         
   940         buildpath = self._getBuildPath()
   943         buildpath = self._getBuildPath()
   941 
   944 
   942         # Eventually create build dir
   945         # Eventually create build dir
   943         if not os.path.exists(buildpath):
   946         if not os.path.exists(buildpath):
   944             os.mkdir(buildpath)
   947             os.mkdir(buildpath)
  1048             self.EnableMethod("_Run", False)
  1051             self.EnableMethod("_Run", False)
  1049             return False
  1052             return False
  1050         
  1053         
  1051         self.EnableMethod("_Run", True)
  1054         self.EnableMethod("_Run", True)
  1052         return True
  1055         return True
  1053         
  1056     
  1054 
  1057     def ShowError(self, logger, from_location, to_location):
       
  1058         chunk_infos = self.GetChunkInfos(from_location, to_location)
       
  1059         self._EditPLC(logger)
       
  1060         for infos, (start_row, start_col) in chunk_infos:
       
  1061             start = (from_location[0] - start_row, from_location[1] - start_col)
       
  1062             end = (to_location[0] - start_row, to_location[1] - start_col)
       
  1063             self.PLCEditor.ShowError(infos, start, end)
       
  1064             
  1055     def _showIECcode(self, logger):
  1065     def _showIECcode(self, logger):
  1056         plc_file = self._getIECcodepath()
  1066         plc_file = self._getIECcodepath()
  1057         new_dialog = wx.Frame(self.AppFrame)
  1067         new_dialog = wx.Frame(self.AppFrame)
  1058         ST_viewer = TextViewer(new_dialog, "", None, None)
  1068         ST_viewer = TextViewer(new_dialog, "", None, None)
  1059         #ST_viewer.Enable(False)
  1069         #ST_viewer.Enable(False)