--- a/PLCGenerator.py Thu Aug 29 19:48:29 2013 +0200
+++ b/PLCGenerator.py Fri Aug 30 09:18:41 2013 +0200
@@ -22,7 +22,7 @@
#License along with this library; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-from plcopen import plcopen
+from plcopen import PLCOpenParser
from plcopen.structures import *
from types import *
import re
@@ -126,26 +126,25 @@
(datatype.getname(), (tagname, "name")),
(" : ", ())]
basetype_content = datatype.baseType.getcontent()
- # Data type derived directly from a string type
- if basetype_content["name"] in ["string", "wstring"]:
- datatype_def += [(basetype_content["name"].upper(), (tagname, "base"))]
+ basetype_content_type = basetype_content.getLocalTag()
# Data type derived directly from a user defined type
- elif basetype_content["name"] == "derived":
- basetype_name = basetype_content["value"].getname()
+ if basetype_content_type == "derived":
+ basetype_name = basetype_content.getname()
self.GenerateDataType(basetype_name)
datatype_def += [(basetype_name, (tagname, "base"))]
# Data type is a subrange
- elif basetype_content["name"] in ["subrangeSigned", "subrangeUnsigned"]:
- base_type = basetype_content["value"].baseType.getcontent()
+ elif basetype_content_type in ["subrangeSigned", "subrangeUnsigned"]:
+ base_type = basetype_content.baseType.getcontent()
+ base_type_type = base_type.getLocalTag()
# Subrange derived directly from a user defined type
- if base_type["name"] == "derived":
- basetype_name = base_type["value"].getname()
+ if base_type_type == "derived":
+ basetype_name = base_type_type.getname()
self.GenerateDataType(basetype_name)
# Subrange derived directly from an elementary type
else:
- basetype_name = base_type["name"]
- min_value = basetype_content["value"].range.getlower()
- max_value = basetype_content["value"].range.getupper()
+ basetype_name = base_type_type
+ min_value = basetype_content.range.getlower()
+ max_value = basetype_content.range.getupper()
datatype_def += [(basetype_name, (tagname, "base")),
(" (", ()),
("%s"%min_value, (tagname, "lower")),
@@ -153,63 +152,59 @@
("%s"%max_value, (tagname, "upper")),
(")",())]
# Data type is an enumerated type
- elif basetype_content["name"] == "enum":
+ elif basetype_content_type == "enum":
values = [[(value.getname(), (tagname, "value", i))]
- for i, value in enumerate(basetype_content["value"].values.getvalue())]
+ for i, value in enumerate(
+ basetype_content.xpath("ppx:values/ppx:value",
+ namespaces=PLCOpenParser.NSMAP))]
datatype_def += [("(", ())]
datatype_def += JoinList([(", ", ())], values)
datatype_def += [(")", ())]
# Data type is an array
- elif basetype_content["name"] == "array":
- base_type = basetype_content["value"].baseType.getcontent()
+ elif basetype_content_type == "array":
+ base_type = basetype_content.baseType.getcontent()
+ base_type_type = base_type.getLocalTag()
# Array derived directly from a user defined type
- if base_type["name"] == "derived":
- basetype_name = base_type["value"].getname()
+ if base_type_type == "derived":
+ basetype_name = base_type.getname()
self.GenerateDataType(basetype_name)
- # Array derived directly from a string type
- elif base_type["name"] in ["string", "wstring"]:
- basetype_name = base_type["name"].upper()
# Array derived directly from an elementary type
else:
- basetype_name = base_type["name"]
+ basetype_name = base_type_type.upper()
dimensions = [[("%s"%dimension.getlower(), (tagname, "range", i, "lower")),
("..", ()),
("%s"%dimension.getupper(), (tagname, "range", i, "upper"))]
- for i, dimension in enumerate(basetype_content["value"].getdimension())]
+ for i, dimension in enumerate(basetype_content.getdimension())]
datatype_def += [("ARRAY [", ())]
datatype_def += JoinList([(",", ())], dimensions)
datatype_def += [("] OF " , ()),
(basetype_name, (tagname, "base"))]
# Data type is a structure
- elif basetype_content["name"] == "struct":
+ elif basetype_content_type == "struct":
elements = []
- for i, element in enumerate(basetype_content["value"].getvariable()):
+ for i, element in enumerate(basetype_content.getvariable()):
element_type = element.type.getcontent()
+ element_type_type = element_type.getLocalTag()
# Structure element derived directly from a user defined type
- if element_type["name"] == "derived":
- elementtype_name = element_type["value"].getname()
+ if element_type_type == "derived":
+ elementtype_name = element_type.getname()
self.GenerateDataType(elementtype_name)
- elif element_type["name"] == "array":
- base_type = element_type["value"].baseType.getcontent()
+ elif element_type_type == "array":
+ base_type = element_type.baseType.getcontent()
+ base_type_type = base_type.getLocalTag()
# Array derived directly from a user defined type
- if base_type["name"] == "derived":
- basetype_name = base_type["value"].getname()
+ if base_type_type == "derived":
+ basetype_name = base_type.getname()
self.GenerateDataType(basetype_name)
- # Array derived directly from a string type
- elif base_type["name"] in ["string", "wstring"]:
- basetype_name = base_type["name"].upper()
# Array derived directly from an elementary type
else:
- basetype_name = base_type["name"]
+ basetype_name = base_type_type.upper()
dimensions = ["%s..%s" % (dimension.getlower(), dimension.getupper())
- for dimension in element_type["value"].getdimension()]
+ for dimension in element_type.getdimension()]
elementtype_name = "ARRAY [%s] OF %s" % (",".join(dimensions), basetype_name)
- # Structure element derived directly from a string type
- elif element_type["name"] in ["string", "wstring"]:
- elementtype_name = element_type["name"].upper()
# Structure element derived directly from an elementary type
else:
- elementtype_name = element_type["name"]
+ elementtype_name = element_type_type.upper()
element_text = [("\n ", ()),
(element.getname(), (tagname, "struct", i, "name")),
(" : ", ()),
@@ -224,7 +219,7 @@
datatype_def += [("\n END_STRUCT", ())]
# Data type derived directly from a elementary type
else:
- datatype_def += [(basetype_content["name"], (tagname, "base"))]
+ datatype_def += [(basetype_content_type.upper(), (tagname, "base"))]
# Data type has an initial value
if datatype.initialValue is not None:
datatype_def += [(" := ", ()),
@@ -271,7 +266,7 @@
extra_variables = self.Controler.GetConfigurationExtraVariables()
if len(extra_variables) > 0:
if len(varlists) == 0:
- varlists = [(plcopen.interface_globalVars(), [])]
+ varlists = [(PLCOpenParser.CreateElement("globalVars", "interface"), [])]
varlists[-1][1].extend(extra_variables)
# Generate any global variable in configuration
@@ -289,8 +284,8 @@
# Generate any variable of this block
for var in varlist_variables:
vartype_content = var.gettype().getcontent()
- if vartype_content["name"] == "derived":
- var_type = vartype_content["value"].getname()
+ if vartype_content.getLocalTag() == "derived":
+ var_type = vartype_content.getname()
self.GenerateDataType(var_type)
else:
var_type = var.gettypeAsText()
@@ -342,8 +337,8 @@
# Generate any variable of this block
for var in varlist.getvariable():
vartype_content = var.gettype().getcontent()
- if vartype_content["name"] == "derived":
- var_type = vartype_content["value"].getname()
+ if vartype_content.getLocalTag() == "derived":
+ var_type = vartype_content.getname()
self.GenerateDataType(var_type)
else:
var_type = var.gettypeAsText()
@@ -458,6 +453,24 @@
# Generator of POU programs
#-------------------------------------------------------------------------------
+[ConnectorClass, ContinuationClass, ActionBlockClass] = [
+ PLCOpenParser.GetElementClass(instance_name, "commonObjects")
+ for instance_name in ["connector", "continuation", "actionBlock"]]
+[InVariableClass, InOutVariableClass, OutVariableClass, BlockClass] = [
+ PLCOpenParser.GetElementClass(instance_name, "fbdObjects")
+ for instance_name in ["inVariable", "inOutVariable", "outVariable", "block"]]
+[ContactClass, CoilClass, LeftPowerRailClass, RightPowerRailClass] = [
+ PLCOpenParser.GetElementClass(instance_name, "ldObjects")
+ for instance_name in ["contact", "coil", "leftPowerRail", "rightPowerRail"]]
+[StepClass, TransitionClass, JumpStepClass,
+ SelectionConvergenceClass, SelectionDivergenceClass,
+ SimultaneousConvergenceClass, SimultaneousDivergenceClass] = [
+ PLCOpenParser.GetElementClass(instance_name, "sfcObjects")
+ for instance_name in ["step", "transition", "jumpStep",
+ "selectionConvergence", "selectionDivergence",
+ "simultaneousConvergence", "simultaneousDivergence"]]
+TransitionObjClass = PLCOpenParser.GetElementClass("transition", "transitions")
+ActionObjClass = PLCOpenParser.GetElementClass("action", "actions")
class PouProgramGenerator:
@@ -548,9 +561,10 @@
def GetLinkedConnector(self, link, body):
parameter = link.getformalParameter()
instance = body.getcontentInstance(link.getrefLocalId())
- if isinstance(instance, (plcopen.fbdObjects_inVariable, plcopen.fbdObjects_inOutVariable, plcopen.commonObjects_continuation, plcopen.ldObjects_contact, plcopen.ldObjects_coil)):
+ if isinstance(instance, (InVariableClass, InOutVariableClass,
+ ContinuationClass, ContactClass, CoilClass)):
return instance.connectionPointOut
- elif isinstance(instance, plcopen.fbdObjects_block):
+ elif isinstance(instance, BlockClass):
outputvariables = instance.outputVariables.getvariable()
if len(outputvariables) == 1:
return outputvariables[0].connectionPointOut
@@ -565,7 +579,7 @@
blockposition = instance.getposition()
if point.x == blockposition.x + relposition[0] and point.y == blockposition.y + relposition[1]:
return variable.connectionPointOut
- elif isinstance(instance, plcopen.ldObjects_leftPowerRail):
+ elif isinstance(instance, LeftPowerRailClass):
outputconnections = instance.getconnectionPointOut()
if len(outputconnections) == 1:
return outputconnections[0]
@@ -591,25 +605,26 @@
if isinstance(body, ListType):
body = body[0]
body_content = body.getcontent()
+ body_type = body_content.getLocalTag()
if self.Type == "FUNCTION":
returntype_content = interface.getreturnType().getcontent()
- if returntype_content["name"] == "derived":
- self.ReturnType = returntype_content["value"].getname()
- elif returntype_content["name"] in ["string", "wstring"]:
- self.ReturnType = returntype_content["name"].upper()
- else:
- self.ReturnType = returntype_content["name"]
+ returntype_content_type = returntype_content.getLocalTag()
+ if returntype_content_type == "derived":
+ self.ReturnType = returntype_content.getname()
+ else:
+ self.ReturnType = returntype_content_type.upper()
for varlist in interface.getcontent():
variables = []
located = []
- for var in varlist["value"].getvariable():
+ varlist_type = varlist.getLocalTag()
+ for var in varlist.getvariable():
vartype_content = var.gettype().getcontent()
- if vartype_content["name"] == "derived":
- var_type = vartype_content["value"].getname()
+ if vartype_content.getLocalTag() == "derived":
+ var_type = vartype_content.getname()
blocktype = self.GetBlockType(var_type)
if blocktype is not None:
self.ParentGenerator.GeneratePouProgram(var_type)
- if body_content["name"] in ["FBD", "LD", "SFC"]:
+ if body_type in ["FBD", "LD", "SFC"]:
block = pou.getinstanceByName(var.getname())
else:
block = None
@@ -627,9 +642,9 @@
initial_value = None
address = var.getaddress()
if address is not None:
- located.append((vartype_content["value"].getname(), var.getname(), address, initial_value))
+ located.append((vartype_content.getname(), var.getname(), address, initial_value))
else:
- variables.append((vartype_content["value"].getname(), var.getname(), None, initial_value))
+ variables.append((vartype_content.getname(), var.getname(), None, initial_value))
else:
var_type = var.gettypeAsText()
initial = var.getinitialValue()
@@ -642,18 +657,18 @@
located.append((var_type, var.getname(), address, initial_value))
else:
variables.append((var_type, var.getname(), None, initial_value))
- if varlist["value"].getconstant():
+ if varlist.getconstant():
option = "CONSTANT"
- elif varlist["value"].getretain():
+ elif varlist.getretain():
option = "RETAIN"
- elif varlist["value"].getnonretain():
+ elif varlist.getnonretain():
option = "NON_RETAIN"
else:
option = None
if len(variables) > 0:
- self.Interface.append((varTypeNames[varlist["name"]], option, False, variables))
+ self.Interface.append((varTypeNames[varlist_type], option, False, variables))
if len(located) > 0:
- self.Interface.append((varTypeNames[varlist["name"]], option, True, located))
+ self.Interface.append((varTypeNames[varlist_type], option, True, located))
LITERAL_TYPES = {
"T": "TIME",
@@ -669,24 +684,25 @@
if isinstance(body, ListType):
body = body[0]
body_content = body.getcontent()
- body_type = body_content["name"]
+ body_type = body_content.getLocalTag()
if body_type in ["FBD", "LD", "SFC"]:
undefined_blocks = []
for instance in body.getcontentInstances():
- if isinstance(instance, (plcopen.fbdObjects_inVariable, plcopen.fbdObjects_outVariable, plcopen.fbdObjects_inOutVariable)):
- expression = instance.getexpression()
+ if isinstance(instance, (InVariableClass, OutVariableClass,
+ InOutVariableClass)):
+ expression = instance.getexpression().text
var_type = self.GetVariableType(expression)
- if isinstance(pou, plcopen.transitions_transition) and expression == pou.getname():
+ if (isinstance(pou, TransitionObjClass)
+ and expression == pou.getname()):
var_type = "BOOL"
- elif (not isinstance(pou, (plcopen.transitions_transition, plcopen.actions_action)) and
+ elif (not isinstance(pou, (TransitionObjClass, ActionObjClass)) and
pou.getpouType() == "function" and expression == pou.getname()):
returntype_content = pou.interface.getreturnType().getcontent()
- if returntype_content["name"] == "derived":
- var_type = returntype_content["value"].getname()
- elif returntype_content["name"] in ["string", "wstring"]:
- var_type = returntype_content["name"].upper()
+ returntype_content_type = returntype_content.getLocalTag()
+ if returntype_content_type == "derived":
+ var_type = returntype_content.getname()
else:
- var_type = returntype_content["name"]
+ var_type = returntype_content_type.upper()
elif var_type is None:
parts = expression.split("#")
if len(parts) > 1:
@@ -698,16 +714,16 @@
elif expression.startswith('"'):
var_type = "WSTRING"
if var_type is not None:
- if isinstance(instance, (plcopen.fbdObjects_inVariable, plcopen.fbdObjects_inOutVariable)):
+ if isinstance(instance, (InVariableClass, InOutVariableClass)):
for connection in self.ExtractRelatedConnections(instance.connectionPointOut):
self.ConnectionTypes[connection] = var_type
- if isinstance(instance, (plcopen.fbdObjects_outVariable, plcopen.fbdObjects_inOutVariable)):
+ if isinstance(instance, (OutVariableClass, InOutVariableClass)):
self.ConnectionTypes[instance.connectionPointIn] = var_type
connected = self.GetConnectedConnector(instance.connectionPointIn, body)
if connected and not self.ConnectionTypes.has_key(connected):
for connection in self.ExtractRelatedConnections(connected):
self.ConnectionTypes[connection] = var_type
- elif isinstance(instance, (plcopen.ldObjects_contact, plcopen.ldObjects_coil)):
+ elif isinstance(instance, (ContactClass, CoilClass)):
for connection in self.ExtractRelatedConnections(instance.connectionPointOut):
self.ConnectionTypes[connection] = "BOOL"
self.ConnectionTypes[instance.connectionPointIn] = "BOOL"
@@ -715,30 +731,30 @@
if connected and not self.ConnectionTypes.has_key(connected):
for connection in self.ExtractRelatedConnections(connected):
self.ConnectionTypes[connection] = "BOOL"
- elif isinstance(instance, plcopen.ldObjects_leftPowerRail):
+ elif isinstance(instance, LeftPowerRailClass):
for connection in instance.getconnectionPointOut():
for related in self.ExtractRelatedConnections(connection):
self.ConnectionTypes[related] = "BOOL"
- elif isinstance(instance, plcopen.ldObjects_rightPowerRail):
+ elif isinstance(instance, RightPowerRailClass):
for connection in instance.getconnectionPointIn():
self.ConnectionTypes[connection] = "BOOL"
connected = self.GetConnectedConnector(connection, body)
if connected and not self.ConnectionTypes.has_key(connected):
for connection in self.ExtractRelatedConnections(connected):
self.ConnectionTypes[connection] = "BOOL"
- elif isinstance(instance, plcopen.sfcObjects_transition):
- content = instance.condition.getcontent()
- if content["name"] == "connection" and len(content["value"]) == 1:
- connected = self.GetLinkedConnector(content["value"][0], body)
+ elif isinstance(instance, TransitionClass):
+ content = instance.getconditionContent()
+ if content["type"] == "connection":
+ connected = self.GetLinkedConnector(content["value"], body)
if connected and not self.ConnectionTypes.has_key(connected):
for connection in self.ExtractRelatedConnections(connected):
self.ConnectionTypes[connection] = "BOOL"
- elif isinstance(instance, plcopen.commonObjects_continuation):
+ elif isinstance(instance, ContinuationClass):
name = instance.getname()
connector = None
var_type = "ANY"
for element in body.getcontentInstances():
- if isinstance(element, plcopen.commonObjects_connector) and element.getname() == name:
+ if isinstance(element, ConnectorClass) and element.getname() == name:
if connector is not None:
raise PLCGenException, _("More than one connector found corresponding to \"%s\" continuation in \"%s\" POU")%(name, self.Name)
connector = element
@@ -760,7 +776,7 @@
self.ConnectionTypes[connection] = var_type
else:
raise PLCGenException, _("No connector found corresponding to \"%s\" continuation in \"%s\" POU")%(name, self.Name)
- elif isinstance(instance, plcopen.fbdObjects_block):
+ elif isinstance(instance, BlockClass):
block_infos = self.GetBlockType(instance.gettypeName(), "undefined")
if block_infos is not None:
self.ComputeBlockInputTypes(instance, block_infos, body)
@@ -848,22 +864,22 @@
if isinstance(body, ListType):
body = body[0]
body_content = body.getcontent()
- body_type = body_content["name"]
+ body_type = body_content.getLocalTag()
if body_type in ["IL","ST"]:
- text = body_content["value"].gettext()
+ text = body_content.getanyText()
self.ParentGenerator.GeneratePouProgramInText(text.upper())
self.Program = [(ReIndentText(text, len(self.CurrentIndent)),
(self.TagName, "body", len(self.CurrentIndent)))]
elif body_type == "SFC":
self.IndentRight()
for instance in body.getcontentInstances():
- if isinstance(instance, plcopen.sfcObjects_step):
+ if isinstance(instance, StepClass):
self.GenerateSFCStep(instance, pou)
- elif isinstance(instance, plcopen.commonObjects_actionBlock):
+ elif isinstance(instance, ActionBlockClass):
self.GenerateSFCStepActions(instance, pou)
- elif isinstance(instance, plcopen.sfcObjects_transition):
+ elif isinstance(instance, TransitionClass):
self.GenerateSFCTransition(instance, pou)
- elif isinstance(instance, plcopen.sfcObjects_jumpStep):
+ elif isinstance(instance, JumpClass):
self.GenerateSFCJump(instance, pou)
if len(self.InitialSteps) > 0 and len(self.SFCComputedBlocks) > 0:
action_name = "COMPUTE_FUNCTION_BLOCKS"
@@ -878,17 +894,17 @@
otherInstances = {"outVariables&coils" : [], "blocks" : [], "connectors" : []}
orderedInstances = []
for instance in body.getcontentInstances():
- if isinstance(instance, (plcopen.fbdObjects_outVariable, plcopen.fbdObjects_inOutVariable, plcopen.fbdObjects_block)):
+ if isinstance(instance, (OutVariableClass, InOutVariableClass, BlockClass)):
executionOrderId = instance.getexecutionOrderId()
if executionOrderId > 0:
orderedInstances.append((executionOrderId, instance))
- elif isinstance(instance, (plcopen.fbdObjects_outVariable, plcopen.fbdObjects_inOutVariable)):
+ elif isinstance(instance, (OutVariableClass, InOutVariableClass)):
otherInstances["outVariables&coils"].append(instance)
- elif isinstance(instance, plcopen.fbdObjects_block):
+ elif isinstance(instance, BlockClass):
otherInstances["blocks"].append(instance)
- elif isinstance(instance, plcopen.commonObjects_connector):
+ elif isinstance(instance, ConnectorClass):
otherInstances["connectors"].append(instance)
- elif isinstance(instance, plcopen.ldObjects_coil):
+ elif isinstance(instance, CoilClass):
otherInstances["outVariables&coils"].append(instance)
orderedInstances.sort()
otherInstances["outVariables&coils"].sort(SortInstances)
@@ -896,17 +912,17 @@
instances = [instance for (executionOrderId, instance) in orderedInstances]
instances.extend(otherInstances["outVariables&coils"] + otherInstances["blocks"] + otherInstances["connectors"])
for instance in instances:
- if isinstance(instance, (plcopen.fbdObjects_outVariable, plcopen.fbdObjects_inOutVariable)):
+ if isinstance(instance, (OutVariableClass, InOutVariableClass)):
connections = instance.connectionPointIn.getconnections()
if connections is not None:
expression = self.ComputeExpression(body, connections)
if expression is not None:
self.Program += [(self.CurrentIndent, ()),
- (instance.getexpression(), (self.TagName, "io_variable", instance.getlocalId(), "expression")),
+ (instance.getexpression().text, (self.TagName, "io_variable", instance.getlocalId(), "expression")),
(" := ", ())]
self.Program += expression
self.Program += [(";\n", ())]
- elif isinstance(instance, plcopen.fbdObjects_block):
+ elif isinstance(instance, BlockClass):
block_type = instance.gettypeName()
self.ParentGenerator.GeneratePouProgram(block_type)
block_infos = self.GetBlockType(block_type, tuple([self.ConnectionTypes.get(variable.connectionPointIn, "ANY") for variable in instance.inputVariables.getvariable() if variable.getformalParameter() != "EN"]))
@@ -918,14 +934,14 @@
block_infos["generate"](self, instance, block_infos, body, None)
except ValueError, e:
raise PLCGenException, e.message
- elif isinstance(instance, plcopen.commonObjects_connector):
+ elif isinstance(instance, ConnectorClass):
connector = instance.getname()
if self.ComputedConnectors.get(connector, None):
continue
expression = self.ComputeExpression(body, instance.connectionPointIn.getconnections())
if expression is not None:
self.ComputedConnectors[connector] = expression
- elif isinstance(instance, plcopen.ldObjects_coil):
+ elif isinstance(instance, CoilClass):
connections = instance.connectionPointIn.getconnections()
if connections is not None:
coil_info = (self.TagName, "coil", instance.getlocalId())
@@ -933,7 +949,7 @@
if expression is not None:
expression = self.ExtractModifier(instance, expression, coil_info)
self.Program += [(self.CurrentIndent, ())]
- self.Program += [(instance.getvariable(), coil_info + ("reference",))]
+ self.Program += [(instance.getvariable().text, coil_info + ("reference",))]
self.Program += [(" := ", ())] + expression + [(";\n", ())]
def FactorizePaths(self, paths):
@@ -968,11 +984,11 @@
for connection in connections:
localId = connection.getrefLocalId()
next = body.getcontentInstance(localId)
- if isinstance(next, plcopen.ldObjects_leftPowerRail):
+ if isinstance(next, LeftPowerRailClass):
paths.append(None)
- elif isinstance(next, (plcopen.fbdObjects_inVariable, plcopen.fbdObjects_inOutVariable)):
- paths.append(str([(next.getexpression(), (self.TagName, "io_variable", localId, "expression"))]))
- elif isinstance(next, plcopen.fbdObjects_block):
+ elif isinstance(next, (InVariableClass, InOutVariableClass)):
+ paths.append(str([(next.getexpression().text, (self.TagName, "io_variable", localId, "expression"))]))
+ elif isinstance(next, BlockClass):
block_type = next.gettypeName()
self.ParentGenerator.GeneratePouProgram(block_type)
block_infos = self.GetBlockType(block_type, tuple([self.ConnectionTypes.get(variable.connectionPointIn, "ANY") for variable in next.inputVariables.getvariable() if variable.getformalParameter() != "EN"]))
@@ -984,7 +1000,7 @@
paths.append(str(block_infos["generate"](self, next, block_infos, body, connection, order, to_inout)))
except ValueError, e:
raise PLCGenException, e.message
- elif isinstance(next, plcopen.commonObjects_continuation):
+ elif isinstance(next, ContinuationClass):
name = next.getname()
computed_value = self.ComputedConnectors.get(name, None)
if computed_value != None:
@@ -992,7 +1008,7 @@
else:
connector = None
for instance in body.getcontentInstances():
- if isinstance(instance, plcopen.commonObjects_connector) and instance.getname() == name:
+ if isinstance(instance, ConnectorClass) and instance.getname() == name:
if connector is not None:
raise PLCGenException, _("More than one connector found corresponding to \"%s\" continuation in \"%s\" POU")%(name, self.Name)
connector = instance
@@ -1005,9 +1021,9 @@
paths.append(str(expression))
else:
raise PLCGenException, _("No connector found corresponding to \"%s\" continuation in \"%s\" POU")%(name, self.Name)
- elif isinstance(next, plcopen.ldObjects_contact):
+ elif isinstance(next, ContactClass):
contact_info = (self.TagName, "contact", next.getlocalId())
- variable = str(self.ExtractModifier(next, [(next.getvariable(), contact_info + ("reference",))], contact_info))
+ variable = str(self.ExtractModifier(next, [(next.getvariable().text, contact_info + ("reference",))], contact_info))
result = self.GeneratePaths(next.connectionPointIn.getconnections(), body, order)
if len(result) > 1:
factorized_paths = self.FactorizePaths(result)
@@ -1021,7 +1037,7 @@
paths.append([variable, result[0]])
else:
paths.append(variable)
- elif isinstance(next, plcopen.ldObjects_coil):
+ elif isinstance(next, CoilClass):
paths.append(str(self.GeneratePaths(next.connectionPointIn.getconnections(), body, order)))
return paths
@@ -1133,16 +1149,16 @@
if isinstance(body, ListType):
body = body[0]
instance = body.getcontentInstance(instanceLocalId)
- if isinstance(instance, plcopen.sfcObjects_transition):
+ if isinstance(instance, TransitionClass):
instances.append(instance)
- elif isinstance(instance, plcopen.sfcObjects_selectionConvergence):
+ elif isinstance(instance, SelectionConvergenceClass):
instances.extend(self.ExtractConvergenceInputs(instance, pou))
- elif isinstance(instance, plcopen.sfcObjects_simultaneousDivergence):
+ elif isinstance(instance, SimultaneousDivergenceClass):
transition = self.ExtractDivergenceInput(instance, pou)
if transition:
- if isinstance(transition, plcopen.sfcObjects_transition):
+ if isinstance(transition, TransitionClass):
instances.append(transition)
- elif isinstance(transition, plcopen.sfcObjects_selectionConvergence):
+ elif isinstance(transition, SelectionConvergenceClass):
instances.extend(self.ExtractConvergenceInputs(transition, pou))
for instance in instances:
self.GenerateSFCTransition(instance, pou)
@@ -1161,16 +1177,16 @@
if isinstance(body, ListType):
body = body[0]
instance = body.getcontentInstance(instanceLocalId)
- if isinstance(instance, plcopen.sfcObjects_transition):
+ if isinstance(instance, TransitionClass):
instances.append(instance)
- elif isinstance(instance, plcopen.sfcObjects_selectionConvergence):
+ elif isinstance(instance, SelectionConvergenceClass):
instances.extend(self.ExtractConvergenceInputs(instance, pou))
- elif isinstance(instance, plcopen.sfcObjects_simultaneousDivergence):
+ elif isinstance(instance, SimultaneousDivergenceClass):
transition = self.ExtractDivergenceInput(instance, pou)
if transition:
- if isinstance(transition, plcopen.sfcObjects_transition):
+ if isinstance(transition, TransitionClass):
instances.append(transition)
- elif isinstance(transition, plcopen.sfcObjects_selectionConvergence):
+ elif isinstance(transition, SelectionConvergenceClass):
instances.extend(self.ExtractConvergenceInputs(transition, pou))
for instance in instances:
self.GenerateSFCTransition(instance, pou)
@@ -1230,16 +1246,16 @@
if isinstance(body, ListType):
body = body[0]
instance = body.getcontentInstance(instanceLocalId)
- if isinstance(instance, plcopen.sfcObjects_step):
+ if isinstance(instance, StepClass):
steps.append(instance)
- elif isinstance(instance, plcopen.sfcObjects_selectionDivergence):
+ elif isinstance(instance, SelectionDivergenceClass):
step = self.ExtractDivergenceInput(instance, pou)
if step:
- if isinstance(step, plcopen.sfcObjects_step):
+ if isinstance(step, StepClass):
steps.append(step)
- elif isinstance(step, plcopen.sfcObjects_simultaneousConvergence):
+ elif isinstance(step, SimultaneousConvergenceClass):
steps.extend(self.ExtractConvergenceInputs(step, pou))
- elif isinstance(instance, plcopen.sfcObjects_simultaneousConvergence):
+ elif isinstance(instance, SimultaneousConvergenceClass):
steps.extend(self.ExtractConvergenceInputs(instance, pou))
transition_infos = {"id" : transition.getlocalId(),
"priority": transition.getpriority(),
@@ -1259,14 +1275,14 @@
self.TagName = self.ParentGenerator.Controler.ComputePouTransitionName(self.Name, transitionValues["value"])
if transitionType == "IL":
transition_infos["content"] = [(":\n", ()),
- (ReIndentText(transitionBody.gettext(), len(self.CurrentIndent)), (self.TagName, "body", len(self.CurrentIndent)))]
+ (ReIndentText(transitionBody.getanyText(), len(self.CurrentIndent)), (self.TagName, "body", len(self.CurrentIndent)))]
elif transitionType == "ST":
transition_infos["content"] = [("\n", ()),
- (ReIndentText(transitionBody.gettext(), len(self.CurrentIndent)), (self.TagName, "body", len(self.CurrentIndent)))]
+ (ReIndentText(transitionBody.getanyText(), len(self.CurrentIndent)), (self.TagName, "body", len(self.CurrentIndent)))]
else:
for instance in transitionBody.getcontentInstances():
- if isinstance(instance, plcopen.fbdObjects_outVariable) and instance.getexpression() == transitionValues["value"]\
- or isinstance(instance, plcopen.ldObjects_coil) and instance.getvariable() == transitionValues["value"]:
+ if isinstance(instance, OutVariableClass) and instance.getexpression().text == transitionValues["value"]\
+ or isinstance(instance, CoilClass) and instance.getvariable().text == transitionValues["value"]:
connections = instance.connectionPointIn.getconnections()
if connections is not None:
expression = self.ComputeExpression(transitionBody, connections)