#include #include "LinkList.h" #include "StrHier.h" #include "SDDAS_types.h" #include "libCfg.h" #include "libserver.h" /******************************************************************************* * * * GET_DATA_KEY SUBROUTINE * * * * DESCRIPTION * * This routine creates a key value which identifies the data set of * * interest by using assigned database names. This key value is used by the * * other generic utility routines to identify the data set. * * * * INPUT VARIABLES * * SDDAS_CHAR *pstr name of the project * * SDDAS_CHAR *mstr name of the mission * * SDDAS_CHAR *estr name of the experiment * * SDDAS_CHAR *istr name of the instrument * * SDDAS_CHAR *vstr name of the virtual instrument * * SDDAS_ULONG *data_key key which uniquely identifies the data set * * being processed * * * * USAGE * * x = swri_get_data_key (pstr, mstr, estr, istr, vstr, &data_key); * * * * NECESSARY SUBPROGRAMS * * SourceByStr () searches the configuration information for * * the requested data level * * SNUM () returns the database assigned value * * fields_to_key () returns the data key based upon database * * assigned numbers * * * * EXTERNAL VARIABLES * * extern LinkList Projects pointer to current configuration info * * * * INTERNAL VARIABLES * * StrHier Scode holds values returned by called module * * SDDAS_SHORT project the project value * * SDDAS_SHORT mission the mission value * * SDDAS_SHORT exper the experiment value * * SDDAS_SHORT inst the instrument value * * SDDAS_SHORT vinst the virtual instrument value * * SDDAS_SHORT params[] array which holds the project, mission, * * experiment, inst and virtual inst values * * * * SUBSYSTEM * * Display Level * * * ******************************************************************************/ SDDAS_SHORT swri_get_data_key (SDDAS_CHAR *pstr, SDDAS_CHAR *mstr, SDDAS_CHAR *estr, SDDAS_CHAR *istr, SDDAS_CHAR *vstr, SDDAS_ULONG *data_key) { extern LinkList Projects; StrHier Scode; SDDAS_SHORT project, mission, exper, inst, vinst, params[5]; /*********************************************************************/ /* Get the assigned database number for the project. */ /*********************************************************************/ assert (Projects != NULL); Scode = SourceByStr (Projects, pstr, (SDDAS_CHAR *) 0); if (Scode == NULL) return (DKEY_PROJECT); else project = SNUM (Scode); /*********************************************************************/ /* Get the assigned database number for the mission. */ /*********************************************************************/ Scode = SourceByStr (Projects, pstr, mstr, (SDDAS_CHAR *) 0); if (Scode == NULL) return (DKEY_MISSION); else mission = SNUM (Scode); /*********************************************************************/ /* Get the assigned database number for the experiment. */ /*********************************************************************/ Scode = SourceByStr (Projects, pstr, mstr, estr, (SDDAS_CHAR *) 0); if (Scode == NULL) return (DKEY_EXPERIMENT); else exper = SNUM (Scode); /*********************************************************************/ /* Get the assigned database number for the instrument. */ /*********************************************************************/ Scode = SourceByStr (Projects, pstr, mstr, estr, istr, (SDDAS_CHAR *) 0); if (Scode == NULL) return (DKEY_INSTRUMENT); else inst = SNUM (Scode); /*********************************************************************/ /* Get the assigned database number for the virtual instrument. */ /*********************************************************************/ Scode = SourceByStr (Projects, pstr, mstr, estr, istr, vstr, (SDDAS_CHAR *) 0); if (Scode == NULL) return (DKEY_VINST); else vinst = SNUM (Scode); /*********************************************************************/ /* Get the data key value. */ /*********************************************************************/ params[0] = project; params[1] = mission; params[2] = exper; params[3] = inst; params[4] = vinst; fields_to_key (params, data_key); return (ALL_OKAY); } #ifdef SwRI_DB SDDAS_SHORT get_data_key (SDDAS_CHAR *pstr, SDDAS_CHAR *mstr, SDDAS_CHAR *estr, SDDAS_CHAR *istr, SDDAS_CHAR *vstr, SDDAS_ULONG *data_key) { return (swri_get_data_key (pstr, mstr, estr, istr, vstr, data_key)); } #endif