Table of Contents

Class LogixContent

Namespace
L5Sharp
Assembly
L5Sharp.dll

Represents the root content of a RSLogix5000 L5X file, providing access to query and manipulate primary components such as Tag, DataType, Module, and more; This is the primary entry point for interacting with the L5X file.

public class LogixContent
Inheritance
LogixContent
Inherited Members

Constructors

LogixContent(XElement)

Creates a new LogixContent instance with the provided root XElement.

public LogixContent(XElement element)

Parameters

element XElement

The root RSLogix5000Content element of the L5X.

Exceptions

ArgumentNullException

element is null.

ArgumentException

element name is not root RSLogix5000Content name.

Properties

Controller

The root Controller component of the L5X file.

public Controller Controller { get; }

Property Value

Controller

A Controller component object.

Remarks

If the L5X does not ContainContext, meaning it is a project export, this will container all the relevant controller properties and configurations. Otherwise most data will be null as the controller serves as just a root container for other component objects.

DataTypes

The container collection of DataType components found in the L5X file.

public LogixContainer<DataType> DataTypes { get; }

Property Value

LogixContainer<DataType>

A LogixContainer<TElement> of DataType components.

Instructions

Gets the collection of AddOnInstruction components found in the L5X file.

public LogixContainer<AddOnInstruction> Instructions { get; }

Property Value

LogixContainer<AddOnInstruction>

A LogixContainer<TElement> of AddOnInstruction components.

L5X

The root L5X content containing all raw XML data for the LogixContent.

public L5X L5X { get; }

Property Value

L5X

Remarks

L5X inherits from XElement and adds some helper properties and methods for interacting with the root content of the L5X file.

Modules

Gets the collection of Module components found in the L5X file.

public LogixContainer<Module> Modules { get; }

Property Value

LogixContainer<Module>

A LogixContainer<TElement> of Module components.

ParameterConnections

The container collection of ParameterConnection components found in the L5X file.

public LogixContainer<ParameterConnection> ParameterConnections { get; }

Property Value

LogixContainer<ParameterConnection>

A LogixContainer<TElement> of ParameterConnection components.

Programs

Gets the collection of Program components found in the L5X file.

public LogixContainer<Program> Programs { get; }

Property Value

LogixContainer<Program>

A LogixContainer<TElement> of Program components.

Tags

Gets the collection of Controller Tags components found in the L5X file.

public LogixContainer<Tag> Tags { get; }

Property Value

LogixContainer<Tag>

A LogixContainer<TElement> of Tags components.

Remarks

To access program specific tag collection user the Programs collection.

Tasks

Gets the collection of Task components found in the L5X file.

public LogixContainer<Task> Tasks { get; }

Property Value

LogixContainer<Task>

A LogixContainer<TElement> of Task components.

The container collection of Trend components found in the L5X file.

public LogixContainer<Trend> Trends { get; }

Property Value

LogixContainer<Trend>

A LogixContainer<TElement> of Trend components.

WatchLists

The container collection of WatchList components found in the L5X file.

public LogixContainer<WatchList> WatchLists { get; }

Property Value

LogixContainer<WatchList>

A LogixContainer<TElement> of WatchList components.

Methods

Export<TComponent>(LogixComponent<TComponent>, Revision?)

Creates a new LogixContent with the provided logix component as the target type.

public static LogixContent Export<TComponent>(LogixComponent<TComponent> target, Revision? softwareRevision = null) where TComponent : LogixComponent<TComponent>

Parameters

target LogixComponent<TComponent>

The L5X target component of the resulting content.

softwareRevision Revision

The optional software revision, or version of Studio to export the component as.

Returns

LogixContent

A LogixContent containing the component as the target of the L5X.

Type Parameters

TComponent

Find<TElement>()

Finds elements of the specified type across the entire L5X and returns as a flat IEnumerable<T> of objects.

public IEnumerable<TElement> Find<TElement>() where TElement : LogixElement

Returns

IEnumerable<TElement>

A IEnumerable<T> containing all found objects of the specified type.

Type Parameters

TElement

The element type to find.

Import(LogixContent, bool)

Merges another LogixContent file into the current L5X by adding or overwriting logix components.

public void Import(LogixContent content, bool overwrite = true)

Parameters

content LogixContent

The LogixContent to merge.

overwrite bool

A bit indicating whether to overwrite incoming components of the same name.

Exceptions

ArgumentNullException

content is null.

Import(string, bool)

Merges the specified L5X file with the current LogixContent L5X by adding or overwriting logix components.

public void Import(string fileName, bool overwrite = true)

Parameters

fileName string

The file name of L5X to merge.

overwrite bool

A bit indicating whether to overwrite incoming components of the same name.

Exceptions

ArgumentException

fileName is null or empty.

Load(string)

Creates a new LogixContent by loading the contents of the provide file name.

public static LogixContent Load(string fileName)

Parameters

fileName string

The full path, including file name, to the L5X file to load.

Returns

LogixContent

A new LogixContent containing the contents of the specified file.

Remarks

This factory method uses the Load(string) to load the contents of the xml file into memory. This means that this method is subject to the same exceptions that could be generated by loading the XDocument. Once loaded, validation is performed to ensure the content adheres to the specified L5X Schema files.

Exceptions

ArgumentException

The string is null or empty.

Parse(string)

Creates a new LogixContent with the provided L5X string content.

public static LogixContent Parse(string text)

Parameters

text string

The string that contains the L5X content to parse.

Returns

LogixContent

A new LogixContent containing the contents of the specified string.

Remarks

This factory method uses the Parse(string) to load the contents of the xml file into memory. This means that this method is subject to the same exceptions that could be generated by parsing the XDocument. Once parsed, validation is performed to ensure the content adheres to the specified L5X Schema files.

Exceptions

ArgumentException

The string is null or empty.

Save(string)

Serialize this LogixContent to a file, overwriting an existing file, if it exists.

public void Save(string fileName)

Parameters

fileName string

A string that contains the name of the file.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.