- Timestamp:
- Jan 1, 2009, 7:13:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20081230/psModules/src/config/pmConfigMask.c
r19870 r21079 45 45 }; 46 46 // Default values in case a bad mask name and its fallback is not defined 47 static const ps MaskType defaultMask[] = { 0x00, // DETECTOR48 0x00, // DARK49 0x01, // FLAT50 0x01, // BLANK51 0x00, // RANGE52 0x01, // SAT53 0x01, // LOW54 0x01, // CONV55 0x00, // CR56 0x00 // GHOST47 static const psImageMaskType defaultMask[] = { 0x00, // DETECTOR 48 0x00, // DARK 49 0x01, // FLAT 50 0x01, // BLANK 51 0x00, // RANGE 52 0x01, // SAT 53 0x01, // LOW 54 0x01, // CONV 55 0x00, // CR 56 0x00 // GHOST 57 57 }; 58 58 // Other mask names to ensure exist; these shouldn't be combined in the MASK.VALUE … … 62 62 }; 63 63 64 static bool maskSetValues(ps MaskType *outMaskValue, // Value of MASK.VALUE, returned65 ps MaskType *outMarkValue, // Value of MARK.VALUE, returned64 static bool maskSetValues(psImageMaskType *outMaskValue, // Value of MASK.VALUE, returned 65 psImageMaskType *outMarkValue, // Value of MARK.VALUE, returned 66 66 psMetadata *source // Source of mask bits 67 67 ) … … 70 70 71 71 // Ensure all the bad mask names exist, and set the value to catch all bad pixels 72 ps MaskType maskValue = 0; // Value to mask to catch all the bad pixels72 psImageMaskType maskValue = 0; // Value to mask to catch all the bad pixels 73 73 for (int i = 0; badMaskNames[i]; i++) { 74 74 const char *name = badMaskNames[i]; // Name for mask … … 76 76 77 77 bool mdok; // Status of MD lookup 78 ps MaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask78 psImageMaskType value = psMetadataLookupImageMask(&mdok, source, name); // Value of mask 79 79 if (!value) { 80 80 if (fallback) { 81 value = psMetadataLookup U8(&mdok, source, fallback);81 value = psMetadataLookupImageMask(&mdok, source, fallback); 82 82 } 83 83 if (!value) { 84 84 value = defaultMask[i]; 85 85 } 86 psMetadataAdd U8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, value);86 psMetadataAddImageMask(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, value); 87 87 } 88 88 maskValue |= value; … … 93 93 const char *name = otherMaskNames[i]; // Name for mask 94 94 bool mdok; // Status of MD lookup 95 ps MaskType value = psMetadataLookupU8(&mdok, source, name); // Value of mask95 psImageMaskType value = psMetadataLookupImageMask(&mdok, source, name); // Value of mask 96 96 if (!value) { 97 psMetadataAdd U8(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, 0x00);97 psMetadataAddImageMask(source, PS_LIST_TAIL, name, PS_META_REPLACE, NULL, 0x00); 98 98 } 99 99 } 100 100 101 101 // search for an unset bit to use for MARK: 102 psMaskType markValue = 0x80; 103 104 int nBits = sizeof(psMaskType) * 8; 102 psImageMaskType markValue = 0x00; 103 psImageMaskType markTrial = 0x01; 104 105 int nBits = sizeof(psImageMaskType) * 8; 105 106 for (int i = 0; !markValue && (i < nBits); i++) { 106 if (maskValue & mark Value) {107 mark Value >>= 1;107 if (maskValue & markTrial) { 108 markTrial <<= 1; 108 109 } else { 109 markValue = mark Value;110 markValue = markTrial; 110 111 } 111 112 } … … 116 117 117 118 // update the list with the results 118 psMetadataAdd U8(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue);119 psMetadataAdd U8(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue);119 psMetadataAddImageMask(source, PS_LIST_TAIL, "MASK.VALUE", PS_META_REPLACE, NULL, maskValue); 120 psMetadataAddImageMask(source, PS_LIST_TAIL, "MARK.VALUE", PS_META_REPLACE, NULL, markValue); 120 121 121 122 if (outMaskValue) { … … 130 131 131 132 // Get a mask value by name(s) 132 static ps MaskType maskGet(psMetadata *source, // Source of masks133 const char *masks // Mask values to get134 )135 { 136 ps MaskType mask = 0; // Mask value, to return133 static psImageMaskType maskGet(psMetadata *source, // Source of masks 134 const char *masks // Mask values to get 135 ) 136 { 137 psImageMaskType mask = 0; // Mask value, to return 137 138 138 139 psArray *names = psStringSplitArray(masks, " ,;", false); // Array of symbolic names … … 140 141 const char *name = names->data[i]; // Symbolic name of interest 141 142 bool mdok; // Status of MD lookup 142 ps MaskType value = psMetadataLookupU8(&mdok, source, name);143 psImageMaskType value = psMetadataLookupImageMask(&mdok, source, name); 143 144 if (!mdok) { 144 145 // Try and generate the value if we can … … 148 149 return 0; 149 150 } 150 value = psMetadataLookup U8(&mdok, source, name);151 value = psMetadataLookupImageMask(&mdok, source, name); 151 152 psAssert(mdok, "Should have generated mask value"); 152 153 } else { … … 187 188 188 189 #if 0 189 bool pmFPAMaskSetValues(ps MaskType *outMaskValue, psMaskType *outMarkValue, pmFPA *fpa)190 bool pmFPAMaskSetValues(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, pmFPA *fpa) 190 191 { 191 192 PS_ASSERT_PTR_NON_NULL(fpa, false); … … 194 195 } 195 196 196 ps MaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config)197 psImageMaskType pmFPAMaskGet(const pmFPA *fpa, const char *masks, const pmConfig *config) 197 198 { 198 199 PS_ASSERT_PTR_NON_NULL(fpa, 0); … … 206 207 } 207 208 208 bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, ps MaskType maskValue)209 bool pmFPAMaskSet(pmFPA *fpa, const char *maskName, psImageMaskType maskValue) 209 210 { 210 211 PS_ASSERT_PTR_NON_NULL(fpa, 0); … … 214 215 fpa->masks = psMetadataAlloc(); 215 216 } 216 return psMetadataAdd U8(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);217 return psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue); 217 218 } 218 219 … … 250 251 continue; 251 252 } 252 ps U8 bit = psMetadataLookupU8(&mdok, header, valuekey);253 psImageMaskType bit = psMetadataLookupImageMask(&mdok, header, valuekey); 253 254 if (!mdok) { 254 255 psWarning("Unable to find header keyword %s when parsing mask", namekey); … … 267 268 } 268 269 } else { 269 psMetadataAdd U8(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit);270 psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, name, 0, NULL, bit); 270 271 } 271 272 } … … 286 287 } 287 288 if (!psMetadataLookup(fpa->masks, item->name)) { 288 psMetadataAdd U8(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment,289 psMetadataAddImageMask(fpa->masks, PS_LIST_TAIL, item->name, 0, item->comment, 289 290 item->data.PS_TYPE_MASK_DATA); 290 291 } … … 322 323 323 324 psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name); 324 psMetadataAdd U8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_MASK_DATA);325 psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_MASK_DATA); 325 326 numMask++; 326 327 } … … 333 334 334 335 335 ps MaskType pmConfigMaskGet(const char *masks, const pmConfig *config)336 psImageMaskType pmConfigMaskGet(const char *masks, const pmConfig *config) 336 337 { 337 338 psAssert(config, "Require configuration"); … … 348 349 349 350 350 bool pmConfigMaskSet(const pmConfig *config, const char *maskName, ps MaskType maskValue)351 bool pmConfigMaskSet(const pmConfig *config, const char *maskName, psImageMaskType maskValue) 351 352 { 352 353 psAssert(config, "Require configuration"); … … 359 360 } 360 361 361 return psMetadataAdd U8(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue);362 return psMetadataAddImageMask(recipe, PS_LIST_TAIL, maskName, PS_META_REPLACE, NULL, maskValue); 362 363 } 363 364 … … 381 382 // versions so that it won't complain later 382 383 if (!psMetadataLookup(recipe, "MASK.VALUE")) { 383 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0);384 psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MASK.VALUE", 0, "Bits to mask", 0); 384 385 } 385 386 if (!psMetadataLookup(recipe, "MARK.VALUE")) { 386 psMetadataAdd U8(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0);387 psMetadataAddImageMask(recipe, PS_LIST_TAIL, "MARK.VALUE", 0, "Bits for marking", 0); 387 388 } 388 389 … … 408 409 continue; 409 410 } 410 ps U8 bit = psMetadataLookupU8(&status, header, valuekey);411 psImageMaskType bit = psMetadataLookupImageMask(&status, header, valuekey); 411 412 if (!status) { 412 413 psWarning("Unable to find header keyword %s when parsing mask", namekey); … … 427 428 428 429 if (already) { 429 if (item && item->data. U8!= bit) {430 if (item && item->data.PS_TYPE_IMAGE_MASK_DATA != bit) { 430 431 psWarning("New mask recipe entry doesn't match previously loaded entry: %x vs %x", 431 bit, item->data. U8);432 bit, item->data.PS_TYPE_IMAGE_MASK_DATA); 432 433 } 433 434 } else { … … 437 438 if (!item) { 438 439 psWarning("Mask recipe entry %s not in recipe\n", name); 439 psMetadataAdd U8(recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit);440 psMetadataAddImageMask(recipe, PS_LIST_TAIL, name, 0, "Bitmask bit value", bit); 440 441 } else { 441 item->data. U8= bit;442 item->data.PS_TYPE_IMAGE_MASK_DATA = bit; 442 443 } 443 444 … … 481 482 } 482 483 483 if (item->type != PS_ DATA_U8) {484 if (item->type != PS_TYPE_IMAGE_MASK) { 484 485 psWarning("mask recipe entry %s is not a bit value\n", item->name); 485 486 continue; … … 490 491 491 492 psMetadataAddStr(header, PS_LIST_TAIL, namekey, 0, "Bitmask bit name", item->name); 492 psMetadataAdd U8(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.U8);493 psMetadataAddImageMask(header, PS_LIST_TAIL, valuekey, 0, "Bitmask bit value", item->data.PS_TYPE_IMAGE_MASK_DATA); 493 494 nMask++; 494 495 } … … 500 501 501 502 502 bool pmConfigMaskSetBits(ps MaskType *outMaskValue, psMaskType *outMarkValue, const pmConfig *config)503 bool pmConfigMaskSetBits(psImageMaskType *outMaskValue, psImageMaskType *outMarkValue, const pmConfig *config) 503 504 { 504 505 PS_ASSERT_PTR_NON_NULL(config, false);
Note:
See TracChangeset
for help on using the changeset viewer.
