483 # Fetch the plugin |
483 # Fetch the plugin |
484 #PlugInstance = self.GetChildByName(PlugName) |
484 #PlugInstance = self.GetChildByName(PlugName) |
485 # Ask to his parent to remove it |
485 # Ask to his parent to remove it |
486 self.PlugParent._doRemoveChild(self) |
486 self.PlugParent._doRemoveChild(self) |
487 |
487 |
488 def PlugAddChild(self, PlugName, PlugType): |
488 def PlugAddChild(self, PlugName, PlugType, IEC_Channel=0): |
489 """ |
489 """ |
490 Create the plugins that may be added as child to this node self |
490 Create the plugins that may be added as child to this node self |
491 @param PlugType: string desining the plugin class name (get name from PlugChildsTypes) |
491 @param PlugType: string desining the plugin class name (get name from PlugChildsTypes) |
492 @param PlugName: string for the name of the plugin instance |
492 @param PlugName: string for the name of the plugin instance |
493 """ |
493 """ |
552 _self.ChangesToSave = False |
552 _self.ChangesToSave = False |
553 else: |
553 else: |
554 # If plugin do not have corresponding file/dirs - they will be created on Save |
554 # If plugin do not have corresponding file/dirs - they will be created on Save |
555 _self.PlugMakeDir() |
555 _self.PlugMakeDir() |
556 # Find an IEC number |
556 # Find an IEC number |
557 _self.FindNewIEC_Channel(0) |
557 _self.FindNewIEC_Channel(IEC_Channel) |
558 # Call the plugin real __init__ |
558 # Call the plugin real __init__ |
559 if getattr(PlugClass, "__init__", None): |
559 if getattr(PlugClass, "__init__", None): |
560 PlugClass.__init__(_self) |
560 PlugClass.__init__(_self) |
561 _self.PlugRequestSave() |
561 _self.PlugRequestSave() |
562 #just created, must be saved |
562 #just created, must be saved |
740 |
740 |
741 def __init__(self, frame, logger): |
741 def __init__(self, frame, logger): |
742 PLCControler.__init__(self) |
742 PLCControler.__init__(self) |
743 |
743 |
744 self.MandatoryParams = None |
744 self.MandatoryParams = None |
745 self.AppFrame = frame |
745 self.SetAppFrame(frame, logger) |
746 self.logger = logger |
|
747 self._builder = None |
746 self._builder = None |
748 self._connector = None |
747 self._connector = None |
749 self.Deleting = False |
748 self.Deleting = False |
750 |
749 |
751 # Setup debug information |
750 # Setup debug information |
752 self.IECdebug_datas = {} |
751 self.IECdebug_datas = {} |
753 self.IECdebug_lock = Lock() |
752 self.IECdebug_lock = Lock() |
754 |
753 |
755 self.DebugTimer=None |
754 self.DebugTimer=None |
756 self.ResetIECProgramsAndVariables() |
755 self.ResetIECProgramsAndVariables() |
757 |
|
758 # Timer to pull PLC status |
|
759 ID_STATUSTIMER = wx.NewId() |
|
760 self.StatusTimer = wx.Timer(self.AppFrame, ID_STATUSTIMER) |
|
761 self.AppFrame.Bind(wx.EVT_TIMER, self.PullPLCStatusProc, self.StatusTimer) |
|
762 |
756 |
763 #This method are not called here... but in NewProject and OpenProject |
757 #This method are not called here... but in NewProject and OpenProject |
764 #self._AddParamsMembers() |
758 #self._AddParamsMembers() |
765 #self.PluggedChilds = {} |
759 #self.PluggedChilds = {} |
766 |
760 |
782 self.PluginMethods = [dic.copy() for dic in self.PluginMethods] |
776 self.PluginMethods = [dic.copy() for dic in self.PluginMethods] |
783 self.LoadSTLibrary() |
777 self.LoadSTLibrary() |
784 |
778 |
785 def __del__(self): |
779 def __del__(self): |
786 self.Deleting = True |
780 self.Deleting = True |
|
781 |
|
782 def SetAppFrame(self, frame, logger): |
|
783 self.AppFrame = frame |
|
784 self.logger = logger |
|
785 self.StatusTimer = None |
|
786 |
|
787 if frame is not None: |
|
788 # Timer to pull PLC status |
|
789 ID_STATUSTIMER = wx.NewId() |
|
790 self.StatusTimer = wx.Timer(self.AppFrame, ID_STATUSTIMER) |
|
791 self.AppFrame.Bind(wx.EVT_TIMER, self.PullPLCStatusProc, self.StatusTimer) |
|
792 |
|
793 def ResetAppFrame(self, logger): |
|
794 if self.AppFrame is not None: |
|
795 self.AppFrame.Unbind(wx.EVT_TIMER, self.StatusTimer) |
|
796 self.StatusTimer = None |
|
797 self.AppFrame = None |
|
798 |
|
799 self.logger = logger |
787 |
800 |
788 def PluginLibraryFilePath(self): |
801 def PluginLibraryFilePath(self): |
789 return os.path.join(os.path.split(__file__)[0], "pous.xml") |
802 return os.path.join(os.path.split(__file__)[0], "pous.xml") |
790 |
803 |
791 def PlugTestModified(self): |
804 def PlugTestModified(self): |
908 |
921 |
909 return None |
922 return None |
910 |
923 |
911 def CloseProject(self): |
924 def CloseProject(self): |
912 self.ClearPluggedChilds() |
925 self.ClearPluggedChilds() |
913 self.AppFrame.Unbind(wx.EVT_TIMER, self.StatusTimer) |
926 self.ResetAppFrame(None) |
914 |
927 |
915 def SaveProject(self): |
928 def SaveProject(self): |
916 if not self.SaveXMLFile(): |
929 if not self.SaveXMLFile(): |
917 self.SaveXMLFile(os.path.join(self.ProjectPath, 'plc.xml')) |
930 self.SaveXMLFile(os.path.join(self.ProjectPath, 'plc.xml')) |
918 result = self.PlugRequestSave() |
931 result = self.PlugRequestSave() |
919 if result: |
932 if result: |