IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 11, 2007, 4:51:44 PM (19 years ago)
Author:
magnier
Message:

adding pmChipDuplicate function (not working)

File:
1 edited

Legend:

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

    r12791 r12810  
    350350}
    351351
     352// create a new pmChip with the data derived from the supplied chip
     353pmChip *pmChipDuplicate(pmFPA *fpa, const pmChip *sourceChip)
     354{
     355    assert(sourceChip);
     356
     357    bool status;
     358    char *chipName = psMetadataLookupStr(&status, sourceChip->concepts, "CHIP.NAME");
     359    pmChip *targetChip = pmChipAlloc (NULL, chipName);
     360    targetChip->parent = fpa;
     361
     362    psArray *sourceCells = sourceChip->cells; // The source cells
     363
     364    for (int i = 0; i < sourceCells->n; i++) {
     365        pmCell *sourceCell = sourceCells->data[i]; // The sources cell
     366        const char *cellName = psMetadataLookupStr(NULL, sourceCell->concepts, "CELL.NAME"); // Name of cell
     367        // XXX are there other concepts I need to copy first?
     368        pmCell *targetCell = pmCellAlloc (targetChip, cellName);
     369        int xParityTarget = psMetadataLookupS32(&status, sourceCell->concepts, "CELL.XPARITY"); // Target x parity
     370        psMetadataAddS32 (targetCell->concepts, PS_LIST_TAIL, "CELL.XPARITY", PS_META_REPLACE, "", xParityTarget);
     371        int yParityTarget = psMetadataLookupS32(&status, sourceCell->concepts, "CELL.YPARITY"); // Target y parity
     372        psMetadataAddS32 (targetCell->concepts, PS_LIST_TAIL, "CELL.YPARITY", PS_META_REPLACE, "", yParityTarget);
     373        if (!cellCopy(targetCell, sourceCell, true, 1, 1)) {
     374            psError(PS_ERR_BAD_PARAMETER_VALUE, false, "failed to duplicate chip\n");
     375            return NULL;
     376        }
     377        // update the attributes
     378        targetCell->file_exists = sourceCell->file_exists;
     379        targetCell->data_exists = sourceCell->data_exists;
     380        targetCell->process     = sourceCell->process;
     381    }
     382
     383    // Update the concepts
     384    psMetadataCopy(targetChip->concepts, sourceChip->concepts);
     385
     386    // update the attributes
     387    targetChip->file_exists = sourceChip->file_exists;
     388    targetChip->data_exists = sourceChip->data_exists;
     389    targetChip->process     = sourceChip->process;
     390
     391    return targetChip;
     392}
     393
    352394// Common engine for pmFPACopy and pmFPACopyStructure.
    353395// Iterate on the components
Note: See TracChangeset for help on using the changeset viewer.