CRIS/SIS Low Level Data Archival Routines

Last Modified Wednesday, 14-Jan-1998 23:05:58 PST.

Here are the low level routines used in the CRIS/SIS data archival libraries. This documentation is primarily intended for those who need to port and/or rewrite parts of the libraries. See notes on setting up the data archival libraries for instructions on setting up the source, makefiles, and directory structure involved in creating the libraries.


createInitializedFile

void createInitializedFile(int fd, char dataBuffer[], int bufferSize, int dataTypeID);
createInitializedFile initializes a day's data file for a particular data type. It writes the 32 byte header and zeros the rest of the file. The file is made large enough on initialization to contain all of the given type of data for the full day. createInitializedFile assumes that the data type has a periodicity of 256 seconds per data struct. Data types with different periododicities use the routine createInitializedFileWithIntervalN. Non-periodic data types use neither.

Input:

Output:


createInitializedFileWithIntervalN

void createInitializedFileWithIntervalN(int fd, char dataBuffer[],
                        int bufferSize, int dataTypeID, int timeInterval);
See notes for routine createInitializedFile.

Input:

Output:


determineDataFilePathAndCreateDirsAsNeeded

void determineDataFilePathAndCreateDirsAsNeeded(uint32 secondsSince1996,
                                const char *dataFileSuffix, char *path,
                                int *pIntervalNumber, char instrumentID);
determineDataFilePathAndCreateDirsAsNeeded determines the path to the archive file of a particular data type from a particular day. If parts of this path do not exist yet, this routine attempts to create them before handing back the file's (or file-to-be's) path.

Input:

Output:


sortTrackers

int sortTrackers(const void *pVoid1, const void *pVoid2);
sortTrackers is called by qsort in a few routines to reorder data structs in their files. This routine is used only for the reordering of non-periodic data types (i.e., those with start and stop time stamps) in their files when a struct needs to be written to an archive file somewhere before the end of the file in order to preserve a chronological ordering of the structs in the file.

Input:

Output:


writeDataStructToFile

int writeDataStructToFile(int fd, int intervalNumber, char dataBuffer[],
                                int bufferSize, char *pDataStruct, char *path);
writeDataStructToFile is used to write a data struct into the proper position in its archive file.

First this routine checks what has been written into the data file at the interval where the passed data struct is to be written. If the interval is all zeros (done at file initialization), the struct is written and a status of 0 is returned.

If the interval is found to contain data already, both the passed struct and the one already in the file are written out to an auxiliary file (same file name with ".overlap" suffix appended), the interval is filled with char -1s, and a status of 1 is returned.

If the interval is filled with char -1s, then the passed struct is written to the auxiliary file and a status of 2 is returned.

Finally, if the passed data struct is identical to the data already in the interval, nothing is written, and a status of 3 is returned.

Input:

Output:


writeHeader

void writeHeader(int fd, int dataTypeID);
writeHeader is used for writing the 32 byte header present at the beginning of every data file in the archive. Header description.

Input:

Output:


bruce