Open Core Interface - MLPI
MLPI-MotionLogicProgrammingInterface(mlpiCore)  1.26.2
UtilParameterHelper
Collaboration diagram for UtilParameterHelper:

Classes

class  MlpiReadEverythingDataAccess
 

Functions

MlpiType utilParameterGetDataTypeFromAttribute (const ULONG attribute)
 
BOOL8 utilParameterGetProcedureCmdFromAttribute (const ULONG attribute)
 
SHORT utilParameterGetDecimalPointFromAttribute (const ULONG attribute)
 
ParamWriteProtection utilParameterGetWriteProtectionFromAttribute (const ULONG attribute)
 
MLPIRESULT utilParameterParseIdn (const WCHAR16 *idn, ULONG *address, ULLONG *type, ULLONG *set, ULLONG *block, ULLONG *si, ULLONG *se, WCHAR16 **idnNxt=NULL)
 
MLPIRESULT utilParameterParseIdn (const WCHAR16 *idnString, ULLONG *idnValue, ULONG *address=NULL)
 
MLPIRESULT utilParameterSplitSidn (const ULLONG sidn, ULLONG *idn, ULONG *address)
 
MLPIRESULT utilParameterSplitSidn (const ULLONG sidn, ULONG *address, ULONG *type, ULONG *block, ULONG *spFlag, ULONG *set, ULONG *si, ULONG *se)
 
WCHAR16utilParameterParseIdn (const ULLONG address, WCHAR16 *idnString, const ULONG numElements)
 
MLPIRESULT utilParameterParseSercosTimeToString (const ULLONG timeStamp, CHAR *time, const ULONG numElements, ULONG *numElementsRet=NULL)
 
MLPIRESULT utilParameterParseSercosTimeToString (const ULLONG timeStamp, WCHAR16 *time, const ULONG numElements, ULONG *numElementsRet=NULL)
 
MLPIRESULT utilParameterParseStringToSercosTime (const CHAR *time, const CHAR separator, ULLONG *timeStamp, CHAR **timeNext=NULL)
 
MLPIRESULT utilParameterParseStringToSercosTime (const WCHAR16 *time, const WCHAR16 separator, ULLONG *timeStamp, WCHAR16 **timeNext=NULL)
 

Detailed Description

This module contains some useful functions and macros for parameter handling.

Please note that this piece of source code is not directly part of the MLPI. You do not need this file to program against the MLPI. Nevertheless, at least parts of this file have been considered to be somewhat useful when using or learning to use MLPI functionality. It is therefore included without any support, but to act as sample code and source of inspiration.


Class Documentation

class MlpiReadEverythingDataAccess

This class helps to access the data read via the 'mlpiParameterReadEverything' function.

Example:
See mlpiParameterReadEverything

Definition at line 1289 of file mlpiParameterHelper.h.

Collaboration diagram for MlpiReadEverythingDataAccess:
Collaboration graph

Function Documentation

MlpiType utilParameterGetDataTypeFromAttribute ( const ULONG  attribute)
inline

This Function extracts the data type which is coded in Sercos attribute and translates it the an MLPI data type of the enum MlpiType.

Parameters
[in]attributeSercos attribute
Returns
If succeeded, returns the type. Otherwise MLPI_TYPE_UNKNOWN is returned.

In most cases, it's too difficult to know the correct data type for a parameter request. This function can help. It takes the original attribute of a parameter and converts it to a type you can use for a parameter request.

