IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 2, 2006, 3:02:08 PM (20 years ago)
Author:
Paul Price
Message:

Applying RHL patch. Generally improves the error handling and traceback. pmConcepts.c and pmConceptsRead.c done by PAP (RHL did this also, but I had already done them). Resolved conflicts, except for pmFPAfile.c, which uses psAbort in some instances where RHL's patch had psError; leave this for Gene to decide.

Location:
trunk/psModules/src/concepts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConcepts.c

    r7310 r7311  
    131131    }
    132132
     133    bool success = true;                // Success in reading concepts?
    133134    if (source & PM_CONCEPT_SOURCE_CAMERA && !(*read & PM_CONCEPT_SOURCE_CAMERA)) {
    134         pmConceptsReadFromCamera(*specs, cell, target);
    135         *read |= PM_CONCEPT_SOURCE_CAMERA;
     135        if (pmConceptsReadFromCamera(*specs, cell, target)) {
     136            *read |= PM_CONCEPT_SOURCE_CAMERA;
     137        } else {
     138            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from camera configuration.\n");
     139            success = false;
     140        }
    136141    }
    137142
    138143    if (source & PM_CONCEPT_SOURCE_DEFAULTS && !(*read & PM_CONCEPT_SOURCE_DEFAULTS)) {
    139         pmConceptsReadFromDefaults(*specs, fpa, chip, cell, target);
    140         *read |= PM_CONCEPT_SOURCE_DEFAULTS;
     144        if (pmConceptsReadFromDefaults(*specs, fpa, chip, cell, target)) {
     145            *read |= PM_CONCEPT_SOURCE_DEFAULTS;
     146        } else {
     147            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from defaults.\n");
     148            success = false;
     149        }
    141150    }
    142151
    143152    if (source & PM_CONCEPT_SOURCE_HEADER && !(*read & PM_CONCEPT_SOURCE_HEADER)) {
    144         pmConceptsReadFromHeader(*specs, fpa, chip, cell, target);
    145         *read |= PM_CONCEPT_SOURCE_HEADER;
    146     }
    147 
     153        if (pmConceptsReadFromHeader(*specs, fpa, chip, cell, target)) {
     154            *read |= PM_CONCEPT_SOURCE_HEADER;
     155        } else {
     156            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from header.\n");
     157            success = false;
     158        }
     159    }
     160
     161    #ifndef OMIT_PSDB
    148162    if (source & PM_CONCEPT_SOURCE_DATABASE && !(*read & PM_CONCEPT_SOURCE_DATABASE)) {
    149         pmConceptsReadFromDatabase(*specs, fpa, chip, cell, db, target);
    150         *read |= PM_CONCEPT_SOURCE_DATABASE;
    151     }
    152 
    153     return true;
     163        if (pmConceptsReadFromDatabase(*specs, fpa, chip, cell, db, target)) {
     164            *read |= PM_CONCEPT_SOURCE_DATABASE;
     165        } else {
     166            psError(PS_ERR_UNKNOWN, false, "Error reading concepts from database.\n");
     167            success = false;
     168        }
     169    }
     170    #endif
     171
     172    return success;
    154173}
    155174
  • trunk/psModules/src/concepts/pmConcepts.h

    r7017 r7311  
    66
    77// Function to call to parse a concept once it has been read
    8 typedef psMetadataItem* (*pmConceptParseFunc)(psMetadataItem *concept, psMetadataItem *pattern, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell);
     8typedef psMetadataItem* (*pmConceptParseFunc)(const psMetadataItem *concept, const psMetadataItem *pattern, const psMetadata *cameraFormat, const pmFPA *fpa, const pmChip *chip, const pmCell *cell);
    99// Function to call to format a concept for writing
    10 typedef psMetadataItem* (*pmConceptFormatFunc)(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell);
     10typedef psMetadataItem* (*pmConceptFormatFunc)(const psMetadataItem *concept, const psMetadata *cameraFormat, const pmFPA *fpa, const pmChip *chip, const pmCell *cell);
    1111
    1212// A "concept" specification
  • trunk/psModules/src/concepts/pmConceptsRead.c

    r7280 r7311  
    7171        parsed = parsePlain(concept, spec->blank);
    7272    }
    73     if (!parsed)
    74         return false;
     73    if (!parsed) {
     74        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s\n", spec->blank->name);
     75        return false;
     76    }
    7577
    7678    // Plug the parsed concept into a new psMetadataItem, so each "concept" has its own version that can
     
    117119
    118120    pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level
    119     if (! hdu) {
     121    if (!hdu) {
    120122        return false;
    121123    }
     
    124126    psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
    125127    psMetadataItem *specItem = NULL;    // Item from the specs metadata
     128    bool status = true;                 // Status of reading concepts
    126129    while ((specItem = psMetadataGetAndIncrement(specsIter))) {
    127130        pmConceptSpec *spec = specItem->data.V; // The specification
    128131        psString name = specItem->name; // The concept name
    129132        psMetadataItem *conceptItem = psMetadataLookup(cellConfig, name); // The concept, or NULL
    130         psMetadataItem *value = NULL; // The value of the concept
    131133        if (conceptItem) {
    132134            if (conceptItem->type == PS_DATA_STRING) {
     
    138140                psFree(nameSource);
    139141                if (mdok && strlen(source) > 0 && strcasecmp(source, "VALUE") == 0) {
    140                     value = conceptItem;
    141                     conceptParse(spec, value, cameraFormat, target, NULL, NULL, cell);
     142                    if (!conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell)) {
     143                        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from camera "
     144                                "configuration\n", name);
     145                        status = false;
     146                    }
    142147                } else if (source && (strlen(source) == 0 || strcasecmp(source, "HEADER") != 0)) {
    143148                    // We leave "HEADER" to pmConceptsReadFromHeader
     
    148153            } else {
    149154                // Another type --- should be OK
    150                 conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell);
     155                if (!conceptParse(spec, conceptItem, cameraFormat, target, NULL, NULL, cell)) {
     156                    psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from camera "
     157                            "configuration.  It has a weird %s.SOURCE: %s\n", name, name);
     158                    status = false;
     159                }
    151160            }
    152161        }
    153162    }
    154163    psFree(specsIter);
    155     return true;
     164    return status;
    156165}
    157166
     
    179188    psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
    180189    psMetadataItem *specItem = NULL;    // Item from the specs metadata
     190    bool status = true;                 // Status of reading concepts
    181191    while ((specItem = psMetadataGetAndIncrement(specsIter))) {
    182192        pmConceptSpec *spec = specItem->data.V; // The specification
    183193        psString name = specItem->name; // The concept name
    184194        psMetadataItem *conceptItem = psMetadataLookup(defaults, name); // The concept, or NULL
    185         conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell);
     195        if (conceptItem && !conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell)) {
     196            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from DEFAULTS.\n", name);
     197            status = false;
     198        }
    186199    }
    187200    psFree(specsIter);
    188     return true;
     201    return status;
    189202}
    190203
     
    213226    psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
    214227    psMetadataItem *specItem = NULL;    // Item from the specs metadata
     228    bool status = true;                 // Status of reading concepts
    215229    while ((specItem = psMetadataGetAndIncrement(specsIter))) {
    216230        pmConceptSpec *spec = specItem->data.V; // The specification
     
    257271
    258272        // This will also clean up the name
    259         conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell);
     273        if (headerItem && !conceptParse(spec, headerItem, cameraFormat, target, fpa, chip, cell)) {
     274            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from header.\n", name);
     275            status = false;
     276        }
    260277    }
    261278    psFree(specsIter);
    262     return true;
     279    return status;
    263280}
    264281
     
    294311    psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator
    295312    psMetadataItem *specItem = NULL;    // Item from the specs metadata
     313    bool status = true;                 // Status of reading concepts
    296314    while ((specItem = psMetadataGetAndIncrement(specsIter))) {
    297315        pmConceptSpec *spec = specItem->data.V; // The specification
     
    374392
    375393                    // Now we have the result
    376                     conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell);
     394                    if (!conceptParse(spec, conceptItem, cameraFormat, target, fpa, chip, cell)) {
     395                        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to parse concept %s from database.\n",
     396                                name);
     397                        status = false;
     398                    }
    377399
    378400                }
     
    385407    psFree(specsIter);
    386408
    387     return true;
     409    return status;
    388410    #endif
    389411}
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r7281 r7311  
    6969                    sscanf(concept->data.V, "%d %d %f", &big, &medium, &small) != 3)
    7070            {
    71                 psError(PS_ERR_IO, true, "Cannot interpret FPA.RA: %s\n", concept->data.V);
     71                psError(PS_ERR_UNKNOWN, true, "Cannot interpret FPA.RA: %s\n", concept->data.V);
    7272                break;
    7373            }
     
    8080        break;
    8181    default:
    82         psError(PS_ERR_IO, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type);
     82        psError(PS_ERR_UNKNOWN, true, "%s concept is of an unexpected type: %x\n", pattern->name, concept->type);
    8383        return NULL;
    8484    }
     
    171171    assert(pattern);
    172172
    173     psRegion *trimsec = psAlloc(sizeof(psRegion)); // Make space for a psRegion (usually passed by value)
     173    psRegion *trimsec = psRegionAlloc(0, 0, 0, 0);
    174174
    175175    if (concept->type != PS_DATA_STRING) {
    176         psError(PS_ERR_IO, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type);
    177         *trimsec = psRegionSet(0.0, 0.0, 0.0, 0.0);
     176        psError(PS_ERR_UNKNOWN, true, "CELL.TRIMSEC after read is not of type STR (%x)\n", concept->type);
    178177    } else {
    179178        *trimsec = psRegionFromString(concept->data.V);
     
    231230        }
    232231    default:
    233         psError(PS_ERR_IO, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "
     232        psError(PS_ERR_UNKNOWN, true, "CELL.BIASSEC after read is not of type STRING or LIST --- assuming "
    234233                "blank.\n");
    235234    }
     
    259258                    (strcmp(pattern->name, "CELL.YBIN") == 0 && sscanf(binString, "%*d %d", &binning) != 1 &&
    260259                     sscanf(binString, "%*d,%d", &binning) != 1)) {
    261                 psError(PS_ERR_IO, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
     260                psError(PS_ERR_UNKNOWN, true, "Unable to parse string to get %s: %s\n", pattern->name, binString);
    262261            }
    263262        }
     
    269268        TYPE_CASE(binning, concept, S32);
    270269    default:
    271         psError(PS_ERR_IO, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
     270        psError(PS_ERR_UNKNOWN, true, "Note sure how to parse %s of type %x --- assuming 1.\n", pattern->name,
    272271                concept->type);
    273272    }
     
    290289    psString sys = concept->data.V;     // The time system string
    291290    if (concept->type != PS_DATA_STRING || strlen(sys) <= 0) {
    292         psError(PS_ERR_IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
     291        psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
    293292    } else if (strcasecmp(sys, "TAI") == 0) {
    294293        timeSys = PS_TIME_TAI;
     
    300299        timeSys = PS_TIME_TT;
    301300    } else {
    302         psError(PS_ERR_IO, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
     301        psError(PS_ERR_UNKNOWN, true, "Can't interpret CELL.TIMESYS --- assuming UTC.\n");
    303302    }
    304303
     
    334333    // Get format
    335334    psMetadata *formats = psMetadataLookupMD(&mdok, cameraFormat, "FORMATS");
    336     if (!mdok || !formats)
     335    if (!mdok || !formats) {
     336        psError(PS_ERR_UNKNOWN, false, "Unable to find FORMATS in camera configuration.\n");
    337337        return NULL;
     338    }
    338339
    339340    psString timeFormat = psMetadataLookupStr(&mdok, formats, "CELL.TIME");
    340     if (!mdok || !timeFormat || !strlen(timeFormat))
     341    if (!mdok || !timeFormat || !strlen(timeFormat)) {
     342        psError(PS_ERR_UNKNOWN, false, "Unable to find CELL.TIME in FORMATS.\n");
    341343        return NULL;
     344    }
    342345
    343346    // Parse the time format
     
    385388            psMetadataItem *timeItem = psListGet(dateTime, PS_LIST_HEAD + 1); // Item containing the time
    386389            if (dateItem->type != PS_DATA_STRING) {
    387                 psError(PS_ERR_IO, true, "Date is not of type STR.\n");
     390                psError(PS_ERR_UNKNOWN, true, "Date is not of type STR.\n");
    388391                return NULL;
    389392            }
     
    392395            if (sscanf(dateString, "%d-%d-%d", &year, &month, &day) != 3 &&
    393396                    sscanf(dateString, "%d/%d/%d", &year, &month, &day) != 3) {
    394                 psError(PS_ERR_IO, true, "Unable to read date: %s\n", dateString);
     397                psError(PS_ERR_UNKNOWN, true, "Unable to read date: %s\n", dateString);
    395398                return NULL;
    396399            }
     
    408411                year = temp;
    409412            }
    410             if (pre2000Time || year < 2000) {
    411                 year += 2000;
    412             }
     413            if (year < 100) {
     414                if (pre2000Time) {
     415                    year += 1900;
     416                } else {
     417                    year += 2000;
     418                }
     419            }
     420            sprintf(dateString,"%04d-%02d-%02d", year, month, day);
     421
    413422            psString timeString = NULL; // The string with the time
    414423            if (timeItem->type == PS_DATA_STRING) {
     
    427436                    TYPE_CASE(seconds, timeItem, F64);
    428437                default:
    429                     psError(PS_ERR_IO, true, "Time is not of an expected type: %x\n", timeItem->type);
     438                    psError(PS_ERR_UNKNOWN, true, "Time is not of an expected type: %x\n", timeItem->type);
    430439                    return NULL;
    431440                }
     
    440449            psStringAppend(&dateTimeString, "%sT%s", dateString, timeString);
    441450            time = psTimeFromISO(dateTimeString, timeSys);
     451            psFree(dateTimeString);
    442452            break;
    443453        }
     
    463473                time = psTimeFromMJD(timeValue);
    464474            } else {
    465                 psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue);
     475                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n",
     476                        timeValue);
    466477                time = psTimeFromJD(timeValue);
    467478            }
     
    475486                time = psTimeFromMJD(timeValue);
    476487            } else {
    477                 psError(PS_ERR_IO, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n", timeValue);
     488                psError(PS_ERR_UNKNOWN, true, "Not sure how to parse CELL.TIME (%f) --- trying JD\n",
     489                        timeValue);
    478490                time = psTimeFromJD(timeValue);
    479491            }
     
    481493        }
    482494    default:
    483         psError(PS_ERR_IO, true, "Unable to parse CELL.TIME.\n");
     495        psError(PS_ERR_UNKNOWN, true, "Unable to parse CELL.TIME.\n");
    484496        return NULL;
    485497    }
     
    526538        TYPE_CASE(offset, concept, S32);
    527539    default:
    528         psError(PS_ERR_IO, true, "Concept %s is not of integer type, as expected.\n", pattern->name);
     540        psError(PS_ERR_UNKNOWN, true, "Concept %s is not of integer type, as expected.\n", pattern->name);
    529541        return NULL;
    530542    }
     
    724736        // XXX: Couldn't be bothered doing these right now
    725737        if (pre2000Time) {
    726             psError(PS_ERR_IO, true, "Don't you realise it's the twenty-first century?\n");
     738            psError(PS_ERR_UNKNOWN, true, "Don't you realise it's the twenty-first century?\n");
    727739            return NULL;
    728740        }
    729741        if (backwardsTime) {
    730             psError(PS_ERR_IO, true, "You want it BACKWARDS?  Not right now, thanks.\n");
     742            psError(PS_ERR_UNKNOWN, true, "You want it BACKWARDS?  Not right now, thanks.\n");
    731743            return NULL;
    732744        }
    733745        if (usaTime) {
    734             psError(PS_ERR_IO, true, "USA?  No OK --- yet.\n");
     746            psError(PS_ERR_UNKNOWN, true, "USA?  No OK.\n");
    735747            return NULL;
    736748        }
     
    778790
    779791    if (concept->type != PS_TYPE_S32) {
    780         psError(PS_ERR_IO, true, "Concept %s is not of type S32, as expected.\n", concept->name);
     792        psError(PS_ERR_UNKNOWN, true, "Concept %s is not of type S32, as expected.\n", concept->name);
    781793        return NULL;
    782794    }
Note: See TracChangeset for help on using the changeset viewer.