IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 2, 2008, 10:53:30 AM (18 years ago)
Author:
gusciora
Message:

Modified file reads to look for dataFiles and then ../dataFiles.
Other additions as well.
First version: tap_pmReadoutFake.c
First version: tap_pmReadoutStack.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/camera/tap_pmFPAHeader.c

    r14882 r15987  
    55#include "tap.h"
    66#include "pstap.h"
    7 // XXX: Use better name for the temporary FITS file
    8 // XXX: The code to generate and free the FPA hierarchy was copied from
    9 // tap-pmFPA.c.  EIther include it directly, or library, or something.
    10 // Also, get rid of the manual free functions and use psFree() once
    11 // it correctly frees child members
    12 // XXX: For the genSimpleFPA() code, add IDs to each function so that
    13 // the values set in each chip-?cell-?hdu-?image are unique
    14 // XXX: For the genSimpleFPA() code, write masks and weights as well
     7/* STATUS:
     8    All functions are tested.
     9*/
    1510
    1611#define CHIP_ALLOC_NAME        "ChipName"
     
    8479    cell->hdu = pmHDUAlloc(extname);
    8580    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    86         cell->readouts->data[i] = generateSimpleReadout(cell);
    87     }
    88 
    89     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     81        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     82    }
     83
     84    // First try to read data from ../dataFiles, then try dataFiles.
     85    bool rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
    9086    if (!rc) {
    91         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     87        rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
     88        if (!rc) {
     89            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     90        }
    9291    }
    9392
     
    104103    }
    105104
    106     //XXX: Should the region be set some other way?  Like through the various config files?
    107 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    108105    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    109     // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     106    // You shouldn't have to remove the key from the metadata.
    110107    psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC");
    111108    psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region);
     
    134131    psArrayRealloc(chip->cells, NUM_CELLS);
    135132    for (int i = 0 ; i < NUM_CELLS ; i++) {
    136         chip->cells->data[i] = generateSimpleCell(chip, i);
    137     }
    138 
    139     // XXX: Add code to initialize chip pmConcepts
    140 
    141 
     133        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip, i));
     134    }
    142135    return(chip);
    143136}
     
    156149    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    157150    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    158 //    fpa->hdu = pmHDUAlloc("fpaExtName");
    159 //
    160 //    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
    161 //    if (!rc) {
    162 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    163 //    }
    164151
    165152    psArrayRealloc(fpa->chips, NUM_CHIPS);
    166153    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    167         fpa->chips->data[i] = generateSimpleChip(fpa, i);
    168     }
    169 
    170     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    171     // reading code from wherever.
     154        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa, i));
     155    }
    172156    pmConceptsBlankFPA(fpa);
    173 //    bool mdok;
    174 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    175 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    176 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    177 
    178157    return(fpa);
    179158}
    180159
    181 // XXX: This should only be necessary until the psFree() functions for
    182 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    183 void myFreeCell(pmCell *cell)
    184 {
    185     for (int k = 0 ; k < cell->readouts->n ; k++) {
    186         psFree(cell->readouts->data[k]);
    187     }
    188     psFree(cell);
    189 }
    190 
    191 void myFreeChip(pmChip *chip) {
    192     for (int j = 0 ; j < chip->cells->n ; j++) {
    193         myFreeCell(chip->cells->data[j]);
    194     }
    195     psFree(chip);
    196 }
    197 
    198 void myFreeFPA(pmFPA *fpa)
    199 {
    200     for (int i = 0 ; i < fpa->chips->n ; i++) {
    201         myFreeChip(fpa->chips->data[i]);
    202     }
    203     psFree(fpa);
    204 }
    205160
    206161
     
    210165    psLogSetLevel(PS_LOG_INFO);
    211166    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    212     plan_tests(25);
     167    plan_tests(75);
    213168
    214169
     
    225180        ok(cell != NULL, "Allocated a pmCell successfully");
    226181        ok(!pmCellReadHeader(cell, NULL), "pmCellReadHeader(cell, NULL) returned FALSE");
    227         myFreeFPA(fpa);
     182        psFree(fpa);
    228183        psFree(camera);
    229184        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    245200    {
    246201        psMemId id = psMemGetId();
    247 
    248202        // Create a FITS file for this test
    249203        psFits* fitsFileW = psFitsOpen(fitsFilename, "w");
     
    264218            psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING,
    265219                         "String Item", extname);
    266             bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     220            bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     221            if (!rc) {
     222                rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     223            }
    267224            ok(rc == true, "pmConfigFileRead() was successful");
    268225            rc = pmHDUWrite(hdu, fitsFileW);
     
    289246        // elsewhere.  However, if we should test it, test it here.
    290247
    291         myFreeFPA(fpa);
     248        psFree(fpa);
    292249        psFree(camera);
    293250        psFree(fitsFileR);
     
    308265        ok(cell != NULL, "Allocated a pmCell successfully");
    309266        ok(!pmChipReadHeader(chip, NULL), "pmChipReadHeader(chip, NULL) returned FALSE");
    310         myFreeFPA(fpa);
     267        psFree(fpa);
    311268        psFree(camera);
    312269        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    347304            psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING,
    348305                         "String Item", extname);
    349             bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     306            bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     307            if (!rc) {
     308               rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     309            }
    350310            ok(rc == true, "pmConfigFileRead() was successful");
    351311            rc = pmHDUWrite(hdu, fitsFileW);
     
    382342        // elsewhere.  However, if we should test it, test it here.
    383343
    384         myFreeFPA(fpa);
     344        psFree(fpa);
    385345        psFree(camera);
    386346        psFree(fitsFileR);
     
    401361        ok(cell != NULL, "Allocated a pmCell successfully");
    402362        ok(!pmFPAReadHeader(fpa, NULL), "pmFPAReadHeader(fpa, NULL) returned FALSE");
    403         myFreeFPA(fpa);
     363        psFree(fpa);
    404364        psFree(camera);
    405365        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     
    440400            psMetadataAdd(hdu->header, PS_LIST_TAIL, "MYSTR", PS_DATA_STRING,
    441401                         "String Item", extname);
    442             bool rc = pmConfigFileRead(&hdu->format, "data/camera0/format0.config", "Camera 0 Config Format");
     402            bool rc = pmConfigFileRead(&hdu->format, "../dataFiles/camera0/format0.config", "Camera 0 Config Format");
     403            if (!rc) {
     404                rc = pmConfigFileRead(&hdu->format, "dataFiles/camera0/format0.config", "Camera 0 Config Format");
     405            }
    443406            ok(rc == true, "pmConfigFileRead() was successful");
    444407            rc = pmHDUWrite(hdu, fitsFileW);
     
    476439        // elsewhere.  However, if we should test it, test it here.
    477440
    478         myFreeFPA(fpa);
     441        psFree(fpa);
    479442        psFree(camera);
    480443        psFree(fitsFileR);
    481444        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    482445    }
    483 
    484 
    485 
    486 
    487 }
    488 
     446}
     447
Note: See TracChangeset for help on using the changeset viewer.