Example:
1 ULONG sercosAttribute;
2 ULONG readCount;
3 
4 // read original sercos attribute
5 mlpiParameterReadAttribute(connection, 1, MLPI_SIDN_O(4), &sercosAttribute);
6 
7 // extract MLPI data type information
8 mlpiType dataType = utilParameterGetDataTypeFromAttribute(sercosAttribute)
9 
10 // read data using the correct function
11 switch(dataType)
12 {
13  case MLPI_TYPE_CHAR_UTF8:
14  case MLPI_TYPE_CHAR_UTF16:
15  mlpiParameterReadDataString(connection, 1, MLPI_SIDN_O(4), strValue, _countof(strValue), &readCount);
16  break;
17  case MLPI_TYPE_UCHAR:
18  mlpiParameterReadDataUchar(connection, 1, MLPI_SIDN_O(4), &cValue);
19  break;
20  case MLPI_TYPE_USHORT:
21  mlpiParameterReadDataUshort(connection, 1, MLPI_SIDN_O(4), &usValue);
22  break;
23  case MLPI_TYPE_SHORT:
24  mlpiParameterReadDataShort(connection, 1, MLPI_SIDN_O(4), &sValue);
25  break;
26  case MLPI_TYPE_ULONG:
27  mlpiParameterReadDataUlong(connection, 1, MLPI_SIDN_O(4), &ulValue);
28  break;
29  case MLPI_TYPE_LONG:
30  mlpiParameterReadDataLong(connection, 1, MLPI_SIDN_O(4), &lValue);
31  break;
32  case MLPI_TYPE_ULLONG:
33  mlpiParameterReadDataUllong(connection, 1, MLPI_SIDN_O(4), &ullValue);
34  break;
35  case MLPI_TYPE_LLONG:
36  mlpiParameterReadDataLlong(connection, 1, MLPI_SIDN_O(4), &llValue);
37  break;
38  case MLPI_TYPE_FLOAT:
39  mlpiParameterReadDataFloat(connection, 1, MLPI_SIDN_O(4), &fValue);
40  break;
41  case MLPI_TYPE_DOUBLE:
42  mlpiParameterReadDataDouble(connection, 1, MLPI_SIDN_O(4), &dValue);
43  break;
44  case MLPI_TYPE_UCHAR_ARRAY:
45  mlpiParameterReadDataUcharArray(connection, 1, MLPI_SIDN_O(4), acValue, _countof(acValue), &readCount);
46  break;
47  case MLPI_TYPE_USHORT_ARRAY:
48  mlpiParameterReadDataUshortArray(connection, 1, MLPI_SIDN_O(4), ausValue, _countof(ausValue), &readCount);
49  break;
50  case MLPI_TYPE_SHORT_ARRAY:
51  mlpiParameterReadDataShortArray(connection, 1, MLPI_SIDN_O(4), asValue, _countof(asValue), &readCount);
52  break;
53  case MLPI_TYPE_ULONG_ARRAY:
54  mlpiParameterReadDataUlongArray(connection, 1, MLPI_SIDN_O(4), aulValue, _countof(aulValue), &readCount);
55  break;
56  case MLPI_TYPE_LONG_ARRAY:
57  mlpiParameterReadDataLongArray(connection, 1, MLPI_SIDN_O(4), alValue, _countof(alValue), &readCount);
58  break;
59  case MLPI_TYPE_ULLONG_ARRAY:
60  mlpiParameterReadDataUllongArray(connection, 1, MLPI_SIDN_O(4), aullValue, _countof(aullValue), &readCount);
61  break;
62  case MLPI_TYPE_LLONG_ARRAY:
63  mlpiParameterReadDataLlongArray(connection, 1, MLPI_SIDN_O(4), allValue, _countof(allValue), &readCount);
64  break;
65  case MLPI_TYPE_FLOAT_ARRAY:
66  mlpiParameterReadDataFloatArray(connection, 1, MLPI_SIDN_O(4), afValue, _countof(afValue), &readCount);
67  break;
68  case MLPI_TYPE_DOUBLE_ARRAY:
69  mlpiParameterReadDataDoubleArray(connection, 1, MLPI_SIDN_O(4), adValue, _countof(adValue), &readCount);
70  break;
71  default:
72  // unknown or invalid data type...
73  break;
74 }

Definition at line 400 of file mlpiParameterHelper.h.

References MLPI_TYPE_CHAR, MLPI_TYPE_CHAR_UTF16, MLPI_TYPE_DOUBLE, MLPI_TYPE_DOUBLE_ARRAY, MLPI_TYPE_FLOAT, MLPI_TYPE_FLOAT_ARRAY, MLPI_TYPE_INVALID, MLPI_TYPE_LLONG, MLPI_TYPE_LLONG_ARRAY, MLPI_TYPE_LONG, MLPI_TYPE_LONG_ARRAY, MLPI_TYPE_SHORT, MLPI_TYPE_SHORT_ARRAY, MLPI_TYPE_UCHAR, MLPI_TYPE_UCHAR_ARRAY, MLPI_TYPE_ULLONG, MLPI_TYPE_ULLONG_ARRAY, MLPI_TYPE_ULONG, MLPI_TYPE_ULONG_ARRAY, MLPI_TYPE_USHORT, and MLPI_TYPE_USHORT_ARRAY.

