cwrite

cwrite — creates a point and writes information to it.

Syntax

(cwrite name type value conf sec locked seconds nanoseconds [flags quality])
    

Arguments

name

The name of the point. This is a string.

type

The type of point. One of

    0 = string

    1 = float (8-byte double)

    2 = integer (32-bit integer)

value

A string representation of the value for the point. It will be interpreted into the type specified by the type parameter.

conf

A confidence factor in the range of 0 to 100. This is not used by the DataHub, so is available to programs that produce graduated confidence, such as expert systems.

sec

A security level for this point. This is rarely used. If a point's security level is set to a non-zero value then attempts to write to that point must claim a security level equal to or greater than the security level of the point. This uses a "good citizen" model - the writer can claim any security it wants, and is assumed to be honest - so there is no strong security here. It is intended for systems that want to avoid accidental changes to values. Security level can be from 0 to 32767.

locked

An indication that the point is locked, and cannot be changed. Can be 0 or 1. Attempts to write to a locked point will fail.

seconds

The UNIX epoch - seconds since Jan. 1, 1970, as produced by the time() function.

nanoseconds

The number of nanoseconds inside this second. Cannot exceed 1,000,000,000.

flags

User level code should always send a 0 for this value.

quality

A quality indicator consistent with the OPC DA specification. This is not a bit field. It can be one of:

PT_QUALITY_BAD0
PT_QUALITY_UNCERTAIN0x40
PT_QUALITY_GOOD0xc0
PT_QUALITY_CONFIG_ERROR0x04
PT_QUALITY_NOT_CONNECTED0x08
PT_QUALITY_DEVICE_FAILURE0x0c
PT_QUALITY_SENSOR_FAILURE0x10
PT_QUALITY_LAST_KNOWN0x14
PT_QUALITY_COMM_FAILURE0x18
PT_QUALITY_OUT_OF_SERVICE0x1c
PT_QUALITY_WAITING_FOR_INITIAL_DATA0x20
PT_QUALITY_LAST_USABLE0x44
PT_QUALITY_SENSOR_CAL0x50
PT_QUALITY_EGU_EXCEEDED0x54
PT_QUALITY_SUB_NORMAL0x58
PT_QUALITY_LOCAL_OVERRIDE0xd8

All strings can be surrounded by double-quotes if the string contains spaces or special characters. The backslash character (\) escapes double quotes and backslashes within the string. Newline, carriage return, form feed and tab are represented with \n, \r, \f, \t respectively. Strings must not contain newline characters.

Returns

A message indicating success or error. Please refer to Return Syntax for details.

Description

This command lets you manually write information to a point. If the point does not exist, the point is automatically created and the value is written. This command is identical to the write command, except that write will produce an error if the point does not exist.