libVIDF Documentation


written by Joey Mukherjee - joey@swri.org
Last Updated - 9/23/99

Table of contents

  1. Overview
  2. Getting Started
  3. ReadVIDF
  4. read_idf (compatibility mode)
  5. CloseVIDF
  6. InitializeVIDFFromFile
  7. ReadFromCurrentVIDF
  8. Appendix A - Incompatible Changes from v2.1 to 3.0

Overview

The libVIDF is a library to enable the application developer to read from the IDFS VIDF file. The VIDF file contains a full description of the virtual instrument which includes the measurements included in the data records, the status measurements included in the header records, and the algorithms to convert each of these measurements into one or more sets of physical units. This library will support version 2.1 binary IDF files, and all ASCII versions after that. IDFS creators are encouraged to create only v3.0 VIDF files from now on since backward compatibility may be removed at a later date.

Getting Started...

This library is dependent on the following IDFS libraries: libant, libCfg, and libserver. Other system libraries include lex and yacc (or their equivalents). When linking, make sure all the libraries are also included.

To use the libVIDF library, include "libVIDF.h" in your source code and use any of the four public calls which are documented below. One must always do an initialize before attempting to read from a VIDF. Unpredictable results will occur otherwise. Initialization can happen in one of two ways, either from a data key and an associated time, or from a filename. After an initialize, you can use the read_idf call which should be backward compatible with previous versions of the read_idf call or you may use the ReadVIDF which is more efficient. The program should then call CloseVIDF prior to completion of the program.

ReadVIDF


int ReadVIDF (SDDAS_ULONG data_key, 
              SDDAS_SHORT btime_yr, SDDAS_SHORT btime_day, 
              SDDAS_LONG btime_sec, SDDAS_LONG btime_nsec,
              SDDAS_SHORT etime_yr, SDDAS_SHORT etime_day,
              SDDAS_LONG etime_sec, SDDAS_LONG etime_nsec,
              void *var, VIDF_DEFS what, SDDAS_SHORT which,
              SDDAS_LONG start, SDDAS_SHORT len);

ReadVIDF is the call most people will use to get information from a VIDF file. The parameters are as follows:

  1. data_key - This is the data key for the VIDF you wish to read.
  2. btime_yr - The start year of the time for what you are interested.
  3. btime_day - The start day of the time for what you are interested.
  4. btime_sec - The start second of the time for what you are interested.
  5. btime_nsec - The start nanosecond of the time for what you are interested.
  6. etime_yr - The ending year of the time for what you are interested.
  7. etime_day - The ending day of the time for what you are interested.
  8. etime_sec - The ending second of the time for what you are interested.
  9. etime_nsec - The ending nanosecond of the time for what you are interested.
  10. var - The memory location to write the data. It must already be pre-allocated.
  11. what - The specific element to read from the VIDF.
  12. which - If there are more than one element of what type, this variable specifies which element to read.
  13. start - If the what is an array, this variable tells the starting location at which to return elements from the array.
  14. len - If the what is an array, this variable tells the number of items to return. If a -1 is used, all items will be returned.

On using new VIDF, ReadVIDF will return error code VIDF_ELEMENT_NOT_FOUND if the specified what value was not found. If it was found, it will return an ALL_OKAY. With an old VIDF, the following return codes may be returned:

read_idf (Compatibility mode)

SDDAS_LONG read_idf (SDDAS_ULONG data_key, char *exten,
                     SDDAS_USHORT vnum, void *var, SDDAS_SHORT quan, SDDAS_SHORT num,
                     SDDAS_LONG start, SDDAS_SHORT len);

If you are using old code, you may have other calls to read_idf which was the previous method of reading from a v2.1 VIDF. We have deprecated the use of this call since we added the time into the call. This enables us to have the VIDF be more time dependent so multiple VIDF files will be handled better and in control of the user. The seperation also allows us to handle either a new or old style VIDF to maintain backwards compatibility. Furthermore, the first three variables are no longer used.

Nevertheless, the call is still available so MOST of your code will not change at all. Please read the appendix dealing with incompatibilities between the old and the new calls.

The only time this call will not work is if you call this function without first opening the VIDF which the IDFS read routines will do for you. If you do not use the IDFS read routines, you MUST use the new ReadVIDF routine.

CloseVIDF


void CloseVIDF ();

This call takes no arguments and returns nothing. It will simply close the file descriptor associated with the VIDF file. If you use the IDFS read routines' free_experiment_info, you should not have to make this call.

InitializeVIDFFromFile


int InitializeVIDFFromFile (char *);

If you know the name of the file prior to opening, call InitializeVIDFFromFile with the filename of the VIDF file. The file must end in either a "I" or a "V.v3". Based on the extension, the initialize routine will use either the old or the new read routines to read the VIDF file.

If the IDFS read routines are being utilized, it will already have made this call and you may just you the routines below to access the current VIDF in memory.

InitializeVIDFFromFile will return an error code if the VIDF can not be opened. Otherwise, ALL_OKAY will be returned.

ReadFromCurrentVIDF


int ReadFromCurrentVIDF (void *var, VIDF_DEFS what, SDDAS_SHORT num,
                         SDDAS_LONG start, SDDAS_SHORT len);


If you used InitializeVIDFFromFile, you will not have a data key or a time. There will only be one VIDF available so you may use the call ReadFromCurrentVIDF to read information from a VIDF. The parameters (which are identical to the related counterparts in ReadVIDF) are as follows:
  1. var - The memory location to write the data. It must already be pre-allocated.
  2. what - The specific element to read from the VIDF.
  3. which - If there are more than one element of what type, this variable specifies which element to read.
  4. start - If the what is an array, this variable tells the starting location at which to return elements from the array.
  5. len - If the what is an array, this variable tells the number of items to return. If a -1 is used, all items will be returned.

Appendix A - Changes/Incompatibilities in the cross over from v2.1 to 3.0

For most people, there is no change needed in using this new library; however, there are several backward incompatibilities between the old read_idf call and the new read_idf call.

The most prominent one is in calling read_idf expecting an array of strings. read_idf no longer expects a preallocated space for the string. It will now return a string pointer which is more memory efficient.

Any field designated as a comment in v2.1 of the VIDF are no longer retrievable using the new VIDF. The reason is comments are now allowed anywhere in the VIDF and you are no longer restricted to their line length or frequency. As a result, they are not retrievable.