A variable of the MATRIX data type encapsulates a two
dimensional matrix of 32-bit floating-point values (corresponding to
the IEC 61131-3 data type REAL ) in [row][column]
format.
Literal values
Literal values of MATRIX variables can be expressed in
BNF syntax as follows:
matrix_literal ::= '[' [vector_literal {',' vector_literal}] ']
vector_literal ::= '[' [float_value {',' float_value}] ']'
The syntax of float_value is any string accepted by the
java.lang.Float.valueOf(String)
method.
Each vector_literal element represents a row of
the matrix; for instance, the literal [[1,2],[3,4]]
represents the matrix
1.0 2.0 3.0 4.0
Missing elements are assigned zero values; for instance, the literal
[[],[1,2],[3,4,5]] represents the matrix
0.0 0.0 0.0 1.0 2.0 0.0 3.0 4.0 5.0
For examples of the use of MATRIX literals, see the
MATRIX_DEMO
and M_OPS_DEMO
system configurations.
ASN.1 Encoding
MATRIX data is transferred according to the following
modified ASN.1 syntax:
MATRIX ::= [PRIVATE 3] IMPLICIT SEQUENCE {
rows IMPLICIT USINT,
cols IMPLICIT USINT,
IMPLICIT SEQUENCE OF IMPLICIT REAL}
The encoding of MATRIX elements is constructed
in the sense of ISO/IEC 8825, with the following extensions to
the COMPACT encoding described in Annex E of IEC
61499-1:
-
rowsandcols, representing the number of rows and columns in the matrix respectively, are encoded as values of theUSINTtype without identifier or length octets, i.e., as two successive 8-bit unsigned integers.-
This restricts the maximum number of elements of a
MATRIXto 65025 (255×255). -
If the matrix data is to be transferred via
PUBLISH/SUBSCRIBE, the maximum number of elements is further restricted by the maximum number of octets (1472) that can be transferred in a single UDP packet without segmentation; otherwise, anOVERFLOWerror will be declared by the corresponding FB instance. -
Since the encoding of a
REALvalue requires 32 bits (4 octets), the maximum number of elements in aMATRIXinstance to be transmitted viaPUBLISH/SUBSCRIBEwould then be (maximum octets - tag octets - length octets)/(element length) = (1472-1-2)/4 = 367 elements. For instance, a square matrix with 19 rows and columns, containing 361 elements, would fit in a UDP packet. -
MATRIXdata larger than the allowed UDP transfer should be transferred using theCLIENT/SERVERmechanism.
-
This restricts the maximum number of elements of a
-
The matrix contents are encoded using the COMPACT syntax for an
ARRAY of IEC 61131-3
REALvalues, without any tag or length subfields. -
Data is encoded in column order; for instance, the matrix
0.0 0.0 0.0 1.0 2.0 0.0 3.0 4.0 5.0
would be encoded in the order
(0.0,1.0,3.0,0.0,2.0,4.0,0.0,0.0,5.0)
For an example of the application of these encoding rules, see the CODEC_TEST2
system configuration.