BOOL8 utilParameterGetProcedureCmdFromAttribute ( const ULONG  attribute)
inline

This Function extracts the 'procedure command' property which is coded in Sercos attribute.

Parameters
[in]attributeSercos attribute.
Returns
0: Parameter is not a 'procedure command', 1: Parameter is a 'procedure command'.

Definition at line 463 of file mlpiParameterHelper.h.

SHORT utilParameterGetDecimalPointFromAttribute ( const ULONG  attribute)
inline

This Function extracts the places after decimal point which is coded in Sercos attribute.

Parameters
[in]attributeSercos attribute.
Returns
Places after decimal point.

Definition at line 478 of file mlpiParameterHelper.h.

ParamWriteProtection utilParameterGetWriteProtectionFromAttribute ( const ULONG  attribute)
inline

This Function extracts the write protection of a parameter in certain states which is coded in Sercos attribute.

Parameters
[in]attributeSercos attribute.
Returns
Returns the state in which a parameter is write protected.

Definition at line 507 of file mlpiParameterHelper.h.

MLPIRESULT utilParameterParseIdn ( const WCHAR16 idn,
ULONG address,
ULLONG type,
ULLONG set,
ULLONG block,
ULLONG si,
ULLONG se,
WCHAR16 **  idnNxt = NULL 
)
inline

This function parses a Sercos IDN string and returns its properties. These can be used to build a binary expression of the Sercos IDN.

Parameters
[in]idnString representation of a Sercos parameter IDN. For example "S-0-0051", "S-0-1050.0.1" or "P-100".
[out]addressPointer to a variable which receives the address.
[out]typePointer to a variable which receives the type.
[out]setPointer to a variable which receives the set element.
[out]blockPointer to a variable which receives the block.
[out]siPointer to a variable which receives the si element.
[out]sePointer to a variable which receives the se element.
[out]idnNxtPointer to the first character after parsed Sercos IDN string.
Returns
Return value indicating success (>=0) or error (<0).

Definition at line 542 of file mlpiParameterHelper.h.

References MLPI_E_INVALIDARG, MLPI_S_OK, MLPI_SIDN_TYPE_AXIS, MLPI_SIDN_TYPE_CONTROL, MLPI_SIDN_TYPE_DRIVE_P, MLPI_SIDN_TYPE_DRIVE_S, MLPI_SIDN_TYPE_KINEMATIC, MLPI_SIDN_TYPE_OSCILLOSCOPE, MLPI_SIDN_TYPE_POSLIMSWITCH, MLPI_SIDN_TYPE_PROBE, wcschr16(), wcslen16(), and wtoi16().

Referenced by utilParameterParseIdn().

Here is the call graph for this function:

Here is the caller graph for this function:

MLPIRESULT utilParameterParseIdn ( const WCHAR16 idnString,
ULLONG idnValue,
ULONG address = NULL 
)
inline

This function parses a Sercos IDN string and returns its binary expression.

Parameters
[in]idnStringString representation of a Sercos parameter IDN. For example, "S-0-0051", "S-0-1050.0.1" or "P-100".
[out]idnValuePointer to a variable which receives the binary expression of the given string. This can be used for subsequent calls to ParameterRead functions.
[out]addressPointer to a variable which receives the address.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 ULLONG ullIdn;
2 utilParameterParseIdn(L"C-0-0012", &ullIdn);
3 mlpiParameterReadData(1, ullIdn, szFirmware, _countof(szFirmware), 0);

Definition at line 684 of file mlpiParameterHelper.h.

References MLPI_SIDN, and utilParameterParseIdn().

Here is the call graph for this function:

MLPIRESULT utilParameterSplitSidn ( const ULLONG  sidn,
ULLONG idn,
ULONG address 
)
inline

Some SIDNs contain the address field in the upper byte of the reserved space. Use this function to cut out the address from the rest of the SIDN. See for example parameters like A-0-0002 or O-0-0003.

Parameters
[in]sidnSercos IDN, in format as from O-0-0003.
[out]idnPointer to a variable which receives the binary expression of the given SIDN. This can be used for subsequent calls to ParameterRead functions.
[out]addressPointer to a variable which receives the address.
Returns
Return value indicating success (>=0) or error (<0).

