DNP3 Driver:  Write Function

Description:           This function writes data to an outstation, and returns an indication of success or failure

Format:                 DNP\Write (Trig, DType, DevAddr, Object, Variation, PointAddr, ExtraInfo, ArrData, ArrStart, ArrLength)

Parameters:          Trig  Trigger to write data from device.

                             DType  Data type < 100 – Parameter, >= 100 – Array.

                             DevAddr  Device address to write data from.

                             Object  DNP Object.  See section on supported DNP objects.

                             Variation  DNP Variation.  See section on supported DNP objects.

                             PointAddr  Point address in device to write from.

                             ExtraInfo  Output type, set to 2 for a latch point, set to 3 for a pulse point.  All other values specify a Trip/Close point.  Used for object 12, Control relay Output Block only.

                             ArrData  Array containing data to write (Type>=100 only).

                             ArrStart  Starting index in ArrData (Type>=100 only).

                             ArrLength  Number of values to Write (Type>=100 only).

Comments:

This function will attempt to write the specified objects to the specified device.  For object 12, Control Relay Output Block, the ExtraInfo parameter specifies the output type.  If ExtraInfo is 2, the point is a latch output and the Code field in the control relay output block will be 4 (latch off) or 3 (latch on) for a value of 0 or 1 respectively and the Ontime and OffTime fields will be 0.  If ExtraInfo is 3 the point is a pulse output and the Code field in the output block will be 1 (pulse off) or 2 (pulse on) for a value <= 0 or > 0 respectively, the Ontime field will be Int(Abs(value)) and the OffTime field will be Frac(Abs(value)) * 1000.  If the ExtraInfo parameter is not 2 or 3, the Code field will be 1, the Trip/Close parameter will be 2 or 1 for a value <= 0 or > 0 respectively, the OnTime field will be Abs(value) with 0 being replaced with 1 and the OffTime field will be 0.

The return value is an error code having one of the following meanings:

 

Value

Meaning

0

No Error

257

Serial Port Parameter(s) Out Of Range

258

Serial Port Not Active

259

Serial Port Failed to Connect

260

Serial Port Disconnected

261

Serial Port Already In Use

287

Serial Port General Failure

343

Serial Port Invalid Parameter

512

Data Link - Invalid Command

513

Data Link - Timed Out Waiting For Echo

514

Data Link - No Reply

515

Data Link - No Acknowledge

516

Data Link Reset - No Acknowledge

768

Station address out of range

769

Object type or variation out of range

771

Point address out of range

772

Data type out of range

773

Invalid parameters

774

RTU - Function code not implemented

775

RTU - Requested objects unknown

776

RTU - Request parameters out of range

777

RTU - Event buffers overflow

778

RTU - Requested operation pending

779

RTU - Configuration corrupt

 

This function may not appear in a script.

 

The object value of a DNP Write statement can be used to provide information about how that read is running by accessing public variables.  These public variables are:

 

Variable

Meaning

Counts

the number of successful communications since starting.

TimeStamp

the time of the last successful communication, in seconds since midnight.

DateStamp

the date of the last successful communication, in days since January 1 1970.

Error

the error code number of the current communication attempt

ErrorCounts

the number of errors encountered since starting.

ErrorDate

the date of the last error encountered in any communication attempt, in days since January 1 1970.

ErrorTime

the time of the last error encountered in any communication attempt, in seconds since midnight.

ErrorStation

is the address of the station which encountered the most recent error.

ErrorPointAddr

is the point address of the point causing the last error

ErrorOwner

is an object variable which holds the object value of the read or write statement which encountered the most recent error.

LastError

the error code number of the last error encountered by any communication attempt.

dT

the time difference between the last two good messages.

InIIN

the value of the Internal Indications field in the last message received.