# HG changeset patch
# User lbessard
# Date 1184850281 -7200
# Node ID 4379e98a30aa28549b39fc2603b3d54e9cff804f
# Parent 42637f721b5b52d006c927272ff8073cfb9232ca
Bug on SFC generation fixed
Adding Action and Transition remove functions
diff -r 42637f721b5b -r 4379e98a30aa PLCControler.py
--- a/PLCControler.py Thu Jul 19 11:53:14 2007 +0200
+++ b/PLCControler.py Thu Jul 19 15:04:41 2007 +0200
@@ -542,6 +542,15 @@
pou = self.Project.getPou(name)
return pou.getBodyType()
+ # Return the actions of a pou
+ def GetPouTransitions(self, pou_name):
+ transitions = []
+ pou = self.Project.getPou(pou_name)
+ if pou.getBodyType() == "SFC":
+ for transition in pou.getTransitionList():
+ transitions.append(transition.getName())
+ return transitions
+
# Return the body language of the transition given by its name
def GetTransitionBodyType(self, pou_name, pou_transition):
# Found the pou correponding to name and return its body language
@@ -549,6 +558,15 @@
transition = pou.getTransition(pou_transition)
return transition.getBodyType()
+ # Return the actions of a pou
+ def GetPouActions(self, pou_name):
+ actions = []
+ pou = self.Project.getPou(pou_name)
+ if pou.getBodyType() == "SFC":
+ for action in pou.getActionList():
+ actions.append(action.getName())
+ return actions
+
# Return the body language of the pou given by its name
def GetActionBodyType(self, pou_name, pou_action):
# Found the pou correponding to name and return its body language
@@ -556,6 +574,16 @@
action = pou.getAction(pou_action)
return action.getBodyType()
+ # Add a Transition to a Project Pou
+ def ProjectRemovePouTransition(self, pou_name, transition_name):
+ pou = self.Project.getPou(pou_name)
+ pou.removeTransition(transition_name)
+
+ # Add a Transition to a Project Pou
+ def ProjectRemovePouAction(self, pou_name, action_name):
+ pou = self.Project.getPou(pou_name)
+ pou.removeAction(action_name)
+
# Extract varlists from a list of vars
def ExtractVarLists(self, vars):
varlist_list = []
diff -r 42637f721b5b -r 4379e98a30aa PLCGenerator.py
--- a/PLCGenerator.py Thu Jul 19 11:53:14 2007 +0200
+++ b/PLCGenerator.py Thu Jul 19 15:04:41 2007 +0200
@@ -62,8 +62,13 @@
self.Interface = []
self.InitialSteps = []
self.SFCNetworks = {"Steps":{}, "Transitions":{}, "Actions":{}}
+ self.ActionNumber = 0
self.Program = ""
+ def GetActionNumber(self):
+ self.ActionNumber += 1
+ return self.ActionNumber
+
def IsAlreadyDefined(self, name):
for list_type, retain, constant, located, vars in self.Interface:
for var_type, var_name, var_address, var_initial in vars:
@@ -272,6 +277,7 @@
if step_name in self.SFCNetworks["Steps"].keys():
actions = actionBlock.getActions()
for action in actions:
+ print action
action_infos = {"qualifier" : action["qualifier"], "content" : action["value"]}
if "duration" in action:
action_infos["duration"] = action["duration"]
@@ -279,6 +285,10 @@
action_infos["indicator"] = action["indicator"]
if action["type"] == "reference":
self.GenerateSFCAction(action["value"], pou)
+ else:
+ action_name = "INLINE%d"%self.GetActionNumber()
+ self.SFCNetworks["Actions"][action_name] = " %s\n"%action["value"]
+ action_infos["content"] = action_name
self.SFCNetworks["Steps"][step_name]["actions"].append(action_infos)
def GenerateSFCAction(self, action_name, pou):
diff -r 42637f721b5b -r 4379e98a30aa PLCOpenEditor.py
--- a/PLCOpenEditor.py Thu Jul 19 11:53:14 2007 +0200
+++ b/PLCOpenEditor.py Thu Jul 19 15:04:41 2007 +0200
@@ -1183,7 +1183,7 @@
def OnRemoveConfigurationMenu(self, event):
configs = self.Controler.GetProjectConfigNames()
- dialog = wxSingleChoiceDialog(self, "Select Configuration to remove:", "Configuration Remove", configs, wxOK|wxCANCEL)
+ dialog = wxSingleChoiceDialog(self, "Select Configuration to remove:", "Remove configuration", configs, wxOK|wxCANCEL)
if dialog.ShowModal() == wxID_OK:
selected = dialog.GetStringSelection()
self.Controler.ProjectRemoveConfiguration(selected)
@@ -1204,6 +1204,17 @@
event.Skip()
def OnRemovePouTransitionMenu(self, event):
+ selected = self.ProjectTree.GetSelection()
+ if self.ProjectTree.GetPyData(selected) == ITEM_POU:
+ pouname = self.ProjectTree.GetItemText(selected)
+ if self.Controler.GetPouBodyType(pouname) == "SFC":
+ transitions = self.Controler.GetPouTransitions(pouname)
+ dialog = wxSingleChoiceDialog(self, "Select Transition to remove:", "Remove transition", transitions, wxOK|wxCANCEL)
+ if dialog.ShowModal() == wxID_OK:
+ selected = dialog.GetStringSelection()
+ self.Controler.ProjectRemovePouTransition(pouname, selected)
+ self.RefreshProjectTree()
+ dialog.Destroy()
event.Skip()
def OnAddPouActionMenu(self, event):
@@ -1220,6 +1231,17 @@
event.Skip()
def OnRemovePouActionMenu(self, event):
+ selected = self.ProjectTree.GetSelection()
+ if self.ProjectTree.GetPyData(selected) == ITEM_POU:
+ pouname = self.ProjectTree.GetItemText(selected)
+ if self.Controler.GetPouBodyType(pouname) == "SFC":
+ actions = self.Controler.GetPouActions(pouname)
+ dialog = wxSingleChoiceDialog(self, "Select Action to remove:", "Remove action", actions, wxOK|wxCANCEL)
+ if dialog.ShowModal() == wxID_OK:
+ selected = dialog.GetStringSelection()
+ self.Controler.ProjectRemovePouAction(pouname, selected)
+ self.RefreshProjectTree()
+ dialog.Destroy()
event.Skip()
def OnAddResourceMenu(self, event):
@@ -1243,7 +1265,7 @@
for config in infos["configs"]:
if config["name"] == config_name:
resources = config["resources"]
- dialog = wxSingleChoiceDialog(self, "Select Resource to remove:", "Resource Remove", resources, wxOK|wxCANCEL)
+ dialog = wxSingleChoiceDialog(self, "Select Resource to remove:", "Remove resource", resources, wxOK|wxCANCEL)
if dialog.ShowModal() == wxID_OK:
resource = dialog.GetStringSelection()
self.Controler.ProjectRemoveConfigurationResource(config_name, resource)
diff -r 42637f721b5b -r 4379e98a30aa examples/example.xml
--- a/examples/example.xml Thu Jul 19 11:53:14 2007 +0200
+++ b/examples/example.xml Thu Jul 19 15:04:41 2007 +0200
@@ -683,11 +683,11 @@
-
+
-
+
@@ -701,19 +701,19 @@
-
+
-
+
-
-
+
+
@@ -721,16 +721,16 @@
-
+
-
-
+
+
-
+
@@ -745,6 +745,11 @@
+
+
+ IN2 := TRUE;
+
+
diff -r 42637f721b5b -r 4379e98a30aa plcopen/plcopen.py
--- a/plcopen/plcopen.py Thu Jul 19 11:53:14 2007 +0200
+++ b/plcopen/plcopen.py Thu Jul 19 15:04:41 2007 +0200
@@ -376,7 +376,7 @@
removed = False
while i < len(transitions) and not removed:
if transitions[i].getName() == name:
- transitions.removeTransition(i)
+ transitions.pop(i)
removed = True
i += 1
if not removed:
@@ -414,7 +414,7 @@
removed = False
while i < len(actions) and not removed:
if actions[i].getName() == name:
- actions.removeAction(i)
+ actions.pop(i)
removed = True
i += 1
if not removed: