Engineering Tip
Many companies want to archive information to either a backup storage device or to the network where others can look at the same data. If you are using DB4HIST for your historian, the procedure for archiving the files is not as easy as just copying the file. The complexity comes from the fact that the DB4 Historian keeps the files open all the time for read/write performance.
The pseudo code for this functionality is as follows:
If you are logging large amounts of data each time the log is triggered, you may want to suspend logging during this period to prevent filling up the logger-historian mailbox. Alarms usually do not produce enough data during this process to fill up the mailbox thus the mailbox acts as a queue until the historian connection is re-established.
This example FLECS 6.5.0 application archives the alarm log to the c:\temp directory at midnight.
You will want to look in the following tables found in the shared domain:
System Configuration
Added FLFM to this domain for archival functions.
Event Timer
Defined Midnight trigger tag. Note that the time is not quite midnight allowing for the archive file names to have the proper date (see flfm configuration).
File Manager
The copy command is configured here. The source is a variable and is setup in IML. Note that the destination is Month/Day stamped so that a different file is created each day and that the destination changes the file name to .dbf so that other programs know the dBase file type.
Historian for dBase IV
Tags for connection disable/enable as well as connection status are defined for each of the databases being archived.
Math and Logic
There are two procedures defined. The main procedure runs every second and contains complex triggering for other procedures as well as special event handling. The archive procedure manages all of the archive events and is setup as a state machine using a public variable. This math is very efficient and allows the other math procedures to run during the archiving process.
View the math procedures comments regarding the logic and program flow. Note: This procedure does not check the file copy status because if the source file does not exist, it never ends. This procedure assumes that the file copies correctly. Additional logic can be added to check file copy status and retry until successful, but this may be dangerous and take a long time to complete.