Definition at line 712 of file mlpiParameterHelper.h.

References MLPI_S_OK, MLPI_SIDN_BLOCK_MASK, MLPI_SIDN_SE_MASK, MLPI_SIDN_SET_MASK, MLPI_SIDN_SI_MASK, and MLPI_SIDN_TYPE_MASK.

Referenced by utilParameterParseIdn().

Here is the caller graph for this function:

MLPIRESULT utilParameterSplitSidn ( const ULLONG  sidn,
ULONG address,
ULONG type,
ULONG block,
ULONG spFlag,
ULONG set,
ULONG si,
ULONG se 
)
inline

This function splits a sercos SIDN and returns its properties. Some SIDNs contain the address field in the upper byte of the reserved space (see for example parameters such as A-0-0002 or O-0-0003). Use this function to cut out the address from the rest of the SIDN as well as all other elements within a SIDN.

Parameters
[in]sidnSIDN which should be split.
[out]addressPointer to a variable which receives the address.
[out]typePointer to a variable which receives the type.
[out]blockPointer to a variable which receives the block.
[out]spFlagPointer to a variable which receives the S or P flag.
[out]setPointer to a variable which receives the set element.
[out]siPointer to a variable which receives the si element.
[out]sePointer to a variable which receives the se element.
Returns
Return value indicating success (>=0) or error (<0).

Definition at line 749 of file mlpiParameterHelper.h.

References MLPI_S_OK.

WCHAR16* utilParameterParseIdn ( const ULLONG  address,
WCHAR16 idnString,
const ULONG  numElements 
)
inline

This function parses a address and returns a sercos IDN string.

Parameters
[in]address64 Bit value of an EIDN.
[out]idnStringPointer to a variable which receives the string. Use define PARAM_MAX_IDN_STRING_LENGTH for creation.
[in]numElementsNumber of WCHAR16 elements in 'idnString' available to read.
Returns
Pointer to 'idnString'.
Example:
1 WCHAR16 idnString[PARAM_MAX_IDN_STRING_LENGTH] = {L'0'};
2 printf("\nParameter %s", utilParameterParseIdn(MLPI_SIDN_C(400), idnString, _countof(idnString)));

Definition at line 796 of file mlpiParameterHelper.h.

References mbstowcs16(), MLPI_SIDN_TYPE_AXIS, MLPI_SIDN_TYPE_CONTROL, MLPI_SIDN_TYPE_DRIVE_S, MLPI_SIDN_TYPE_KINEMATIC, MLPI_SIDN_TYPE_OSCILLOSCOPE, MLPI_SIDN_TYPE_POSLIMSWITCH, MLPI_SIDN_TYPE_PROBE, PARAM_MAX_IDN_STRING_LENGTH, utilParameterSplitSidn(), wcscat16(), wcscpy16(), and wcslen16().

Here is the call graph for this function:

MLPIRESULT utilParameterParseSercosTimeToString ( const ULLONG  timeStamp,
CHAR time,
const ULONG  numElements,
ULONG numElementsRet = NULL 
)
inline

This function parse a 64-bit sercos time value and returns a sercos time string (CHAR). Structure of sercos time Bit 63-32: seconds since 1970-01-01, 00:00:00 Nit 31-00: nanoseconds up to 999.999.999.

Parameters
[in]timeStamp64-bit sercos time value.
[out]timePointer to a variable which receives the sercos time string (ISO-8601). Use define PARAM_SERCOS_TIME_STRING_LENGTH for creation.
[in]numElementsNumber of CHAR elements in 'time' available to write.
[in]numElementsRetNumber of CHAR elements in complete 'time'.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 ULLONG timeStamp = 0x50E227003B9AC9FF;
2 CHAR time[PARAM_SERCOS_TIME_STRING_LENGTH] = "";
3 ULONG numElementsRet = 0;
4 MLPIRESULT result = utilParameterParseSercosTimeToString(timeStamp, time, _countof(time), &numElementsRet);

Definition at line 901 of file mlpiParameterHelper.h.

References MLPI_E_BUFFERTOOSHORT, MLPI_E_INVALIDARG, MLPI_E_LIMIT_MAX, MLPI_E_UNIMPLEMENTED, MLPI_S_OK, and PARAM_SERCOS_TIME_STRING_LENGTH.

