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_pmFPAUtils.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"
     
    8176    cell->hdu = pmHDUAlloc("cellExtName");
    8277    for (int i = 0 ; i < NUM_READOUTS ; i++) {
    83         cell->readouts->data[i] = generateSimpleReadout(cell);
    84     }
    85 
    86     bool rc = pmConfigFileRead(&cell->hdu->format, "data/camera0/format0.config", "Camera format 0");
     78        cell->readouts->data[i] = psMemDecrRefCounter((psPtr) generateSimpleReadout(cell));
     79    }
     80
     81    // First try to read data from ../dataFiles, then try dataFiles.
     82    bool rc = pmConfigFileRead(&cell->hdu->format, "dataFiles/camera0/format0.config", "Camera format 0");
    8783    if (!rc) {
    88         diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     84        rc = pmConfigFileRead(&cell->hdu->format, "../dataFiles/camera0/format0.config", "Camera format 0");
     85        if (!rc) {
     86            diag("pmConfigFileRead() was unsuccessful (from generateSimpleCell())");
     87        }
    8988    }
    9089
     
    102101
    103102    //XXX: Should the region be set some other way?  Like through the various config files?
    104 //    psRegion *region = psRegionAlloc(0.0, TEST_NUM_COLS-1, 0.0, TEST_NUM_ROWS-1);
    105103    psRegion *region = psRegionAlloc(0.0, 0.0, 0.0, 0.0);
    106     // You shouldn't have to remove the key from the metadata.  Find out how to simply change the key value.
     104    // You shouldn't have to remove the key from the metadata.
    107105    psMetadataRemoveKey(cell->concepts, "CELL.TRIMSEC");
    108106    psMetadataAddPtr(cell->concepts, PS_LIST_TAIL|PS_META_REPLACE, "CELL.TRIMSEC", PS_DATA_REGION, "I am a region", region);
     
    122120    psMetadataAddS32(chip->analysis, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    123121    psMetadataAddS32(chip->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    124 //    chip->hdu = pmHDUAlloc("chipExtName");
    125 //
    126 //    bool rc = pmConfigFileRead(&chip->hdu->format, "data/camera0/format0.config", "Camera format 0");
    127 //    if (!rc) {
    128 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleChip())");
    129 //    }
    130 //
     122
    131123    psArrayRealloc(chip->cells, NUM_CELLS);
    132124    for (int i = 0 ; i < NUM_CELLS ; i++) {
    133         chip->cells->data[i] = generateSimpleCell(chip);
    134     }
    135 
    136     // XXX: Add code to initialize chip pmConcepts
    137 
    138 
     125        chip->cells->data[i] = psMemDecrRefCounter((psPtr) generateSimpleCell(chip));
     126    }
    139127    return(chip);
    140128}
     
    153141    psMetadataAddS32((psMetadata *) fpa->camera, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    154142    psMetadataAddS32(fpa->concepts, PS_LIST_HEAD, MISC_NAME, 0, NULL, MISC_NUM);
    155 //    fpa->hdu = pmHDUAlloc("fpaExtName");
    156 //
    157 //    bool rc = pmConfigFileRead(&fpa->hdu->format, "data/camera0/format0.config", "Camera format 0");
    158 //    if (!rc) {
    159 //        diag("pmConfigFileRead() was unsuccessful (from generateSimpleFPA())");
    160 //    }
    161143
    162144    psArrayRealloc(fpa->chips, NUM_CHIPS);
    163145    for (int i = 0 ; i < NUM_CHIPS ; i++) {
    164         fpa->chips->data[i] = generateSimpleChip(fpa);
    165     }
    166 
    167     // XXX: Eventually, when you finish the pmConcepts tests, add full concept
    168     // reading code from wherever.
     146        fpa->chips->data[i] = psMemDecrRefCounter((psPtr) generateSimpleChip(fpa));
     147    }
    169148    pmConceptsBlankFPA(fpa);
    170 //    bool mdok;
    171 //    psMetadata *fileData = psMetadataLookupMetadata(&mdok, fpa->hdu->format, "FILE");
    172 //    char *fpaNameHdr = psMetadataLookupStr(&mdok, fileData, "FPA.NAME");
    173 //    psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.NAME", PS_META_REPLACE, NULL, fpaNameHdr);
    174 
    175149    return(fpa);
    176 }
    177 
    178 // XXX: This should only be necessary until the psFree() functions for
    179 // FPA/chip/cell/readout correctly free all child chips/cells/readouts
    180 void myFreeCell(pmCell *cell)
    181 {
    182     for (int k = 0 ; k < cell->readouts->n ; k++) {
    183         psFree(cell->readouts->data[k]);
    184     }
    185     psFree(cell);
    186 }
    187 
    188 void myFreeChip(pmChip *chip) {
    189     for (int j = 0 ; j < chip->cells->n ; j++) {
    190         myFreeCell(chip->cells->data[j]);
    191     }
    192     psFree(chip);
    193 }
    194 
    195 void myFreeFPA(pmFPA *fpa)
    196 {
    197     for (int i = 0 ; i < fpa->chips->n ; i++) {
    198         myFreeChip(fpa->chips->data[i]);
    199     }
    200     psFree(fpa);
    201150}
    202151
     
    207156    psLogSetLevel(PS_LOG_INFO);
    208157    psTraceSetLevel("err", ERR_TRACE_LEVEL);
    209     plan_tests(72);
     158    plan_tests(40);
     159
    210160
    211161    // ----------------------------------------------------------------------
    212     // int pmFPAFindChip(const pmFPA *fpa, const char *name)
    213     {
    214         psMemId id = psMemGetId();
    215         int rc = pmFPAFindChip(NULL, "bogus");
    216         ok(-1 == rc, "pmFPAFindChip() returns -1 with NULL pmFPA input param");
    217         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    218     }
    219 
    220 
    221     // ----------------------------------------------------------------------
    222     // int pmFPAFindChip(const pmFPA *fpa, const char *name)
     162    // pmFPAFindChip() tests
     163    // Call pmFPAFindChip() with NULL pmFPA input parameter
     164    {
     165        psMemId id = psMemGetId();
     166        int rc = pmFPAFindChip(NULL, "chip-0");
     167        ok(-1 == rc, "pmFPAFindChip() returns -1 with NULL pmFPA input parameter");
     168        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     169    }
     170
     171
     172    // Call pmFPAFindChip() with bogus chip name
     173    {
     174        psMemId id = psMemGetId();
     175        pmFPA* fpa = generateSimpleFPA(NULL);
     176        int rc = pmFPAFindChip(fpa, "bogus");
     177        ok(-1 == rc, "pmFPAFindChip() returns -1 with bogus chip name");
     178        psFree(fpa);
     179        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     180    }
     181
     182
     183    // Call pmFPAFindChip() with NULL chip name
    223184    {
    224185        psMemId id = psMemGetId();
    225186        // Generate the pmFPA heirarchy
    226         psMetadata *camera = psMetadataAlloc();
    227         pmFPA* fpa = generateSimpleFPA(camera);
    228         pmChip *chip = fpa->chips->data[0];
    229         pmCell *cell = chip->cells->data[0];
    230         ok(fpa != NULL, "Allocated a pmFPA successfully");
    231         ok(chip != NULL, "Allocated a pmChip successfully");
    232         ok(cell != NULL, "Allocated a pmCell successfully");
     187        pmFPA* fpa = generateSimpleFPA(NULL);
     188        ok(fpa != NULL, "Allocated a pmFPA successfully");
    233189        int rc = pmFPAFindChip(fpa, NULL);
    234190        ok(-1 == rc, "pmFPAFindChip() returns -1 with NULL name input param");
    235         myFreeFPA(fpa);
    236         psFree(camera);
    237         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    238     }
    239 
    240 
    241     // ----------------------------------------------------------------------
    242     // int pmFPAFindChip(const pmFPA *fpa, const char *name)
     191        psFree(fpa);
     192        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     193    }
     194
     195
     196    // Call pmFPAFindChip() with acceptable input parameters
    243197    {
    244198        psMemId id = psMemGetId();
    245199        // Generate the pmFPA heirarchy
    246         psMetadata *camera = psMetadataAlloc();
    247         pmFPA* fpa = generateSimpleFPA(camera);
    248         pmChip *chip = fpa->chips->data[0];
    249         pmCell *cell = chip->cells->data[0];
    250         ok(fpa != NULL, "Allocated a pmFPA successfully");
    251         ok(chip != NULL, "Allocated a pmChip successfully");
    252         ok(cell != NULL, "Allocated a pmCell successfully");
     200        pmFPA* fpa = generateSimpleFPA(NULL);
     201        ok(fpa != NULL, "Allocated a pmFPA successfully");
    253202        // Set unique chip names
    254203        for (int chipID = 0 ; chipID < fpa->chips->n ; chipID++) {
     
    267216        }
    268217
    269         myFreeFPA(fpa);
    270         psFree(camera);
     218        psFree(fpa);
    271219        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    272220    }
     
    275223
    276224    // ----------------------------------------------------------------------
    277     // int pmChipFindCell(const pmChip *chip, const char *name)
    278     {
    279         psMemId id = psMemGetId();
    280         int rc = pmChipFindCell(NULL, "bogus");
     225    // pmChipFindCell() tests
     226    // Call pmChipFindCell() with bogus cell name
     227    {
     228        psMemId id = psMemGetId();
     229        int rc = pmChipFindCell(NULL, "cell-0");
    281230        ok(-1 == rc, "pmChipFindCell() returns -1 with NULL pmChip input param");
    282231        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    283232    }
    284233
    285 
    286     // ----------------------------------------------------------------------
    287     // int pmChipFindCell(const pmChip *chip, const char *name)
     234    // Call pmChipFindCell() with bogus cell name
     235    {
     236        psMemId id = psMemGetId();
     237        pmFPA* fpa = generateSimpleFPA(NULL);
     238        pmChip *chip = fpa->chips->data[0];
     239        int rc = pmChipFindCell(chip, "bogus");
     240        ok(-1 == rc, "pmChipFindCell() returns -1 with bogus cell name");
     241        psFree(fpa);
     242        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     243    }
     244
     245
     246    // Call pmChipFindCell() with NULL cell name
    288247    {
    289248        psMemId id = psMemGetId();
    290249        // Generate the pmChip heirarchy
    291         psMetadata *camera = psMetadataAlloc();
    292         pmFPA* fpa = generateSimpleFPA(camera);
     250        pmFPA* fpa = generateSimpleFPA(NULL);
    293251        pmChip *chip = fpa->chips->data[0];
    294252        pmCell *cell = chip->cells->data[0];
     
    298256        int rc = pmChipFindCell(chip, NULL);
    299257        ok(-1 == rc, "pmChipFindCell() returns -1 with NULL name input param");
    300         myFreeFPA(fpa);
    301         psFree(camera);
    302         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    303     }
    304 
    305 
    306     // ----------------------------------------------------------------------
    307     // int pmChipFindCell(const pmChip *chip, const char *name)
     258        psFree(fpa);
     259        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     260    }
     261
     262
     263    // Call pmChipFindCell() with acceptable input parameters
    308264    {
    309265        psMemId id = psMemGetId();
    310266        // Generate the pmChip heirarchy
    311         psMetadata *camera = psMetadataAlloc();
    312         pmFPA* fpa = generateSimpleFPA(camera);
     267        pmFPA* fpa = generateSimpleFPA(NULL);
    313268        pmChip *chip = fpa->chips->data[0];
    314269        pmCell *cell = chip->cells->data[0];
     
    332287        }
    333288
    334         myFreeFPA(fpa);
    335         psFree(camera);
    336         ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
    337     }
    338 
    339 }
     289        psFree(fpa);
     290        ok(!psMemCheckLeaks (id, NULL, NULL, false), "no memory leaks");
     291    }
     292
     293}
Note: See TracChangeset for help on using the changeset viewer.