Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions TcMatrix/TcMatrix/POUs/Array2DStaticMatrix.TcPOU
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.9">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.11">
<POU Name="Array2DStaticMatrix" Id="{a6eb7602-4f25-0098-0e69-1891a5e44e4f}" SpecialFunc="None">
<Declaration><![CDATA[(*
Derived Matrix FB that wraps a provided 2D array of LREALS into an invariantly sized matrix
*)
<Declaration><![CDATA[/// Derived Matrix FB that wraps a provided 2D array of LREALS into an invariantly sized matrix
{attribute 'reflection'}
{attribute 'no_assign'}
FUNCTION_BLOCK Array2DStaticMatrix EXTENDS StaticMatrix
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
R0 : DINT;
C0 : DINT;
Expand All @@ -25,14 +19,14 @@ Init_(Array2D_Rows(Data),Array2D_Cols(Data));]]></ST>
</Implementation>
<Folder Name="Overrides" Id="{6fc454d7-7110-0aab-201f-31ae3ea4054e}" />
<Method Name="GetI" Id="{ad4aff6f-ab24-028f-3c4b-cbe7797bb10d}" FolderPath="Overrides\">
<Declaration><![CDATA[//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:
// - 0 <= I < Rows*Cols
// - Matrix is not empty
//If the supplied index is out of bounds the value 0 is returned and a warning is generated in the Error List
METHOD PUBLIC GetI : LREAL//The value of the element at the specified index, or 0 if an invalid index is supplied
<Declaration><![CDATA[/// 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
/// - 0 <= I < Rows*Cols
/// - Matrix is not empty
/// If the supplied index is out of bounds the value 0 is returned and a warning is generated in the Error List
METHOD PUBLIC GetI : LREAL //< The value of the element at the specified index, or 0 if an invalid index is supplied
VAR_INPUT
I : UINT;//The index of the element which should have its value returned
I : UINT; //< The index of the element which should have its value returned
END_VAR
VAR
Ri : UINT;
Expand All @@ -57,12 +51,12 @@ END_IF]]></ST>
</Implementation>
</Method>
<Method Name="SetI" Id="{d3833573-b0e3-0a5b-0936-52509088aeb3}" FolderPath="Overrides\">
<Declaration><![CDATA[//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: - 0 <= I < Rows*Cols
METHOD PUBLIC SetI : BOOL//TRUE if the specified index is valid and the data is copied. FLASE otherwise
<Declaration><![CDATA[/// 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 - 0 <= I < Rows*Cols
METHOD PUBLIC SetI : BOOL //< TRUE if the specified index is valid and the data is copied. FLASE otherwise
VAR_INPUT
I : UINT;//The index specifying which element should be modified
Val : LREAL;//The value copied to the corresponding element
I : UINT; //< The index specifying which element should be modified
Val : LREAL; //< The value copied to the corresponding element
END_VAR
VAR
Ri : UINT;
Expand Down
6 changes: 3 additions & 3 deletions TcMatrix/TcMatrix/POUs/Csv/MatrixCsvReader.TcPOU
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.9">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.11">
<POU Name="MatrixCsvReader" Id="{57e330de-3a6c-0c50-1c55-a24f6c132b53}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK MatrixCsvReader
VAR_IN_OUT CONSTANT
Expand All @@ -8,8 +8,8 @@ END_VAR
VAR_INPUT
bExecute : BOOL;
sPathName : T_MaxString;
tTimeout : TIME;//timeout applied indidivudally to each file operation
nHeaderLines : UDINT;//number of lines to skip at the beginning
tTimeout : TIME; //< timeout applied indidivudally to each file operation
nHeaderLines : UDINT; //< number of lines to skip at the beginning
END_VAR
VAR_OUTPUT
bBusy : BOOL;
Expand Down
16 changes: 8 additions & 8 deletions TcMatrix/TcMatrix/POUs/Csv/MatrixCsvWriter.TcPOU
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.9">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.11">
<POU Name="MatrixCsvWriter" Id="{b9c4277f-dd1d-07b9-250c-5d70c700e57b}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK MatrixCsvWriter
VAR_IN_OUT
M : Matrix;
END_VAR
VAR_INPUT
bExecute : BOOL;
sPathName : T_MaxString;
tTimeout : TIME;//timeout applied indidivudally to each file operation
sPathName : Tc2_System.T_MaxString;
tTimeout : TIME; //< timeout applied indidivudally to each file operation
pHeader : POINTER TO STRING;
cbHeaderLen : UDINT;
END_VAR
Expand All @@ -19,10 +19,10 @@ VAR_OUTPUT
nErrStep : UDINT;
END_VAR
VAR
FileOpen : FB_FileOpen;
CsvWrite : FB_CSVMemBufferWriter;
FileWrite : FB_FileWrite;
FileClose : FB_FileClose;
FileOpen : Tc2_System.FB_FileOpen;
CsvWrite : Tc2_Utilities.FB_CSVMemBufferWriter;
FileWrite : Tc2_System.FB_FileWrite;
FileClose : Tc2_System.FB_FileClose;

hFile : UINT;
buffer : STRING(bufferSize+1);
Expand All @@ -31,7 +31,7 @@ VAR

Ri : UINT;
Ci : UINT;
BuffCmd : E_EnumCmdType;
BuffCmd : Tc2_Utilities.E_EnumCmdType;
END_VAR
VAR CONSTANT
bufferSize : UDINT := 1024;
Expand Down
75 changes: 32 additions & 43 deletions TcMatrix/TcMatrix/POUs/DynamicMatrix.TcPOU
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.9">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.11">
<POU Name="DynamicMatrix" Id="{48b9f1ca-1ace-0f6f-3081-31a18046958e}" SpecialFunc="None">
<Declaration><![CDATA[{attribute 'no_assign'}
{attribute 'reflection'}
FUNCTION_BLOCK DynamicMatrix EXTENDS Matrix
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR
Rows_ : UINT := 0;
Cols_ : UINT := 0;

Data : POINTER TO LREAL;//1D array of reals, such that I = F(R,C) = R*Cols + C (row-major)
Data : POINTER TO LREAL; // 1D array of reals, such that I = F(R,C) = R*Cols + C (row-major)

MemManager : FB_DynMem_Manager2;
END_VAR
Expand All @@ -26,7 +22,7 @@ END_VAR
<Folder Name="Overrides" Id="{78694c69-7fc5-08cd-0afe-6c21638c5b6b}" />
<Folder Name="Resultants" Id="{e9cc64b5-17e3-05cb-0547-28b67d88aa8b}" />
<Method Name="AsColVector" Id="{8333982d-97ec-03df-25f4-b8160437c221}" FolderPath="Resultants\">
<Declaration><![CDATA[//Resets the content of this matrix to be a column vector, copied from the specified column of the input matrix
<Declaration><![CDATA[/// Resets the content of this matrix to be a column vector, copied from the specified column of the input matrix
METHOD PUBLIC AsColVector : BOOL
VAR_IN_OUT CONSTANT
M : Matrix;
Expand All @@ -46,7 +42,7 @@ END_VAR
</Implementation>
</Method>
<Method Name="AsElementDifference" Id="{6b700784-8326-0bcf-2c9d-ca6331de219c}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the content of this matrix to be the result of subtracting the input subtrahend matrix from the input minuend matrix element by element
<Declaration><![CDATA[/// Resets the content of this matrix to be the result of subtracting the input subtrahend matrix from the input minuend matrix element by element
METHOD PUBLIC AsElementDifference : BOOL
VAR_IN_OUT CONSTANT
Minuend : Matrix;
Expand All @@ -68,7 +64,7 @@ AsElementDifference := Matrix_ElementSum(Minuend,Subtrahend,THIS^);]]></ST>
</Implementation>
</Method>
<Method Name="AsElementProduct" Id="{1d639892-7279-0584-2a80-52cd430c8d25}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the content of this matrix to be the result of multiplying the input matricies element by element
<Declaration><![CDATA[/// Resets the content of this matrix to be the result of multiplying the input matricies element by element
METHOD PUBLIC AsElementProduct : BOOL
VAR_IN_OUT CONSTANT
A : Matrix;
Expand All @@ -90,7 +86,7 @@ AsElementProduct := Matrix_ElementProduct(A,B,THIS^);]]></ST>
</Implementation>
</Method>
<Method Name="AsElementSum" Id="{1ed69aa6-4c59-063d-134e-146775a583ed}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the content of this matrix to be the result of adding the input matricies element by element
<Declaration><![CDATA[/// Resets the content of this matrix to be the result of adding the input matricies element by element
METHOD PUBLIC AsElementSum : BOOL
VAR_IN_OUT CONSTANT
A : Matrix;
Expand All @@ -112,7 +108,7 @@ AsElementSum := Matrix_ElementSum(A,B,THIS^);]]></ST>
</Implementation>
</Method>
<Method Name="AsGrown" Id="{3cd3cf6d-f6c0-085c-3642-2ba18a0c7d35}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the content of this matrix to be a larger (by one row and one column) matrix copy of the input matrix. Initial values of the new row, column, and diagonal are controlled by other inputs.
<Declaration><![CDATA[/// Resets the content of this matrix to be a larger (by one row and one column) matrix copy of the input matrix. Initial values of the new row, column, and diagonal are controlled by other inputs.
METHOD PUBLIC AsGrown : BOOL
VAR_IN_OUT CONSTANT
M : Matrix;
Expand All @@ -136,7 +132,7 @@ AsGrown := Matrix_Grow(M,THIS^,Row,Col,DiagVal,RowVal,ColVal);]]></ST>
</Implementation>
</Method>
<Method Name="AsInverse" Id="{fffae31c-4722-0c74-25e1-98f5de4d08c5}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the contents of this matrix to be the inverse of the input matrix.
<Declaration><![CDATA[/// Resets the contents of this matrix to be the inverse of the input matrix.
METHOD PUBLIC AsInverse : BOOL
VAR_IN_OUT CONSTANT
M : Matrix;
Expand All @@ -157,7 +153,7 @@ AsInverse := THIS^.InvertSquare(Tolerance);]]></ST>
</Implementation>
</Method>
<Method Name="AsMatrixProduct" Id="{53280527-f75b-06ac-01d7-498318ada10c}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the content of this matrix to be the product of input matrix A x input matrix B
<Declaration><![CDATA[/// Resets the content of this matrix to be the product of input matrix A x input matrix B
METHOD PUBLIC AsMatrixProduct : BOOL
VAR_IN_OUT CONSTANT
A : Matrix;
Expand All @@ -179,7 +175,7 @@ AsMatrixProduct := Matrix_Product(A,B,THIS^);]]></ST>
</Implementation>
</Method>
<Method Name="AsRowVector" Id="{46190744-41a6-0d8f-0bf6-d07b0ad4ecb0}" FolderPath="Resultants\">
<Declaration><![CDATA[//Resets the content of this matrix to be a row vector, copied from the specified row of the input matrix
<Declaration><![CDATA[/// Resets the content of this matrix to be a row vector, copied from the specified row of the input matrix
METHOD PUBLIC AsRowVector : BOOL
VAR_IN_OUT CONSTANT
M : Matrix;
Expand All @@ -199,7 +195,7 @@ END_VAR
</Implementation>
</Method>
<Method Name="AsScaled" Id="{b4ebfd3a-7f84-0c68-3eb7-f5f1a49c6aeb}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the contents of this matrix to be an element by element product of the input matrix and the input scalar
<Declaration><![CDATA[/// Resets the contents of this matrix to be an element by element product of the input matrix and the input scalar
METHOD PUBLIC AsScaled : BOOL
VAR_IN_OUT CONSTANT
M : Matrix;
Expand All @@ -219,7 +215,7 @@ Scale(Scalar);]]></ST>
</Implementation>
</Method>
<Method Name="AsShrunk" Id="{37c92294-b9bc-00a9-17a2-cb7d0631759a}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the contents of this matrix to be a copy of the input matrix with one fewer row and column (the specified row and column are removed)
<Declaration><![CDATA[/// Resets the contents of this matrix to be a copy of the input matrix with one fewer row and column (the specified row and column are removed)
METHOD PUBLIC AsShrunk : BOOL
VAR_IN_OUT CONSTANT
M : Matrix;
Expand All @@ -240,7 +236,7 @@ AsShrunk := Matrix_Shrink(M,THIS^,Row,Col);]]></ST>
</Implementation>
</Method>
<Method Name="AsSubMatrix" Id="{f93c8810-7b34-0e2d-0d0e-56744d128372}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the contents of this matrix to be a copy of a continuous submatrix of the input reference matrix
<Declaration><![CDATA[/// Resets the contents of this matrix to be a copy of a continuous submatrix of the input reference matrix
METHOD PUBLIC AsSubMatrix : BOOL
VAR_IN_OUT CONSTANT
M : Matrix;
Expand Down Expand Up @@ -273,7 +269,7 @@ AsSubMatrix := Matrix_SubMatrix(M,THIS^,RowStart,RowCount,ColStart,ColCount);]]>
</Implementation>
</Method>
<Method Name="AsTransposed" Id="{a2212529-f813-054e-209a-a7ba6ac5c31a}" FolderPath="Resultants\">
<Declaration><![CDATA[//Resets the contents of this matrix to be a transposed copy of the input matrix
<Declaration><![CDATA[/// Resets the contents of this matrix to be a transposed copy of the input matrix
METHOD PUBLIC AsTransposed : BOOL
VAR_IN_OUT CONSTANT
M : Matrix;
Expand All @@ -288,10 +284,8 @@ AsTransposed := Matrix_Transpose(M,THIS^);]]></ST>
</Implementation>
</Method>
<Method Name="AsVectorCrossProduct" Id="{3ec0f3e8-0a31-090c-3d7c-88ea53422b02}" FolderPath="Resultants\">
<Declaration><![CDATA[//resets the contents of this matrix to be the result of a sequential vector cross product of all of the input matricies
<Declaration><![CDATA[/// Resets the contents of this matrix to be the result of a sequential vector cross product of all of the input matricies
METHOD PUBLIC AsVectorCrossProduct : BOOL
VAR_INPUT
END_VAR
VAR_IN_OUT CONSTANT
Vectors : ARRAY[*] OF POINTER TO Matrix;
END_VAR
Expand Down Expand Up @@ -327,7 +321,7 @@ AsVectorCrossProduct := Vector_CrossProduct(Res := THIS^, Vectors := Vectors);]]
</Implementation>
</Method>
<Property Name="Cols" Id="{09c98137-9055-00b0-0894-d32717273f77}" FolderPath="Overrides\">
<Declaration><![CDATA[//Total number of columns in this matrix
<Declaration><![CDATA[/// Total number of columns in this matrix
PROPERTY PUBLIC Cols : UINT]]></Declaration>
<Get Name="Get" Id="{ce7151de-32b2-073c-1f3b-8ce75ec362a9}">
<Declaration><![CDATA[VAR
Expand Down Expand Up @@ -362,10 +356,7 @@ END_VAR
</Implementation>
</Method>
<Method Name="Free" Id="{ed9227e7-8e2a-060e-3b7c-fa220c6f8eaf}" FolderPath="Initializers\">
<Declaration><![CDATA[METHOD PUBLIC Free
VAR_INPUT
END_VAR
]]></Declaration>
<Declaration><![CDATA[METHOD PUBLIC Free]]></Declaration>
<Implementation>
<ST><![CDATA[Resize(0,0,FALSE,FALSE);
Rows_ := 0;
Expand All @@ -376,14 +367,14 @@ END_IF;]]></ST>
</Implementation>
</Method>
<Method Name="GetI" Id="{a2b5b528-33de-0111-2730-98e9e03688a1}" FolderPath="Overrides\">
<Declaration><![CDATA[//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
//If the supplied index is out of bounds the value 0 is returned and a warning is generated in the Error List
METHOD PUBLIC GetI : LREAL//The value of the element at the specified index, or 0 if an invalid index is supplied
<Declaration><![CDATA[/// 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
/// If the supplied index is out of bounds the value 0 is returned and a warning is generated in the Error List
METHOD PUBLIC GetI : LREAL //< The value of the element at the specified index, or 0 if an invalid index is supplied
VAR_INPUT
I : UINT;//The index of the element which should have its value returned
I : UINT; //< The index of the element which should have its value returned
END_VAR
]]></Declaration>
<Implementation>
Expand Down Expand Up @@ -491,7 +482,7 @@ END_VAR
<Method Name="InitMagicSquare" Id="{b6028141-d29b-0bb0-2bb8-954bb3757e26}" FolderPath="Initializers\">
<Declaration><![CDATA[METHOD PUBLIC InitMagicSquare : BOOL
VAR_INPUT
Size : UINT;//must be an odd number!
Size : UINT; //< must be an odd number!
END_VAR
VAR
Result : BOOL;
Expand Down Expand Up @@ -619,7 +610,7 @@ MemManager.Free2(Buffer);]]></ST>
VAR_INPUT
NewRows : UINT;
NewCols : UINT;
RetainVals : BOOL;//retains
RetainVals : BOOL; //< retains
ClearVals : BOOL;
END_VAR
VAR
Expand Down Expand Up @@ -689,7 +680,7 @@ END_IF
</Implementation>
</Method>
<Property Name="Rows" Id="{5a9e21cc-4483-01f1-1ffd-f7170d98d654}" FolderPath="Overrides\">
<Declaration><![CDATA[//Total number of rows in this matrix
<Declaration><![CDATA[/// Total number of rows in this matrix
PROPERTY PUBLIC Rows : UINT]]></Declaration>
<Get Name="Get" Id="{851dbb5a-4632-0955-0ca2-0204caf2236d}">
<Declaration><![CDATA[VAR
Expand All @@ -701,12 +692,12 @@ END_VAR
</Get>
</Property>
<Method Name="SetI" Id="{8240be42-2571-04a1-0d81-a5786edab7a1}" FolderPath="Overrides\">
<Declaration><![CDATA[//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
METHOD PUBLIC SetI : BOOL//TRUE if the specified index is valid and the data is copied. FLASE otherwise
<Declaration><![CDATA[/// 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
METHOD PUBLIC SetI : BOOL //< TRUE if the specified index is valid and the data is copied. FLASE otherwise
VAR_INPUT
I : UINT;//The index specifying which element should be modified
Val : LREAL;//The value copied to the corresponding element
I : UINT; //< The index specifying which element should be modified
Val : LREAL; //< The value copied to the corresponding element
END_VAR
]]></Declaration>
<Implementation>
Expand Down Expand Up @@ -743,8 +734,6 @@ Shrink := AsShrunk(Temp,Row,Col);]]></ST>
</Method>
<Method Name="Transpose" Id="{5895d9f9-ae16-04ed-0e86-43484feeb00d}" FolderPath="Modifiers\">
<Declaration><![CDATA[METHOD PUBLIC Transpose : BOOL
VAR_INPUT
END_VAR
VAR
Temp : DynamicMatrix;
END_VAR]]></Declaration>
Expand Down
Loading