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:

  1. Event occurs that signals the archive
  2. Disconnect from the file
  3. Wait for confirmation that the file is closed
  4. Copy file to network drive or removable media
  5. Wait for confirmation that file copied
  6. Reconnect to file
  7.  Let's take a look at the tasks and tags required for each step of this process.
    1. The event used to start the archive is usually an event trigger, such as midnight. Do not trigger any complex events exactly at midnight.  This will cause a lot of special things to happen at that moment. Setup any midnight events to trigger 15-30 seconds after midnight to avoid the other events.
    2. To disconnect from the file, you must define a tag in the Disable/enable Database Connection column of the Historian Information for the dBase IV table. If you are going to archive multiple database aliases, use the same digital tag for all of them.
    3. The Connection Status of the database can also found in the Historian Information table. Define a different analog tag for each database alias being archived.
    4. Although IML/CML can copy files using system commands, it is more efficient to use File Manager. File Manager will copy the files and allow IML/CML to continue running during the archive. The default domain for File Manager is the user domain, but if you are using WebClient, you will be running multiple copies of the FLFM task. For this type of archival functionality, consider configuring FLFM for both the shared and user domains and archive in the shared domain. Configure a copy command trigger, source and destination information for the files to be archived.
    5. Be sure to include an analog status tag and completion tag for the FLFM copy command in order to monitor the copy command for completion.
    6. We will write to the tag defined in #2 to reconnect.

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.