User Documentation

Table Of Contents
Data recorder
System manual
2696790000/02/04.2020
88
Special case in the change-based recording mode with a monitored variable:
The mere number of calls from by DataRecApiSampleValues is not a part of
the number of recordings to be stored, since not every call needs to be
stored. Instead, only the actual recording calls of the function are those
which count. In the remaining modes, by contrast, the pure calls to DataRe-
cApiSampleValues do count.
In the course of the registration, the DataRecApiAddVar registration function
determines the locality of a variable. This information is made available to
the user by means of the DataRecApiGetFirstVar, DataRecApiGet-
NextVar and DataRecApiGetVars query functions and can be used for in-
spection purposes. The delivered isLocal flag indicates whether the vari-
able is process-local, and as such, that it can be sampled real-time capable.
Settings carried out using DataRecApiSetSampleHook are not permanent
(code addresses depend on start-up), but rather must be newly carried out in
the course of every start-up of the application (before the recording start).
14.7.1 Profile with manual recording
The following example shows the easiest application: The application regis-
ters two variables with a variable server via MemApi and registers their paths
at a profile with the Continuous buffer type and a capacity of 1000 samples
an.
The recording is started in the start function, while it is stopped again in the
stop function. The ModuleCallback application function is called up in one-
second intervals and logs the variables by means of a call by DataRe-
cApiSampleValues.
It is not necessary to explicitly delete the profile in the exit function, since all
remaining profiles are deleted after all applications are exited. Persistent
data is not affected by this deletion.
void ModuleInit() {
DataRecApiInfo info;
DataRecApiResult rc;
char varPath[80];
LogApiAddId(traceid, "TestRec");
LogApiTrace(traceid, "TestDataRecApp initialized");
MemApiInit();
MemApiAddVar(scVarNameTemp, MemApiSInt32, &sTemp, sizeof sTemp);
MemApiAddVar(scVarNamePres, MemApiReal, &sPres, sizeof sPres);
sTemp = 0;
sPres = 0.0;
strcpy(info.name, scProfileName);
info.size = 1000; /* space for 1000 samples */
info.maxVarCnt = 5; /* max. 5 variables per sample */
info.bufType = DataRecApiBufTypeContinuous; /* ring buffer type */
info.level = DataRecApiLevelApplRt; /* (unsupported yet) */
info.autoStart = 0; /* application starts recording */
rc = DataRecApiCreateProfile(&info, &sP1Id);
ReturnIfNot(rc == DataRecApiResultOk && sP1Id != DataRecApiNoId);
snprintf(varPath, sizeof varPath, "APPL.MEM.%s", scVarNameTemp);
rc = DataRecApiAddVar(sP1Id, varPath, 0, &sTempId);
ReturnIfNot(rc == DataRecApiResultOk && sTempId != DataRecApiNoId);
snprintf(varPath, sizeof varPath, "APPL.MEM.%s", scVarNamePres);
rc = DataRecApiAddVar(sP1Id, varPath, 0, &sPresId);
ReturnIfNot(rc == DataRecApiResultOk && sPresId != DataRecApiNoId);
}
/