m4MLogicReadVariableBySymbolData
Logic-Function: Read data from a single symbolic variable.
Description
This function reads data from a single symbolic variable and returns it as predefined data type. This function supports code generation.
The function reads data from a single symbolic variable. The IEC data type of the variable can be BOOL, BYTE, WORD, DWORD, SINT, INT, DINT, USINT, UINT, UDINT, REAL, LREAL, STRING, TIME, DATE, TIME_OF_DAY, DATE_AND_TIME and ENUM. The dimension can be a scalar, a 1D, a 2D or a 3D array.
According to the IEC data types the input argument data must be predefined with a MATLAB data type. The function handles data types logical, uint8, int8, uint16, int16, uint32, int32, single, double and char. Variables of type STRING must be predefined as 1xL char array. If an empty string is read from the target all characters will be set to char(0).
The correspondance table for IEC data types and MATLAB data types can be found in the introduction section. Another correspondance table for mlpiCore data types and MATLAB data types can be found in the type definition of MlpiType.
In order to define the data type and size of the output argument data it has to be predefined prior to calling the function. Refer to the sample file for details.
Caution: The function performs a dimension and type check between symbolic variable and input argument data except for char arrays if it is used in MATLAB. If code is generated from this function the code does not perform a dimension nor a type check for performance reasons.
The symbolic variables must be available in the 'symbol configuration' of the PLC.
Syntax
[data] = m4MLogicReadVariableBySymbolData(connection,...
varSymbol, data)
[data, result] = m4MLogicReadVariableBySymbolData(connection,...
varSymbol, data)
Input Arguments
connection defines the connection that will be used. The argument must be scalar and of type MlpiConnection.
varSymbol specifies the complete instance path of a single symbolic variables. The argument must be a 1xL char array.
data specifies the dimension and type of output argument data. The input argument will be filled by the function with values read from the symbolic variable. The argument can be of type logical, uint8, int8, uint16, int16, uint32, int32, single, double or char.
The argument can have the following dimensions for native data types of the symbolic variable:
- scalar: if the symbolic variable is scalar.
- 1xL char array: if the symbolic variable is a string.
- Mx1 matrix: if the symbolic variable is a 1-dimensional array.
- MxN matrix: if the symbolic variable is a 2-dimensional array.
- MxNxK matrix: if the symbolic is a 3-dimensional array.
K, M, and N must be smaller than M4M_CONST.MEX_ARRAY_ELEMENTS_MAX+1. The maximum number of elements is M4M_CONST.MEX_ARRAY_ELEMENTS_MAX.
Some data types available in the PLC environment are not available as native data types in MATLAB. The following data types can be predefined to read the PLC data types:
- uint32 to read TIME. The value is the time in milliseconds.
- uint32 to read DATE. The value is the time in seconds beginning with January 1, 1970 at 12:00 a.m. (00:00 a.m.).
- uint32 to read DATEANDTIME. The value is the time in seconds beginning with January 1, 1970 at 12:00 a.m. (00:00 a.m.).
- uint32 to read TIMEOFDAY. The value is the time in milliseconds, time begins at 12:00 a.m. (00:00 a.m.).
- int16 to read an ENUM value.
Non-native IEC data types are not supported by this function.
Output Arguments
data contains the data read from the symbolic variable. The type and the dimension of the argument is equal to the input argument data. The values of the input argument will be overwritten.
result contains the return value of the MLPI function. The argument is scalar and of type int32. Negative values indicate a failed function call. If the function call fails, other output arguments will be set to NaN. For details refer to the section Error Identification and Handling in Fundamentals of MLPI Programming.
Example Files
Here you will find instructions to use the examples.
The following example is available in the folder ./mlpi/mlpi4MATLAB/bin:
See also
Reference to mlpiCore
This function maps to the mlpiCore function: mlpiLogicReadVariableBySymbol
Copyright
Legal notice and version: © 2017 Bosch Rexroth Corporation http://www.boschrexroth.com DC-AE/EAS1 (MGo) Library version: 1.26.2.0.0