equal
deleted
inserted
replaced
2 # -*- coding: utf-8 -*- |
2 # -*- coding: utf-8 -*- |
3 |
3 |
4 #This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
4 #This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
5 #based on the plcopen standard. |
5 #based on the plcopen standard. |
6 # |
6 # |
7 #Copyright (C): Edouard TISSERANT and Laurent BESSARD |
7 #Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
8 # |
8 # |
9 #See COPYING file for copyrights details. |
9 #See COPYING file for copyrights details. |
10 # |
10 # |
11 #This library is free software; you can redistribute it and/or |
11 #This library is free software; you can redistribute it and/or |
12 #modify it under the terms of the GNU General Public |
12 #modify it under the terms of the GNU General Public |
14 #version 2.1 of the License, or (at your option) any later version. |
14 #version 2.1 of the License, or (at your option) any later version. |
15 # |
15 # |
16 #This library is distributed in the hope that it will be useful, |
16 #This library is distributed in the hope that it will be useful, |
17 #but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 #but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19 #Lesser General Public License for more details. |
19 #General Public License for more details. |
20 # |
20 # |
21 #You should have received a copy of the GNU General Public |
21 #You should have received a copy of the GNU General Public |
22 #License along with this library; if not, write to the Free Software |
22 #License along with this library; if not, write to the Free Software |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
24 |
474 pou.setName(new_name) |
474 pou.setName(new_name) |
475 # If pou is currently opened, change its name in the list of opened pous |
475 # If pou is currently opened, change its name in the list of opened pous |
476 if old_name in self.ElementsOpened: |
476 if old_name in self.ElementsOpened: |
477 idx = self.ElementsOpened.index(old_name) |
477 idx = self.ElementsOpened.index(old_name) |
478 self.ElementsOpened[idx] = new_name |
478 self.ElementsOpened[idx] = new_name |
|
479 self.Project.updateElementName(old_name, new_name) |
479 self.RefreshPouUsingTree() |
480 self.RefreshPouUsingTree() |
480 self.RefreshBlockTypes() |
481 self.RefreshBlockTypes() |
481 self.BufferProject() |
482 self.BufferProject() |
482 |
483 |
483 # Change the name of a pou transition |
484 # Change the name of a pou transition |
647 # Set configuration global vars |
648 # Set configuration global vars |
648 configuration.setGlobalVars([]) |
649 configuration.setGlobalVars([]) |
649 for vartype, varlist in self.ExtractVarLists(vars): |
650 for vartype, varlist in self.ExtractVarLists(vars): |
650 configuration.globalVars.append(varlist) |
651 configuration.globalVars.append(varlist) |
651 self.RefreshBlockTypes() |
652 self.RefreshBlockTypes() |
652 self.BufferProject() |
|
653 |
653 |
654 # Return the configuration globalvars |
654 # Return the configuration globalvars |
655 def GetConfigurationGlobalVars(self, name): |
655 def GetConfigurationGlobalVars(self, name): |
656 vars = [] |
656 vars = [] |
657 # Found the configuration corresponding to name |
657 # Found the configuration corresponding to name |
690 if resource: |
690 if resource: |
691 resource.setGlobalVars([]) |
691 resource.setGlobalVars([]) |
692 for vartype, varlist in self.ExtractVarLists(vars): |
692 for vartype, varlist in self.ExtractVarLists(vars): |
693 resource.globalVars.append(varlist) |
693 resource.globalVars.append(varlist) |
694 self.RefreshBlockTypes() |
694 self.RefreshBlockTypes() |
695 self.BufferProject() |
|
696 |
695 |
697 # Return the resource globalvars |
696 # Return the resource globalvars |
698 def GetConfigurationResourceGlobalVars(self, config_name, name): |
697 def GetConfigurationResourceGlobalVars(self, config_name, name): |
699 vars = [] |
698 vars = [] |
700 # Found the resource corresponding to name |
699 # Found the resource corresponding to name |
767 if not pou.interface: |
766 if not pou.interface: |
768 pou.interface = plcopen.pou_interface() |
767 pou.interface = plcopen.pou_interface() |
769 # Set Pou interface |
768 # Set Pou interface |
770 pou.setVars(self.ExtractVarLists(vars)) |
769 pou.setVars(self.ExtractVarLists(vars)) |
771 self.RefreshBlockTypes() |
770 self.RefreshBlockTypes() |
772 self.BufferProject() |
|
773 |
771 |
774 # Replace the return type of the pou given by its name (only for functions) |
772 # Replace the return type of the pou given by its name (only for functions) |
775 def SetPouInterfaceReturnType(self, name, type): |
773 def SetPouInterfaceReturnType(self, name, type): |
776 pou = self.Project.getPou(name) |
774 pou = self.Project.getPou(name) |
777 if not pou.interface: |
775 if not pou.interface: |
782 return_type = plcopen.dataType() |
780 return_type = plcopen.dataType() |
783 pou.interface.setReturnType(return_type) |
781 pou.interface.setReturnType(return_type) |
784 # Change return type |
782 # Change return type |
785 return_type.setValue(type) |
783 return_type.setValue(type) |
786 self.RefreshBlockTypes() |
784 self.RefreshBlockTypes() |
787 self.BufferProject() |
785 |
|
786 def UpdateProjectUsedPous(self, old_name, new_name): |
|
787 if self.Project: |
|
788 self.Project.updateElementName(old_name, new_name) |
|
789 |
|
790 def UpdateCurrentPouEditingUsedVariable(self, old_name, new_name): |
|
791 pou = self.GetCurrentElementEditing() |
|
792 if pou: |
|
793 pou.updateElementName(old_name, new_name) |
788 |
794 |
789 # Return the return type of the pou given by its name |
795 # Return the return type of the pou given by its name |
790 def GetPouInterfaceReturnTypeByName(self, name): |
796 def GetPouInterfaceReturnTypeByName(self, name): |
791 # Found the pou correponding to name and return the return type |
797 # Found the pou correponding to name and return the return type |
792 return self.GetPouInterfaceReturnType(self.Project.getPou(name)) |
798 return self.GetPouInterfaceReturnType(self.Project.getPou(name)) |
2036 if self.Buffering: |
2042 if self.Buffering: |
2037 self.Project = self.Copy(self.Project) |
2043 self.Project = self.Copy(self.Project) |
2038 self.Buffering = False |
2044 self.Buffering = False |
2039 |
2045 |
2040 def ProjectIsSaved(self): |
2046 def ProjectIsSaved(self): |
2041 return self.ProjectBuffer.IsCurrentSaved() |
2047 if self.ProjectBuffer: |
|
2048 return self.ProjectBuffer.IsCurrentSaved() |
|
2049 else: |
|
2050 return False |
2042 |
2051 |
2043 def LoadPrevious(self): |
2052 def LoadPrevious(self): |
2044 self.Project = self.Copy(self.ProjectBuffer.Previous()) |
2053 self.Project = self.Copy(self.ProjectBuffer.Previous()) |
2045 |
2054 |
2046 def LoadNext(self): |
2055 def LoadNext(self): |