The VTSDriver API

The VTSDriver module is supplied with VTScada. It includes the generic driver interface for VTScada and is used in combination with each device-specific communication driver.

 

Several of the functions in VTSDriver are called directly from I/O tags. For example, AddRead is called by an input or status tag to request that data be sent from the driver. AddRead will call VTSRead in the device-specific communication driver to do the actual work according to the particular device’s requirements.

Note that you cannot call VTSDriver\PollAll() directly after calling AddRead(). AddRead takes a non-zero time to start, but PollAll synchronously triggers all current reads. The solution is to wait for VTSDriver\RefreshReady to become TRUE after calling AddRead. VTSDriver\RefreshReady is FALSE when read modules are being changed (in flux), and TRUE after they have stabilized on their new state. AddRead and DelRead set it FALSE, and it is then set TRUE again after the Read modules are up and running.

For a driver that saves its values on a comm failure, VTSDriver relies on that driver having a local variable or parameter named "Hold", set to TRUE if driver is holding its values.

VTSDriver and multi-server applications

If you are running a multi-server application, note the following details:

  • The subroutines VTSRead and Write will not run on client workstations.
  • I/O addresses that are configured only on a client workstation will not be read. They must be committed to the server before they will be used.
  • Data blocks are synchronized on startup.
  • Switching can occur on RecommendAlternate to provide for soft fail-overs.
  • Drivers sharing the same serial port must be in the same RPC service. The RPCService variable sets the service name for a driver instance.

 

Started

A flag to let you know that RPC is ready.

RPCStatus

Provides the client/server state.

AddRead

A subroutine called by I/O tags to request a read from the communication driver. Does not force a read to occur immediately.

Parameters:

Address
The address from which to get the data.
N
The number of elements to get
Value
Either a pointer to the destination for the data or an object value if VTSDriver will call Value\NewData when data changes.
Rate
The data update period, measured in seconds.

NewData

Typically called from within an I/O tag when RefreshData is called and before the data is returned. NewData will only be called when there is new data available - including invalids.

Parameters:

Address
From the original AddRead
Time
StampIn seconds, UTC
Data
The new data - either a single value or an array of values.
Attribute
Data attributes. Single value or array, matching Data.

DelRead

A module that must be called when the address changes.

Read

A module that performs a one-shot read, the data from which will be sent only to the calling server.

Write

The main subroutine used to request a write to the communication driver.

AddWrite

Obsolete. Was used to request a write to the communication driver.

PollAll

Forces all pending reads to occur immediately. This subroutine, which includes feedback, is especially useful with radio links where reads must occur when the link is established.

CoalesceRPC

Obsolete. Do not use in new code. Remove from code being upgraded to the current version of VTScada.