writePoint

writePoint — writes a new value to a DataHub point.

Synopsis

For C++:
ST_STATUS writePoint(point,  
 create,  
 force); 
CDataHubPoint& point;
bool create=TRUE;
int force=FALSE;
 
ST_STATUS writePoint(pointname,  
 value,  
 create,  
 force); 
LPCTSTR pointname;
int value;
bool create=TRUE;
bool force=FALSE;
 
ST_STATUS writePoint(pointname,  
 value,  
 create,  
 force); 
LPCTSTR pointname;
double value;
bool create=TRUE;
bool force=FALSE;
 
ST_STATUS writePoint(pointname,  
 value,  
 create,  
 force); 
LPCTSTR pointname;
LPCTSTR value;
bool create=TRUE;
bool force=FALSE;
 
For Java:
Exception writePoint(point,  
 create,  
 force); 
DataHubPoint point;
boolean create;
boolean force;
 
Exception writePoint(pointname,  
 value,  
 create,  
 force); 
String pointname;
String value;
boolean create;
boolean force;
 
Exception writePoint(pointname,  
 value); 
String pointname;
String value;
 
Exception writePoint(pointname,  
 value,  
 create,  
 force); 
String pointname;
double value;
boolean create;
boolean force;
 
Exception writePoint(pointname,  
 value); 
String pointname;
double value;
 
Exception writePoint(pointname,  
 value,  
 create,  
 force); 
String pointname;
int value;
boolean create;
boolean force;
 
Exception writePoint(pointname,  
 value); 
String pointname;
int value;
 
Exception writePoint(pointname,  
 type,  
 value_as_string,  
 create,  
 force); 
String pointname;
int type;
String value_as_string;
boolean create;
boolean force;
 
For C#:
Exception writePoint(point,  
 create,  
 force); 
DataHubPoint point;
bool create;
bool force;
 
Exception writePoint(pointname,  
 value,  
 create,  
 force); 
String pointname;
String value;
bool create;
bool force;
 
Exception writePoint(pointname,  
 value); 
String pointname;
String value;
 
Exception writePoint(pointname,  
 value,  
 create,  
 force); 
String pointname;
double value;
bool create;
bool force;
 
Exception writePoint(pointname,  
 value); 
String pointname;
double value;
 
Exception writePoint(pointname,  
 value,  
 create,  
 force); 
String pointname;
int value;
bool create;
bool force;
 
Exception writePoint(pointname,  
 value); 
String pointname;
int value;
 
Exception writePoint(pointname,  
 type,  
 value_as_string,  
 create,  
 force); 
String pointname;
int type;
String value_as_string;
bool create;
bool force;
 

Parameters

point

A DataHubPoint object. The name, type, value, seconds and nanoseconds members must be valid.

create

If TRUE, then the point is created if it does not already exist. If FALSE and the point does not exist, then an error message will be generated.

force

If a valid connection to the DataHub instance exists but the message is undeliverable immediately (due to the TCP buffer being full), then if the force parameter is TRUE, the message is queued and will be transmitted when possible.

pointname

The name of the point. The point timestamp is automatically set to the current time.

value

The integer, double, or string value to write to the point. The type of the point in the DataHub instance will be changed accordingly.

Returns

For C++:
  • ST_OK if the command was successfully sent to the DataHub instance. Since the command is sent asynchronously, the actual success or failure of the command must be determined through the onSuccess or onError message handlers.

  • ST_NO_TASK if a connection to the DataHub instance does not exist.

  • ST_ERROR if the connection socket is unable to send the message.

Description

This method writes the given point to the DataHub instance. If a DataHubPoint is used, then the point name, type, value, quality and timestamp members must be set. If the point is specified by name, then the type is determined by the specific overloaded method and the timestamp is set to the current time.

If a domain name has been associated with the client (see setDefaultDomain), then the point will be written to that domain, otherwise it will be written to the domain named default. In any case, the domain can always be overridden by qualifying the point name as domain name:point name (see qualifyName).

If the point has been registered (see registerPoint), and the DataHub point is successfully written, then the onPointEcho method will be invoked.

If the create parameter is FALSE and the point does not exist, then the DataHub instance will respond with an error, and onError will be called with the following arguments:

status: ST_NO_POINT
msg: "Point does not exist"

Examples

CDataHubPoint point;
point.name = "point1";
point.type = PT_TYPE_REAL;
point.quality = PT_QUALITY_GOOD;
point.value = 123.456;
setPointTimeStamp(&point);
// point must exist or error is generated
writePoint(&point, FALSE);	
// write real-valued point, create if needed
writePoint(_T("point2"), 123.456);

See Also

readPoint