ParaLib 2.0.28-master SHA: b4a0dafd73
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
(RestoreDefaultFunction*)SetToDefaultFunction_STD_F32, // SetToDefaultFunction
//-----------------------------
DEFAULT_BACKUP_LOCATION, // Store Location
FLAG_NONE, //Flags
"", //Substitution Texts
};
RestoreDefaultFunction_F32 SetToDefaultFunction_STD_F32
Definition: PARA_Lib.h:1201
WriteFunction_F32 WriteFunction_STD_F32
Definition: PARA_Lib.h:1188
#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:151
ReadFunction_F32 ReadFunction_STD_F32
Definition: PARA_Lib.h:1176
@ PROFESSIONAL_WRITE
Definition: PARA_Lib.h:846
@ PROFESSIONAL_READ
Definition: PARA_Lib.h:845
@ USER_READ
Definition: PARA_Lib.h:843
@ DEVELOPER_WRITE
Definition: PARA_Lib.h:848
@ VIEWER_READ
Definition: PARA_Lib.h:841
@ DEVELOPER_READ
Definition: PARA_Lib.h:847
@ FLAG_NONE
No special flags.
Definition: PARA_Lib.h:909
@ TYPE_float
Definition: SYS_Type.h:83
Parameter-data structure for float (32-Bit)
Definition: PARA_Lib.h:1061
Parameter definition (datatype independent).

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"