Class ExternalStaticMatrix
This simple concrete derivative of the StaticMatrix class uses an external ARRAY OF LREAL as the memory source for the matrix data. It is accessed in row-major order based on the logic in the GetI and SetI functions. It is most useful when someone doesn't trust dynamically allocated memory, but also doesn't want to make multiple size-specific custom derived FBs just to set up a single complex matrix operation.
Init(R,C,pD) : Must be called in order to setup the matrix (it will be empty until this method is called).
warning
It is the callers responsibility to ensure that the pointer provided to the initializer is valid: - The length of the data structure pointed to (probably an array of LREAL) is at least as long as Rows x Cols - The scope of the data structure pointed to is the same as the scope of the corresponding ExternalStaticMatrix (probably declared adjacent to eachother as a VAR or GVL) Additionally, direct assignment (:=) should not be used with this type of matrix because a second copy of the Matrix, but with a pointer to the original's data source, would be created. For this reason, the pragma {attribute 'no_assign'} is used to block assignment at compile-time. Keep in mind that returning a value from a function is also a form of assignment and is not allowed.
Inherited Members
Namespace: PlcDocu.TcMatrix
Assembly: TcMatrixConnector.dll
Syntax
public abstract class ExternalStaticMatrix : StaticMatrix
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 |