00001 /** @file pmConfig.h 00002 * 00003 * @author PAP, IfA 00004 * 00005 * @version $Revision: 1.11 $ $Name: rel12 $ 00006 * @date $Date: 2006/06/28 00:49:13 $ 00007 * 00008 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 00009 * 00010 */ 00011 #ifndef PM_CONFIG_H 00012 #define PM_CONFIG_H 00013 00014 #include "pslib.h" 00015 00016 // What recipe sources have been read so far? 00017 typedef enum { 00018 P_PM_RECIPE_SOURCE_NONE = 0x00, // None yet 00019 P_PM_RECIPE_SOURCE_SITE = 0x01, // Site configuration 00020 P_PM_RECIPE_SOURCE_CAMERA = 0x02, // Camera configuration 00021 P_PM_RECIPE_SOURCE_CL = 0x04, // Command-line 00022 P_PM_RECIPE_SOURCE_ALL = 0x07 // All sources 00023 } p_pmRecipeSource; 00024 00025 // Configuration information 00026 typedef struct 00027 { 00028 psMetadata *site; // Site configuration 00029 psMetadata *camera; // Camera specification 00030 psMetadata *recipes; // Recipes for processing 00031 psMetadata *arguments; // Processed command-line arguments 00032 psMetadata *files; // pmFPAfiles used for analysis 00033 psDB *database; // Database handle 00034 int argc; // Number of command-line arguments 00035 char **argv; // Command-line arguments (raw version) 00036 // Private members 00037 p_pmRecipeSource recipesRead; // Which recipe sources have been read 00038 psMetadata *recipesSource; // Where each recipe came from 00039 } 00040 pmConfig; 00041 00042 pmConfig *pmConfigAlloc(int argc, // Number of command-line arguments 00043 char **argv // Command-line arguments 00044 ); 00045 00046 void pmConfigSet(const char *path); // set the configPath 00047 00048 // Free static variables 00049 void pmConfigDone(void); 00050 00051 /** pmConfigRead 00052 * 00053 * pmConfigRead shall load the site configuration (according to the above rule 00054 * for determining the source). The camera configuration shall also be loaded if 00055 * it is specified on the command line (argc, argv); otherwise it shall be set to 00056 * NULL. The recipe shall also be loaded from the command line (if specified) or, 00057 * if the camera configuration has been loaded, from the camera configuration and 00058 * recipe specification therein (see below). In dealing with the command line 00059 * parameters, the functions shall use the appropriate functions in psLib to 00060 * retrieve and remove the relevant options from the argument list; this 00061 * simplifies assignment of the mandatory arguments, since all the optional 00062 * command line arguments are removed leaving only the mandatory arguments. The 00063 * following psLib setups shall also be performed if they are specified in the 00064 * site configuration: 00065 * 00066 */ 00067 pmConfig *pmConfigRead( 00068 int argc, 00069 char **argv); 00070 00071 /** we need this elsewhere; make it public **/ 00072 bool readConfig( 00073 psMetadata **config, // Config to output 00074 const char *name, // Name of file 00075 const char *description // Description of file 00076 ); 00077 00078 /** pmConfigValidateCamera 00079 * 00080 * This function, used by pmConfigCameraFromHeader, shall return true if the 00081 * FITS header matches the rule contained in the camera configuration (see 00082 * x2.2.2.3); otherwise it shall return false. 00083 * 00084 */ 00085 bool pmConfigValidateCameraFormat( 00086 const psMetadata *cameraFormat, 00087 const psMetadata *header); 00088 00089 00090 /** pmConfigCameraFromHeader 00091 * 00092 * pmConfigCameraFromHeader shall load the camera configuration based on the 00093 * contents of the FITS header, using the list of known cameras contained in the 00094 * site configuration. If more than one camera matches the FITS header, a warning 00095 * shall be generated and the first matching camera returned. 00096 * 00097 */ 00098 psMetadata *pmConfigCameraFormatFromHeader( 00099 pmConfig *config, // The configuration 00100 const psMetadata *header // The FITS header 00101 ); 00102 00103 00104 // find the camera given the name 00105 psMetadata *pmConfigCameraByName( 00106 pmConfig *config, // The configuration 00107 const char *cameraName // The camera name header 00108 ); 00109 00110 /** pmConfigRecipeFromCamera 00111 * 00112 * pmConfigRecipeFromCamera shall load the recipes from the list of known recipes contained in the camera 00113 * configuration. 00114 * 00115 */ 00116 bool pmConfigReadRecipes(pmConfig *config // Configuration 00117 ); 00118 00119 /** pmConfigDB 00120 * 00121 * pmConfigDB shall use the site configuration data to open a database handle. 00122 * This is fairly straightforward at the moment, but will change when we beef up 00123 * security. (TBD) 00124 * 00125 */ 00126 psDB *pmConfigDB( 00127 pmConfig *config // Configuration 00128 ); 00129 00130 /** pmConfigConformHeader 00131 * 00132 * Make the supplied header conform to the nominated camera format. 00133 */ 00134 bool pmConfigConformHeader(psMetadata *header, // Header to conform 00135 const psMetadata *format // Camera format 00136 ); 00137 00138 00139 psArray *pmConfigFileSets(pmConfig *config, char *file, char *list); 00140 bool pmConfigFileSetsMD (psMetadata *metadata, pmConfig *config, char *name, char *file, char *list); 00141 00142 00143 #endif
1.4.4