Class StringType
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
stringThe 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
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
stringThe name of the string type.
value
stringThe string value of the type.
length
ushortThe 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 thanlength
.
StringType(XElement)
Creates a new StringType initialized from the provided XElement data.
public StringType(XElement element)
Parameters
element
XElementThe 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
XElementThe element to parse as the new member object.
length
ushortThe 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 thanlength
.
Properties
DATA
Gets the array of bytes that represent the ASCII encoded string value.
public ArrayType<SINT> DATA { get; set; }
Property Value
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
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
objectThe object to compare with the current object.
Returns
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
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
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
StringTypeThe value to convert.
Returns
implicit operator StringType(string)
Converts the provided string to a StringType value.
public static implicit operator StringType(string input)
Parameters
input
stringThe value to convert.
Returns
- StringType
A StringType type value.