DB module. It provides the support of *.dbf files, version 3.0.
License:
GPL
Introduction
The module is designed to provide in the system OpenSCADA support of the type of database files *.dbf. The module is based on the library for work with dbf files for "Complex2" firm "DIYA" Ltd. The module allows you to perform operations on databases, tables and contents of tables.
1. Operations over the database
The operations of opening and closing of the database is supported, with the possibility of creating a new database when you open and delete existing at the close. In terms of the subsystem "DB" of system OpenSCADA opening of DB is its registration for further using of it in the system.
Under the DB, in the case of the dbf-files it is meant the directory containing the dbf-files. Therefore, operation of the creating and deleting of the database - creates and deletes the directory where the table (dbf-files) are stored. The role of the address of database plays the full name of the directory with dbf-files. Access to the database is defined by the system rights of access to the directory.
2. Operations over the table
The operations of opening and closing of the table with the possibility of creating a new table when you open and deleting the existing one at the closing are supported.
Actually dbf-file is the table. Creation and deletion of tables implies creation and deletion of dbf-file. Table name is the name of dbf-file in the directory of DB. Access to the table are define by the rights of access to dbf-file.
3. Operations over the contents of the table
Scanning of the records of the table;
Request the values of these records;
Setting the values of these records;
Removing the records.
API of subsystem “DB” suppose the access to the contents of the table on the value of key(s) fields. Thus, the operation of request of the record implies the preset of key columns of the object TConfig, which will fulfill the request. Creating a new record(string) is the installation of the values of record, which does not exist.
The module allows you to dynamically change the structure of the database tables DBF. Thus, in the event of a discrepancy of the table and the structure determined by record, the structure of the table will be reduced to the the required structure of record. In the case of the request of the value of the record, and mismatching of the structures of record and the table there will be available only to the values of common elements of the record and table. The module does not track the order of the elements in the record and in the structure of the table!
While access to the values of the tables the synchronization is used by through the capture of the resource to have access to the table. This avoids the destruction of data in the case of multi-access!
The types of the elements of dbf-file that correspond to types of elements of system OpenSCADA in the following way:
The types of fields of system OpenSCADA
Type of field of dbf-file
TFld::String
"C"
TFld::Integer, TFld::Real
"N"
TFld::Boolean
"L"
4. Productivity of DB
Measurement of productivity of DB were carried out by the test "DB" of the module of system tests "SystemTests", by performing operations over the records of the structure: <name char (20), descr char (50), val double (10.2), id int (7), stat bool, reqKey string, reqVal string>.