IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2010, 3:55:49 PM (16 years ago)
Author:
eugene
Message:

update merges from trunk

Location:
branches/eam_branches/20100225
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20100225

  • branches/eam_branches/20100225/ppStack/src/ppStack.c

    r27076 r27517  
    1919    psTimerStart("PPSTACK_STEPS");
    2020
     21    pmErrorRegister();
     22    ppStackErrorRegister();
     23    psphotErrorRegister();
     24
    2125    pmConfig *config = pmConfigRead(&argc, argv, PPSTACK_RECIPE); // Configuration
     26    ppStackOptions *options = NULL;                               // Options for stacking
    2227    if (!config) {
    2328        goto die;
     
    5055    }
    5156
    52     if (!ppStackLoop(config)) {
     57    options = ppStackOptionsAlloc();
     58    if (!ppStackLoop(config, options)) {
    5359        goto die;
    5460    }
     
    5864    // Common code for the death.
    5965    {
    60         psExit exitValue = PS_EXIT_SUCCESS;        // Exit value for program
    61         psErrorCode errorCode = psErrorCodeLast(); // Error code
    62         if (errorCode != PS_ERR_NONE) {
    63             psErrorStackPrint(stderr, "Unable to perform stack.");
    64             switch (errorCode) {
    65               case PPSTACK_ERR_UNKNOWN:
    66               case PS_ERR_UNKNOWN:
    67                 exitValue = PS_EXIT_UNKNOWN_ERROR;
    68                 break;
    69               case PS_ERR_IO:
    70               case PS_ERR_DB_CLIENT:
    71               case PS_ERR_DB_SERVER:
    72               case PS_ERR_BAD_FITS:
    73               case PS_ERR_OS_CALL_FAILED:
    74               case PPSTACK_ERR_IO:
    75                 exitValue = PS_EXIT_SYS_ERROR;
    76                 break;
    77               case PS_ERR_BAD_PARAMETER_VALUE:
    78               case PS_ERR_BAD_PARAMETER_TYPE:
    79               case PS_ERR_BAD_PARAMETER_NULL:
    80               case PS_ERR_BAD_PARAMETER_SIZE:
    81               case PPSTACK_ERR_ARGUMENTS:
    82               case PPSTACK_ERR_CONFIG:
    83                 exitValue = PS_EXIT_CONFIG_ERROR;
    84                 break;
    85               case PPSTACK_ERR_PSF:
    86               case PPSTACK_ERR_REJECTED:
    87               case PPSTACK_ERR_DATA:
    88                 exitValue = PS_EXIT_DATA_ERROR;
    89                 break;
    90               case PS_ERR_UNEXPECTED_NULL:
    91               case PS_ERR_PROGRAMMING:
    92               case PPSTACK_ERR_NOT_IMPLEMENTED:
    93               case PPSTACK_ERR_PROG:
    94               default:
    95                 // It's a programming error if we're not dealing with the error correctly
    96                 exitValue = PS_EXIT_PROG_ERROR;
    97                 break;
    98             }
    99         }
     66        psExit exitValue = ppStackExitCode(PS_EXIT_SUCCESS); // Exit code
    10067
    10168        // Ensure everything closes
     
    10370            ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true);
    10471            ppStackFileActivation(config, PPSTACK_FILES_CONVOLVE, true);
    105             ppStackFileActivation(config, PPSTACK_FILES_COMBINE, true);
     72            ppStackFileActivation(config, PPSTACK_FILES_STACK, true);
     73            ppStackFileActivation(config, PPSTACK_FILES_UNCONV, true);
    10674            ppStackFileActivation(config, PPSTACK_FILES_PHOT, true);
    10775            if (!ppStackFilesIterateUp(config)) {
    108                 psErrorStackPrint(stderr, "Unable to close files.");
     76                psError(psErrorCodeLast(), false, "Unable to close files.");
     77                exitValue = ppStackExitCode(exitValue);
     78                pmFPAfileFreeSetStrict(false);
    10979            }
     80        }
     81
     82        // Write out summary statistics
     83        if (options && options->stats) {
     84
     85            psMetadataAddS32(options->stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE,
     86                             "Bad data quality flag", options->quality);
     87            psMetadataAddF32(options->stats, PS_LIST_TAIL, "TIME_STACK", 0,
     88                             "Total time", psTimerClear("PPSTACK_TOTAL"));
     89
     90            const char *statsMDC = psMetadataConfigFormat(options->stats);
     91            if (!statsMDC || strlen(statsMDC) == 0) {
     92                psError(PS_ERR_IO, false, "Unable to get statistics MDC file.");
     93                return false;
     94            }
     95            if (fprintf(options->statsFile, "%s", statsMDC) != strlen(statsMDC)) {
     96                psError(PS_ERR_IO, false, "Unable to write statistics MDC file.");
     97                return false;
     98            }
     99            psFree(statsMDC);
     100            if (fclose(options->statsFile) == EOF) {
     101                psError(PS_ERR_IO, false, "Unable to close statistics MDC file.");
     102                return false;
     103            }
     104            options->statsFile = NULL;
     105            pmConfigRunFilenameAddWrite(config, "STATS",
     106                                        psMetadataLookupStr(NULL, config->arguments, "STATS"));
     107        }
     108        psFree(options);
     109
     110        // Dump configuration
     111        bool mdok;                                                                    // Status of MD lookup
     112        psString dump = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); // File for config
     113        if (dump && !pmConfigDump(config, dump)) {
     114            psError(psErrorCodeLast(), false, "Unable to dump configuration.");
     115            exitValue = ppStackExitCode(exitValue);
    110116        }
    111117
     
    119125        pmVisualClose();
    120126
     127        exitValue = ppStackExitCode(exitValue);
    121128        exit(exitValue);
    122129    }
Note: See TracChangeset for help on using the changeset viewer.