IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 23, 2007, 1:45:05 PM (19 years ago)
Author:
magnier
Message:

fixed bugs related to setting the camera from the command line (-camera); require this option to pass a camera abstract name, not a camera config file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfig.c

    r14505 r14651  
    44 *  @author EAM (IfA)
    55 *
    6  *  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-08-15 20:21:18 $
     6 *  @version $Revision: 1.102 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-08-23 23:45:05 $
    88 *
    99 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    295295// Read the calibrations for a camera
    296296static bool cameraReadCalibrations(psMetadata *camera, // Camera for which to read the formats
    297                                    const char *name // Name of the camera, for error messages
     297                                   const char *cameraName // Name of the camera, for error messages
    298298    )
    299299{
    300300    assert(camera);
    301     assert(name);
     301    assert(cameraName);
    302302
    303303    psMetadataItem *darkNorm = psMetadataLookup(camera, "DARK.NORM"); // The dark normalisation calibration
     
    305305        if (darkNorm->type == PS_DATA_STRING) {
    306306            const char *darkNormName = darkNorm->data.str; // The file name
    307             psTrace("config", 2, "Reading %s dark normalisation: %s\n", name, darkNormName);
     307            psTrace("config", 2, "Reading %s dark normalisation: %s\n", cameraName, darkNormName);
    308308            psMetadata *new = NULL;         // New metadata
    309309            if (!pmConfigFileRead(&new, darkNormName, "Dark normalisation")) {
    310310                psError(PM_ERR_CONFIG, false, "Trouble reading reading %s dark normalisation %s --- "
    311                         "ignored.\n", name, darkNormName);
     311                        "ignored.\n", cameraName, darkNormName);
    312312                psFree(new);
    313313                return false;
     
    320320            darkNorm->data.md = new;
    321321        } else if (darkNorm->type != PS_DATA_METADATA) {
    322             psWarning("DARK.NORM in camera %s is not of type STR or METADATA (%x)", name, darkNorm->type);
     322            psWarning("DARK.NORM in camera %s is not of type STR or METADATA (%x)", cameraName, darkNorm->type);
    323323        }
    324324    } else {
     
    541541                     "ignored.\n");
    542542        } else {
    543             char *cameraFile = argv[argNum]; // The camera configuration file to read
    544 
    545             // look for a symbolic camera name in the CAMERAS metadata
    546             // otherwise fall back to trying the -camera option as a literal
    547             // filename
    548543            bool mdok = true;           // Status of MD lookup
     544            char *cameraName = argv[argNum]; // symbolic name of the camera
     545
     546            // look for the CAMERAS list in config->site
    549547            psMetadata *cameras = psMetadataLookupMetadata(&mdok, config->site, "CAMERAS");
    550             if (mdok && cameras) {
    551                 char *newFile = psMetadataLookupStr(NULL, cameras, cameraFile); // The filename
    552                 if (newFile) {
    553                     cameraFile = newFile;
    554                 } else {
    555                     psLogMsg ("psModules.config", PS_LOG_INFO,
    556                               "%s is not listed in the site CAMERAS list,\n"
    557                               "trying as a camera configuration file\n", cameraFile);
    558                 }
    559             } else {
     548            if (!cameras) {
    560549                psError(PS_ERR_IO, false, "Unable to find CAMERAS in site configuration.\n");
    561550                psFree(config);
     
    563552            }
    564553
    565             if (!pmConfigFileRead(&config->camera, cameraFile, "camera")) {
    566                 psError(PM_ERR_CONFIG, false, "Problem reading %s", cameraFile);
     554            // look for the symbolic camera name in the CAMERAS metadata
     555            char *cameraFile = psMetadataLookupStr(&mdok, cameras, cameraName); // The filename
     556            if (!cameraFile) {
     557                psError(PS_ERR_IO, false, "%s is not listed in the site CAMERAS list\n", cameraName);
    567558                psFree(config);
    568559                return NULL;
    569560            }
    570561
     562            // load this camera's configuration informatoin
     563            if (!pmConfigFileRead(&config->camera, cameraFile, "camera")) {
     564                psError(PM_ERR_CONFIG, false, "Problem reading %s", cameraName);
     565                psFree(config);
     566                return NULL;
     567            }
     568            // save the name for future uses
     569            config->cameraName = psStringCopy (cameraName);
     570           
    571571            psArgumentRemove(argNum, argc, argv);
    572572
     
    580580
    581581            // Read in any camera-specific calibrations
    582             if (!cameraReadCalibrations(config->camera, cameraFile)) {
     582            if (!cameraReadCalibrations(config->camera, cameraName)) {
    583583                psError(PS_ERR_UNKNOWN, false,
    584584                        "Unable to read calibrations within camera configuration %s.\n",
    585                         cameraFile);
     585                        cameraName);
    586586                psFree(config);
    587587                return NULL;
    588588            }
    589589
    590             psMetadataAddMetadata(cameras, PS_LIST_HEAD, cameraFile, PS_META_REPLACE,
     590            psMetadataAddMetadata(cameras, PS_LIST_HEAD, cameraName, PS_META_REPLACE,
    591591                                  "Camera specified on command line", config->camera);
    592592
    593             if (!pmConfigCameraSkycellVersion(config->site, cameraFile)) {
     593            if (!pmConfigCameraSkycellVersion(config->site, cameraName)) {
    594594                psError(PS_ERR_UNKNOWN, false,
    595595                        "Unable to generate skycell versions of specified camera %s.\n",
    596                         cameraFile);
     596                        cameraName);
    597597                psFree(config);
    598598                return NULL;
    599599            }
    600600
    601             if (!pmConfigCameraMosaickedVersions(config->site, cameraFile)) {
     601            if (!pmConfigCameraMosaickedVersions(config->site, cameraName)) {
    602602                psError(PS_ERR_UNKNOWN, false,
    603603                        "Unable to generate mosaicked versions of specified camera %s.\n",
    604                         cameraFile);
     604                        cameraName);
    605605                psFree(config);
    606606                return NULL;
     
    875875    assert(camera);
    876876    assert(header);
    877     assert(cameraName && strlen(cameraName) > 0);
     877    assert(cameraName);
     878    assert(*cameraName);
    878879
    879880    bool result = false;                // Did we find the first match?
     
    10081009        psFree(name);
    10091010    }
    1010     return format;
     1011    return psMemIncrRefCounter(format);
    10111012}
    10121013
Note: See TracChangeset for help on using the changeset viewer.