Updating via the Data Server InterfaceΒΆ

If data source items are to be updated that do not belong to the currently active visualization, you must use the data server interface functions. These functions are provided by the DataServer library and you can call them via the object g_DataServer. In order to save transmission capacity, you can also configure a variable in this way so that the data server only updates it over a defined time period.

Example

The following code shows an example of how you can activate (and deactivate) a variable ivar using the g_DataServer methods so that the DataServer transfers its value:

g_DataServer.BeginDataConfiguration(TRUE);  //Synchronizing with the DataServerTask; Blocking until access is possible;
//regard the feedback in ERR_OK resp. in ERR_DE_MULTITASKING_LOCKED
g_DataServer.UseData(ADR('OtherDevice.Application.PLC_PRG.iVar')); // Activating variable
//g_DataServer.ReleaseData(ADR('OtherDevice.Application.PLC_PRG.iVar')); // Deactivating variable
g_DataServer.EndDataConfiguration();

Start the data configuration with BeginDataConfiguration (TRUE). This initiates the synchronization of the DataServer task with the application task. With TRUE you can block the execution until access to the variable becomes possible. With FALSE you enable repetitive access attempts without blocking. The return values ERR_OK or ERR_DS_MULTITASKING_LOCKED provide an appropriate feedback to these attempts.

After successful synchronization, activate the variable with the help of the UseData method. After that, close the data configuration with the EndDataConfiguration method, i.e. the synchronization of the DataServer task is released again.

In the same way you can use the ReleaseData method in order to deactivate the variable again at the desired execution time.