def __init__(self, rootElement, parentObject=None, forcedName=None ): plcElementXML.__init__( self, rootElement, parentObject, forcedName ) self.disabled = "true" self.mainRoutineName = "" self.tags = [] self.daughters.append(self.tags) # The prefix that gets added to program-scoped PLC tags in RSLogix5000 is "Program:" self.prefix = "Program:" + self.name self.addNameToPath( self.prefix ) # Check if this program is claimed to be disabled in the XML file, and skip its tags if it is if ( "Disabled" in self.root.attrib.keys() ): self.disabled = self.root.attrib["Disabled"] if( self.disabled == "true" ): print "Program <{0}> is disabled, skipping its tags".format( self.name ) if( "MainRoutineName" in self.root.attrib.keys() ): self.mainRoutineName = self.root.attrib["MainRoutineName"] # Find all the Tag XML elements in the XML file and build the corresponding objects for them tagElms = self.root.xpath( "Tags/Tag") for tagElm in tagElms: newTag = plcTag( tagElm, self ) self.tags.append( newTag ) return
def __init__(self, rootElement, parentObject=None, forcedName=None): plcElementXML.__init__(self, rootElement, parentObject, forcedName) self.disabled = "true" self.mainRoutineName = "" self.tags = [] self.daughters.append(self.tags) # The prefix that gets added to program-scoped PLC tags in RSLogix5000 is "Program:" self.prefix = "Program:" + self.name self.addNameToPath(self.prefix) # Check if this program is claimed to be disabled in the XML file, and skip its tags if it is if ("Disabled" in self.root.attrib.keys()): self.disabled = self.root.attrib["Disabled"] if (self.disabled == "true"): print "Program <{0}> is disabled, skipping its tags".format( self.name) if ("MainRoutineName" in self.root.attrib.keys()): self.mainRoutineName = self.root.attrib["MainRoutineName"] # Find all the Tag XML elements in the XML file and build the corresponding objects for them tagElms = self.root.xpath("Tags/Tag") for tagElm in tagElms: newTag = plcTag(tagElm, self) self.tags.append(newTag) return
def __init__( self, rootElement, searchRoot=None ): plcElementXML.__init__( self, rootElement ) self.tags = [] self.modules = [] self.programs = [] self.daughters.append( self.tags ) self.daughters.append( self.modules ) self.daughters.append( self.programs ) self.processorType = "" self.nFailedAliases = 0 # This static variable should not change while the controller tree is being built plcElementXML.treeSeacrh.rootObject = self # Set the static variable if( searchRoot != None ) : # If searching tree is specified, then set it to what was sepcified plcElementXML.treeSeacrh.rootObject = searchRoot plcElementXML.treeSeacrh.nFailed = 0 # Number of failed searches is zero now # Get the processor type attribute if( "ProcessorType" in self.root.attrib.keys() ): self.processorType = self.root.attrib["ProcessorType"] # Get all the modules moduleElements = self.root.xpath("Modules/Module") for moduleElm in moduleElements: newModule = plcModule( moduleElm, self ) self.modules.append( newModule ) # Get all the programs programElements = self.root.xpath("Programs/Program") for programElm in programElements: newProgram = plcProgram( programElm, self ) self.programs.append( newProgram ) # Get all controller scoped tags tagElms = self.root.xpath( "Tags/Tag") for tagElm in tagElms: newTag = plcTag( tagElm, self ) self.tags.append( newTag ) self.nFailedAliases = plcElementXML.treeSeacrh.nFailed print "Number of failed searches is ", plcElementXML.treeSeacrh.nFailed return
def __init__(self, rootElement, searchRoot=None): plcElementXML.__init__(self, rootElement) self.tags = [] self.modules = [] self.programs = [] self.daughters.append(self.tags) self.daughters.append(self.modules) self.daughters.append(self.programs) self.processorType = "" self.nFailedAliases = 0 # This static variable should not change while the controller tree is being built plcElementXML.treeSeacrh.rootObject = self # Set the static variable if (searchRoot != None): # If searching tree is specified, then set it to what was sepcified plcElementXML.treeSeacrh.rootObject = searchRoot plcElementXML.treeSeacrh.nFailed = 0 # Number of failed searches is zero now # Get the processor type attribute if ("ProcessorType" in self.root.attrib.keys()): self.processorType = self.root.attrib["ProcessorType"] # Get all the modules moduleElements = self.root.xpath("Modules/Module") for moduleElm in moduleElements: newModule = plcModule(moduleElm, self) self.modules.append(newModule) # Get all the programs programElements = self.root.xpath("Programs/Program") for programElm in programElements: newProgram = plcProgram(programElm, self) self.programs.append(newProgram) # Get all controller scoped tags tagElms = self.root.xpath("Tags/Tag") for tagElm in tagElms: newTag = plcTag(tagElm, self) self.tags.append(newTag) self.nFailedAliases = plcElementXML.treeSeacrh.nFailed print "Number of failed searches is ", plcElementXML.treeSeacrh.nFailed return
def __init__(self, rootElement, parentObj=None): plcElementXML.__init__(self, rootElement, parentObj) self.confTags = [] self.inTags = [] self.outTags = [] self.ports = [] self.daughters.append(self.inTags) self.daughters.append(self.outTags) self.daughters.append(self.confTags) if (self.name == ""): self.name = "UnNamedModule" + str(plcModule.nUnNamed) plcModule.nUnNamed += 1 if ("ParentModule" not in self.root.attrib.keys()): print "Module <{0}> does not have ParentModule XML attribute".format( self.name) sys.exit(-1) self.parentModuleName = self.root.attrib["ParentModule"] if ("ParentModPortId" not in self.root.attrib.keys()): print "Module <{0}> does not have ParentModPortId XML attribute".format( self.name) sys.exit(-1) self.parentModulePortID = self.root.attrib["ParentModPortId"] # print "Creating Module named ", self.name, " type ", self.root.attrib["CatalogNumber"] # Get all the ports that have PointIO, Ethernet and ICP interfaces self.portElms = self.root.xpath( "Ports/Port[@Type='PointIO' or @Type='ICP' or @Type='Ethernet' or @Type='Compact']" ) for portElm in self.portElms: # print "Port: ", portElm.attrib newPort = plcPort(portElm, self) self.ports.append(newPort) subTagName = None # if( self.parentModuleName != "Local" ): if (True): moduleIsControlled = False # Loopo over all the ports to see if the module tags will be called by its name or parents name # At this point we will go only one lever up, that is the module tags cannot be named after their grandparents. # It is either their name with address 0 or the parents name with the address of the corresponding port. portAddress = None for port in self.ports: if (port.upstream == "true" and port.type in plcPort.controlledTypes): # Apparently this means that this module is controlled from upstream # Declare the module to be controlled by the parent and break out of the loop moduleIsControlled = True portAddress = port.address break if (moduleIsControlled): # subTagName = self.parentModuleName + ":" + self.parentModulePortID + ":" subTagName = self.parentModuleName + ":" + portAddress + ":" else: # subTagName = self.name + ":0:" subTagName = self.name + ":" else: subTagName = self.name + ":0:" # print "SubTageName is ", subTagName # Get all configuration tags for the module self.confTagElms = self.root.xpath( "Communications/ConfigTag[@ExternalAccess='Read/Write']") for tagElm in self.confTagElms: # print "Tag: ", tagElm.attrib newTag = plcTag.plcTag(tagElm, self, subTagName + "C") self.confTags.append(newTag) # Get all input tags for the module self.inTagElms = self.root.xpath( "Communications/Connections/Connection/InputTag[@ExternalAccess='Read/Write']" ) for tagElm in self.inTagElms: # print "Tag: ", tagElm.attrib newTag = plcTag.plcTag(tagElm, self, subTagName + "I") self.inTags.append(newTag) # Get all output tags for the module self.outTagElms = self.root.xpath( "Communications/Connections/Connection/OutputTag[@ExternalAccess='Read/Write']" ) for tagElm in self.outTagElms: # print "Tag: ", tagElm.attrib newTag = plcTag.plcTag(tagElm, self, subTagName + "O") self.outTags.append(newTag) return
def __init__(self, rootElement, parentObj=None ): plcElementXML.__init__(self, rootElement, parentObj ) self.confTags = [] self.inTags = [] self.outTags = [] self.ports = [] self.daughters.append(self.inTags) self.daughters.append(self.outTags) self.daughters.append(self.confTags) if( self.name == "" ): self.name = "UnNamedModule" + str(plcModule.nUnNamed) plcModule.nUnNamed += 1 if( "ParentModule" not in self.root.attrib.keys() ): print "Module <{0}> does not have ParentModule XML attribute".format( self.name ) sys.exit(-1) self.parentModuleName = self.root.attrib["ParentModule"] if( "ParentModPortId" not in self.root.attrib.keys() ): print "Module <{0}> does not have ParentModPortId XML attribute".format( self.name ) sys.exit(-1) self.parentModulePortID = self.root.attrib["ParentModPortId"] # print "Creating Module named ", self.name, " type ", self.root.attrib["CatalogNumber"] # Get all the ports that have PointIO, Ethernet and ICP interfaces self.portElms = self.root.xpath("Ports/Port[@Type='PointIO' or @Type='ICP' or @Type='Ethernet' or @Type='Compact']") for portElm in self.portElms: # print "Port: ", portElm.attrib newPort = plcPort( portElm, self ) self.ports.append( newPort ) subTagName = None # if( self.parentModuleName != "Local" ): if( True ): moduleIsControlled = False # Loopo over all the ports to see if the module tags will be called by its name or parents name # At this point we will go only one lever up, that is the module tags cannot be named after their grandparents. # It is either their name with address 0 or the parents name with the address of the corresponding port. portAddress = None for port in self.ports: if( port.upstream == "true" and port.type in plcPort.controlledTypes ): # Apparently this means that this module is controlled from upstream # Declare the module to be controlled by the parent and break out of the loop moduleIsControlled = True portAddress = port.address break if( moduleIsControlled ): # subTagName = self.parentModuleName + ":" + self.parentModulePortID + ":" subTagName = self.parentModuleName + ":" + portAddress + ":" else : # subTagName = self.name + ":0:" subTagName = self.name + ":" else : subTagName = self.name+ ":0:" # print "SubTageName is ", subTagName # Get all configuration tags for the module self.confTagElms = self.root.xpath("Communications/ConfigTag[@ExternalAccess='Read/Write']") for tagElm in self.confTagElms : # print "Tag: ", tagElm.attrib newTag = plcTag.plcTag(tagElm, self, subTagName+"C" ) self.confTags.append(newTag) # Get all input tags for the module self.inTagElms = self.root.xpath("Communications/Connections/Connection/InputTag[@ExternalAccess='Read/Write']") for tagElm in self.inTagElms : # print "Tag: ", tagElm.attrib newTag = plcTag.plcTag(tagElm, self, subTagName+"I" ) self.inTags.append(newTag) # Get all output tags for the module self.outTagElms = self.root.xpath("Communications/Connections/Connection/OutputTag[@ExternalAccess='Read/Write']") for tagElm in self.outTagElms : # print "Tag: ", tagElm.attrib newTag = plcTag.plcTag(tagElm, self, subTagName+"O" ) self.outTags.append(newTag) return