3.1 Format of the configuration file

The *.rio file is a text file, therefore it can be edited in any plain-text editor (e.g. Notepad). The structure is illustrated below:

ODBC {  
  Connection "DRIVER=MySQL;SERVER=192.168.1.200;PORT=3306;"  
"DATABASE=dbname;UID=dbuser;PWD=dbpassword;"  
  #Connection "DSN=mydatabase;"  
  Archive {  
   Mode      1  
   SQL       "alarm1"  
   ArchiveID 0  
   Items     0,104,114,1000  
  }  
  #Archive {  
   Mode      2  
   SQL       "trend1"  
   ArchiveID 0  
   Items     100,100  
  }  
  Archive {  
   Mode      3  
   SQL       "insert into trend1 (Time, GroupID, Value1, Value2, Value4)"  
"values(?T,?I,?1,?,?4)"  
   ArchiveID 0  
   Items     100,111  
  }  
  Group {  
   Mode      2  
   SQL       "test1"  
   Period    5  
   Items     "r1,i2,i3,r4"  
  }  
  Group {  
   Mode      130  
   SQL       "test2"  
   Period    60  
   Items     "d1,d2,i10,i11"  
  }  
  Group {  
   Mode      3  
   SQL       "select d1,d2,i10,i11, Time from test2 where Time < ? and "  
"StationID=000 order by Time desc,ID desc limit 2"  
   Period    5  
   Items     "gr1,gr2,gr3,gr4"  
  }  
  Group {  
   Mode      131  
   SQL       "insert into test2 (Time,StationID,d1,d2,i10,i11) values "  
"(UTC_TIMESTAMP(),2,?1,?,?,?)"  
   Period    10  
   Items     "gw1,gw2,gw3,gw4"  
  }  
}

The parameters whose name start with # are ignored and can be used for comments. Long lines (typically SQL queries) can be split among several lines as shown above. There can be no white-space characters at the beginning of consecutive lines. The Alarm section is repeated as necessary to define all the rules (filters) for exporting archives of the REX Control System. Similarly for reading and writing data directly from the algorithm the Group sections are used. All the parameter and section names are case sensitive.

The meaning of individual parameters follows:

Connection
– The so-called connection-string defining the database to connect to. A full connection-string with all the parameters can be used. Alternatively it is possible to define the connection by DSN (DataSourceName), which is defined within the ODBC interface and contains all the necessary information for the connection.
Mode
– Defines the structure of reading/writing from/to the database. The options are:

For the Archive section:

0

Nothing gets exported (used for disabling the item temporarily).

1

Only the alarms and events are exported (filtered by additional parameters). The table in the database must contain the following columns: Time, AlarmID, Code, Level, Value.

2

Only the trends are exported, i.e. the data stored by the TRND block. The data is filtered by additional parameters. The table in the database must contain the following columns: Time, GroupID, Value1, Value2, ...

3

Only the trends are exported, but on the contrary to the above the SQL parameter has the meaning of a full SQL query, to which the values are injected. The following placeholders can be used: ?T = time; ?I =itemID; ?1 =1st item; ?2 =2nd item; ... A plain question mark has the meaning of next item in the following order: 1st value, 2nd value, ...; )

For the Group section:

0

Nothing gets read (used for disabling the item temporarily).

1

It is assumed that the table is ordered by the ID column. The row with the highest ID is supplied to the corresponding input flags in the task. The columns and the items/flags must have the same name.

2

It is assumed that the table is ordered by the Time column (ID is the secondary key). The row with the highest time not placed in the future is selected and the resulting data is supplied to the corresponding input flags in the task. The columns and the items/flags must have the same name. This mode allows applying a pre-generated sequence of data.

3

The SQL query from the SQL parameter is executed, the inputs are updated by the first row of the response (1st column to the 1st item, ...). It is possible to use ?T in the SQL query, which gets replaced by the current time. It is also possible to use ?1 in the SQL query, which gets replaced by the value of 1st item, ?2 , which gets replaced by the value of 2st item,...

128

Nothing gets written (used for disabling the item temporarily).

129

The values from the corresponding flags in the tasks are written to the database. The columns and the items/flags must have the same name.

130

Similar to the above, only there is one more column named Time which contains the current time of the REX runtime core in UTC.

131

The SQL query from the SQL parameter is executed. The following placeholders can be used: ?T = time; ?I =itemID; ?1 =1st item; ?2 =2nd item; ... A plain question mark has the meaning of next item in the following order: 1st value, 2nd value, ...; )

SQL
– Table name or full SQL command as defined by the Mode parameter. In some cases the notation <database_name>.<table_name> must be used for referencing database tables.
ArchiveID
– Number of archive to read the data from. The archives are numbered from 1 in the order of appearance in the configuration of REX executive (ARCHIVE blocks connected to the EXEC block).
Period
– Period in seconds to generate the SQL query.
Items
– A list of items to read/write (in the Group section) or a range of IDs (the id parameter of the originating block) to export from archive to the database (in the Archive section). In the case of archives there must be even number of entries, where the odd entries define the start of an interval and the even entries define its end. Therefore e.g. "100,100,104,109" means IDs 100, 104, 105, …, 109. The entries must be sorted in ascending order.