ParaLib 2.0.15-master SHA: 2e03d68caa
Definition of a parameter in source code

A parameter allows access to a global variable. It can be read or written on a per parameter defined Access restrictions. A parameter needs to be defined globally in a c-file.

Example of a simple parameter of the datatype float. It gives access to the global variable "g_fRatedSpeed". Allow reading by the users VIEWER, USER, and read/write by PROFESSIONAL and DEVELOPER. It can be changed between 0 and 5000.

&g_fRatedSpeed, // Pointer to the parameter variable
PARA_ID_IDM_RatedSpeed, // ParaID
GROUP_ID_Drive, // GroupID
// -----------------------------
"n_N", // Name
"Rated Speed", // Description
// ---- English Help: ----------
"Nominal speed.<br />"
"The nominal speed of the induction machine given by the machine type plate.",
// ---- German Help: -----------
"Nenndrehzahl<br />"
"Dieser Wert entspricht der Nenndrehzahl laut Typenschild der Asynchronmaschine.",
"{0}rpm", // Unit
// ---- Substitution Texts: ----
"",
// -----------------------------
1, // Count
0, // MinValue
5000, // MaxValue
0.0, // DefaultValue
// -----------------------------
ReadFunction_STD_F32, // OnReadFunction
WriteFunction_STD_F32, // OnWriteFunction
SetToDefaultFunction_STD_F32, // RestoreDefaultFunction
// ---- Access -----------------
DEFAULT_BACKUP_LOCATION, // Store Location
FLAG_NONE // Flags
)
const ParaData_F32 ParaData_fRatedSpeed =
{
&g_fRatedSpeed, // Pointer to Parametervariable
0, // Backup
0, // MinValue
5000, // MaxValue
0.0 // DefaultValue
};
//-----------------------------
const Parameter PARA_fRatedSpeed __attribute__((section("para_descriptor"))) =
{
GROUP_ID_Drive, // GroupID
PARA_ID_IDM_RatedSpeed, // ParaID
//-----------------------------
TYPE_float, // DataType
//-----------------------------
"n_N", // Name
"Rated Speed\
DOC_D Nenndrehzahl<br />\
Dieser Wert entspricht der Nenndrehzahl laut Typenschild der Asynchronmaschine.\
DOC_E Nominal speed.<br />\
The nominal speed of the induction machine given by the machine type plate.", // Description
"{0}rpm", // Unit
//-----------------------------
1, // Count
(void*)&ParaData_fRatedSpeed, // Data*
//-----------------------------
(ReadFunction*)ReadFunction_STD_F32, // OnReadFunction
(WriteFunction*)WriteFunction_STD_F32, // OnWriteFunction
//-----------------------------
DEFAULT_BACKUP_LOCATION, // Store Location
FLAG_NONE, //Flags
"", //Substitution Texts
};
int32_t WriteFunction_STD_F32(Parameter *ptThis, uint16_t ui16SubId, void *pData, int32_t ui32MaxCount, uint32_t ui32Offset, ParameterAccessSource tAccessSource, uint8_t ui8AccessLevel)
Default write-function for float (32-Bit) datatype.
Definition: PARA_Data.c:1529
int32_t SetToDefaultFunction_STD_F32(Parameter *ptThis, uint16_t ui16SubId, ParameterAccessSource tAccessSource, uint8_t ui8AccessLevel)
Default setToDefault-function for float (32-Bit) datatype.
Definition: PARA_Data.c:1557
int32_t ReadFunction_STD_F32(Parameter *ptThis, uint16_t ui16SubId, void *pData, int32_t ui32MaxCount, uint32_t ui32Offset, ParameterAccessSource tAccessSource, uint8_t ui8AccessLevel)
Default read-function for float (32-Bit) datatype.
Definition: PARA_Data.c:1504
int32_t WriteFunction(void *ptThis, uint16_t ui16SubId, void *pData, int32_t ui32MaxCount, uint32_t ui32Offset, ParameterAccessSource tAccessSource, uint8_t ui8AccessLevel)
Definition: PARA_Lib.h:856
int32_t RestoreDefaultFunction(void *ptThis, uint16_t ui16SubId, ParameterAccessSource tAccessSource, uint8_t ui8AccessLevel)
Definition: PARA_Lib.h:857
#define ParameterF32(VARIABLE_NAME, PARA_ID, GROUP_ID, NAME, UNIT, DESCRIPTION, HELP_EN, HELP_DE, SUBSTITUTION, COUNT, MIN, MAX, DEFAULT, ON_READ, ON_WRITE, SET_TO_DEFAULT, ACCESS, STORE_LOCATION, FLAGS)
Defines an 32 bit floating point parameter.
Definition: PARA_Lib.h:135
int32_t ReadFunction(void *ptThis, uint16_t ui16SubId, void *pData, int32_t ui32MaxCount, uint32_t ui32Offset, ParameterAccessSource tAccessSource, uint8_t ui8AccessLevel)
Definition: PARA_Lib.h:855
@ PROFESSIONAL_WRITE
Definition: PARA_Lib.h:797
@ PROFESSIONAL_READ
Definition: PARA_Lib.h:796
@ USER_READ
Definition: PARA_Lib.h:794
@ DEVELOPER_WRITE
Definition: PARA_Lib.h:799
@ VIEWER_READ
Definition: PARA_Lib.h:792
@ DEVELOPER_READ
Definition: PARA_Lib.h:798
@ FLAG_NONE
No special flags.
Definition: PARA_Lib.h:845
@ TYPE_float
Definition: SYS_Type.h:83
Parameter-data structure for float (32-Bit)
Definition: PARA_Lib.h:966
Parameter definition.
Definition: PARA_Lib.h:861

Every parameter consists of two structs:

  1. The ParaData structure is type-specific and holds all datatype related fields. For every usable datatype one structure is defined in the library:

    All datastructures contains of the following fields:

    • The type of the pointer to the data value must match the datastructure type.
    • The Backup-value is only neccessary for some storage drivers, normally it can be set to 0. See details on page Storage of parameter-values in a non volatile memory.
    • Minimum and maximum values are used by the pc-tool to check the limits of the parameter before writing.
    • The default-value is used to
      1. Reset the value manually if SetToDefault is selected in pc-tool
      2. initialize in case the readout of the non volatile parameter storage fails (see page Storage of parameter-values in a non volatile memory).
  2. The Parameter structure contains all metadata describing the parameter.

    The Parameter variable must be defined globally with a special attribute to direct this variable to a separated area by the linker. See details on page Neccessary Linker settings and initialization to get the parameter-interface working.

The header-file of the parameter interface library and the definition-file of the identifier have to be included:

#include "lib/PARA_Lib.h"
#include "PARA_ID_Device.h"