TSignalRecorder, palette SmartSCADA System, unit SignalRecorder.pas

 

  Component inherited from TTable. It saves analog signals values to database. It cerates historian trend. Additional properties of this component are:

- Automatic table creating if it not exists. Field structure corresponds to signals names (signal property name).

- Fixed table size

 

IMPORTANT!

 

Component automatically creates FloatTable.db in folder defined by alias PROCESS. It is assumed that system uses only alias PROCESS. That means that other aliases are not allowed! Putting this component on the form, component automatically creates alias if it does not exists. Path to alias is set to working folder of project in design time. If alias exists, component change path to working folder of project.

If path of PROCESS alias is changed after exiting from Delphi workspace, after Delphi reloading path will not be changed to project working directory.

This problem can be solved on two ways>

- Using DataBaseDesktop program set path before start,

- By putting new SignalRecorder component, which will automatically change the path.

 

To change alias on start of application, put routine from module TsAliasUtils in project *.dpr file:

SetAlias('PROCESS', DataDir)

o   first parameter is name of existing alias

o   second parameter is desired directory. If this parameter is empty string then path set to project working directory.

 

To check consistency of database, put routine from module TsAliasUtils in project *.dpr file:

ReindexTables('PROCESS')

o   parameter is existing alias.

This routine automatically reindexes all databases from alias and makes copies of all databases in BACKUP folder. If repairing is not possible, then over writes bed database with good one from BACKUP folder.

It is very important to disable this routine in design time because reindexing of tables requires exclusive mode of operation so there is a possibility for error in database access. This specially relates to those tables that are open in design time.

If it is necessary to use this routine in design time, then it is best to keep all tables closed and to open them in run time or to keep modules with these tables closed while reindexing.

 

Component automatically creates fields with selected signals names.

 

PROPERTIES

 

EnabledMaxNumRecords: Boolean

Determines if database will have fixed size or not.

 

MaxNumRecords: longint

Defines the size of database (number of records).

 

FillTable: boolean

When change this property in design time, database will be filled to defined size. After that, property is reset to false. This is introduced to escape fragmentation of database. Our experience shows that fragmented database file can dramatically slow down whole system and in extreme cases (big fragmented database file and short interval of saving data), system can be almost stopped. In such cases, windows almost all the time read and write from/to hard disk (database and virtual memory – page file).

 

Signals: TStrings read FSignals write SetSignals;

List of analog signals whose values to be saved in database. This property has its own editor:

 

Figure 18. Editor that enables TSignalRecorder linking with signals

WorkingDirectory: string

Read only property that shows path of Process alias.

 

EnableSavePeriod: boolean

Enables or disables data recording.

 

SavePeriod: string

Period of database writing. Set it in next format "00:01:00" that means recording will take place every minute. It cannot be less than 5 seconds (“00:00:05”).

 

Operator: Operator read TOperator write TOperator;

Pointer to TOperator component that hold data about logged o perator.

 

METHODS

Run; virtual;

Executes recording data to database. Never is called directly.