Table of Contents

Class LogixComponent<TComponent>

Namespace
L5Sharp
Assembly
L5Sharp.dll

A common logix element that is able to be identified by name.

public abstract class LogixComponent<TComponent> : LogixElement, ILogixSerializable where TComponent : LogixComponent<TComponent>

Type Parameters

TComponent
Inheritance
LogixComponent<TComponent>
Implements
Derived
Inherited Members

Remarks

This is the base class for all logix component classes. All components can be identified by a unique name that is typically subject to the some naming constraints defined by a Rockwell. Logix internally may create components that do not adhere to the naming constraints, which is why the property is a simple string. Names should be unique any attempt to create duplicated names should fail. All components also contain a simple string description and Use to identify the purpose of the component.

Constructors

LogixComponent()

Creates a new default LogixElement initialized with an XElement having the L5XType name of the element.

protected LogixComponent()

LogixComponent(XElement)

Initializes a new LogixElement with the provided XElement

protected LogixComponent(XElement element)

Parameters

element XElement

The L5X XElement to initialize the entity with.

Exceptions

ArgumentNullException

element is null.

Properties

Description

The description of the component.

public virtual string? Description { get; set; }

Property Value

string

A string containing the component description if it exists; Otherwise, null.

Name

The unique name of the component.

public virtual string Name { get; set; }

Property Value

string

A string representing the component name.

Remarks

The name servers as a unique identifier for various types of components. In most cases, the component name should satisfy Logix naming constraints of alphanumeric and underscore ('_') characters, start with a letter, and be between 1 and 40 characters. Validation is not performed by this library, so importing components with invalid names may fail.

Use

The Use of the component within the L5X file.

public Use? Use { get; set; }

Property Value

Use

Remarks

Typically used when exporting individual components (DataType, AOI, Module) to indicate whether the component is the target of the L5X content, or exists solely as a context or dependency of the target component. When saving a project as an L5X, the top level controller component is the target, and all other components will not have this property.

Methods

AddAfter(TComponent)

Adds a new component of the same type directly after this component in the L5X document.

public void AddAfter(TComponent component)

Parameters

component TComponent

The component to add.

Remarks

This method requires the component be attached to the L5X or LogixContent, as it will access the parent of the underlying XElement to perform the function.

Exceptions

ArgumentNullException

component is null.

InvalidOperationException

No parent exists for the underlying element. This could happen if the component was created in memory and not yet added to the L5X.

AddBefore(TComponent)

Adds a new component of the same type directly before this component in the L5X document.

public void AddBefore(TComponent component)

Parameters

component TComponent

The component to add.

Remarks

This method requires the component be attached to the L5X or LogixContent, as it will access the parent of the underlying XElement to perform the function.

Exceptions

ArgumentNullException

component is null.

InvalidOperationException

No parent exists for the underlying element. This could happen if the component was created in memory and not yet added to the L5X.

Clone()

Returns a new deep cloned instance of the current LogixComponent<TComponent>.

public TComponent Clone()

Returns

TComponent

A new instance of the specified component with the same property values.

Remarks

This method will simply deserialize a new instance using the current underlying element data.

Exceptions

InvalidOperationException

The object being cloned does not have a constructor accepting a single XElement argument.

Remove()

Removes the component from it's parent container.

public void Remove()

Remarks

This method requires the component be attached to the L5X or LogixContent, as it will access the parent of the underlying XElement to perform the function.

Exceptions

InvalidOperationException

No parent exists for the underlying element. This could happen if the component was created in memory and not yet added to the L5X.

Replace(TComponent)

Replaces the component instance with a new instance of the same type.

public void Replace(TComponent component)

Parameters

component TComponent

The new component to replace this component with.

Remarks

This method requires the component be attached to the L5X or LogixContent, as it will access the parent of the underlying XElement to perform the function.

Exceptions

ArgumentNullException

component is null.

InvalidOperationException

No parent exists for the underlying element. This could happen if the component was created in memory and not yet added to the L5X.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Remarks

This override returns the component name of the type.