IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6417


Ignore:
Timestamp:
Feb 9, 2006, 4:43:17 PM (20 years ago)
Author:
jhoblitt
Message:

major config options update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/regtoolConfig.c

    r6368 r6417  
    77
    88    if (! pmConfigRead(&config->site, &config->camera, &config->recipe, &argc, argv, RECIPE)) {
    9         psErrorStackPrint(stderr, "Can't find site configuration!\n");
     9        psError(PS_ERR_UNKNOWN, false, "Can't find site configuration!\n");
    1010        exit(EXIT_FAILURE);
    1111    }
    12 
    13     // Parse other command-line arguments
    14     psMetadata *arguments = psMetadataAlloc(); // The arguments, with default values
    1512
    1613    int N;
     
    1916        psArgumentRemove (N, &argc, argv);
    2017        if (config->mode) {
    21             psAbort (argv[0], "only one mode selection is allowed");
     18            psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed");
    2219        }
    2320        config->mode = PX_MODE_PENDING;
     
    2623        psArgumentRemove (N, &argc, argv);
    2724        if (config->mode) {
    28             psAbort (argv[0], "only one mode selection is allowed");
     25            psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed");
    2926        }
    3027        config->mode = PX_MODE_UPDATE;
     
    3229   
    3330    // paul's argument parsing convention requires: -key value
    34     psMetadataAddStr(arguments, PS_LIST_TAIL, "-pending", 0, "examine pending image table, write ppImage output", "");
    35     psMetadataAddStr(arguments, PS_LIST_TAIL, "-update",  0, "update pending image table", "");
     31    // Parse other command-line arguments
     32    psMetadata *args = psMetadataAlloc();
     33    psMetadataAddStr(args , PS_LIST_TAIL, "-pending", 0,
     34        "examine pending image table, write ppImage output", "");
     35    psMetadataAddStr(args , PS_LIST_TAIL, "-update",  0,
     36        "update pending image table", "");
    3637
    3738
    3839    // -pending search
    39     psMetadataAddStr(arguments, PS_LIST_TAIL, "-exp_id",  0, "define exposure ID", "");
    40     psMetadataAddStr(arguments, PS_LIST_TAIL, "-inst",  0, "define camera of interest", "");
    41     psMetadataAddStr(arguments, PS_LIST_TAIL, "-telescope",  0, "define camera of interest", "");
    42     psMetadataAddStr(arguments, PS_LIST_TAIL, "-exp_type",  0, "define class", "");
    43     psMetadataAddStr(arguments, PS_LIST_TAIL, "-class",  0, "define class", "");
     40    psMetadata *pendingArgs = psMetadataAlloc();
     41    psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_id",  0,
     42        "define exposure ID", "");
     43    psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-inst",  0,
     44        "define camera of interest", "");
     45    psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-telescope",  0,
     46        "define camera of interest", "");
     47    psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_type",  0,
     48        "define class", "");
     49    psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-class",  0,
     50        "define class", "");
     51
    4452
    4553    // -update inputs
    46 //    psMetadataAddStr(arguments, PS_LIST_TAIL, "-exp_id",  0, "define class", "");
    47     psMetadataAddStr(arguments, PS_LIST_TAIL, "-filter",  0, "define filter of interest", "");
    48     psMetadataAddStr(arguments, PS_LIST_TAIL, "-stat",  0, "define URL", "");
    49     psMetadataAddStr(arguments, PS_LIST_TAIL, "-recipe",  0, "define URL", "");
    50     psMetadataAddStr(arguments, PS_LIST_TAIL, "-mosiac",  0, "define URL", "");
     54    psMetadata *updateArgs = psMetadataAlloc();
     55    psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-exp_id",  0,
     56        "define class", "");
     57    psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-filter",  0,
     58        "define filter of interest", "");
     59    psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-stat",  0,
     60        "define URL", "");
     61    psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-recipe",  0,
     62        "define URL", "");
     63    psMetadataAddStr(updateArgs, PS_LIST_TAIL, "-mosiac",  0,
     64        "define URL", "");
    5165
     66    bool argErr = false;
    5267    if (config->mode == PX_MODE_NONE) {
    53         fprintf (stderr, "search mode not specified\n");
    54         psArgumentHelp(arguments);
    55         psFree(arguments);
     68        argErr = true;
     69        fprintf (stderr, "mode argument is required\n");
     70    } else if (! psArgumentParse(args, &argc, argv) || argc != 1) {
     71        argErr = true;
     72        fprintf (stderr, "error parsing arguments\n");
     73    }
     74
     75    if (argErr) {
     76        printf("\nPan-STARRS Phase 0 Search Tool\n");
     77        printf("Usage: %s <mode> [<options>]\n\n", argv[0]);
     78        printf(" <mode> : -pending | -update\n\n");
     79        fprintf (stdout, "-pending ");
     80        psArgumentHelp(pendingArgs);
     81        fprintf (stdout, "-update ");
     82        psArgumentHelp(updateArgs);
     83        psFree(args);
     84        psFree(pendingArgs);
     85        psFree(updateArgs);
    5686        exit(EXIT_FAILURE);
    5787    }
    58 
    59     if (! psArgumentParse(arguments, &argc, argv) || argc != 1) {
    60         printf("\nPan-STARRS Phase 2 Search Tool\n\n");
    61         printf("Usage: %s [mode] [options]\n\n", argv[0]);
    62         printf(" [mode] : -quick | -define | -pending | -donee\n\n");
    63         psArgumentHelp(arguments);
    64         psFree(arguments);
    65         exit(EXIT_FAILURE);
    66     }
    67 
    68     bool status;
    69     config->camera_name = psMetadataLookupStr(&status, arguments,
    70         "-inst");
    71     config->filter = psMetadataLookupStr(&status, arguments, "-filter");
    72     config->exp_id = psMetadataLookupStr(&status, arguments, "-exp_id");
    73     config->class = psMetadataLookupStr(&status, arguments, "-class");
    74     config->class_id = psMetadataLookupStr(&status, arguments,
    75         "-class_id");
    76     config->url = psMetadataLookupStr(&status, arguments, "-url");
    7788
    7889    // XXX why is "" being returned when -[foo] isn't specified?
     
    8293    }
    8394
    84     EMPTY_TO_NULL_STRING(config->camera_name);
    85     EMPTY_TO_NULL_STRING(config->filter);
    86     EMPTY_TO_NULL_STRING(config->exp_id);
    87     EMPTY_TO_NULL_STRING(config->class);
    88     EMPTY_TO_NULL_STRING(config->class_id);
    89     EMPTY_TO_NULL_STRING(config->url);
     95    switch (config->mode) {
     96        bool status;
     97        case PX_MODE_PENDING:
     98            // -exp_id
     99            config->exp_id = psMetadataLookupStr(&status, args, "-exp_id");
     100            psMemIncrRefCounter(config->exp_id);
     101            EMPTY_TO_NULL_STRING(config->exp_id);
     102            // -inst
     103            config->camera_name = psMetadataLookupStr(&status, args, "-inst");
     104            psMemIncrRefCounter(config->camera_name);
     105            EMPTY_TO_NULL_STRING(config->camera_name);
     106            // -telescope
     107            config->camera_name = psMetadataLookupStr(&status, args,
     108                "-telescope");
     109            psMemIncrRefCounter(config->telescope);
     110            EMPTY_TO_NULL_STRING(config->telescope);
     111            // -exp_type
     112            config->class = psMetadataLookupStr(&status, args, "-exp_type");
     113            psMemIncrRefCounter(config->exp_type);
     114            EMPTY_TO_NULL_STRING(config->exp_type);
     115            // -class
     116            config->class = psMetadataLookupStr(&status, args, "-class");
     117            psMemIncrRefCounter(config->class);
     118            EMPTY_TO_NULL_STRING(config->class);
     119            break;
     120        case PX_MODE_UPDATE:
     121            // -exp_id
     122            config->exp_id = psMetadataLookupStr(&status, args, "-exp_id");
     123            psMemIncrRefCounter(config->exp_id);
     124            EMPTY_TO_NULL_STRING(config->exp_id);
     125            // -filter
     126            config->filter = psMetadataLookupStr(&status, args, "-filter");
     127            psMemIncrRefCounter(config->filter);
     128            EMPTY_TO_NULL_STRING(config->filter);
     129
     130            break;
     131        default:
     132            psAbort(argv[0], "invalid option (this should not happen)");
     133    }
     134
     135    psFree(args);
     136    psFree(pendingArgs);
     137    psFree(updateArgs);
     138
    90139
    91140    psMetadata *where = psMetadataAlloc();
     
    132181
    133182
    134     // add the input and output images to the arguments list
    135     //psMetadataAddStr (arguments, PS_LIST_TAIL, "-output", 0, "Name of the output image", argv[1]);
     183    // add the input and output images to the args list
     184    //psMetadataAddStr (args, PS_LIST_TAIL, "-output", 0, "Name of the output image", argv[1]);
    136185
    137186    // define Database handle, if used
Note: See TracChangeset for help on using the changeset viewer.