Moved some definitions away from controller class, and adaped references them through all code.
--- a/BeremizIDE.py Mon Feb 19 13:24:57 2018 +0100
+++ b/BeremizIDE.py Mon Feb 19 15:14:30 2018 +0100
@@ -56,7 +56,8 @@
from controls import EnhancedStatusBar as esb
from dialogs.AboutDialog import ShowAboutDialog
-from PLCControler import \
+from plcopen.types_enums import \
+ ComputeConfigurationName, \
LOCATION_CONFNODE, \
LOCATION_MODULE, \
LOCATION_GROUP, \
@@ -64,9 +65,10 @@
LOCATION_VAR_OUTPUT, \
LOCATION_VAR_MEMORY, \
ITEM_PROJECT, \
- ITEM_RESOURCE
-
-from ProjectController import ProjectController, GetAddMenuItems, MATIEC_ERROR_MODEL, ITEM_CONFNODE
+ ITEM_RESOURCE, \
+ ITEM_CONFNODE
+
+from ProjectController import ProjectController, GetAddMenuItems, MATIEC_ERROR_MODEL
from IDEFrame import \
TITLE,\
@@ -1093,7 +1095,7 @@
def ShowHighlight(self, infos, start, end, highlight_type):
config_name = self.Controler.GetProjectMainConfigurationName()
- if config_name is not None and infos[0] == self.Controler.ComputeConfigurationName(config_name):
+ if config_name is not None and infos[0] == ComputeConfigurationName(config_name):
self.CTR._OpenView()
selected = self.TabsOpened.GetSelection()
if selected != -1:
--- a/IDEFrame.py Mon Feb 19 13:24:57 2018 +0100
+++ b/IDEFrame.py Mon Feb 19 15:14:30 2018 +0100
@@ -44,6 +44,7 @@
from controls.DebugVariablePanel import DebugVariablePanel
from dialogs import ProjectDialog, PouDialog, PouTransitionDialog, PouActionDialog, FindInPouDialog, SearchInProjectDialog
from util.BitmapLibrary import GetBitmap
+from plcopen.types_enums import *
# Define PLCOpenEditor controls id
[
@@ -824,7 +825,7 @@
return notebook.GetPageIndex(page_ref)
elif page_infos[0] == "editor":
tagname = page_infos[1]
- page_ref = self.EditProjectElement(self.Controler.GetElementType(tagname), tagname)
+ page_ref = self.EditProjectElement(GetElementType(tagname), tagname)
if page_ref is not None:
page_ref.RefreshView()
return notebook.GetPageIndex(page_ref)
@@ -1646,8 +1647,8 @@
abort = True
if not abort:
self.Controler.ChangeDataTypeName(old_name, new_name)
- self.RefreshEditorNames(self.Controler.ComputeDataTypeName(old_name),
- self.Controler.ComputeDataTypeName(new_name))
+ self.RefreshEditorNames(ComputeDataTypeName(old_name),
+ ComputeDataTypeName(new_name))
self.RefreshPageTitles()
elif item_infos["type"] == ITEM_POU:
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames() if name != old_name]:
@@ -1660,8 +1661,8 @@
messageDialog.Destroy()
if not abort:
self.Controler.ChangePouName(old_name, new_name)
- self.RefreshEditorNames(self.Controler.ComputePouName(old_name),
- self.Controler.ComputePouName(new_name))
+ self.RefreshEditorNames(ComputePouName(old_name),
+ ComputePouName(new_name))
self.RefreshLibraryPanel()
self.RefreshPageTitles()
elif item_infos["type"] == ITEM_TRANSITION:
@@ -1674,8 +1675,8 @@
else:
words = item_infos["tagname"].split("::")
self.Controler.ChangePouTransitionName(words[1], old_name, new_name)
- self.RefreshEditorNames(self.Controler.ComputePouTransitionName(words[1], old_name),
- self.Controler.ComputePouTransitionName(words[1], new_name))
+ self.RefreshEditorNames(ComputePouTransitionName(words[1], old_name),
+ ComputePouTransitionName(words[1], new_name))
self.RefreshPageTitles()
elif item_infos["type"] == ITEM_ACTION:
pou_item = self.ProjectTree.GetItemParent(event.GetItem())
@@ -1687,8 +1688,8 @@
else:
words = item_infos["tagname"].split("::")
self.Controler.ChangePouActionName(words[1], old_name, new_name)
- self.RefreshEditorNames(self.Controler.ComputePouActionName(words[1], old_name),
- self.Controler.ComputePouActionName(words[1], new_name))
+ self.RefreshEditorNames(ComputePouActionName(words[1], old_name),
+ ComputePouActionName(words[1], new_name))
self.RefreshPageTitles()
elif item_infos["type"] == ITEM_CONFIGURATION:
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_name]:
@@ -1706,8 +1707,8 @@
messageDialog.Destroy()
if not abort:
self.Controler.ChangeConfigurationName(old_name, new_name)
- self.RefreshEditorNames(self.Controler.ComputeConfigurationName(old_name),
- self.Controler.ComputeConfigurationName(new_name))
+ self.RefreshEditorNames(ComputeConfigurationName(old_name),
+ ComputeConfigurationName(new_name))
self.RefreshPageTitles()
elif item_infos["type"] == ITEM_RESOURCE:
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames()]:
@@ -1726,8 +1727,8 @@
if not abort:
words = item_infos["tagname"].split("::")
self.Controler.ChangeConfigurationResourceName(words[1], old_name, new_name)
- self.RefreshEditorNames(self.Controler.ComputeConfigurationResourceName(words[1], old_name),
- self.Controler.ComputeConfigurationResourceName(words[1], new_name))
+ self.RefreshEditorNames(ComputeConfigurationResourceName(words[1], old_name),
+ ComputeConfigurationResourceName(words[1], new_name))
self.RefreshPageTitles()
if message or abort:
if message:
@@ -2465,7 +2466,7 @@
name = self.ProjectTree.GetItemText(selected)
if self.CheckDataTypeIsUsedBeforeDeletion(name):
self.Controler.ProjectRemoveDataType(name)
- tagname = self.Controler.ComputeDataTypeName(name)
+ tagname = ComputeDataTypeName(name)
idx = self.IsOpened(tagname)
if idx is not None:
self.TabsOpened.DeletePage(idx)
@@ -2482,7 +2483,7 @@
name = self.ProjectTree.GetItemText(selected)
if self.CheckPouIsUsedBeforeDeletion(name):
self.Controler.ProjectRemovePou(name)
- tagname = self.Controler.ComputePouName(name)
+ tagname = ComputePouName(name)
idx = self.IsOpened(tagname)
if idx is not None:
self.TabsOpened.DeletePage(idx)
@@ -2495,7 +2496,7 @@
transition = self.ProjectTree.GetItemText(selected)
pou_name = item_infos["tagname"].split("::")[1]
self.Controler.ProjectRemovePouTransition(pou_name, transition)
- tagname = self.Controler.ComputePouTransitionName(pou_name, transition)
+ tagname = ComputePouTransitionName(pou_name, transition)
idx = self.IsOpened(tagname)
if idx is not None:
self.TabsOpened.DeletePage(idx)
@@ -2508,7 +2509,7 @@
action = self.ProjectTree.GetItemText(selected)
pou_name = item_infos["tagname"].split("::")[1]
self.Controler.ProjectRemovePouAction(pou_name, action)
- tagname = self.Controler.ComputePouActionName(pou_name, action)
+ tagname = ComputePouActionName(pou_name, action)
idx = self.IsOpened(tagname)
if idx is not None:
self.TabsOpened.DeletePage(idx)
@@ -2519,7 +2520,7 @@
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_CONFIGURATION:
name = self.ProjectTree.GetItemText(selected)
self.Controler.ProjectRemoveConfiguration(name)
- tagname = self.Controler.ComputeConfigurationName(name)
+ tagname = ComputeConfigurationName(name)
idx = self.IsOpened(tagname)
if idx is not None:
self.TabsOpened.DeletePage(idx)
@@ -2532,7 +2533,7 @@
resource = self.ProjectTree.GetItemText(selected)
config_name = item_infos["tagname"].split("::")[1]
self.Controler.ProjectRemoveConfigurationResource(config_name, resource)
- tagname = self.Controler.ComputeConfigurationResourceName(config_name, selected)
+ tagname = ComputeConfigurationResourceName(config_name, selected)
idx = self.IsOpened(tagname)
if idx is not None:
self.TabsOpened.DeletePage(idx)
@@ -2549,7 +2550,7 @@
self.RefreshProjectTree()
self.ProjectTree.Unselect()
else:
- self.EditProjectElement(self.Controler.GetElementType(infos[0]), infos[0])
+ self.EditProjectElement(GetElementType(infos[0]), infos[0])
selected = self.TabsOpened.GetSelection()
if selected != -1:
viewer = self.TabsOpened.GetPage(selected)
--- a/PLCControler.py Mon Feb 19 13:24:57 2018 +0100
+++ b/PLCControler.py Mon Feb 19 15:14:30 2018 +0100
@@ -136,19 +136,19 @@
return self.TagName
def ConfigTagName(self, context, *args):
- self.TagName = self.Controller.ComputeConfigurationName(args[0][0])
+ self.TagName = ComputeConfigurationName(args[0][0])
def ResourceTagName(self, context, *args):
- self.TagName = self.Controller.ComputeConfigurationResourceName(args[0][0], args[1][0])
+ self.TagName = ComputeConfigurationResourceName(args[0][0], args[1][0])
def PouTagName(self, context, *args):
- self.TagName = self.Controller.ComputePouName(args[0][0])
+ self.TagName = ComputePouName(args[0][0])
def ActionTagName(self, context, *args):
- self.TagName = self.Controller.ComputePouActionName(args[0][0], args[0][1])
+ self.TagName = ComputePouActionName(args[0][0], args[0][1])
def TransitionTagName(self, context, *args):
- self.TagName = self.Controller.ComputePouTransitionName(args[0][0], args[0][1])
+ self.TagName = ComputePouTransitionName(args[0][0], args[0][1])
# -------------------------------------------------------------------------------
@@ -559,7 +559,7 @@
datatypes["values"].append({
"name": datatype.getname(),
"type": ITEM_DATATYPE,
- "tagname": self.ComputeDataTypeName(datatype.getname()),
+ "tagname": ComputeDataTypeName(datatype.getname()),
"values": []})
pou_types = {
"function": {
@@ -581,7 +581,7 @@
for pou in project.getpous():
pou_type = pou.getpouType()
pou_infos = {"name": pou.getname(), "type": ITEM_POU,
- "tagname": self.ComputePouName(pou.getname())}
+ "tagname": ComputePouName(pou.getname())}
pou_values = []
if pou.getbodyType() == "SFC":
transitions = []
@@ -589,7 +589,7 @@
transitions.append({
"name": transition.getname(),
"type": ITEM_TRANSITION,
- "tagname": self.ComputePouTransitionName(pou.getname(), transition.getname()),
+ "tagname": ComputePouTransitionName(pou.getname(), transition.getname()),
"values": []})
pou_values.append({"name": TRANSITIONS, "type": ITEM_TRANSITIONS, "values": transitions})
actions = []
@@ -597,7 +597,7 @@
actions.append({
"name": action.getname(),
"type": ITEM_ACTION,
- "tagname": self.ComputePouActionName(pou.getname(), action.getname()),
+ "tagname": ComputePouActionName(pou.getname(), action.getname()),
"values": []})
pou_values.append({"name": ACTIONS, "type": ITEM_ACTIONS, "values": actions})
if pou_type in pou_types:
@@ -609,7 +609,7 @@
config_infos = {
"name": config_name,
"type": ITEM_CONFIGURATION,
- "tagname": self.ComputeConfigurationName(config.getname()),
+ "tagname": ComputeConfigurationName(config.getname()),
"values": []}
resources = {"name": RESOURCES, "type": ITEM_RESOURCES, "values": []}
for resource in config.getresource():
@@ -617,7 +617,7 @@
resource_infos = {
"name": resource_name,
"type": ITEM_RESOURCE,
- "tagname": self.ComputeConfigurationResourceName(config.getname(), resource.getname()),
+ "tagname": ComputeConfigurationResourceName(config.getname(), resource.getname()),
"values": []}
resources["values"].append(resource_infos)
config_infos["values"] = [resources]
@@ -657,7 +657,7 @@
elif words[0] in ['T', 'A']:
return ["%s.%s" % (instance, words[2])
for instance in self.SearchPouInstances(
- self.ComputePouName(words[1]), debug)]
+ ComputePouName(words[1]), debug)]
return []
def GetPouInstanceTagName(self, instance_path, debug=False):
@@ -780,7 +780,7 @@
# Add the datatype to project
self.Project.appenddataType(datatype_name)
self.BufferProject()
- return self.ComputeDataTypeName(datatype_name)
+ return ComputeDataTypeName(datatype_name)
return None
# Remove a Data Type from project
@@ -797,7 +797,7 @@
if pou_type == "function":
self.SetPouInterfaceReturnType(pou_name, "BOOL")
self.BufferProject()
- return self.ComputePouName(pou_name)
+ return ComputePouName(pou_name)
return None
def ProjectChangePouType(self, name, pou_type):
@@ -855,7 +855,7 @@
self.Project.insertpou(0, new_pou)
self.BufferProject()
- return self.ComputePouName(new_name),
+ return ComputePouName(new_name),
# Remove a Pou from project
def ProjectRemovePou(self, pou_name):
@@ -879,7 +879,7 @@
config_name = self.GenerateNewName(None, None, "configuration%d")
self.Project.addconfiguration(config_name)
self.BufferProject()
- return self.ComputeConfigurationName(config_name)
+ return ComputeConfigurationName(config_name)
return None
# Remove a configuration from project
@@ -895,7 +895,7 @@
resource_name = self.GenerateNewName(None, None, "resource%d")
self.Project.addconfigurationResource(config_name, resource_name)
self.BufferProject()
- return self.ComputeConfigurationResourceName(config_name, resource_name)
+ return ComputeConfigurationResourceName(config_name, resource_name)
return None
# Remove a resource from a configuration of the project
@@ -911,7 +911,7 @@
if pou is not None:
pou.addtransition(transition_name, transition_type)
self.BufferProject()
- return self.ComputePouTransitionName(pou_name, transition_name)
+ return ComputePouTransitionName(pou_name, transition_name)
return None
# Remove a Transition from a Project Pou
@@ -930,7 +930,7 @@
if pou is not None:
pou.addaction(action_name, action_type)
self.BufferProject()
- return self.ComputePouActionName(pou_name, action_name)
+ return ComputePouActionName(pou_name, action_name)
return None
# Remove an Action from a Project Pou
@@ -1762,45 +1762,6 @@
return values
# -------------------------------------------------------------------------------
- # Project Element tag name computation functions
- # -------------------------------------------------------------------------------
-
- # Compute a data type name
- def ComputeDataTypeName(self, datatype):
- return "D::%s" % datatype
-
- # Compute a pou name
- def ComputePouName(self, pou):
- return "P::%s" % pou
-
- # Compute a pou transition name
- def ComputePouTransitionName(self, pou, transition):
- return "T::%s::%s" % (pou, transition)
-
- # Compute a pou action name
- def ComputePouActionName(self, pou, action):
- return "A::%s::%s" % (pou, action)
-
- # Compute a pou name
- def ComputeConfigurationName(self, config):
- return "C::%s" % config
-
- # Compute a pou name
- def ComputeConfigurationResourceName(self, config, resource):
- return "R::%s::%s" % (config, resource)
-
- def GetElementType(self, tagname):
- words = tagname.split("::")
- return {
- "D": ITEM_DATATYPE,
- "P": ITEM_POU,
- "T": ITEM_TRANSITION,
- "A": ITEM_ACTION,
- "C": ITEM_CONFIGURATION,
- "R": ITEM_RESOURCE
- }[words[0]]
-
- # -------------------------------------------------------------------------------
# Project opened Data types management functions
# -------------------------------------------------------------------------------
--- a/PLCGenerator.py Mon Feb 19 13:24:57 2018 +0100
+++ b/PLCGenerator.py Mon Feb 19 15:14:30 2018 +0100
@@ -28,6 +28,7 @@
import re
from plcopen import PLCOpenParser
from plcopen.structures import *
+from plcopen.types_enums import *
# Dictionary associating PLCOpen variable categories to the corresponding
@@ -134,7 +135,7 @@
# Getting datatype model from project
datatype = self.Project.getdataType(datatype_name)
- tagname = self.Controler.ComputeDataTypeName(datatype.getname())
+ tagname = ComputeDataTypeName(datatype.getname())
datatype_def = [(" ", ()),
(datatype.getname(), (tagname, "name")),
(" : ", ())]
@@ -268,7 +269,7 @@
# Generate a configuration from its model
def GenerateConfiguration(self, configuration):
- tagname = self.Controler.ComputeConfigurationName(configuration.getname())
+ tagname = ComputeConfigurationName(configuration.getname())
config = [("\nCONFIGURATION ", ()),
(configuration.getname(), (tagname, "name")),
("\n", ())]
@@ -342,7 +343,7 @@
# Generate a resource from its model
def GenerateResource(self, resource, config_name):
- tagname = self.Controler.ComputeConfigurationResourceName(config_name, resource.getname())
+ tagname = ComputeConfigurationResourceName(config_name, resource.getname())
resrce = [("\n RESOURCE ", ()),
(resource.getname(), (tagname, "name")),
(" ON PLC\n", ())]
@@ -518,7 +519,7 @@
self.ParentGenerator = parent
self.Name = name
self.Type = type
- self.TagName = self.ParentGenerator.Controler.ComputePouName(name)
+ self.TagName = ComputePouName(name)
self.CurrentIndent = " "
self.ReturnType = None
self.Interface = []
@@ -578,7 +579,7 @@
current_type = var_type
break
else:
- tagname = self.ParentGenerator.Controler.ComputeDataTypeName(current_type)
+ tagname = ComputeDataTypeName(current_type)
infos = self.ParentGenerator.Controler.GetDataTypeInfos(tagname)
if infos is not None and infos["type"] == "Structure":
name = parts.pop(0)
@@ -841,10 +842,10 @@
if body_type == "SFC":
previous_tagname = self.TagName
for action in pou.getactionList():
- self.TagName = self.ParentGenerator.Controler.ComputePouActionName(self.Name, action.getname())
+ self.TagName = ComputePouActionName(self.Name, action.getname())
self.ComputeConnectionTypes(action)
for transition in pou.gettransitionList():
- self.TagName = self.ParentGenerator.Controler.ComputePouTransitionName(self.Name, transition.getname())
+ self.TagName = ComputePouTransitionName(self.Name, transition.getname())
self.ComputeConnectionTypes(transition)
self.TagName = previous_tagname
@@ -1497,7 +1498,7 @@
actionContent = pou.getaction(action_name)
if actionContent is not None:
previous_tagname = self.TagName
- self.TagName = self.ParentGenerator.Controler.ComputePouActionName(self.Name, action_name)
+ self.TagName = ComputePouActionName(self.Name, action_name)
self.ComputeProgram(actionContent)
self.SFCNetworks["Actions"][action_name] = (self.Program, (self.TagName, "name"))
self.Program = []
@@ -1540,7 +1541,7 @@
transitionType = transitionContent.getbodyType()
transitionBody = transitionContent.getbody()
previous_tagname = self.TagName
- self.TagName = self.ParentGenerator.Controler.ComputePouTransitionName(self.Name, transitionValues["value"])
+ self.TagName = ComputePouTransitionName(self.Name, transitionValues["value"])
if transitionType == "IL":
transition_infos["content"] = [(":\n", ()),
(ReIndentText(transitionBody.getcontent().getanyText(), len(self.CurrentIndent)), (self.TagName, "body", len(self.CurrentIndent)))]
--- a/ProjectController.py Mon Feb 19 13:24:57 2018 +0100
+++ b/ProjectController.py Mon Feb 19 15:14:30 2018 +0100
@@ -58,6 +58,7 @@
from dialogs import DiscoveryDialog
from PLCControler import PLCControler
from plcopen.structures import IEC_KEYWORDS
+from plcopen.types_enums import ComputeConfigurationResourceName, ITEM_CONFNODE
import targets
from runtime.typemapping import DebugTypesSize, UnpackDebugBuffer
from ConfigTreeNode import ConfigTreeNode, XSDSchemaErrorMessage
@@ -66,7 +67,6 @@
MATIEC_ERROR_MODEL = re.compile(".*\.st:(\d+)-(\d+)\.\.(\d+)-(\d+): (?:error)|(?:warning) : (.*)$")
-ITEM_CONFNODE = 25
def ExtractChildrenTypesFromCatalog(catalog):
@@ -420,7 +420,7 @@
config = self.Project.getconfiguration(self.GetProjectMainConfigurationName())
resource = config.getresource()[0].getname()
config = config.getname()
- resource_tagname = self.ComputeConfigurationResourceName(config, resource)
+ resource_tagname = ComputeConfigurationResourceName(config, resource)
def_task = [
{'Priority': '0', 'Single': '', 'Interval': 'T#20ms', 'Name': 'task0', 'Triggering': 'Cyclic'}]
def_instance = [
--- a/controls/PouInstanceVariablesPanel.py Mon Feb 19 13:24:57 2018 +0100
+++ b/controls/PouInstanceVariablesPanel.py Mon Feb 19 15:14:30 2018 +0100
@@ -30,13 +30,7 @@
import wx.lib.agw.customtreectrl as CT
import wx.lib.buttons
-from PLCControler import \
- ITEMS_VARIABLE, \
- ITEM_CONFIGURATION, \
- ITEM_RESOURCE, \
- ITEM_POU, \
- ITEM_TRANSITION, \
- ITEM_ACTION
+from plcopen.types_enums import *
from util.BitmapLibrary import GetBitmap
@@ -220,7 +214,7 @@
if tagname == "Project":
config_name = self.Controller.GetProjectMainConfigurationName()
if config_name is not None:
- tagname = self.Controller.ComputeConfigurationName(config_name)
+ tagname = ComputeConfigurationName(config_name)
if pou_instance is not None:
self.PouInstance = pou_instance
@@ -316,20 +310,20 @@
def EditButtonCallback(self, infos):
var_class = infos.var_class
if var_class == ITEM_RESOURCE:
- tagname = self.Controller.ComputeConfigurationResourceName(
+ tagname = ComputeConfigurationResourceName(
self.InstanceChoice.GetStringSelection(),
infos.name)
elif var_class == ITEM_TRANSITION:
- tagname = self.Controller.ComputePouTransitionName(
+ tagname = ComputePouTransitionName(
self.PouTagName.split("::")[1],
infos.name)
elif var_class == ITEM_ACTION:
- tagname = self.Controller.ComputePouActionName(
+ tagname = ComputePouActionName(
self.PouTagName.split("::")[1],
infos.name)
else:
var_class = ITEM_POU
- tagname = self.Controller.ComputePouName(infos.type)
+ tagname = ComputePouName(infos.type)
self.ParentWindow.EditProjectElement(var_class, tagname)
def DebugButtonCallback(self, infos):
@@ -346,21 +340,21 @@
self.ParentWindow.OpenDebugViewer(
var_class,
var_path,
- self.Controller.ComputePouTransitionName(
+ ComputePouTransitionName(
self.PouTagName.split("::")[1],
infos.name))
elif var_class == ITEM_ACTION:
self.ParentWindow.OpenDebugViewer(
var_class,
var_path,
- self.Controller.ComputePouActionName(
+ ComputePouActionName(
self.PouTagName.split("::")[1],
infos.name))
else:
self.ParentWindow.OpenDebugViewer(
var_class,
var_path,
- self.Controller.ComputePouName(infos.type))
+ ComputePouName(infos.type))
def DebugButtonDClickCallback(self, infos):
if self.InstanceChoice.GetSelection() != -1:
@@ -420,7 +414,7 @@
instance_path = self.InstanceChoice.GetStringSelection()
if item_infos.var_class == ITEM_RESOURCE:
if instance_path != "":
- tagname = self.Controller.ComputeConfigurationResourceName(
+ tagname = ComputeConfigurationResourceName(
instance_path,
item_infos.name)
else:
@@ -428,11 +422,11 @@
else:
parent_infos = self.VariablesList.GetPyData(selected_item.GetParent())
if item_infos.var_class == ITEM_ACTION:
- tagname = self.Controller.ComputePouActionName(parent_infos.type, item_infos.name)
+ tagname = ComputePouActionName(parent_infos.type, item_infos.name)
elif item_infos.var_class == ITEM_TRANSITION:
- tagname = self.Controller.ComputePouTransitionName(parent_infos.type, item_infos.name)
+ tagname = ComputePouTransitionName(parent_infos.type, item_infos.name)
else:
- tagname = self.Controller.ComputePouName(item_infos.type)
+ tagname = ComputePouName(item_infos.type)
if tagname is not None:
if instance_path != "":
item_path = "%s.%s" % (instance_path, item_infos.name)
--- a/controls/SearchResultPanel.py Mon Feb 19 13:24:57 2018 +0100
+++ b/controls/SearchResultPanel.py Mon Feb 19 15:14:30 2018 +0100
@@ -32,6 +32,7 @@
from PLCControler import *
from util.BitmapLibrary import GetBitmap
+from plcopen.types_enums import GetElementType
def GenerateName(infos):
@@ -196,7 +197,7 @@
words = tagname.split("::")
- element_type = self.ParentWindow.Controler.GetElementType(tagname)
+ element_type = GetElementType(tagname)
if element_type == ITEM_POU:
element_type = self.ParentWindow.Controler.GetPouType(words[1])
--- a/editors/ProjectNodeEditor.py Mon Feb 19 13:24:57 2018 +0100
+++ b/editors/ProjectNodeEditor.py Mon Feb 19 15:14:30 2018 +0100
@@ -28,6 +28,7 @@
from controls import ProjectPropertiesPanel, VariablePanel
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
+from plcopen.types_enums import ComputeConfigurationName
class ProjectNodeEditor(ConfTreeNodeEditor):
@@ -50,9 +51,9 @@
return self.ProjectProperties
def __init__(self, parent, controler, window):
- configuration = controler.GetProjectMainConfigurationName()
+ configuration = GetProjectMainConfigurationName()
if configuration is not None:
- tagname = controler.ComputeConfigurationName(configuration)
+ tagname = ComputeConfigurationName(configuration)
else:
tagname = ""
--- a/editors/Viewer.py Mon Feb 19 13:24:57 2018 +0100
+++ b/editors/Viewer.py Mon Feb 19 15:14:30 2018 +0100
@@ -32,6 +32,7 @@
import wx
from plcopen.structures import *
+from plcopen.types_enums import ComputePouName
from PLCControler import ITEM_VAR_LOCAL, ITEM_POU, ITEM_PROGRAM, ITEM_FUNCTIONBLOCK
from graphics.DebugDataConsumer import DebugDataConsumer
@@ -2285,7 +2286,7 @@
self.ParentWindow.OpenDebugViewer(
pou_type,
"%s.%s" % (self.GetInstancePath(True), self.SelectedElement.GetName()),
- self.Controler.ComputePouName(instance_type))
+ ComputePouName(instance_type))
else:
iec_path = self.GetElementIECPath(self.SelectedElement)
if iec_path is not None:
@@ -2305,7 +2306,7 @@
if instance_type in self.Controler.GetProjectPouNames(self.Debug):
self.ParentWindow.EditProjectElement(
ITEM_POU,
- self.Controler.ComputePouName(instance_type))
+ ComputePouName(instance_type))
else:
self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling)
elif event.ControlDown() and event.ShiftDown():
--- a/plcopen/types_enums.py Mon Feb 19 13:24:57 2018 +0100
+++ b/plcopen/types_enums.py Mon Feb 19 15:14:30 2018 +0100
@@ -40,6 +40,8 @@
ITEM_VAR_INOUT
] = range(17, 24)
+ITEM_CONFNODE = 25
+
VAR_CLASS_INFOS = {
"Local": ("localVars", ITEM_VAR_LOCAL),
"Global": ("globalVars", ITEM_VAR_GLOBAL),
@@ -78,5 +80,45 @@
DATA_TYPES, TRANSITIONS, ACTIONS, CONFIGURATIONS,
RESOURCES, PROPERTIES] = UNEDITABLE_NAMES
+# -------------------------------------------------------------------------------
+# Project Element tag name computation functions
+# -------------------------------------------------------------------------------
+
+# Compute a data type name
+def ComputeDataTypeName(datatype):
+ return "D::%s" % datatype
+
+# Compute a pou name
+def ComputePouName(pou):
+ return "P::%s" % pou
+
+# Compute a pou transition name
+def ComputePouTransitionName(pou, transition):
+ return "T::%s::%s" % (pou, transition)
+
+# Compute a pou action name
+def ComputePouActionName(pou, action):
+ return "A::%s::%s" % (pou, action)
+
+# Compute a pou name
+def ComputeConfigurationName(config):
+ return "C::%s" % config
+
+# Compute a pou name
+def ComputeConfigurationResourceName(config, resource):
+ return "R::%s::%s" % (config, resource)
+
+def GetElementType(tagname):
+ words = tagname.split("::")
+ return {
+ "D": ITEM_DATATYPE,
+ "P": ITEM_POU,
+ "T": ITEM_TRANSITION,
+ "A": ITEM_ACTION,
+ "C": ITEM_CONFIGURATION,
+ "R": ITEM_RESOURCE
+ }[words[0]]
+
+
# remove gettext override
del _