dpCreate()

Creates a datapoint.

Synopsis

int dpCreate(string dpname, string dptype [, int sysnum, unsigned dpNo]]);

Parameters

Parameter Meaning
dpname Name of the datapoint to be created
dptype Type of datapoint to be created
sysnum When creating a datapoint on a remote system in a distributed system, this parameter must contain the system number.
dpNo The ID of the datapoint. If a datapoint with the given ID already exists, a random ID is chosen.

Return Value

dpCreate() returns 0 on success and -1 on failure. In some cases the function returns 0 (success) but due to e.g.: name clashes the DP could not be created. This can be queried using getLastError().

Errors

Errors can be retrieved with getLastError(). This includes incorrect or missing arguments.

Description

The function dpCreate() create s a datapoint with the name dpname of the datapoint type dptype. The specified datapoint type must already exist. If a datapoint with the specified name already exists, the call of the function dpCreate() has no effect. dpCreate() is a waiting function, it waits until the DP has been created.

Refer to nameCheck() for not permitted characters in datapoint names.

Example

Creating the datapoint number_1 of the datapoint type ExampleDP_Int. If the data point already exists, a message is issued. Furthermore a datapoint named TestDP of the datapoint type PUMP1 is created on the system with number 2.

main()
{
  if (dpExists("number_1")) DebugN("already exists");
  else dpCreate("number_1","ExampleDP_Int"); // Create
  dpCreate("TestDP", "PUMP1", 2); /*Create DP on the system with
  number 2*/
}

Assignment

Datapoint function, Waiting Control function

Availability

UI, CTRL