CSV File Tag

Introduction

The CSV File Tag Register Block Icon represents a comma separated variables (CSV) file that the driver reads and extracts values from. The CSV File driver supports write operations using a CSV Update File:

CSV File Operation

CSV is not a formal standard. The Internet Engineering Task Force (IETF) has published memo RFC 4180, which describes the format and layout of CSV files.

The driver supports CSV files conforming to RFC 4180.

Configuration Properties

The CSV File Tag supports the configuration properties of the Core Tag plus these properties:

Property Type Version Description
ReadInterval TIME 1.6 The interval between each read. An interval value of zero (T#0s) disables periodic query execution. See Interval and Offset for information on how timed activities are scheduled.
ReadOffset TIME 1.6 The offset added to the ReadInterval to get the actual read time. See Interval and Offset for information on how timed activities are scheduled.
FileName WSTRING 1.6 The name of the CSV file to read.
RetryAttempts UINT 1.6 The maximum number of consecutive file open failures before a file access attempt is considered failed.
RetryInterval TIME 1.6 The interval between consecutive file open attempts.
AlarmSeverity UINT 1.6 The severity of the alarm raised when all attempts to read the CSV file have failed.
UpdateFileName WSTRING 1.6 The name of the optional CSV update file. Write requests to tags are appended to this file. If write operations are not required, this field can be left blank.

UpdateFileName

The CSV File driver can support write operations using a CSV update file. When a write request is made on a tag, a new line is appended to the CSV update file. The format of the new line is:

TagName=Value

The tag name is taken from the WriteTagName property of the tag. To complete the write request, an external program should periodically read and delete the CSV update file.

RetryAttempts & RetryInterval

The driver expects the CSV File and CSV Update File will be occasionally inaccessible because an external program is accessing these file(s). To avoid false alarms, the CSV File driver will try up to RetryAttempts to open the external file before reporting an error. The delay between retry attempts is configured by the RetryInterval property.

If the driver can not read the CSV File after using all of the retry attempts, an alarm will be raised. If the driver can not access the CSV Update File after using all of the retry attempts, the write request(s) will be failed.

When Fernhill SCADA reads the CSV file it will be temporarily locked to prevent updates. Any external program generating the CSV file should be written to handle the CSV file being locked.

Dynamic Properties

The CSV File supports the dynamic properties of the Alarm Tag, plus these additional dynamic properties:

Property Type Description
FileState UINT A code indicating the state of the external CSV File. The value 15 shows the CSV file was successfully read. Other values indicate an error. The ErrorMessage property may give additional information.
ErrorMessage WSTRING An error message providing additional information.
ReadTimer TimerStatus The status of the read timer.

The FileState property can be used to diagnose problems with the CSV file:

ServerStateDescription
0Initial state before the driver has started
1The driver was unable to open the CSV File
15The CSV file was successfully read

Tag Commands

The CSV File supports the tag commands of the Alarm Tag plus these tag commands:

Tag Command Version Description
Refresh 1.6 Requests an immediate read of all of the tags associated with this CSV File.

Note: Event triggered data reads (from the Refresh tag command) and periodic data reads (defined by the ReadInterval property) are independent. You can use the Refresh tag command, or the ReadInterval property, or both to determine when the tags are read.

Relationships to Other Tag Types

The CSV File Tag builds on the features of these tag types:

Further Information

Interval and Offset

To learn how activities are scheduled using Interval and Offset.

IO Analog Data Tag

To learn about the IO Analog Data Tag that can be associated with the CSV File.

IO Digital Data Tag

To learn about the IO Digital Data Tag that can be associated with the CSV File.

IO String Data Tag

To learn about the IO String Data Tag that can be associated with the CSV File.

IO Word Data Tag

To learn about the IO Word Data Tag that can be associated with the CSV File.

IO Double Word Data Tag

To learn about the IO Double Word Data Tag that can be associated with the CSV File.

CSV File Driver

For an overview of the CSV File Driver.

Glossary

For the meaning of terms used in Fernhill SCADA.