IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2007, 2:51:20 PM (19 years ago)
Author:
Paul Price
Message:

Fixing issues with file formats: some formats weren't getting the PHU where required (because the create was following the open, and the open was attempting to write the blank PHU). Added pmFPAfileBlank to write a blank where required. Cleaned up the pmFPAfile stuff a little.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAConstruct.c

    r11792 r11801  
    469469// It returns a view corresponding to the PHU
    470470static pmFPAview *addSource(pmFPA *fpa,       // The FPA
     471                            const char *fpaname, // The desired FPA name
    471472                            const pmFPAview *phuView, // The view corresponding to the PHU, or NULL
    472473                            const psMetadata *header, // The PHU header, or NULL
     
    479480    assert(format);
    480481
    481     bool mdok = true;                   // Status from metadata lookups
     482    bool mdok;                          // Status of MD lookup
     483
     484    // If FPA.NAME is already defined, new name must match it; otherwise, warn the user that something
     485    // potentially bad is happening.
     486    if (fpaname && install) {
     487        const char *currentName = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.NAME"); // Current name
     488        if (mdok && currentName && strlen(currentName) > 0 && strcmp(currentName, fpaname) != 0) {
     489            psLogMsg(__func__, PS_LOG_WARN, "FPA.NAME for new source (%s) doesn't match FPA.NAME for current "
     490                     "fpa (%s).\n", fpaname, currentName);
     491        }
     492        psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", PS_META_REPLACE, "Name of FPA", fpaname);
     493    } else if (!psMetadataLookup(fpa->concepts, "FPA.NAME")) {
     494        // Make sure there is an FPA.NAME
     495        psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", 0, "Name of FPA", "UNKNOWN");
     496    }
     497
    482498    psMetadata *fileInfo = psMetadataLookupMetadata(&mdok, format, "FILE"); // The file information
    483499    if (!mdok || !fileInfo) {
     
    759775
    760776
    761 bool pmFPAAddSourceFromView(pmFPA *fpa, const pmFPAview *phuView, const psMetadata *format)
     777bool pmFPAAddSourceFromView(pmFPA *fpa, const char *fpaname, const pmFPAview *phuView,
     778                            const psMetadata *format)
    762779{
    763780    PS_ASSERT_PTR_NON_NULL(fpa, false);
     
    765782    PS_ASSERT_PTR_NON_NULL(format, false);
    766783
    767     pmFPAview *view = addSource(fpa, phuView, NULL, format, true);
     784    pmFPAview *view = addSource(fpa, fpaname, phuView, NULL, format, true);
    768785    bool status = (view != NULL);
    769786    psFree(view);
     
    785802
    786803    // Check the name of the FPA
    787     psString newFPAname = phuNameFromHeader("FPA.NAME", fileInfo, phu); // New name for the FPA
    788     if (!newFPAname) {
    789         psError(PS_ERR_IO, true, "Unable to determine FPA.NAME : check for FPA.NAME in FILE in FORMAT");
    790         return NULL;
    791     }
    792 
    793     // If FPAname already defined, new name must match it; otherwise, warn the user that something potentially
    794     // bad is happening.
    795     const char *currentFPAname = psMetadataLookupStr(&mdok, fpa->concepts, "FPA.NAME"); // Current name
    796     if (mdok && currentFPAname && strlen(currentFPAname) > 0 && strcmp(currentFPAname, newFPAname) != 0) {
    797         psLogMsg(__func__, PS_LOG_WARN, "FPA.NAME for new source (%s) doesn't match FPA.NAME for current "
    798                  "fpa (%s).\n", newFPAname, currentFPAname);
    799     }
    800     psMetadataAddStr(fpa->concepts, PS_LIST_HEAD, "FPA.NAME", PS_META_REPLACE, "Name of FPA", newFPAname);
    801     psFree(newFPAname);                 // Drop reference
    802 
    803     return addSource(fpa, NULL, phu, format, true);
     804    psString fpaname = phuNameFromHeader("FPA.NAME", fileInfo, phu); // New name for the FPA
     805    if (!fpaname || strlen(fpaname) == 0) {
     806        psError(PS_ERR_IO, true, "Unable to determine FPA.NAME: check for FPA.NAME in FILE in camera format");
     807        return NULL;
     808    }
     809
     810    pmFPAview *view = addSource(fpa, fpaname, NULL, phu, format, true); // View of PHU, to return
     811    psFree(fpaname);
     812
     813    return view;
    804814}
    805815
     
    811821    PS_ASSERT_PTR_NON_NULL(format, NULL);
    812822
    813     return addSource(fpa, NULL, phu, format, false);
     823    return addSource(fpa, NULL, NULL, phu, format, false);
    814824}
    815825
Note: See TracChangeset for help on using the changeset viewer.