Applies To:
  • CitectSCADA 3.30 4.10

Summary:
This is the trend history file format. This information supersedes Q1334 and is for versions 3.30 4.10 and greater. 

Solution:
The trend history system has a master file for each trend. This master file manages the trend history data files. When a history file is filled, data will be written to another trend data file (pointed to by the master file).

Master File structure

The master file has a header followed by an array of history file information. The history files are ordered in a such a way that the most recent one is at the top.

  • MASTERHDR
  • HISTFILE (most recent)
  • HISTFILE
  • HISTFILE

MASTERHDR structure

title 128 Title of the file (ASCII). It contains information, such as file version, type, start time and logging name.
ID 8 ID for Citect files. It is set to "CITECT".
type 2 Type of the Citect file. It is set to TREND.
version 2 Version number of the trends.
alignment 4 alignment for 16 bytes
Mode 4 Indicates the mode of the MASTER file. (For future use. Currently it is set to 0.)
History 2 Number of history files created for the logging.
nFiles 2 Number of history files created.
next 2 Next history file number. Internal use only, users MUST NOT use this entry to get the next history file.
AddOn 2 Shows the number of history files added onto the system through user functions. User can add old (backed up) history files to the system temporarily.
alignment 20 alignment for 16 bytes

HISTFILE structure

Name 144 History file name.
BinHdr 96 History file binary header. See HISTBINHDR structure.

HISTBINHDR structure

ID 8 ID for Citect files. It is set to "CITECT".
type 2 Type of the Citect file. It is set to TREND.
version 2 Version number of the trends.
StartEvNo 4 Starting Number for events in this history file. (Event Trends only.)
LogName 32 Name of the trend record hat owns the history file.
Mode 4 Indicates the mode of the history file. (For future use. Currently it is set to 0.)
Area 2 The area that has access to the acquired data.
Priv 2 The access rights required to execute the command.
FileType 2 History file type.
SamplePeriod 4 Sample period of logging.
sEngUnits 8 Units of scales. (Set to the units of the trend record.)
Format 4 Format of scales. (Set to the format of the trend record.)
StartTime 4 History file creation time.
EndTime 4 When the history file is created EndTime is set to ZERO. When the file becomes full the EndTime is set to the current time (to indicate that the file is no longer active).
DataLength 4 Shows the number of data items. DataLength = (File Size - HeaderSize) / 2
FilePointer 4 Points to the last data in the file.
EndEvNo 4 the history file is created EndEvNo is set to ZERO. When the file becomes full the EndEvNo is set to the current event number (to indicate that the file is no longer active). (Event trends only)
alignment 2 for 16 bytes

NOTE: You have to read the whole master file to determine the sequence of history files.

Trend Data File structure

HISTFILEHDR

data (2 bytes per data)

HISTFILEHDR structure

title 128 ASCII title of the file. It contains information, such as, file version, type, start time and logging name.
BinHdr 96 Binary header for history files. See HISTBINHDR structure

Citect version 3.3 and 4.10 onward HISTFILEHDR structure has been altered to cater for inserting the default scales into the trend history files. The new HISTFILEHDR structure is as follows:

New HISTFILEHDR structure

title 112 ASCII title of the file. It contains information, such as, file version, type, start time and logging name.
DefScale 16 default scales. See the structure of DEFAULTSCALES below.
BinHdr 96 Binary header for history files. See HISTBINHDR structure

DEFAULTSCALES structure

RawZero 4 (float)
RawFull 4 (float)
EngZero 4 (float)
EngFull 4 (float)

 

NOTE: Trend values are stored in Citect generic format, so the raw scale is not used.  To convert from generic format to the scaled format, use the following function. There are 2 special generic values:

-32001 no value logged
-32002 Gated value

#define MAX_GENERIC_VALUE 32000

double
GenericToEng(unsigned long generic, double EngZero, double EngFull, SHORT *error)
{
    double engRange;
    double engValue;

    engRange = EngFull - EngZero;
    if (engRange == 0.0)
    {
        engRange = 1.0;
    }

    *error = 0;

    engValue = ((double)generic * engRange / (double)MAX_GENERIC_SCALE) + EngZero;
    if (EngCheck(engValue, EngZero, EngFull) == FALSE)
    {
        *error = TRUE;
    }
    return engValue;
}

 

Keywords:
 

Attachments