Driver Diagnostic tools

The VTScada driver contains two subroutines that you should use for diagnostics, ReportTraffic and SaveCommStats.

ReportTraffic

ReportTraffic allows the driver communications stream to be viewed or logged by viewer applications. The interface is accessed through the TMObj variable within the scope of the "Driver" object value. Traffic must be manually reported by the driver tag using this subroutine.

Usage:

Script Only.

Format:

Driver\TMObj\ReportTraffic(PortName, Direction, TrafficData);

Parameters:

PortName
This should be set to a text string identifying the port tag used by the driver.
Direction
Specifies the direction of the traffic (0 = Receive, 1 = Transmit).
Traffic
Data Text string used to display the actual contents of the communications data. This string will be displayed as is and should be formatted into a legible string before being passed to the ReportTraffic Module.

The "Active" flag located within the scope of TMObj indicates whether any listener applications are monitoring the driver. ReportTraffic should only be executed if the "Active" flag is set.

IfThen(Driver\TMObj\Active,
  Driver\TMObj\ReportTraffic(ExternalPort\Name, Direction, Data);
);

SaveCommStats

Use to log statistics about the status of the communications driver. The communications driver is responsible for calling this subroutine whenever a successful or a failed communications attempt has been detected. In other words, anytime the error value of the driver is set.

Usage:

Script Only.

Format:

Driver\SaveCommStats(ErrorValue[, ErrorAddress, ErrorAfterRetry, ResponseTime, CommStatsCallerInfo]);

Parameters:

ErrorValue
Required numeric. Set to the current numerical error value of the communications driver. A value of 0 indicates success.
ErrorAddress
Optional text. The memory address that caused the error to occur.
ErrorAfterRetry
Optional Boolean. A flag indicating whether the error, or the success, occurred on a retry. A value of 1 indicates this was a retry attempt, a value of 0 indicates this was the initial attempt. Defaults to 0.
ResponseTime
Optional numeric. Expressed in seconds, this parameter specifies the time it took the I/O device to receive a command, process it, and send a response. This should only be valid if the ErrorValueParm is 0, meaning a successful communication.
CommStatsCallerInfo
Optional text. Allows the I/O driver to pass a string that can be displayed in a real time Statistics viewer. This value is not logged, and will default to the module name of the SaveCommStats caller.

The ResponseTime is defined as the time it took the I/O device to receiver a command, process it, and return a response. The I/O driver is responsible for calculating the response time. It should be calculated using the following formula:

ResponseTime = EndTime - StartTime - XmitTime - RcvTime

Where XmitTime is the time it took to transmit any data and RcvTime is the time it took to receive the data based on the number of bytes sent, the baud rate, parity, stop bits, whether there is an echo expected and whether RTS key delays are used. It is the responsibility of the communications driver to calculate the ResponseTime.

Communications driver (driver tag) statistics variables are automatically synchronized between clients and servers of the I/O Driver service by the VTScada driver module. The communications driver is not responsible for this task.