Class MatrixAccessor
Matrix accessors are a way of interacting with the data of a parent Matrix through a special lens, without copying the data into a new Matrix and then back again.
This type of Matrix works by creating a function that converts the I-based indexing of the accessor matrix into the I-based indexing of the parent matrix, then using it to intercept calls to GetI and SetI.
Concrete Matrix Accessor Classes can be easily created from the parent MatrixAccessor abstract class by implementing the This2Parent method in order to define the index conversion.
Note that matrix accessor allow both read and write access to the parent matrix!
Matrix Accessors inherently store a pointer (BY REFERENCE) to their parent matrix. If the parent matrix goes out of scope (through function return) or is moved (through an online change) then the Matrix Accessor will no longer work. Therefore, they are best used quickly then destroyed, all within the scope of a single F or FB.
note
warning
Inheritance
Inherited Members
Namespace: PlcDocu.TcMatrix
Assembly: TcMatrixConnector.dll
Syntax
public abstract class MatrixAccessor : Matrix
Fields
| Improve this Doc View SourceM_
Declaration
public Matrix M_
Field Value
| Type | Description |
|---|---|
| Matrix |
Methods
| Improve this Doc View SourceGetI(Object)
Gets the value of the element in this matrix at the supplied location as if the elements were stored in a 1D row-major array Prerequisites:
- I < Rows*Cols
- Matrix is not empty
note
If the supplied index is out of bounds the value 0 is returned and a warning is generated in the Error List
Declaration
[IgnoreReflection]
public dynamic GetI(dynamic I)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | I | The index of the element which should have its value returned |
Returns
| Type | Description |
|---|---|
| System.Object | The value of the element at the specified index, or 0 if an invalid index is supplied |
SetI(Object, Object)
Sets the element specified BY the supplied index TO the suppleid value, assuming the data OF the matrix is stored in a 1D row-major ARRAY Prerequisites: - I < Rows*Cols
Declaration
[IgnoreReflection]
public dynamic SetI(dynamic I, dynamic Val)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | I | The index specifying which element should be modified |
| System.Object | Val | The value copied to the corresponding element |
Returns
| Type | Description |
|---|---|
| System.Object | TRUE if the specified index is valid and the data is copied. FLASE otherwise |