IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 23, 2007, 5:11:19 PM (19 years ago)
Author:
Paul Price
Message:

Enabling different formats for output pmFPAfiles. To do this, needed to overhaul the writing functions to generate a new FPA using the new format, and write that. To get the blank PHU, needed to do similarly for the open function (!), since it writes blanks immediately after opening the file. Tested with inputting 6 megacam split chips and writing to spliced format --- works successfully.

File:
1 edited

Legend:

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

    r11242 r11255  
    106106}
    107107
     108// Check the various levels for file operations to make sure that they are suitable based on the format
     109static void adjustLevels(pmFPAfile *file, // File for which to adjust levels
     110                         const psMetadata *format // Format to use to adjust levels
     111                        )
     112{
     113    assert(file);
     114    assert(format);
     115
     116
     117    return;
     118}
     119
    108120// define a pmFPAfile, bind to the optional fpa if supplied
    109121pmFPAfile *pmFPAfileDefineOutput(pmConfig *config, pmFPA *fpa, const char *name)
     
    167179    }
    168180
    169     file->fileLevel = pmFPALevelFromName(psMetadataLookupStr(&status, data, "FILE.LEVEL"));
     181    file->camera = psMemIncrRefCounter(config->camera);
     182    const char *formatName = psMetadataLookupStr (&status, data, "FILE.FORMAT");
     183    psMetadata *format = NULL;          // Camera format to use
     184    if (formatName && strcasecmp(formatName, "NONE") != 0) {
     185        // select the format list from the selected camera
     186        psMetadata *formats = psMetadataLookupMetadata(&status, file->camera, "FORMATS"); // List of formats
     187
     188        // select the desired format
     189        format = psMetadataLookupMetadata(&status, formats, formatName);
     190        if (!format) {
     191            psError(PS_ERR_IO, false, "format %s for %s not defined", formatName, name);
     192            psFree(file);
     193            return NULL;
     194        }
     195        file->format = psMemIncrRefCounter(format);
     196        #if 0
     197
     198        file->src = psMemIncrRefCounter(fpa);
     199        file->fpa = pmFPAConstruct(file->camera);
     200        #endif
     201
     202    } else {
     203        format = config->format;
     204        #if 0
     205
     206        file->fpa = psMemIncrRefCounter(fpa);
     207        #endif
     208
     209    }
     210    #if 1
     211    file->fpa = psMemIncrRefCounter(fpa);
     212    #endif
     213
     214
     215    file->fileLevel = pmFPAPHULevel(format);
    170216    if (file->fileLevel == PM_FPA_LEVEL_NONE) {
    171         psError(PS_ERR_IO, true, "FILE.LEVEL is not set for %s\n", name);
    172         return NULL;
    173     }
    174 
    175     file->dataLevel = pmFPALevelFromName(psMetadataLookupStr (&status, data, "DATA.LEVEL"));
     217        psError(PS_ERR_IO, true, "Unable to determine file level for %s\n", name);
     218        return NULL;
     219    }
     220
     221    file->dataLevel = pmFPALevelFromName(psMetadataLookupStr(&status, data, "DATA.LEVEL"));
    176222    if (file->dataLevel == PM_FPA_LEVEL_NONE) {
    177223        psError(PS_ERR_IO, true, "DATA.LEVEL is not set for %s\n", name);
     
    182228    file->freeLevel = file->dataLevel;
    183229
    184     if (fpa != NULL) {
    185         file->fpa = psMemIncrRefCounter(fpa);
    186     }
    187 
    188     #if 0
    189     // for WRITE type of data, the output format needs to be determined
    190     // this is only needed if the output file is not identical in structure to the input?
    191     // for
    192     char *formatLine = psMetadataLookupStr (&status, data, "FILE.FORMAT");
    193     if (formatLine && strcasecmp (formatLine, "NONE")) {
    194 
    195         char *formatName = NULL;
    196 
    197         psArray *words = psStringSplitArray (formatLine, ":", false);
    198         if (!words || !words->n) {
    199             psAbort("pmFPAfileDefine", "programming error: cannot be NULL or empty!");
    200         }
    201         if (words->n == 1) {
    202             // format selected in this camera
    203             formatName = formatLine;
    204             file->camera = psMemIncrRefCounter (config->camera);
    205         }
    206         if (words->n == 2) {
    207             // select the requested camera
    208             formatName = words->data[1];
    209             file->camera = pmConfigCameraByName(config, words->data[0]);
    210             // XXX do we need to save the camera name?
    211             if (!file->camera) {
    212                 psError(PS_ERR_IO, false, "camera %s not found\n", (char *)words->data[0]);
    213                 psFree(words);
    214                 return NULL;
    215             }
    216         }
    217 
    218         // select the format list from the selected camera
    219         psMetadata *formats = psMetadataLookupMetadata(&status, file->camera, "FORMATS"); // List of formats
    220 
    221         // select the desired format
    222         char *formatFile = psMetadataLookupStr (&status, formats, formatName);
    223         if (!formatFile) {
    224             psError(PS_ERR_IO, false, "format %s for %s not defined", formatName, name);
    225             psFree (file);
    226             psFree (words);
    227             return NULL;
    228         }
    229         pmConfigFileRead(&file->format, formatFile, formatName);
    230         psFree (words);
    231     }
    232     #endif
     230    pmFPALevel extLevel = pmFPAExtensionsLevel(format); // Level for extensions
     231    if (extLevel != PM_FPA_LEVEL_NONE) {
     232        if (extLevel < file->dataLevel) {
     233            psWarning("Level for extensions is higher than desired data level --- adjusting.\n");
     234            file->dataLevel = extLevel;
     235        }
     236        if (extLevel < file->freeLevel) {
     237            psWarning("Level for extensions is higher than desired free level --- adjusting.\n");
     238            file->freeLevel = extLevel;
     239        }
     240    }
     241    adjustLevels(file, format);
     242
    233243
    234244    // add argument-supplied OUTPUT name to this file
    235245    char *outname = psMetadataLookupStr(&status, config->arguments, "OUTPUT");
    236     psMetadataAddStr (file->names, PS_LIST_TAIL, "OUTPUT", PS_META_NO_REPLACE, "", outname);
     246    psMetadataAddStr(file->names, PS_LIST_TAIL, "OUTPUT", PS_META_NO_REPLACE, "", outname);
    237247
    238248    // place the resulting file in the config system
     
    241251    return (file); // the returned value is a view into the version on 'files'
    242252}
     253
    243254
    244255// search for argname on the config->argument list
Note: See TracChangeset for help on using the changeset viewer.