Table of Contents

Class StringType

Namespace
L5Sharp.Types
Assembly
L5Sharp.dll

A LogixType that represents a string or collection of ASCII characters.

public class StringType : StructureType, ILogixSerializable, IEnumerable<char>, IEnumerable
Inheritance
StringType
Implements
Derived
Inherited Members

Remarks

A logix string type has predefined members LEN and DATA, which contain the current string length and set of ASCII characters representing the string value, respectively. This class is inherited by STRING, which is Rockwell's built in base string type.

StringType has special cases in terms of it's L5X structure. Rockwell treats strings sort of like a value type, giving it a special DataFormat. However, when serialized as a member of a complex structure, the data looks more like a generic structure type.

Constructors

StringType()

Creates a new StringType initialized with default name and data.

public StringType()

Remarks

This creates a default instance named "StringType" with an empty string.

StringType(string)

Creates a new StringType initialized with default name and provided string data.

public StringType(string value)

Parameters

value string

The string value to initialize the type with.

Remarks

This creates a instance named "StringType" with the provided string value.

StringType(string, string)

Creates a new StringType instance with the provided data.

public StringType(string name, string value)

Parameters

name string

The name of the string type.

value string

The string value of the type.

Exceptions

ArgumentException

name is null or empty.

StringType(string, string, ushort)

Creates a new StringType object with the provided name and string value.

protected StringType(string name, string value, ushort length)

Parameters

name string

The name of the string type.

value string

The string value of the type.

length ushort

The length to initialize DATA with. This should be greater or equal than the length of value.

Remarks

This constructor allows you to instantiate a string type with a specified DATA length so that values of different lengths may be assigned. This is meant to be used by deriving classes such as the predefined Rockwell STRING type and any other user defined string type.

Exceptions

ArgumentException

name is null or empty.

ArgumentOutOfRangeException

value is longer than length.

StringType(XElement)

Creates a new StringType initialized from the provided XElement data.

public StringType(XElement element)

Parameters

element XElement

The element to parse as the new member object.

Exceptions

ArgumentNullException

element is null.

InvalidOperationException

element does not have required attributes or child elements.

StringType(XElement, ushort)

Creates a new StringType initialized from the provided XElement and data length value.

protected StringType(XElement element, ushort length)

Parameters

element XElement

The element to parse as the new member object.

length ushort

The length to initialize DATA with. This should be greater or equal than the length of the value found on the provided element object.

Remarks

This constructor allows you to instantiate a string type with a specified DATA length so that values of different lengths may be assigned. This is meant to be used by deriving classes such as the predefined Rockwell STRING type and any other user defined string type.

Exceptions

ArgumentNullException

element is null.

InvalidOperationException

element does not have required attributes or child elements.

ArgumentOutOfRangeException

element contains a value longer than length.

Properties

DATA

Gets the array of bytes that represent the ASCII encoded string value.

public ArrayType<SINT> DATA { get; set; }

Property Value

ArrayType<SINT>

An array of SINT logix atomic values representing the bytes of the string.

Family

The family (string or none) of the type.

public override sealed DataTypeFamily Family { get; }

Property Value

DataTypeFamily

A DataTypeFamily option representing the family value.

LEN

Gets the LEN member of the string type structure.

public DINT LEN { get; }

Property Value

DINT

A DINT logix atomic value representing the integer length of the string.

Remarks

Setting this value will do nothing. The LEN member of a string type is a computed value based on the length of DATA (non-zero characters only). Internally, the data changed event is captured to sync this property value with that of the string length.

Methods

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<char> GetEnumerator()

Returns

IEnumerator<char>

An enumerator that can be used to iterate through the collection.

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

Serialize()

Returns a XElement representing the serialized L5X data for a given object.

public override XElement Serialize()

Returns

XElement

A XElement containing the XML data.

SerializeStructure()

A custom serialization method that returns the string type as a structure element, instead of the string formatted L5X structure.

public XElement SerializeStructure()

Returns

XElement

A XElement object representing the serialized string structure data.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Operators

implicit operator string(StringType)

Converts the provided StringType to a string value.

public static implicit operator string(StringType input)

Parameters

input StringType

The value to convert.

Returns

string

A string type value.

implicit operator StringType(string)

Converts the provided string to a StringType value.

public static implicit operator StringType(string input)

Parameters

input string

The value to convert.

Returns

StringType

A StringType type value.