TINE Local History Server module plus API routines. More...
Functions | |
int | AppendHistoryData (char *eqm, char *prp, char *dev, DTYPE *dout) |
Inserts local history data into the local history ring buffer. More... | |
int | AppendHistoryInformation (char *eqm, char *prp, char *dev, int len, int fmt, int idx, HistorySpecification *hspec) |
Inserts a local history element into the local history server. More... | |
int | AppendHistoryInformationEx (char *eqm, char *prp, char *dev, int len, int fmt, int idx, HistorySpecification *hspec, int hstFlags) |
Inserts a local history element into the local history server. More... | |
int | ApplyHistoryFilter (int idx, char *parsableFilterString) |
Applies a history filter to an existing local history record. More... | |
char * | GetHistoryFilesRepository (void) |
Returns the directory location where local history files are maintained. More... | |
char * | GetHistoryStaticFilesRepository (void) |
Returns the directory location where static local history files are maintained. More... | |
int | GetLastStoredData (char *eqm, char *prp, char *dev, int index, BYTE *data, int fmt, int len) |
Retreives the last stored data set from disk for the given input parameters. More... | |
int | GetLastStoredDataEx (char *eqm, char *prp, char *dev, int index, BYTE *data, int fmt, int len, double *tstamp) |
Retreives the last stored data set from disk for the given input parameters (extended call). More... | |
int | GetStandardSpillOverSize (void) |
Gets the amount of additional space (number of addition records) to allocate as a worst case when using the standard local history data file set. More... | |
int | GetUseStandardHistoryFiles (int index) |
Returns TRUE of FALSE depending on whether the given history record index makes use of the so-called 'standard' set of local history files. More... | |
void | SetHistoryFilesRepository (char *path) |
Sets the directory location where local history files are maintained. More... | |
void | SetHistoryStaticFilesRepository (char *path) |
Sets the directory location where static local history files are maintained. More... | |
void | SetMaximumHistoryTableRecords (int value) |
Sets the maximum local history table size. More... | |
void | SetMinimumDiskSpaceInBlocks (UINT32 spaceInBlocks) |
Sets the amount of free disk space the local history subsystem should try to maintain. More... | |
void | SetPointsOfInterestRangeFactor (float value) |
Sets the definitive property range (maximum-minimum) factor which determines whether a value is consider a point of interest. More... | |
void | SetPointsOfInterestToleranceFactor (float value) |
Sets the definitive property tolerance factor which determines whether a value is consider a point of interest. More... | |
void | SetStandardSpillOverSize (int value) |
Sets the amount of additional space (number of addition records) to allocate as a worst case when using the standard local history data file set. More... | |
void | SetUseStandardHistoryFiles (int value) |
Instructs the server to use the so-called 'standard' set of local history files. More... | |
Variables | |
int | useMinimalStorage = FALSE |
Instructs the local history server to use a simple UTC timestamp (4-byte integer) when saving data to disk. More... | |
int | useMonthlyHistoryFiles = FALSE |
Instructs the local history server to keep monthly archive files instead of daily files. More... | |
TINE Local History Server module plus API routines.
A TINE server can be instructed to maintain a local history of certain properties. The stored data can then be obtained with normal data acquition calls to the TINE Local History Server. By and large the instructions as to which properties are to be maintained in the local history server and as to what filtering criteria are to be used in commiting the data to disk are typically entered into a startup configuration file 'history.csv'. As an alternative, see AppendHistoryInformation(). The local history server maintains two sets of histories, a short-term history kept in main memory and a long-term history kept on disk. Whereas the short-term history can be kept on a millisecond time raster, the long-term history will not be written to disk any more often than once per second.
int AppendHistoryData | ( | char * | eqm, |
char * | prp, | ||
char * | dev, | ||
DTYPE * | dout | ||
) |
Inserts local history data into the local history ring buffer.
A server can insert data into the local history ring buffer directly with this call. The inserted data behave in exactly the same manner as if added via a call the the designated equipment module from the local history subsystem.
The information provided in the call MUST correspond to a registered local history element or the call will fail. The server developer can ensure that history data are inserted ONLY via this call (and not via the local history subsystem) by trapping the CA_HIST bit in the access flag within the equipment module dispatch and returning an error condition such as 'not_implemented'.
eqm | is the 6-character local equipment identifier name, which is internal to server. |
prp | is the requested property for which a history record is being kept. |
dev | is the device name for which a history record is being kept. |
dout | is a reference to a DTYPE object specifying the array length, data format, timestamp and other data stamps of the history record along with the accompanying data. |
Example:
References argument_list_error, HstTblEntry::c, DTYPE::dArrayLength, and DTYPE::dFormat.
int AppendHistoryInformation | ( | char * | eqm, |
char * | prp, | ||
char * | dev, | ||
int | len, | ||
int | fmt, | ||
int | idx, | ||
HistorySpecification * | hspec | ||
) |
Inserts a local history element into the local history server.
A server can instruct the local history server to keep a history of the given property by utilizing this call. The local history server will periodically call the property as specified according to the following input parameters.
eqm | is the 6-character local equipment identifier name, which is internal to server. |
prp | is the requested property for which a history is to be kept |
dev | is the device name to be associated with the property name supplied as the second parameter. |
len | is the length of the local history call. |
fmt | is the TINE format of the local history call. |
idx | is the local history index to be identified with this local history element (Note: this must be unique with this server process and within the history data repository). |
hspec | is a pointer to a HistorySpecification structure, where the relevant filtering criteria are given. |
Example:
References AppendHistoryInformationEx().
int AppendHistoryInformationEx | ( | char * | eqm, |
char * | prp, | ||
char * | dev, | ||
int | len, | ||
int | fmt, | ||
int | idx, | ||
HistorySpecification * | hspec, | ||
int | hstFlags | ||
) |
Inserts a local history element into the local history server.
A server can instruct the local history server to keep a history of the given property by utilizing this call. The local history server will periodically call the property as specified according to the following input parameters. The extended version allows passing the additional parameter 'hstFlags' which can be used to direct the style of points-of-interest (USE_POI_NONE, USE_POI_RANGE, USE_POI_TOLERANCE).
eqm | is the 6-character local equipment identifier name, which is internal to server. |
prp | is the requested property for which a history is to be kept |
dev | is the device name to be associated with the property name supplied as the second parameter. |
len | is the length of the local history call. |
fmt | is the TINE format of the local history call. |
idx | is the local history index to be identified with this local history element (Note: this must be unique with this server process and within the history data repository). |
hspec | is a pointer to a HistorySpecification structure, where the relevant filtering criteria are given. |
hstFlags | gives additional storage directives. For example if no 'points of interest' companion files are desired, setting hstFlags = USE_POI_NONE will instruct the subsystem not to maintain them. If this parameter is 0, then the default criteria are used, and the call collapses to AppendHistoryInformation(). |
Example:
References argument_list_error.
Referenced by AppendHistoryInformation().
int ApplyHistoryFilter | ( | int | idx, |
char * | parsableFilterString | ||
) |
Applies a history filter to an existing local history record.
A server can filter out long term storage by applying a filter condition which must be satisfied.
idx | is the local history record index of the history element to which the filter should by applied. (Note: this must already be allocated). |
parsableFilterString | is a parsable filter string defining the filter condition. This should be of the form /<context>/<server/<device>[<property>]<comparator><value> where <comparator> is one of '=', '!=', '>', or '<' and <value> is the filter's threshold value. Multiple comparator/value combinations can be ANDed (&&) or ORed (||) to refine the filter condition. The filter targer address should deliver (or be able to deliver) a single numeric or string name value. If the filter string cannot be parsed or the target address does not exists, then no filter will be established. |
char* GetHistoryFilesRepository | ( | void | ) |
Returns the directory location where local history files are maintained.
Typically the location for the local history repository is established by
the environment variable HISTORY_HOME. If not set, the default location for local history files is given by an adjacent directory to the FEC_HOME location given by the sub-directory name HISTORY.
char* GetHistoryStaticFilesRepository | ( | void | ) |
Returns the directory location where static local history files are maintained.
Normally the local history subsystem maintains a volatile history repository where history files older than the long term depth are regularly removed from the disk. If it is desired to keep certain local history files from being automatically removed, such files can be copied by hand into the designated static files repository.
By default, this will be a sub-directory 'SAVED' located within the normal history files repository given by e.g. the HISTORY_HOME environment variable or otherwise set via API. The location of the static repository can be retrieved via this API call.
int GetLastStoredData | ( | char * | eqm, |
char * | prp, | ||
char * | dev, | ||
int | idx, | ||
BYTE * | data, | ||
int | fmt, | ||
int | len | ||
) |
Retreives the last stored data set from disk for the given input parameters.
A server can retrieve the last stored data set from disk for any given local history property. This is frequently useful to insure that a server restart will reload data various sets, for instance when data are collected according to intermittent triggers, etc.
eqm | is the 6-character local equipment identifier name, which is internal to server. |
prp | is the requested property for which a history is to be kept |
dev | is the device name to be associated with the property name supplied as the second parameter. |
idx | is the targeted array index (if the history element represents an array) identifying the beginning of the range of data to retrieve. |
data | is the buffer to receive the data. It must be pre-allocated to at least the array length specified in the 'len' parameter. |
fmt | is the TINE format of the local history call. |
len | is the length of the local history call. |
Example:
References GetLastStoredDataEx().
int GetLastStoredDataEx | ( | char * | eqm, |
char * | prp, | ||
char * | dev, | ||
int | idx, | ||
BYTE * | data, | ||
int | fmt, | ||
int | len, | ||
double * | tstamp | ||
) |
Retreives the last stored data set from disk for the given input parameters (extended call).
A server can retrieve the last stored data set from disk for any given local history property. This is frequently useful to insure that a server restart will reload data various sets, for instance when data are collected according to intermittent triggers, etc. The extended call can also return the timestamp of the last stored data if required.
eqm | is the 6-character local equipment identifier name, which is internal to server. |
prp | is the requested property for which a history is to be kept |
dev | is the device name to be associated with the property name supplied as the second parameter. |
idx | is the targeted array index (if the history element represents an array) identifying the beginning of the range of data to retrieve. |
data | is the buffer to receive the data. It must be pre-allocated to at least the array length specified in the 'len' parameter. |
fmt | is the TINE format of the local history call. |
len | is the length of the local history call. |
tstamp | (out) will contain the TINE data timestamp of the last stored data if the call is successful and a non-NULL reference pointer is passed. |
Referenced by GetLastStoredData().
int GetStandardSpillOverSize | ( | void | ) |
Gets the amount of additional space (number of addition records) to allocate as a worst case when using the standard local history data file set.
The local history standard file set is pre-allocated to manage a 'worst-case' number of stored records based on all filtering criteria coming up negative and making use of the configured history record polling interval and record size.
int GetUseStandardHistoryFiles | ( | int | index | ) |
Returns TRUE of FALSE depending on whether the given history record index makes use of the so-called 'standard' set of local history files.
The 'standard' set of local history files is pre-allocated on the local file system to be able to contain a 'worst-case' respository of random-access local history records according to the assigned polling interval and data size of the record (i.e. a null result is assumed for any would-be filtering action). The initial allocation of such a file set is of course time-consuming if a depth of several months is required and the records are large. However the subsequent data retrieval is very fast.
index | is the history record index for which the setting is desired. |
void SetHistoryFilesRepository | ( | char * | path | ) |
Sets the directory location where local history files are maintained.
Typically the location for the local history repository is established by
the environment variable HISTORY_HOME. If not set, the default location for local history files is given by an adjacent directory to the FEC_HOME location given by the sub-directory name HISTORY.
path | is the desired history files repository location. |
void SetHistoryStaticFilesRepository | ( | char * | path | ) |
Sets the directory location where static local history files are maintained.
Normally the local history subsystem maintains a volatile history repository where history files older than the long term depth are regularly removed from the disk. If it is desired to keep certain local history files from being automatically removed, such files can be copied by hand into the designated static files repository.
By default, this will be a sub-directory 'SAVED' located within the normal history files repository given by e.g. the HISTORY_HOME environment variable or otherwise set via API. The location of the static repository can otherwise be set via this API call.
path | is the desired static history files repository location. |
void SetMaximumHistoryTableRecords | ( | int | value | ) |
Sets the maximum local history table size.
The local history subsystem makes use of a table containing all relevant history contracts. The maximum size of the this table is governed by this routine.
value | is the desired maximum history table size (default is 100). |
void SetMinimumDiskSpaceInBlocks | ( | UINT32 | spaceInBlocks | ) |
Sets the amount of free disk space the local history subsystem should try to maintain.
Normally the local history subsystem maintains a history repository based on the assigned depth in months of the history records. In addition, one can make use of this call to establish a minimum floor to the amount of free disk space which should be maintained on the server. If this floor is reached, then the oldest history files will be removed until the disk free space is once again above the assigned floor.
value | is the desired minimum free disk space (in blocks) to be maintained on the local history partition. |
void SetPointsOfInterestRangeFactor | ( | float | value | ) |
Sets the definitive property range (maximum-minimum) factor which determines whether a value is consider a point of interest.
If the change in a property's readback value is greater than the value's display range times this range factor, then the value is considered a point of interest and therefore always returned in archive calls over the relevant time range.
value | is the desired display range factor (default is 0.25). |
void SetPointsOfInterestToleranceFactor | ( | float | value | ) |
Sets the definitive property tolerance factor which determines whether a value is consider a point of interest.
If the change in a property's readback value is greater than the value's tolerance (if non-zero) times this range factor, then the value is considered a point of interest and therefore always returned in archive calls over the relevant time range.
value | is the desired display range factor (default is 10). |
void SetStandardSpillOverSize | ( | int | value | ) |
Sets the amount of additional space (number of addition records) to allocate as a worst case when using the standard local history data file set.
The local history standard file set is pre-allocated to manage a 'worst-case' number of stored records based on all filtering criteria coming up negative and making use of the configured history record polling interval and record size. If it is anticipated that some local history data will be scheduled, then an additional spill-over space should be applied.
value | is the desired additional spill over size (default 1000). |
void SetUseStandardHistoryFiles | ( | int | value | ) |
Instructs the server to use the so-called 'standard' set of local history files.
The 'standard' set of local history files is pre-allocated on the local file system to be able to contain a 'worst-case' respository of random-access local history records according to the assigned polling interval and data size of the record (i.e. a null result is assumed for any would-be filtering action). The initial allocation of such a file set is of course time-consuming if a depth of several months is required and the records are large. However the subsequent data retrieval is very fast.
This routine will enforce the usage of the standard local history file set.
value | is the desired value of this setting (default: FALSE). |
int useMinimalStorage = FALSE |
Instructs the local history server to use a simple UTC timestamp (4-byte integer) when saving data to disk.
By default, the local history subsystem will timestamp the data records stored to disk with a higher resolution timestamp than the traditional UTC variable. The data system stamps will likewise be stored with the data record. This results in more disk space being used by an archive record, as the record prefix is now 16 bytes per archived record instead of 4. This can be controlled by setting this variable to TRUE (small prefix) or FALSE (large prefix).
Default: FALSE
int useMonthlyHistoryFiles = FALSE |
Instructs the local history server to keep monthly archive files instead of daily files.
The local history subsystem maintains one file per record per day. In some cases it might be advantageous to keep one file per record per month, for instance when many small records are being maintained. You can influence this behavior be setting this flag to TRUE.