Changeset 15940 for trunk/psModules/src/camera/pmFPAConstruct.c
- Timestamp:
- Dec 27, 2007, 6:38:05 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAConstruct.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAConstruct.c
r15652 r15940 66 66 67 67 psList *values = psStringSplit(string, " ,;", true); // List of the parts 68 69 if (first) { 70 *first = psArrayAlloc(values->n); 71 } 72 if (second) { 73 *second = psArrayAlloc(values->n); 74 } 75 if (third) { 76 *third = psArrayAlloc(values->n); 77 } 78 int num = 0; 68 int num = values->n; // number of parsed content elements 69 70 // extend the arrays if they exist, create new ones if they don't 71 if (first && !*first) { 72 *first = psArrayAllocEmpty(values->n); 73 } 74 if (second && !*second) { 75 *second = psArrayAllocEmpty(values->n); 76 } 77 if (third && !*third) { 78 *third = psArrayAllocEmpty(values->n); 79 } 80 79 81 psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator for values 80 82 psString value = NULL; // "first:second:third" string … … 83 85 switch (numArrays) { 84 86 case 3: 85 psArray Set(*third, num, fst->data[2]);87 psArrayAdd(*third, 8, fst->data[2]); 86 88 case 2: 87 psArray Set(*second, num, fst->data[1]);89 psArrayAdd(*second, 8, fst->data[1]); 88 90 case 1: 89 psArray Set(*first, num, fst->data[0]);91 psArrayAdd(*first, 8, fst->data[0]); 90 92 break; 91 93 default: 92 94 psAbort("Should never get here."); 93 95 } 94 num++;95 96 psFree(fst); 96 97 } … … 395 396 // Process a chip, using the cellName:cellType pair 396 397 static bool processChip(const psMetadata *format, // Camera format 397 const char *chipContents, // Contents of chip, cellName:cellType pairs398 const psMetadataItem *chipContents, // Contents of chip, cellName:cellType pairs (either in a string or a metadata) 398 399 pmFPA *fpa, // FPA of interest 399 400 pmChip *chip, // Chip of interest 400 401 pmFPALevel level, // Level for HDU to go 401 402 pmHDU *hdu // HDU to add 402 )403 ) 403 404 { 404 405 assert(format); … … 414 415 psArray *cellNames = NULL; // Cell names 415 416 psArray *cellTypes = NULL; // Cell types 416 if (parseContent(&cellNames, &cellTypes, NULL, chipContents) == 0) { 417 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 418 "Unable to parse chip contents (within %s in camera format) as cellName:cellType", 419 CHIP_TYPES); 420 psFree(cellNames); 421 psFree(cellTypes); 422 return false; 417 418 int nParsed = 0; 419 420 switch (chipContents->type) { 421 case PS_DATA_STRING: { 422 nParsed = parseContent(&cellNames, &cellTypes, NULL, chipContents->data.str); 423 break; 424 } 425 case PS_DATA_METADATA: { 426 psMetadataIterator *iter = psMetadataIteratorAlloc(chipContents->data.md, PS_LIST_HEAD, NULL); // Iterator 427 psMetadataItem *item; // Item from iteration 428 while ((item = psMetadataGetAndIncrement(iter))) { 429 if (item->type != PS_DATA_STRING) { 430 psWarning ("Item %s in camera format chip table is not of type STR.", item->name); 431 continue; 432 } 433 nParsed += parseContent(&cellNames, &cellTypes, NULL, item->data.str); 434 } 435 psFree (iter); 436 break; 437 } 438 default: 439 psWarning ("Item %s in camera format chip table is not of type STR.", chipContents->name); 440 break; 441 } 442 443 if (nParsed == 0) { 444 psError(PS_ERR_BAD_PARAMETER_VALUE, false, 445 "Unable to parse chip contents (within %s in camera format) as cellName:cellType", 446 CHIP_TYPES); 447 psFree(cellNames); 448 psFree(cellTypes); 449 return false; 423 450 } 424 451 … … 552 579 pmChip *chip = fpa->chips->data[chipNum]; // Chip of interest 553 580 554 const char *chipContents = psMetadataLookupStr(NULL,chips, chipType); // Contents of chip581 const psMetadataItem *chipContents = psMetadataLookup(chips, chipType); // Contents of chip 555 582 psFree(chipType); 556 583 if (!chipContents) { … … 775 802 psMetadataItem *contentItem; // Content, from iteration 776 803 while ((contentItem = psMetadataGetAndIncrement(contentsIter))) { 777 if (contentItem->type != PS_DATA_STRING) { 778 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 779 "Type for %s (%x) in %s METADATA in camera format is not STR", 780 contentItem->name, contentItem->type, TABLE_OF_CONTENTS); 781 psFree(contentsIter); 782 return false; 783 } 784 785 const char *extname = contentItem->name; // Extension name 786 pmHDU *hdu = pmHDUAlloc(extname); // HDU for this extension 804 pmHDU *hdu = pmHDUAlloc(contentItem->name); // HDU for this extension 787 805 // Casting to avoid "warning: passing arg 1 of `p_psMemIncrRefCounter' discards qualifiers from 788 806 // pointer target type" 789 807 hdu->format = psMemIncrRefCounter((const psPtr)format); 790 808 791 if (!processChip(format, contentItem ->data.str, fpa, chip, PM_FPA_LEVEL_CELL, hdu)) {809 if (!processChip(format, contentItem, fpa, chip, PM_FPA_LEVEL_CELL, hdu)) { 792 810 psError(PS_ERR_UNKNOWN, false, "Unable to process chip\n"); 793 811 psFree(hdu); … … 871 889 872 890 // What's in the chip? 873 ps String chipContents = psMetadataLookupStr(NULL,chips, chipType); // Contents of the chip891 psMetadataItem *chipContents = psMetadataLookup(chips, chipType); // Contents of the chip 874 892 if (!chipContents) { 875 893 psError(PS_ERR_UNEXPECTED_NULL, false,
Note:
See TracChangeset
for help on using the changeset viewer.
