RSLogix .L5X interface.
This package aims to implement an interface for manipulating content of RSLogix .L5X export files using a native Pythonic approach as opposed to dealing with raw XML.
All access to .L5X data is through a top-level Project object, instantiated by passing a filename to the constructor. If the project is to be modified the write method writes the updated data back to a file for importing into RSLogix. Typical execution flow is as follows:
import l5x prj = l5x.Project('project.L5X') # Read or modify data as needed. prj.write('modified.L5X')
The controller attribute of a project has the following attributes:
- A tag scope containing controller tags; see Tags.
- Permits reading and modifying the controller’s communication path. Setting to None will delete the communication path.
>>> prj.controller.tags['tag_name'].description = 'A controller tag' >>> prj.controller.comm_path 'AB_ETHIP-1\\192.168.1.10\\Backplane\\0'
- Safety network number; see Modules for details.
A project’s programs attribute contains a names attribute that evaluates to an iterable of program names, members of which can be used as indices to access program-scoped tags.
>>> prj.programs.names ['MainProgram', 'AnotherProgram'] >>> prj.programs['MainProgram'].tags['a_program_tag'].value = 50
The project’s modules attribute provides access to modules defined in the I/O Configuration tree. A list of modules can be obtained with the names attribute.
>> prj.modules.names ['Controller', 'DOUT1', 'ENBT']
Each module is comprised of a set of communication ports identified by a unique integer. Ports feature a read-only type attribute to query the interface type and a read-write address attribute to get or set the type-specific address. A typical example for manipulating the IP address of an Ethernet port, which is usually port 2:
>> prj.modules['ENBT'].ports.type 'Ethernet' >> prj.modules['ENBT'].ports.address = '192.168.0.1'
Ports configured for network address translation(NAT) can access the NAT address through the nat_address attribute. NAT addresses can only be read or altered by the L5X module, not enabled or disabled. In other words, the port must first be configured for NAT by RSLogix before the NAT address can be accessed, and the L5X module can not be used to disable NAT.
>> prj.modules['no_nat'].ports.nat_address # NAT not configured. None >> prj.modules['ENBT'].ports.nat_address '10.0.0.1' >> prj.modules['ENBT'].ports.nat_address = '192.168.0.1'
Safety Network Numbers
Safety network numbers for safety modules, including the controller, can be accessed via the snn attribute of either the module or its ports. For modules with a single safety network number, such as safety I/O modules, the snn is an attribute of the module itself. Safety modules with multiple communication ports, such as controllers with integrated Ethernet ports, have multiple safety network numbers, which are attributes of its ports.
Module and port safety network numbers use the same format: a twelve character string representing the hexadecimal safety network number; intervening underscores as seen with RSLogix are stripped away. Acceptable values to set a new number need not be zero padded and may contain intervening underscores, however, it must be a string yielding a hexadecimal number not exceeding 48 bits.
>>> prj.controller.snn # Controller with a single SNN. '000011112222' >>> prj.controller.ports.snn # Controller with multiple, port-specific SNNs. '0123456789AB' >>> prj.modules['safe_in'].snn 'AAAABBBBCCCC' >>> prj.controller.snn = '42' >>> prj.modules['safe_out'].snn = '0001_0002_0003'
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size l5x-1.5-py2.py3-none-any.whl (51.7 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size l5x-1.5.tar.gz (50.3 kB)||File type Source||Python version None||Upload date||Hashes View|