--- 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 = []
--- 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):
--- 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)
--- 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 @@
</condition>
</transition>
<transition localId="15" height="2" width="20">
- <position y="316" x="486"/>
+ <position y="346" x="486"/>
<connectionPointIn>
<relPosition y="0" x="10"/>
<connection refLocalId="10">
- <position y="316" x="496"/>
+ <position y="346" x="496"/>
<position y="261" x="496"/>
</connection>
</connectionPointIn>
@@ -701,19 +701,19 @@
</condition>
</transition>
<selectionConvergence localId="16" height="1" width="163">
- <position y="343" x="333"/>
+ <position y="373" x="333"/>
<connectionPointIn>
<relPosition y="0" x="0"/>
<connection refLocalId="14">
- <position y="343" x="333"/>
+ <position y="373" x="333"/>
<position y="288" x="333"/>
</connection>
</connectionPointIn>
<connectionPointIn>
<relPosition y="0" x="163"/>
<connection refLocalId="15">
- <position y="343" x="496"/>
- <position y="318" x="496"/>
+ <position y="373" x="496"/>
+ <position y="348" x="496"/>
</connection>
</connectionPointIn>
<connectionPointOut>
@@ -721,16 +721,16 @@
</connectionPointOut>
</selectionConvergence>
<jumpStep localId="19" height="13" width="12" targetName="Init">
- <position y="369" x="407"/>
+ <position y="399" x="407"/>
<connectionPointIn>
<relPosition y="0" x="6"/>
<connection refLocalId="16">
- <position y="369" x="413"/>
- <position y="344" x="413"/>
+ <position y="399" x="413"/>
+ <position y="374" x="413"/>
</connection>
</connectionPointIn>
</jumpStep>
- <actionBlock localId="20" height="60" width="181">
+ <actionBlock localId="20" height="90" width="173">
<position y="232" x="545"/>
<connectionPointIn>
<relPosition y="15" x="0"/>
@@ -745,6 +745,11 @@
<action qualifier="D" duration="T#10s">
<reference name="IN1"/>
</action>
+ <action qualifier="P">
+ <inline>
+ <ST>IN2 := TRUE;</ST>
+ </inline>
+ </action>
</actionBlock>
<simultaneousDivergence localId="21" height="3" width="118">
<position y="234" x="105"/>
--- 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: