FB_CMA_SourcePaired
This function block writes data from external PLC data buffers to a pair of MultiArray buffers.
It accumulates input data continuously, until the maximum size of the multi-array is reached. When these are completely filled, it is transferred to the target analysis ID.
Synchronization of the data The assignment of the data from the first stream to the second is direct, i.e. the first value from Stream A is related to the first value from Stream B. Measured data, e.g. position and vibration values must be synchronized in advance. |
An instance of FB_CMA_Source must not be used as target for any other analysis function block. It offers only source functionality.
A time series collection can be interrupted in the event of an error. Lost signal data can lead to an unexpected result of the analysis chain, depending on the configuration of the algorithms.
Inputs and outputs
The output buffers correspond to the following definition (Shape). The variable parameters are part of the function block input stInitPars
.
MultiArray in the | Element type | Dimensions | Dimensional variables |
---|---|---|---|
output stream A | eTypeCode |
|
|
output stream B | eTypeCode |
|
|
VAR_INPUT
stInitParsA : ST_MA_MultiArray_InitPars; // init parameters for first MultiArray
stInitParsB : ST_MA_MultiArray_InitPars; // init parameters for second MultiArray
nOwnID : UDINT; // ID for this FB instance
aDestIDs : ARRAY[1..cCMA_MaxDest] OF UDINT; // IDs of destinations for output
nResultBuffers : UDINT := 4; // number of MultiArrays which should be initialized for results (0 for no initialization)
tTransferTimeout : LTIME := LTIME#40US; // timeout checking off during access to inter-task FIFOs
END_VAR
Input parameters
The input parameters of this function block represent initialization parameters and must already be assigned in the declaration of the FB instance! (Alternatively: Init() method). They may only be assigned once. A change at runtime is not possible.
stInitParsA
: Function-block-specific structure of the initialization parameters of the type ST_MA_MultiArray_InitPars. MultiArray buffers are specified for the result buffers. These parameters must correlate to the above definition of the output buffers.stInitParsB
: Function-block-specific structure of the initialization parameters of the type ST_MA_MultiArray_InitPars. MultiArray buffers are specified for the result buffers. These parameters must correlate to the above definition of the output buffers.nOwnID
: Identifies the function block instance with a unique ID. This must always be greater than zero. A proven approach is to define an enumeration for this purpose.aDestIDs
: Defines the destinations to which the results are to be forwarded by specifying the IDs of the destinations. The definition of the output buffer (as described above) must correlate to the definition of the input buffer of each selected destination.nResultBuffers
: The function block initializes a Transfer Tray Stream with the specified number of MultiArray buffers. The default value is four.tTransferTimeout
: Setting of the synchronous timeout for internal MultiArray forwardings. See section Parallel processing.
Output parameters
VAR_OUTPUT
bError : BOOL; // TRUE if an error occurs. Reset by next method call.
hrErrorCode : HRESULT; // '< 0' = error; '> 0' = info; '0' = no error/info
ipErrorMessage : I_TcMessage := fbErrorMessage; // Shows detailed information about occurred errors, warnings and more.
nCntResults : ULINT; // Counts outgoing results (MultiArrays were calculated and sent to transfer tray).
END_VAR
-
bError
: The output isTRUE
if an error occurs. -
hrErrorCode
: If an error occurs, a corresponding error code of the typeHRESULT
is output. Possible values are described in the List of error codes. -
ipErrorMessage
: Contains more detailed information on the current return value. Refer here to the section Error description and information. This special interface pointer is internally secured so that it is always valid/assigned.
Properties
The following properties can optionally be used to specify the timestamp of the input values associated with the next input call. If the properties are not set, a current timestamp and a typical time difference between two input values are automatically determined internally.
At FB_CMA_Sink, the timespan and time stamp of the input values of the analysis chain are assigned to the result of the analysis.
Name | Type | Access | Description |
---|---|---|---|
nTimestamp | ULINT | Set | Specification of the timestamp associated with the oldest value, which is transferred with the next input call. |
tSamplePeriod | LTIME | Set | Specification of the time difference between two input values. |
Methods
Input1D():
Writes data from external one-dimensional data buffers to a pair of MultiArrays. This method must be called whenever new input samples are available, usually cyclically.
- Return value: If an error occurs, a corresponding error code of the type
HRESULT
is output. Possible values are described in the List of error codes.
METHOD Input1D : HRESULT
VAR_INPUT
pDataInA : POINTER TO BYTE; // address of data buffer (e.g. oversampling data) as one-dimensional array
nDataInSizeA : UDINT; // size of data buffer in bytes
pDataInB : POINTER TO BYTE; // address of data buffer (e.g. oversampling data) as one-dimensional array
nDataInSizeB : UDINT; // size of data buffer in bytes
eElementTypeA : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
eElementTypeB : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
nWorkDimA : UDINT; // It designates the dimension in the first multi array being processed.
nWorkDimB : UDINT; // It designates the dimension in the second multi array being processed.
pStartIndexA : POINTER TO UDINT; (* optional: default:0->internally handled; It designates the index of the first MultiArray element to be copied.
If allocated it must point to a onedimensional array of UDINT with so many elements as dimensions of the MultiArray.
Upon successful completion of the copy, corresponding StartIndex is incremented by the number of copied elements. *)
pStartIndexB : POINTER TO UDINT; // see pStartIndexA
nOptionPars : DWORD; // option mask
END_VAR
VAR_OUTPUT
bNewResult : BOOL; // TRUE every time when outgoing MultiArray was calculated and sent to transfer tray.
bError : BOOL; // TRUE if an error occurs.
hrErrorCode : HRESULT; // '< 0' = error; '> 0' = info; '0' = no error/info
END_VAR
pDataInA
,pDataInB
: The data buffer must contain the data from all channels.eElementTypeA
,eElementTypeB
: This input is of the type E_MA_ElementTypeCode. The element type of the specified MultiArray buffer (initialization parameters) must match the element type of the specified external data buffer.nWorkDimA
,nWorkDimB
: Defines the dimension in which the data are accumulated. In general the MultiArray is also one-dimensional andnWorkDimA := 0
ornWorkDimB := 0
, but the MultiArray can also have additional dimensions, which may not then be processed, however.pStartIndexA
,pStartIndexB
: This is an optional parameter, which can be useful if the MultiArray has more than one dimension. Specifies the index of the first MultiArray element to be copied. If assigned, it must point to a one-dimensional array ofUDINT
that has as many elements as the MultiArray has dimensions. After a successful copy process, the corresponding Start Index is incremented by the number of copied elements.bError
: This output isTRUE
if an error occurs.hrErrorCode
: If an error occurs, then a descriptive error code of the type HRESULT is displayed. Possible values are defined in the List of error codes. This output is identical to the return value of the method.
Input1DStd():
Writes data from external one-dimensional data buffers to a pair of MultiArrays. This method must be called whenever new input samples are available, usually cyclically.
This method uses default values for the parameters nWorkDimA := 0
, nWorkDimB := 0
and pStartIndexA := 0
, pStartIndexB := 0
.
- Return value: If an error occurs, a corresponding error code of the type
HRESULT
is output. Possible values are described in the List of error codes.
METHOD Input1DStd : HRESULT
VAR_INPUT
pDataInA : POINTER TO BYTE; // address of data buffer (e.g. oversampling data) as one-dimensional array
nDataInSizeA : UDINT; // size of data buffer in bytes
pDataInB : POINTER TO BYTE; // address of data buffer (e.g. oversampling data) as one-dimensional array
nDataInSizeB : UDINT; // size of data buffer in bytes
eElementTypeA : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
eElementTypeB : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
nOptionPars : DWORD; // option mask
END_VAR
VAR_OUTPUT
bNewResult : BOOL; // TRUE every time when outgoing MultiArray was calculated and sent to transfer tray.
bError : BOOL; // TRUE if an error occurs.
hrErrorCode : HRESULT; // '< 0' = error; '> 0' = info; '0' = no error/info
END_VAR
pDataInA
,pDataInB
: The data buffer must contain the data from all channels.eElementTypeA
,eElementTypeB
: This input is of the type E_MA_ElementTypeCode. The element type of the specified MultiArray buffer (initialization parameters) must match the element type of the specified external data buffer.bError
: This output isTRUE
if an error occurs.hrErrorCode
: If an error occurs, then a descriptive error code of the type HRESULT is displayed. Possible values are defined in the List of error codes. This output is identical to the return value of the method.
Input2D():
Writes data from external two-dimensional data buffers to a pair of MultiArrays. This method must be called whenever new input samples are available, usually cyclically.
- Return value: If an error occurs, a corresponding error code of the type
HRESULT
is output. Possible values are described in the List of error codes.
METHOD Input2D : HRESULT
VAR_INPUT
pDataInA : POINTER TO BYTE; // address of data buffer (e.g. oversampling data) as one-dimensional array
nDataInSizeA : UDINT; // size of data buffer in bytes
pDataInB : POINTER TO BYTE; // address of data buffer (e.g. oversampling data) as one-dimensional array
nDataInSizeB : UDINT; // size of data buffer in bytes
eElementTypeA : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
eElementTypeB : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
nWorkDimA0 : UDINT; // It designates the first dimension in the first multi array being processed.
nWorkDimA1 : UDINT; // It designates the second dimension in the first multi array being processed.
nWorkDimB0 : UDINT; // It designates the first dimension in the second multi array being processed.
nWorkDimB1 : UDINT; // It designates the second dimension in the second multi array being processed.
pStartIndexA : POINTER TO UDINT; (* optional: default:0->internally handled; It designates the index of the first MultiArray element to be copied.
If allocated it must point to a onedimensional array of UDINT with so many elements as dimensions of the MultiArray.
Upon successful completion of the copy, corresponding StartIndex is incremented by the number of copied elements. *)
pStartIndexB : POINTER TO UDINT; // see pStartIndexA
nOptionPars : DWORD; // option mask
END_VAR
VAR_OUTPUT
bNewResult : BOOL; // TRUE every time when outgoing MultiArray was calculated and sent to transfer tray.
bError : BOOL; // TRUE if an error occurs.
hrErrorCode : HRESULT; // '< 0' = error; '> 0' = info; '0' = no error/info
END_VAR
pDataInA
,pDataInB
: The data buffer must contain the data from all channels.eElementTypeA
,eElementTypeB
: This input is of the type E_MA_ElementTypeCode. The element type of the specified MultiArray buffer (initialization parameters) must match the element type of the specified external data buffer.nWorkDimA0
,nWorkDimB0
: Defines the dimension that matches the number of channels. In general, the MultiArray is also two-dimensional andnWorkDimA0 := 0
ornWorkDimB0 := 0,
but the MultiArray can also have additional dimensions, which may then not be processed.
E.g: If the first index of the specified data buffer stands for the channels, but the second dimension of the MultiArray enumerates the channels, then setnWorkDimA0 := 1
ornWorkDimB0 := 1
.nWorkDimA1
,nWorkDimB1
: Defines the dimension in which the data are accumulated. In general, the MultiArray is also two-dimensional andnWorkDimA1 := 1
ornWorkDimB1 := 1
, but the MultiArray can also have additional dimensions, which may then not be processed.
E.g: If the second index of the specified data buffer stands for the collected data, but the first dimension of the MultiArray collects the data, then setnWorkDimB1 := 0
ornWorkDimB1 := 0
.pStartIndexA
,pStartIndexB
: This is an optional parameter, which can be useful if the MultiArray has more than one dimension. Specifies the index of the first MultiArray element to be copied. If assigned, it must point to a one-dimensional array ofUDINT
that has as many elements as the MultiArray has dimensions. After a successful copy process, the corresponding Start Index is incremented by the number of copied elements.bError
: This output isTRUE
if an error occurs.hrErrorCode
: If an error occurs, then a descriptive error code of the type HRESULT is displayed. Possible values are defined in the List of error codes. This output is identical to the return value of the method.
Input2DStd():
Writes data from external two-dimensional data buffers to a pair of MultiArrays. This method must be called whenever new input samples are available, usually cyclically.
This method uses default values for the parameters nWorkDimA0 := 0
, nWorkDimA1 := 1
, nWorkDimB0 := 0
, nWorkDimB1 := 1
and pStartIndexA := 0
, pStartIndexB := 0
.
- Return value: If an error occurs, a corresponding error code of the type
HRESULT
is output. Possible values are described in the List of error codes.
METHOD Input2D : HRESULT
VAR_INPUT
pDataInA : POINTER TO BYTE; // address of data buffer (e.g. oversampling data) as one-dimensional array
nDataInSizeA : UDINT; // size of data buffer in bytes
pDataInB : POINTER TO BYTE; // address of data buffer (e.g. oversampling data) as one-dimensional array
nDataInSizeB : UDINT; // size of data buffer in bytes
eElementTypeA : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
eElementTypeB : E_MA_ElementTypeCode; // valid types: LREAL, INT32, UINT64, LCOMPLEX
nOptionPars : DWORD; // option mask
END_VAR
VAR_OUTPUT
bNewResult : BOOL; // TRUE every time when outgoing MultiArray was calculated and sent to transfer tray.
bError : BOOL; // TRUE if an error occurs.
hrErrorCode : HRESULT; // '< 0' = error; '> 0' = info; '0' = no error/info
END_VAR
pDataInA
,pDataInB
: The data buffer must contain the data from all channels.eElementTypeA
,eElementTypeB
: This input is of the type E_MA_ElementTypeCode. The element type of the specified MultiArray buffer (initialization parameters) must match the element type of the specified external data buffer.bError
: This output isTRUE
if an error occurs.hrErrorCode
: If an error occurs, then a descriptive error code of the type HRESULT is displayed. Possible values are defined in the List of error codes. This output is identical to the return value of the method.
METHOD Init : HRESULT
VAR_INPUT
stInitParsA : ST_MA_MultiArray_InitPars; // init parameters for first MultiArray
stInitParsB : ST_MA_MultiArray_InitPars; // init parameters for second MultiArray
nOwnID : UDINT; // ID for this FB instance
aDestIDs : ARRAY[1..cCMA_MaxDest] OF UDINT; // IDs of destinations for output
nResultBuffers : UDINT := 4; // number of MultiArrays which should be initialized for results (0 for no initialization)
END_VAR
Init():
This method is not usually necessary in a Condition Monitoring application. It offers an alternative to the function block initialization. The Init()
method may only be called during the initialization phase of the PLC. It cannot be used at runtime. You are referred to the use of an FB_init
method or the attribute 'call_after_init'
(see TwinCAT PLC reference). In addition, this facilitates the function block encapsulation.
The input parameters of the function block instance may not be assigned in the declaration if the initialization is to take place using the Init() method.
- Return value: If an error occurs, a corresponding error code of the type
HRESULT
is output. Possible values are described in the List of error codes.
stInitParsA
: Function-block-specific structure of the initialization parameters of the type ST_MA_MultiArray_InitPars. MultiArray buffers are specified for the result buffers. These parameters must correlate to the above definition of the output buffers.stInitParsB
: Function-block-specific structure of the initialization parameters of the type ST_MA_MultiArray_InitPars. MultiArray buffers are specified for the result buffers. These parameters must correlate to the above definition of the output buffers.nOwnID
: Identifies the function block instance with a unique ID. This must always be greater than zero. A proven approach is to define an enumeration for this purpose.aDestIDs
: Defines the destinations to which the results are to be forwarded by specifying the IDs of the destinations. The definition of the output buffer (as described above) must correlate to the definition of the input buffer of each selected destination.nResultBuffers
: The function block initializes a Transfer Tray Stream with the specified number of MultiArray buffers. The default value is four.
ResetData():
The method deletes all data sets that have already been added so that the current output buffer (MultiArray) can be filled from the start again. If external indices are to be used when filling (pStartIndex
parameter), they must be explicitly reset.
- Return value: If an error occurs, a corresponding error code of the type
HRESULT
is output. Possible values are described in the List of error codes.
METHOD ResetData : HRESULT
VAR_INPUT
END_VAR
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.4022.25 | PC or CX (x86, x64) | Tc3_CM, Tc3_CM_Base, Tc3_MultiArray |