SQL Logger Group Tags

Not counted towards your tag license limit.

SQL Logging will record, in an ODBC-compatible database, the values from any tag that could normally be logged.

The SQL Logger Group tag type works in combination with the SQL Logger tag. You use the SQL Logger Group tag to define a database and the frequency of data logging for all the SQL Logger tags associated with it. The SQL Logger tag is used to select which values are to be logged to that database. You may link one or more SQL Logger tags to one SQL Logger Group, recording one or more values into a single database.

Before You Begin:

Before you can log values to a database, you will need to have 1) a database containing two tables created using the template in the VTScada examples folder, and 2) an ODBC DSN configured for your database.

  1. Setting up a database:

You can use any ODBC compatible database such as MS-Access, MS-SQL, MySQL, Oracle, etc. Instructions for how to install and configure a database program are beyond the scope of this documentation.

After you have created a database, you will need two tables within it to hold the data that VTScada will export. In the Example folder under VTScada (normally found as C:\VTScada\Examples) there are four files to help you with this task.

  • SQLLoggerAccess.mdb
  • SQLLoggerMySQL.SQL
  • SQLLoggerOracle.SQL
  • SQLLoggerSQLServer.SQL

The three files which end with the extension ".SQL", contain SQL commands to create the tables you will need in your database.

If you do not have a database and do not own a database program, you can still use this feature of VTScada by following these steps:

  1. From the examples folder of VTScada, copy the file named SQLLoggerAccess.mdb to your application folder.
  2. Rename it to match the data you plan to collect, being sure to keep the .MDB extension on the name

You are now ready to proceed.

  1. Configure an ODBC data source name (DSN)

This is created using the Windows™ Open Data Base Connectivity (ODBC) tool. A 64-bit version of this utility can be found in the Administrative Tools section the Windows™ configuration menu. A 32-bit version is available as "C:\Windows\Syswow64\odbcad32.exe". Instructions for using the Microsoft utility are beyond the scope of this topic.

This must be done on all potential servers for a networked VTScada application. The DSN must be identical on each machine.

SQL Logger Group properties Settings tab

The Settings tab holds the properties required to connect this tag to a database.

Database DSN

As described in the introduction to this topic, you must create and configure a database before using the SQL Logger Group tag.

The DSN (Data Source Name) must already exist on your system and be pointing to the database you created for this tag.

Database Type

Tell VTScada what type of database you are writing to.

CAUTION: The Database Type selection MUST match your database. Choosing an incompatible type will result in the tag failing to write values to your database due to differences in data format.

Auto Delete Records Older Than (Days)

Limit the size of the database by automatically deleting records older than (n) days.

You may choose to set this value to 0 to turn off the auto-delete feature.

Username, Password

The Username and Password fields should match whatever is required to connect to your database. If you are using MS Access and did not configure a user name and password, then you may leave these fields blank.

Due to the method by which the password is encrypted, it is not possible configure it using a parameter expression.

Tag ID Table Name, Tag Data Table Name

The two table name fields should not be changed under ordinary circumstances. The database configuration utility supplied with VTScada created these table names for you by default. (see SQL Logger Group Tag: Before you begin)

SQL Logger Group properties Log Settings tab

Contains options to configure the timing for when data will be written to the database.

There are three choices of Log Type: Interval, Triggered and On Data Change. Note that all the tags attached to a particular SQL Logger Group through the associated SQL Logger tags will use these settings.

Log Type

  • "Interval" - Record values every (n) seconds. Use this when you want continuous monitoring of the system, setting the interval to the number of seconds you want between each data output.
  • "Triggered" - Write values only when some condition changes. The write could be triggered by a tag changing value, or you can create an expression to define precise conditions that will cause a value to be written. Note that the trigger does not need to be activated by the same tag whose value you are recording. You could potentially record the level of a holding tank every time a pump switches on or off.

When logging is to be triggered, you must also choose what the trigger will be. For testing purposes you can choose Constant, setting the value to 1 or 0. You can also write an expression that will evaluate to TRUE or FALSE (1 or 0), or you can select a tag that will have a value of 1 or 0.

Trigger On

If you have chosen Triggered as the Log Type, you also have the choice of whether the trigger happens on a Value Change, a Rising Edge (from FALSE to TRUE) or a Falling Edge (from TRUE to FALSE. This applies to Constants, Expressions and Tags.

Log Type: On Data Change

This option for log triggering passes more control over to the Logger tags attached to this Logger Group. Essentially, you are indicating that log values are to be written when the value of the tag you are monitoring changes. See the section on the SQL Logger tags for more information.

If using this log type, please read the following section: Log Invalids for an important note.

Log Invalids

You have the option of whether to record "invalids" as part of the data being written. An invalid data value is essentially a NULL.

Note that if you select On Data Change as your trigger and you have not chosen to log invalids, then if the data changes from a valid value to invalid (or vice versa), no value will be written. You must enable Log Invalids to capture these data changes.

Enable

Where triggering controls the timing of data output, Enable sets whether data is to be output at all. Where the two controls offer the same options of "Constant", "Expression" and "Tag", the difference may seem subtle, but it is fundamentally different. Enabling the logger group means that logging is switched on or off. Triggering means that (if logging is enabled) data values are written when the trigger signals them to be.

If a SQL Logger Group is disabled, then all the SQL Logger tags attached to that group are automatically disabled.

Use Coordinated Universal Time (UTC)

A switch giving you the option to record the time stamp using either local time or UTC.

SQL Logger Group properties SQL Logger tab

Each Logger Group Tag must have one or more SQL Logger tags contributing data to it before it will be useful. As noted, the SQL Logger Group Tag creates a link to a database and sets a frequency of logging - it does not actually select what data is being logged. That job is assigned to the SQL Logger tag as described in the following section.