IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 1, 2005, 2:21:14 PM (21 years ago)
Author:
Paul Price
Message:

Rough draft of pmFPAMorph working

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/scripts/src/papFocalPlane.c

    r4386 r4694  
    254254}
    255255
    256 psMetadataItem *psCellGetValue(papFPA *fpa, // The FPA that contains the cell
    257                                const char *chipName, // The name of the chip
    258                                const char *cellName, // The name of the cell
     256psMetadataItem *psCellGetValue(papCell *cell, // The cell
    259257                               const char *valueName // Name of value
    260258                               )
    261259{
    262     psTrace(__func__, 3, "Trying to retrieve %s for %s:%s...\n", valueName, chipName, cellName);
    263 
    264     bool mdStatus = true;               // Status of MD lookup
    265     papChip *chip = psMetadataLookupChip(&mdStatus, fpa->chips, chipName); // The chip
    266     if (!mdStatus) {
    267         psError(PS_ERR_IO, false, "Unable to find chip named %s\n", chipName);
    268         return NULL;
    269     }
    270     papCell *cell = psMetadataLookupCell(&mdStatus, chip->cells, cellName); // The cell
    271     if (!mdStatus) {
    272         psError(PS_ERR_IO, false, "Unable to find cell named %s in chip %s\n", cellName, chipName);
    273         return NULL;
    274     }
     260    psTrace(__func__, 3, "Trying to retrieve %s...\n", valueName);
     261
     262    papChip *chip = cell->parent;       // The chip
     263    papFPA *fpa = chip->parent;         // The FPA
    275264
    276265    // Try cache, headers, database, defaults in order
     
    293282}
    294283
    295 float psCellGetValueF32(papFPA *fpa, // The FPA that contains the cell
    296                         const char *chipName, // The name of the chip
    297                         const char *cellName, // The name of the cell
     284float psCellGetValueF32(papCell *cell, // The cell
    298285                        const char *valueName // Name of value
    299286                        )
    300287{
    301288    float value = NAN;                  // Result
    302     psMetadataItem *item = psCellGetValue(fpa, chipName, cellName, valueName); // The item
    303     if (! item) {
    304         psError(PS_ERR_IO, true, "Unable to find value %s in %s:%s.\n", valueName, chipName, cellName);
     289    psMetadataItem *item = psCellGetValue(cell, valueName); // The item
     290    if (! item) {
     291        psError(PS_ERR_IO, true, "Unable to find value %s in cell.\n", valueName);
    305292    } else if (item->type != PS_META_F32) {
    306         psError(PS_ERR_IO, true, "Metadata item type for %s (%s:%s) is not F32.\n", valueName, chipName,
    307                 cellName);
     293        psError(PS_ERR_IO, true, "Metadata item type for %s is not F32.\n", valueName);
    308294    } else {
    309295        value = item->data.F32;
     
    313299}
    314300
    315 int psCellGetValueS32(papFPA *fpa, // The FPA that contains the cell
    316                       const char *chipName, // The name of the chip
    317                       const char *cellName, // The name of the cell
     301int psCellGetValueS32(papCell *cell, // The cell
    318302                      const char *valueName // Name of value
    319303    )
    320304{
    321305    int value = 0;                      // Result
    322     psMetadataItem *item = psCellGetValue(fpa, chipName, cellName, valueName); // The item
    323     if (! item) {
    324         psError(PS_ERR_IO, true, "Unable to find value %s in %s:%s.\n", valueName, chipName, cellName);
     306    psMetadataItem *item = psCellGetValue(cell, valueName); // The item
     307    if (! item) {
     308        psError(PS_ERR_IO, true, "Unable to find value %s.\n", valueName);
    325309    } else if (item->type != PS_META_S32) {
    326         psError(PS_ERR_IO, true, "Metadata item type for %s (%s:%s) is not S32.\n", valueName, chipName,
    327                 cellName);
     310        psError(PS_ERR_IO, true, "Metadata item type for %s is not S32.\n", valueName);
    328311    } else {
    329312        value = item->data.S32;
     
    334317
    335318
    336 double psCellGetValueF64(papFPA *fpa, // The FPA that contains the cell
    337                          const char *chipName, // The name of the chip
    338                          const char *cellName, // The name of the cell
     319double psCellGetValueF64(papCell *cell, // The cell
    339320                         const char *valueName // Name of value
    340321                         )
    341322{
    342323    double value = NAN;                 // Result
    343     psMetadataItem *item = psCellGetValue(fpa, chipName, cellName, valueName); // The item
    344     if (! item) {
    345         psError(PS_ERR_IO, true, "Unable to find value %s in %s:%s.\n", valueName, chipName, cellName);
     324    psMetadataItem *item = psCellGetValue(cell, valueName); // The item
     325    if (! item) {
     326        psError(PS_ERR_IO, true, "Unable to find value %s.\n", valueName);
    346327    } else if (item->type != PS_META_F64) {
    347         psError(PS_ERR_IO, true, "Metadata item type for %s (%s:%s) is not F64.\n", valueName, chipName,
    348                 cellName);
     328        psError(PS_ERR_IO, true, "Metadata item type for %s is not F64.\n", valueName);
    349329    } else {
    350330        value = item->data.F64;
     
    355335
    356336
    357 psString psCellGetValueString(papFPA *fpa, // The FPA that contains the cell
    358                               const char *chipName, // The name of the chip
    359                               const char *cellName, // The name of the cell
     337psString psCellGetValueString(papCell *cell, // The cell
    360338                              const char *valueName // Name of value
    361339    )
    362340{
    363341    psString value = NULL;              // Result
    364     psMetadataItem *item = psCellGetValue(fpa, chipName, cellName, valueName); // The item
    365     if (! item) {
    366         psError(PS_ERR_IO, true, "Unable to find value %s in %s:%s.\n", valueName, chipName, cellName);
     342    psMetadataItem *item = psCellGetValue(cell, valueName); // The item
     343    if (! item) {
     344        psError(PS_ERR_IO, true, "Unable to find value %s.\n", valueName);
    367345    } else if (item->type != PS_META_STR) {
    368         psError(PS_ERR_IO, true, "Metadata item type for %s (%s:%s) is not STR.\n", valueName, chipName,
    369                 cellName);
     346        psError(PS_ERR_IO, true, "Metadata item type for %s is not STR.\n", valueName);
    370347    } else {
    371348        value = item->data.V;
     
    394371    fpa->camera = psMemIncrRefCounter((psPtr)camera);
    395372    fpa->db = db;
    396     fpa->chips = psMetadataAlloc();
    397 
     373    fpa->chips = psArrayAlloc(0);
     374
     375    fpa->extname = NULL;
    398376    fpa->pixels = NULL;
    399377    fpa->header = NULL;
     
    418396
    419397papChip *papChipAlloc(papFPA *fpa,      // FPA to which the chip belongs
    420                       const char *name  // Name of the chip
     398                      psString name     // Chip name
    421399    )
    422400{
     
    424402    psMemSetDeallocator(chip, (psFreeFcn)p_papChipFree);
    425403
    426     // Push onto the FPA
    427     psMetadataAdd(fpa->chips, PS_LIST_TAIL, name, PS_META_CHIP, "Chip added on allocation", chip);
     404    // Push onto the array of chips
     405    fpa->chips = psArrayAdd(fpa->chips, 0, chip);
    428406
    429407    // Fill in the components
     
    435413
    436414    chip->values = psMetadataAlloc();
    437     chip->cells = psMetadataAlloc();
    438 
     415    chip->parent = psMemIncrRefCounter(fpa);
     416    chip->cells = psArrayAlloc(0);
     417
     418    chip->extname = NULL;
    439419    chip->pixels = NULL;
    440420    chip->header = NULL;
    441421
    442     psMetadataAdd(chip->values, PS_LIST_TAIL, "CHIP.NAME", PS_META_STR, "Name of the chip",
    443                   psStringCopy(name));
     422    psMetadataAddStr(chip->values, PS_LIST_HEAD, "CHIP.NAME", "Chip name added at papChipAlloc", name);
    444423
    445424    return chip;
     
    453432    psFree(chip->values);
    454433    psFree(chip->cells);
     434    psFree(chip->parent);
    455435
    456436    psFree(chip->pixels);
     
    459439
    460440papCell *papCellAlloc(papChip *chip,    // Chip to which the cell belongs
    461                       const char *name, // Name of the cell
    462                       int nReadouts     // Number of readouts contained
     441                      psString name     // Name of cell
    463442    )
    464443{
     
    466445    psMemSetDeallocator(cell, (psFreeFcn)p_papCellFree);
    467446
    468     // Push onto the chip
    469     psMetadataAdd(chip->cells, PS_LIST_TAIL, name, PS_META_CELL, "Cell added on allocation", cell);
     447    // Push onto the array of chips
     448    chip->cells = psArrayAdd(chip->cells, 0, cell);
    470449
    471450    // Fill in components
     
    480459
    481460    cell->values = psMetadataAlloc();
    482     cell->readouts = psArrayAlloc(nReadouts);
    483 
     461    cell->readouts = psArrayAlloc(0);
     462    cell->parent = psMemIncrRefCounter(chip);
     463
     464    cell->extname = NULL;
    484465    cell->pixels = NULL;
    485466    cell->header = NULL;
    486467
    487     psMetadataAdd(cell->values, PS_LIST_TAIL, "CELL.NAME", PS_META_STR, "Name of the cell",
    488                   psStringCopy(name));
     468    psMetadataAddStr(cell->values, PS_LIST_HEAD, "CELL.NAME", "Cell name added at papCellAlloc", name);
    489469
    490470    return cell;
     
    501481    psFree(cell->values);
    502482    psFree(cell->readouts);
     483    psFree(cell->parent);
    503484
    504485    psFree(cell->pixels);
Note: See TracChangeset for help on using the changeset viewer.