IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 24, 2006, 2:22:25 PM (20 years ago)
Author:
Paul Price
Message:

Cleaned up some functions. Added "mosaic" to pmChip.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/astrom/pmFPA.c

    r6930 r6970  
    1212* XXX: Should we implement non-linear cell->chip transforms?
    1313*
    14 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    15 *  @date $Date: 2006-04-20 22:30:33 $
     14*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     15*  @date $Date: 2006-04-25 00:22:25 $
    1616*
    1717*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3333/******************************************************************************
    3434 *****************************************************************************/
    35 #define PS_FREE_HIERARCHY 1
    36 #define PARENT_LINKS 0
    3735
    3836static void readoutFree(pmReadout *readout)
    3937{
    40     psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t) readout, (size_t) readout->parent);
     38    psTrace(__func__, 9, "Removing readout %lx from cell %lx...\n", (size_t)readout, (size_t)readout->parent);
    4139    if (readout->parent) {
    4240        psArray *readouts = readout->parent->readouts;
    4341        for (int i = 0; i < readouts->n; i++) {
    4442            if (readouts->data[i] == readout) {
    45                 //                    pmReadout *tmpReadout = readouts->data[i];
    4643                readouts->data[i] = NULL;
    47                 #if PARENT_LINKS
    48 
    49                 psFree(tmpReadout);
    50                 #endif
    51 
    52                 break;
    5344            }
    5445        }
    5546    }
    5647    psTrace(__func__, 9, "Freeing readout %lx\n", (size_t) readout);
    57 
    58     #if PARENT_LINKS
    59 
    60     psFree(readout->parent);
    61     #endif
    62 
    6348    psFree(readout->image);
    6449    psFree(readout->mask);
     
    7560        for (int i = 0; i < cells->n; i++) {
    7661            if (cells->data[i] == cell) {
    77                 //                    pmCell *tmpCell = cells->data[i];
    7862                cells->data[i] = NULL;
    79                 #if PARENT_LINKS
    80 
    81                 psFree(tmpCell);
    82                 #endif
    83 
    84                 break;
    8563            }
    8664        }
    8765    }
    8866    psTrace(__func__, 9, "Freeing cell %lx\n", (size_t)cell);
    89 
    9067    pmCellFreeReadouts(cell);
    9168    psFree(cell->readouts);
    92     #if PARENT_LINKS
    93 
    94     psFree(cell->parent);
    95     #endif
    9669
    9770    psFree(cell->concepts);
     
    10881        for (int i = 0; i < chips->n; i++) {
    10982            if (chips->data[i] == chip) {
    110                 //                    pmChip *tmpChip = chips->data[i];
    11183                chips->data[i] = NULL;
    112                 #if PARENT_LINKS
    113 
    114                 psFree(tmpChip);
    115                 #endif
    116 
    117                 break;
    11884            }
    11985        }
    12086    }
    12187    psTrace(__func__, 9, "Freeing chip %lx\n", (size_t)chip);
    122 
    12388    pmChipFreeCells(chip);
    12489    psFree(chip->cells);
    125     #if PARENT_LINKS
    126 
    127     psFree(chip->parent);
    128     #endif
    129 
    130     #if 0
    131 
    132     psFree(chip->toFPA);
    133     psFree(chip->fromFPA);
    134     #endif
    13590
    13691    psFree(chip->concepts);
    13792    psFree(chip->analysis);
    13893    psFree(chip->hdu);
     94    psFree(chip->mosaic);
    13995}
    14096
     
    14399{
    144100    psTrace(__func__, 9, "Freeing fpa %lx\n", (size_t)fpa);
    145     #if 0
    146 
    147     psFree(fpa->fromTangentPlane);
    148     psFree(fpa->toTangentPlane);
    149     psFree(fpa->projection);
    150     #endif
    151 
    152     psFree(fpa->concepts);
    153     psFree(fpa->analysis);
    154     psFree(fpa->camera);
    155     //
    156     // Set the parent to NULL in all fpa->chips before psFree(fpa->chips)
    157     // in order to avoid memory reference counter problems.
    158     //
    159101    psArray *chips = fpa->chips;
    160102    for (psS32 i = 0 ; i < chips->n ; i++) {
     
    165107        chips->data[i] = NULL;
    166108        tmpChip->parent = NULL;
    167         if (PS_FREE_HIERARCHY == 1) {
    168             psFree(tmpChip);
    169         }
    170109    }
    171110    psFree(fpa->chips);
     111    psFree(fpa->concepts);
     112    psFree(fpa->analysis);
     113    psFree(fpa->camera);
    172114    psFree(fpa->hdu);
    173115}
     
    189131        psTrace(__func__, 9, "Will now free readout %lx...\n", (size_t)tmpReadout);
    190132        psFree(tmpReadout); // Drop the readout
    191         #if PARENT_LINKS
    192 
    193         psFree(cell); // Decrement reference counter on cell, since readout->parent isn't held any more
    194         #endif
    195 
    196133    }
    197134    cell->readouts = psArrayRealloc(cell->readouts, 0);
     
    216153        pmCellFreeReadouts(tmpCell);// Drop all readouts the cell holds
    217154        psFree(tmpCell);            // Drop the cell
    218         #if PARENT_LINKS
    219 
    220         psFree(chip); // Decrement reference counter on chip, since cell->parent isn't held any more
    221         #endif
    222 
    223155    }
    224156    chip->cells = psArrayRealloc(chip->cells, 0);
     
    230162{
    231163    pmReadout *tmpReadout = (pmReadout *) psAlloc(sizeof(pmReadout));
    232     tmpReadout->row0 = 0;
    233     tmpReadout->col0 = 0;
     164    psMemSetDeallocator(tmpReadout, (psFreeFunc) readoutFree);
    234165
    235166    tmpReadout->image = NULL;
     
    238169    tmpReadout->bias = psListAlloc(NULL);
    239170    tmpReadout->analysis = psMetadataAlloc();
    240     #if PARENT_LINKS
    241 
    242     tmpReadout->parent = psMemIncrRefCounter(cell);
    243     #else
    244 
    245171    tmpReadout->parent = cell;
    246     #endif
    247 
    248172    if (cell != NULL) {
    249173        cell->readouts = psArrayAdd(cell->readouts, 1, (psPtr) tmpReadout);
     
    254178    tmpReadout->data_exists = false;       // data yet read in
    255179
    256     psMemSetDeallocator(tmpReadout, (psFreeFunc) readoutFree);
     180    tmpReadout->row0 = 0;
     181    tmpReadout->col0 = 0;
     182
    257183    return(tmpReadout);
    258184}
    259185
    260 // XXX: Verify these default values for row0, col0.
    261 // PAP: These values may disappear in the future in favour of values in the "concepts"?
    262186pmCell *pmCellAlloc(
    263187    pmChip *chip,
    264     const char *name)
     188    const char *name
     189)
    265190{
    266191    pmCell *tmpCell = (pmCell *) psAlloc(sizeof(pmCell));
    267 
    268     tmpCell->concepts = psMetadataAlloc();
    269     tmpCell->conceptsRead = PM_CONCEPT_SOURCE_NONE;
    270     psBool rc = psMetadataAddStr(tmpCell->concepts, PS_LIST_HEAD, "CELL.NAME", 0, NULL, name);
    271     if (rc == false) {
    272         psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CELL.NAME to metadata.\n");
    273     }
     192    psMemSetDeallocator(tmpCell, (psFreeFunc) cellFree);
     193
    274194    tmpCell->config = NULL;
    275195    tmpCell->analysis = psMetadataAlloc();
    276196    tmpCell->readouts = psArrayAlloc(0);
    277     #if PARENT_LINKS
    278 
    279     tmpCell->parent = psMemIncrRefCounter(chip);
    280     #else
    281 
    282197    tmpCell->parent = chip;
    283     #endif
    284 
    285198    if (chip != NULL) {
    286199        chip->cells = psArrayAdd(chip->cells, 1, (psPtr) tmpCell);
    287200    }
     201    tmpCell->hdu = NULL;
    288202    tmpCell->process = true;            // All cells are processed by default
    289203    tmpCell->file_exists = false;       // Not yet identified
    290204    tmpCell->data_exists = false;       // Not yet read in
    291     tmpCell->hdu = NULL;
    292 
     205
     206    tmpCell->concepts = psMetadataAlloc();
     207    tmpCell->conceptsRead = PM_CONCEPT_SOURCE_NONE;
     208    if (!psMetadataAddStr(tmpCell->concepts, PS_LIST_HEAD, "CELL.NAME", 0, NULL, name)) {
     209        psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CELL.NAME to metadata.\n");
     210    }
    293211    pmConceptsBlankCell(tmpCell);
    294212
    295     psMemSetDeallocator(tmpCell, (psFreeFunc) cellFree);
    296213    return(tmpCell);
    297214}
    298215
    299 // XXX: Verify these default values for row0, col0.
    300 // PAP: row0, col0 may disappear in the future in favour of storing values in the "concepts".
    301216pmChip *pmChipAlloc(
    302217    pmFPA *fpa,
     
    304219{
    305220    pmChip *tmpChip = (pmChip *) psAlloc(sizeof(pmChip));
    306 
    307     #if 0
    308 
    309     tmpChip->col0 = 0;
    310     tmpChip->row0 = 0;
    311     tmpChip->toFPA = NULL;
    312     tmpChip->fromFPA = NULL;
    313     #endif
    314 
    315     tmpChip->concepts = psMetadataAlloc();
    316     tmpChip->conceptsRead = PM_CONCEPT_SOURCE_NONE;
    317     psBool rc = psMetadataAddStr(tmpChip->concepts, PS_LIST_HEAD, "CHIP.NAME", 0, NULL, name);
    318     if (rc == false) {
    319         psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CHIP.NAME to metadata.\n");
    320     }
     221    psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree);
     222
    321223    tmpChip->analysis = psMetadataAlloc();
    322224    tmpChip->cells = psArrayAlloc(0);
    323     #if PARENT_LINKS
    324 
    325     tmpChip->parent = psMemIncrRefCounter(fpa);
    326     #else
    327 
    328225    tmpChip->parent = fpa;
    329     #endif
    330 
    331226    if (fpa != NULL) {
    332227        fpa->chips = psArrayAdd(fpa->chips, 1, (psPtr) tmpChip);
    333228    }
     229    tmpChip->hdu = NULL;
     230    tmpChip->mosaic = NULL;
    334231    tmpChip->process = true;            // Work on all chips, by default
    335232    tmpChip->file_exists = false;       // Not yet identified
    336233    tmpChip->data_exists = false;       // Not yet read in
    337     tmpChip->hdu = NULL;
    338 
     234
     235    if (!psMetadataAddStr(tmpChip->concepts, PS_LIST_HEAD, "CHIP.NAME", 0, NULL, name)) {
     236        psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CHIP.NAME %s to concepts.\n", name);
     237    }
     238    tmpChip->concepts = psMetadataAlloc();
     239    tmpChip->conceptsRead = PM_CONCEPT_SOURCE_NONE;
    339240    pmConceptsBlankChip(tmpChip);
    340241
    341     psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree);
    342242    return(tmpChip);
    343243}
     
    346246{
    347247    pmFPA *tmpFPA = (pmFPA *) psAlloc(sizeof(pmFPA));
    348 
    349     #if 0
    350 
    351     tmpFPA->fromTangentPlane = NULL;
    352     tmpFPA->toTangentPlane = NULL;
    353     tmpFPA->projection = NULL;
    354     #endif
    355 
    356     tmpFPA->concepts = psMetadataAlloc();
    357     tmpFPA->conceptsRead = PM_CONCEPT_SOURCE_NONE;
     248    psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree);
     249
    358250    tmpFPA->analysis = NULL;
    359251    tmpFPA->camera = psMemIncrRefCounter((psPtr)camera);
     
    361253    tmpFPA->hdu = NULL;
    362254
     255    tmpFPA->concepts = psMetadataAlloc();
     256    tmpFPA->conceptsRead = PM_CONCEPT_SOURCE_NONE;
    363257    pmConceptsBlankFPA(tmpFPA);
    364258
    365     psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree);
    366259    return(tmpFPA);
    367260}
     
    369262static psBool cellCheckParents(pmCell *cell)
    370263{
    371     if (cell == NULL) {
     264    if (!cell) {
    372265        return(true);
    373266    }
     
    387280static psBool chipCheckParents(pmChip *chip)
    388281{
    389     if (chip == NULL) {
     282    if (!chip) {
    390283        return(true);
    391284    }
     
    407300psBool pmFPACheckParents(pmFPA *fpa)
    408301{
    409     if (fpa == NULL) {
     302    if (!fpa) {
    410303        return(true);
    411304    }
Note: See TracChangeset for help on using the changeset viewer.