Referenced by utilParameterParseSercosTimeToString().

Here is the caller graph for this function:

MLPIRESULT utilParameterParseSercosTimeToString ( const ULLONG  timeStamp,
WCHAR16 time,
const ULONG  numElements,
ULONG numElementsRet = NULL 
)
inline

This function parse a 64-bit sercos time value and returns a sercos time string (CHAR). Structure of sercos time Bit 63-32: seconds since 1970-01-01, 00:00:00 Nit 31-00: nanoseconds up to 999.999.999.

Parameters
[in]timeStamp64-bit sercos time value.
[out]timePointer to a variable which receives the sercos time string (ISO-8601). Use define PARAM_SERCOS_TIME_STRING_LENGTH for creation.
[in]numElementsNumber of WCHAR16 elements in 'time' available to write.
[in]numElementsRetNumber of WCHAR16 elements in complete 'time'.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 ULLONG timeStamp = 0x50E227003B9AC9FF;
2 CHAR time[PARAM_SERCOS_TIME_STRING_LENGTH] = "";
3 ULONG numElementsRet = 0;
4 MLPIRESULT result = utilParameterParseSercosTimeToString(timeStamp, time, _countof(time), &numElementsRet);

Definition at line 976 of file mlpiParameterHelper.h.

References mbstowcs16(), MLPI_S_OK, PARAM_SERCOS_TIME_STRING_LENGTH, and utilParameterParseSercosTimeToString().

Here is the call graph for this function:

MLPIRESULT utilParameterParseStringToSercosTime ( const CHAR time,
const CHAR  separator,
ULLONG timeStamp,
CHAR **  timeNext = NULL 
)
inline

This function parse a sercos time string (CHAR) and returns a 64-bit sercos time value. Structure of sercos time Bit 63-32: seconds since 1970-01-01, 00:00:00 Nit 31-00: nanoseconds up to 999.999.999.

Parameters
[in]timePointer to a variable which contains at least one sercos time string (ISO-8601).
[in]separatorSeparator between two or more sercos time strings. Use space character at default.
[out]timeStamp64-bit sercos time value.
[out]timeNextPointer next sercos time string.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 CHAR time[] = L"2000-01-01T23:55:00.123456789Z 2100-12-24T20:00:00.999999999Z 2007-08-14T12:00:00Z";
2 CHAR separator = ' ';
3 ULLONG timeStamp = 0;
4 CHAR *timeNext = NULL;
5 MLPIRESULT result = utilParameterParseStringToSercosTime(time, separator, &timeStamp, &timeNext );

Definition at line 1012 of file mlpiParameterHelper.h.

References MLPI_E_INVALIDARG, MLPI_E_UNIMPLEMENTED, MLPI_S_OK, MLPI_SUCCEEDED, and PARAM_SERCOS_TIME_STRING_LENGTH.

Referenced by utilParameterParseStringToSercosTime().

Here is the caller graph for this function:

MLPIRESULT utilParameterParseStringToSercosTime ( const WCHAR16 time,
const WCHAR16  separator,
ULLONG timeStamp,
WCHAR16 **  timeNext = NULL 
)
inline

This function parse a sercos time string (WCHAR16) and returns a 64-bit sercos time value. Structure of sercos time Bit 63-32: seconds since 1970-01-01, 00:00:00 Nit 31-00: nanoseconds up to 999.999.999.

Parameters
[in]timePointer to a variable which contains at least one sercos time string (ISO-8601).
[in]separatorSeparator between two or more sercos time strings. Use space character at default.
[out]timeStamp64-bit sercos time value.
[out]timeNextPointer next sercos time string.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 WCHAR16 time[] = L"2000-01-01T23:55:00.123456789Z 2100-12-24T20:00:00.999999999Z 2007-08-14T12:00:00Z";
2 WCHAR16 separator = " ";
3 ULLONG timeStamp = 0;
4 WCHAR16 *timeNext = NULL;
5 MLPIRESULT result = utilParameterParseStringToSercosTime(time, separator, &timeStamp, &timeNext );

Definition at line 1242 of file mlpiParameterHelper.h.

References MLPI_E_INVALIDARG, MLPI_S_OK, MLPI_SUCCEEDED, PARAM_SERCOS_TIME_STRING_LENGTH, and utilParameterParseStringToSercosTime().

Here is the call graph for this function: