IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16218


Ignore:
Timestamp:
Jan 23, 2008, 3:26:20 PM (18 years ago)
Author:
Paul Price
Message:

When copying concepts, don't copy the names of the fpa/chip/cell,
since this would overwrite important values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConcepts.c

    r15770 r16218  
    739739        }
    740740
    741         // FPA.PON.TIME
     741        // FPA.PON.TIME
    742742        {
    743743            psMetadataItem *item = psMetadataItemAllocF32("FPA.PON.TIME", "Power On Time", NAN);
     
    10351035
    10361036
    1037 // XXX EAM : Paul, please handle the biassec independently so the
    1038 // psList is copied without a verbose warning.  when this is fixed, you can
    1039 // convert the trace back to a log (psMetadata.c:429)
     1037// List of concepts not to copy, for each level.
     1038// Must be NULL-terminated
     1039static const char *dontCopyConceptsFPA[] = { "FPA.NAME", 0 };
     1040static const char *dontCopyConceptsChip[] = { "CHIP.NAME", 0 };
     1041static const char *dontCopyConceptsCell[] = { "CELL.NAME", "CELL.TRIMSEC", "CELL.BIASSEC", 0 };
     1042
     1043// Copy concepts from a source container to a target container, avoiding certain entries
     1044static void copyConcepts(psMetadata *target, // Target metadata container
     1045                         psMetadata *source, // Source metadata container
     1046                         const char *dontCopyConcepts[] // Don't copy these concepts
     1047                         )
     1048{
     1049    assert(target);
     1050    assert(source);
     1051    assert(dontCopyConcepts);
     1052
     1053    psMetadataIterator *iter = psMetadataIteratorAlloc(source, PS_LIST_HEAD, NULL);
     1054    psMetadataItem *item;               // Item from iteration
     1055    while ((item = psMetadataGetAndIncrement(iter))) {
     1056        const char *name = item->name;  // Name of concept
     1057        bool copyOK = false;            // OK to copy
     1058        for (int i = 0; dontCopyConcepts[i] && copyOK; i++) {
     1059            if (strcmp(name, dontCopyConcepts[i]) == 0) {
     1060                copyOK = false;
     1061            }
     1062        }
     1063        if (!copyOK) {
     1064            continue;
     1065        }
     1066        psMetadataItem *new = psMetadataItemCopy(item); // New item, a copy of the old
     1067        psMetadataAddItem(target, new, PS_LIST_TAIL, PS_META_REPLACE);
     1068        psFree(new);                    // Drop reference
     1069    }
     1070    psFree(iter);
     1071
     1072    return;
     1073}
     1074
    10401075
    10411076bool pmFPACopyConcepts(pmFPA *target, const pmFPA *source)
     
    10451080
    10461081    // Copy FPA concepts
    1047     target->concepts = psMetadataCopy(target->concepts, source->concepts);
     1082    copyConcepts(target->concepts, source->concepts, dontCopyConceptsFPA);
    10481083
    10491084    // Copy chip concepts
     
    10611096            continue;
    10621097        }
    1063         targetChip->concepts = psMetadataCopy(targetChip->concepts, sourceChip->concepts);
     1098
     1099        copyConcepts(targetChip->concepts, sourceChip->concepts, dontCopyConceptsChip);
    10641100
    10651101        // Copy cell concepts
     
    10781114            }
    10791115
    1080             psMetadataIterator *iter = psMetadataIteratorAlloc(sourceCell->concepts, PS_LIST_HEAD, NULL);
    1081             psMetadataItem *item;       // Item from iteration
    1082             while ((item = psMetadataGetAndIncrement(iter))) {
    1083                 psMetadataItem *new;    // New item, a copy of the old
    1084                 // Don't copy TRIMSEC or BIASSEC
    1085                 if (strcmp(item->name, "CELL.TRIMSEC") != 0 && strcmp(item->name, "CELL.BIASSEC")) {
    1086                     new = psMetadataItemCopy(item);
    1087                 } else {
    1088                     new = psMetadataItemAlloc(item->name, item->type, item->comment, NULL);
    1089                 }
    1090                 psMetadataAddItem(targetCell->concepts, new, PS_LIST_TAIL, PS_META_REPLACE);
    1091                 psFree(new);        // Drop reference
    1092             }
    1093             psFree(iter);
     1116            copyConcepts(targetCell->concepts, sourceCell->concepts, dontCopyConceptsCell);
    10941117        }
    10951118    }
Note: See TracChangeset for help on using the changeset viewer.