Changeset 23428 for trunk/psModules/src/concepts/pmConceptsWrite.c
- Timestamp:
- Mar 19, 2009, 11:45:11 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/concepts/pmConceptsWrite.c (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/concepts/pmConceptsWrite.c
r22699 r23428 226 226 } 227 227 228 // Return the camera format appropriate for a focal plane hierarchy 229 static psMetadata *conceptsCameraFormat(const pmFPA *fpa, const pmChip *chip, const pmCell *cell) 230 { 231 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 232 if (!hdu) { 233 return NULL; 234 } 235 return hdu->format; 236 } 237 238 // Return the DATABASE metadata from the format 239 static psMetadata *conceptsDatabase(const psMetadata *format) 240 { 241 bool mdok; // Status of MD lookup 242 return psMetadataLookupMetadata(&mdok, format, "DEFAULTS"); 243 } 244 245 // Return the TRANSLATION metadata from the format 246 static psMetadata *conceptsTranslation(const psMetadata *format) 247 { 248 bool mdok; // Status of MD lookup 249 return psMetadataLookupMetadata(&mdok, format, "TRANSLATION"); 250 } 251 252 // Return the DEFAULTS metadata from the format 253 static psMetadata *conceptsDefaults(const psMetadata *format) 254 { 255 bool mdok; // Status of MD lookup 256 return psMetadataLookupMetadata(&mdok, format, "DEFAULTS"); 257 } 258 228 259 229 260 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 231 262 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 232 263 233 bool p_pmConceptsWriteToCells(const psMetadata *specs, const pmCell *cell, const psMetadata *concepts) 234 { 235 PS_ASSERT_PTR_NON_NULL(specs, false); 236 PS_ASSERT_PTR_NON_NULL(concepts, false); 264 bool p_pmConceptWriteToCells(const pmCell *cell, const pmConceptSpec *spec, 265 const psMetadataItem *conceptItem, const psMetadata *format) 266 { 237 267 if (!cell) { 238 268 return false; … … 242 272 } 243 273 244 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // The HDU at the lowest level 274 if (!format) { 275 format = conceptsCameraFormat(NULL, NULL, cell); 276 if (!format) { 277 return false; 278 } 279 } 280 281 psMetadataItem *cameraItem = psMetadataLookup(cell->config, conceptItem->name); // Version in the config 282 if (!cameraItem) { 283 return false; 284 } 285 286 psString nameSource = NULL; // String with the concept name and ".SOURCE" added 287 psStringAppend(&nameSource, "%s.SOURCE", conceptItem->name); 288 bool mdok = true; // Status of MD lookup 289 psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source 290 if (mdok && strlen(source) > 0) { 291 psTrace("psModules.concepts", 8, "%s is %s\n", nameSource, source); 292 if (strcasecmp(source, "HEADER") == 0) { 293 if (cameraItem->type != PS_DATA_STRING) { 294 psWarning("Concept %s is specified by header, but is not of type STR --- ignored.", 295 conceptItem->name); 296 psFree(nameSource); 297 return false; 298 } 299 300 // Formatted version 301 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 302 format, NULL, NULL, cell); 303 if (!formatted) { 304 psFree(nameSource); 305 return true; 306 } 307 308 psTrace("psModules.concepts", 8, "Writing %s to header %s\n", 309 conceptItem->name, cameraItem->data.str); 310 pmHDU *hdu = pmHDUGetLowest(NULL, NULL, cell); // Header data unit 311 if (!hdu) { 312 psError(PS_ERR_UNEXPECTED_NULL, false, 313 "Unable to find HDU to write concept %s", conceptItem->name); 314 return false; 315 } 316 writeHeader(hdu, cameraItem->data.V, formatted); 317 psFree(formatted); 318 } else if (strcasecmp(source, "VALUE") == 0) { 319 // Formatted version 320 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 321 format, NULL, NULL, cell); 322 if (!formatted) { 323 psFree(nameSource); 324 return true; 325 } 326 327 psTrace("psModules.concepts", 8, "Checking %s against camera format.\n", conceptItem->name); 328 if (!compareConcepts(formatted, cameraItem)) { 329 psWarning("Concept %s is specified by value in the camera format, but the values don't match", 330 conceptItem->name); 331 } 332 psFree(formatted); 333 } else { 334 psWarning("Concept source %s isn't HEADER or VALUE --- can't write", nameSource); 335 } 336 } else { 337 // Assume it's specified by value 338 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 339 format, NULL, NULL, cell); 340 if (!formatted) { 341 psFree(nameSource); 342 return true; 343 } 344 345 if (!compareConcepts(formatted, cameraItem)) { 346 psWarning("Concept %s is specified by value in the camera format, but the values don't match.", 347 conceptItem->name); 348 } 349 psFree(formatted); 350 } 351 psFree(nameSource); 352 353 return true; 354 } 355 356 bool p_pmConceptWriteToDefaults(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 357 const pmConceptSpec *spec, const psMetadataItem *conceptItem, 358 const psMetadata *format, const psMetadata *defaults) 359 { 360 if (!format) { 361 format = conceptsCameraFormat(fpa, chip, cell); 362 if (!format) { 363 return false; 364 } 365 } 366 if (!defaults) { 367 defaults = conceptsDefaults(format); 368 if (!defaults) { 369 return false; 370 } 371 } 372 373 psMetadataItem *defaultItem = p_pmConceptsReadSingleFromDefaults(conceptItem->name, defaults, 374 fpa, chip, cell); 375 if (!defaultItem) { 376 return false; 377 } 378 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DEFAULTS, 379 format, fpa, chip, cell); 380 if (!formatted) { 381 return true; 382 } 383 384 if (strcmp(defaultItem->name, conceptItem->name) != 0) { 385 // Correct the name to match the concept name 386 defaultItem = psMetadataItemCopy(defaultItem); 387 psFree(defaultItem->name); 388 defaultItem->name = psStringCopy(conceptItem->name); 389 } else { 390 psMemIncrRefCounter(defaultItem); 391 } 392 393 if (!compareConcepts(formatted, defaultItem)) { 394 psWarning("Concept %s is specified by the DEFAULTS in the camera format, but the values don't match.", 395 conceptItem->name); 396 } 397 psFree(defaultItem); 398 psFree(formatted); 399 400 return true; 401 } 402 403 404 bool p_pmConceptWriteToHeader(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 405 const pmConceptSpec *spec, const psMetadataItem *conceptItem, 406 const psMetadata *format, const psMetadata *translation) 407 { 408 if (!format) { 409 format = conceptsCameraFormat(fpa, chip, cell); 410 if (!format) { 411 return false; 412 } 413 } 414 if (!translation) { 415 translation = conceptsTranslation(format); 416 if (!translation) { 417 return false; 418 } 419 } 420 421 psMetadataItem *headerItem = psMetadataLookup(translation, conceptItem->name); // How to format for header 422 if (!headerItem) { 423 return false; 424 } 425 if (headerItem->type == PS_DATA_METADATA) { 426 // This is a menu 427 psTrace("psModules.concepts", 5, "%s is of type METADATA.\n", conceptItem->name); 428 headerItem = p_pmConceptsDepend(conceptItem->name, headerItem->data.md, translation, fpa, chip, cell); 429 if (!headerItem) { 430 return false; 431 } 432 } 433 if (headerItem->type != PS_DATA_STRING) { 434 psWarning("TRANSLATION keyword for concept %s isn't of type STR --- ignored.", conceptItem->name); 435 return false; 436 } 437 psTrace("psModules.concepts", 3, "Writing %s to header %s\n", conceptItem->name, headerItem->data.str); 438 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 439 format, fpa, chip, cell); 440 if (!formatted) { 441 // Found it, but it doesn't need to be written 442 return true; 443 } 444 445 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // HDU to which to write 245 446 if (!hdu) { 246 return false; 247 } 248 psMetadata *cameraFormat = hdu->format; // The camera format 249 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 250 psMetadataItem *specItem = NULL; // Item from the specs metadata 251 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 252 pmConceptSpec *spec = specItem->data.V; // The specification 253 psString name = specItem->name; // The concept name 254 psMetadataItem *cameraItem = psMetadataLookup(cell->config, name); // The concept from the camera, 255 // or NULL 256 if (cameraItem) { 257 // Grab the concept 258 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The concept 259 260 psString nameSource = NULL; // String with the concept name and ".SOURCE" added 261 psStringAppend(&nameSource, "%s.SOURCE", name); 262 bool mdok = true; // Status of MD lookup 263 psString source = psMetadataLookupStr(&mdok, cell->config, nameSource); // The source 264 if (mdok && strlen(source) > 0) { 265 psTrace("psModules.concepts", 8, "%s is %s\n", nameSource, source); 266 if (strcasecmp(source, "HEADER") == 0) { 267 if (cameraItem->type != PS_DATA_STRING) { 268 psWarning("Concept %s is specified by header, but is not " 269 "of type STR --- ignored.\n", conceptItem->name); 270 continue; 271 } 272 273 // Formatted version 274 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 275 cameraFormat, NULL, NULL, cell); 276 if (!formatted) { 277 continue; 278 } 279 280 psTrace("psModules.concepts", 8, "Writing %s to header %s\n", name, cameraItem->data.str); 281 writeHeader(hdu, cameraItem->data.V, formatted); 282 psFree(formatted); 283 } else if (strcasecmp(source, "VALUE") == 0) { 284 // Formatted version 285 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 286 cameraFormat, NULL, NULL, cell); 287 if (!formatted) { 288 continue; 289 } 290 291 psTrace("psModules.concepts", 8, "Checking %s against camera format.\n", name); 292 if (! compareConcepts(formatted, cameraItem)) { 293 psWarning("Concept %s is specified by value in the camera " 294 "format, but the values don't match.\n", name); 295 } 296 psFree(formatted); 297 } else { 298 psWarning("Concept source %s isn't HEADER or VALUE --- can't " 299 "write\n", nameSource); 300 } 301 } else { 302 // Assume it's specified by value 303 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_CELLS, 304 cameraFormat, NULL, NULL, cell); 305 if (!formatted) { 306 continue; 307 } 308 309 if (! compareConcepts(formatted, cameraItem)) { 310 psWarning("Concept %s is specified by value in the camera " 311 "format, but the values don't match.\n", name); 312 } 313 psFree(formatted); 314 } 315 psFree(nameSource); 316 } 317 318 } 319 psFree(specsIter); 447 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find HDU to write concept %s", conceptItem->name); 448 return false; 449 } 450 writeHeader(hdu, headerItem->data.V, formatted); 451 psFree(formatted); 452 320 453 return true; 321 454 } 322 455 323 bool p_pmConceptsWriteToDefaults(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip, 324 const pmCell *cell, const psMetadata *concepts) 325 { 326 PS_ASSERT_PTR_NON_NULL(specs, false); 327 PS_ASSERT_PTR_NON_NULL(concepts, false); 328 329 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 330 if (!hdu) { 331 return false; 332 } 333 psMetadata *cameraFormat = hdu->format; // The camera format 334 bool mdok = true; // Status of MD lookup 335 psMetadata *defaults = psMetadataLookupMetadata(&mdok, cameraFormat, "DEFAULTS"); // The DEFAULTS spec 336 if (!mdok || !defaults) { 337 return false; 338 } 339 340 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 341 psMetadataItem *specItem = NULL; // Item from the specs metadata 342 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 343 pmConceptSpec *spec = specItem->data.V; // The specification 344 psString name = specItem->name; // The concept name 345 346 psMetadataItem *defaultItem = p_pmConceptsReadSingleFromDefaults(name, defaults, fpa, chip, cell); 347 if (!defaultItem) { 348 continue; 349 } 350 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 351 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DEFAULTS, 352 cameraFormat, fpa, chip, cell); 353 if (!formatted) { 354 continue; 355 } 356 357 if (strcmp(defaultItem->name, name) != 0) { 358 // Correct the name to match the concept name 359 defaultItem = psMetadataItemCopy(defaultItem); 360 psFree(defaultItem->name); 361 defaultItem->name = psStringCopy(name); 362 } else { 363 psMemIncrRefCounter(defaultItem); 364 } 365 366 if (!compareConcepts(formatted, defaultItem)) { 367 psWarning("Concept %s is specified by the DEFAULTS in the camera " 368 "format, but the values don't match.\n", name); 369 } 370 psFree(defaultItem); 371 psFree(formatted); 372 } 373 psFree(specsIter); 456 bool p_pmConceptWriteToDatabase(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 457 pmConfig *config, const pmConceptSpec *spec, 458 const psMetadataItem *conceptItem, const psMetadata *format, 459 const psMetadata *database) 460 { 461 PS_ASSERT_PTR_NON_NULL(config, false); 462 463 #ifndef HAVE_PSDB 464 return false; 465 #else 466 467 if (!format) { 468 format = conceptsCameraFormat(fpa, chip, cell); 469 if (!format) { 470 return false; 471 } 472 } 473 if (!database) { 474 database = conceptsDatabase(format); 475 if (!database) { 476 return false; 477 } 478 } 479 480 psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(conceptItem->name, database, config, 481 fpa, chip, cell); // Database version 482 if (!dbItem) { 483 return false; 484 } 485 486 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE, 487 format, fpa, chip, cell); 488 if (!formatted) { 489 return false; 490 } 491 492 if (strcmp(dbItem->name, conceptItem->name) != 0) { 493 // Correct the name to match the concept name 494 dbItem = psMetadataItemCopy(dbItem); 495 psFree(dbItem->name); 496 dbItem->name = psStringCopy(conceptItem->name); 497 } else { 498 psMemIncrRefCounter(dbItem); 499 } 500 501 if (!compareConcepts(formatted, dbItem)) { 502 psWarning("Concept %s is specified by the DATABASE in the camera " 503 "format, but the values don't match.\n", conceptItem->name); 504 } 505 psFree(dbItem); 506 psFree(formatted); 507 374 508 return true; 375 } 376 377 378 bool p_pmConceptsWriteToHeader(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip, 379 const pmCell *cell, const psMetadata *concepts) 380 { 381 PS_ASSERT_PTR_NON_NULL(specs, false); 382 PS_ASSERT_PTR_NON_NULL(concepts, false); 383 384 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level 385 if (!hdu) { 386 return false; 387 } 388 psMetadata *cameraFormat = hdu->format; // The camera format 389 bool mdok = true; // Status of MD lookup 390 psMetadata *translation = psMetadataLookupMetadata(&mdok, cameraFormat, "TRANSLATION"); // The TRANSLATION spec 391 if (!mdok || !translation) { 392 return false; 393 } 394 395 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator 396 psMetadataItem *specItem = NULL; // Item from the specs metadata 397 while ((specItem = psMetadataGetAndIncrement(specsIter))) { 398 pmConceptSpec *spec = specItem->data.V; // The specification 399 psString name = specItem->name; // The concept name 400 psMetadataItem *headerItem = psMetadataLookup(translation, name); // The item from the TRANSLATION 401 if (!headerItem) { 402 continue; 403 } 404 if (headerItem->type == PS_DATA_METADATA) { 405 // This is a menu 406 psTrace("psModules.concepts", 5, "%s is of type METADATA.\n", name); 407 headerItem = p_pmConceptsDepend(name, headerItem->data.md, translation, fpa, chip, cell); 408 if (!headerItem) { 409 continue; 410 } 411 } 412 if (headerItem->type != PS_DATA_STRING) { 413 psWarning("TRANSLATION keyword for concept %s isn't of type STR --- ignored.", name); 414 continue; 415 } 416 psTrace("psModules.concepts", 3, "Writing %s to header %s\n", name, headerItem->data.str); 417 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts 418 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_HEADER, 419 cameraFormat, fpa, chip, cell); 420 if (!formatted) { 421 continue; 422 } 423 writeHeader(hdu, headerItem->data.V, formatted); 424 psFree(formatted); 425 } 426 psFree(specsIter); 509 #endif 510 } 511 512 513 bool pmConceptWriteSingle(const pmFPA *fpa, const pmChip *chip, const pmCell *cell, 514 pmConfig *config, const psMetadataItem *conceptItem) 515 { 516 pmConceptsInit(); 517 518 psMetadata *format = conceptsCameraFormat(fpa, chip, cell); // Camera format 519 if (!format) { 520 psError(PS_ERR_UNKNOWN, false, "Unable to retrieve camera format."); 521 return false; 522 } 523 524 const char *name = conceptItem->name; // Name of concept 525 526 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications for FPA 527 bool mdok; // Status of MD lookup 528 pmConceptSpec *spec = psMetadataLookupPtr(&mdok, conceptsFPA, name); // Concept specification of interest 529 if (!spec) { 530 psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications for Chip 531 spec = psMetadataLookupPtr(&mdok, conceptsChip, name); 532 if (!spec) { 533 psMetadata *conceptsCell = pmConceptsSpecs(PM_FPA_LEVEL_CELL); // Concept specifications for Cell 534 spec = psMetadataLookupPtr(&mdok, conceptsCell, name); 535 if (!spec) { 536 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find specification for concept %s", name); 537 return false; 538 } 539 } 540 } 541 542 if (!p_pmConceptWriteToCells(cell, spec, conceptItem, format) && 543 !p_pmConceptWriteToDefaults(fpa, chip, cell, spec, conceptItem, format, NULL) && 544 !p_pmConceptWriteToHeader(fpa, chip, cell, spec, conceptItem, format, NULL) && 545 !p_pmConceptWriteToDatabase(fpa, chip, cell, config, spec, conceptItem, format, NULL)) { 546 return false; 547 } 427 548 return true; 428 549 } 429 430 // XXX Warning: This code has not been tested at all431 bool p_pmConceptsWriteToDatabase(const psMetadata *specs, const pmFPA *fpa, const pmChip *chip,432 const pmCell *cell, pmConfig *config, const psMetadata *concepts)433 {434 PS_ASSERT_PTR_NON_NULL(specs, false);435 PS_ASSERT_PTR_NON_NULL(concepts, false);436 PS_ASSERT_PTR_NON_NULL(config, false);437 438 #ifndef HAVE_PSDB439 return false;440 #else441 442 pmHDU *hdu = pmHDUGetLowest(fpa, chip, cell); // The HDU at the lowest level443 if (!hdu) {444 return false;445 }446 psMetadata *cameraFormat = hdu->format; // The camera format447 bool mdok = true; // Status of MD lookup448 psMetadata *database = psMetadataLookupMetadata(&mdok, cameraFormat, "DATABASE"); // The DATABASE spec449 if (!mdok || !database) {450 return false;451 }452 psMetadataIterator *specsIter = psMetadataIteratorAlloc(specs, PS_LIST_HEAD, NULL); // Iterator453 psMetadataItem *specItem = NULL; // Item from the specs metadata454 while ((specItem = psMetadataGetAndIncrement(specsIter))) {455 pmConceptSpec *spec = specItem->data.V; // The specification456 psString name = specItem->name; // The concept name457 458 psMetadataItem *dbItem = p_pmConceptsReadSingleFromDatabase(name, database, config, fpa, chip, cell);459 if (!dbItem) {460 continue;461 }462 463 psMetadataItem *conceptItem = psMetadataLookup(concepts, name); // The item from the concepts464 psMetadataItem *formatted = conceptFormat(spec, conceptItem, PM_CONCEPT_SOURCE_DATABASE,465 cameraFormat, fpa, chip, cell);466 if (!formatted) {467 continue;468 }469 470 if (strcmp(dbItem->name, name) != 0) {471 // Correct the name to match the concept name472 dbItem = psMetadataItemCopy(dbItem);473 psFree(dbItem->name);474 dbItem->name = psStringCopy(name);475 } else {476 psMemIncrRefCounter(dbItem);477 }478 479 if (!compareConcepts(formatted, dbItem)) {480 psWarning("Concept %s is specified by the DATABASE in the camera "481 "format, but the values don't match.\n", name);482 }483 psFree(dbItem);484 psFree(formatted);485 }486 psFree(specsIter);487 return true;488 #endif489 }490 491 492 493 550 494 551 … … 498 555 const pmChip *chip, // The chip 499 556 const pmCell *cell, // The cell 500 pmConceptSource source, // The source of the concepts to write501 557 pmConfig *config, // Configuration 502 558 psMetadata *concepts // The concepts to write out … … 508 564 pmConceptsInit(); 509 565 510 psTrace("psModules.concepts", 3, "Writing concepts (%p %p %p): %d\n", fpa, chip, cell, source); 511 512 if (source & PM_CONCEPT_SOURCE_CELLS) { 513 p_pmConceptsWriteToCells(*specs, cell, concepts); 514 } 515 if (source & PM_CONCEPT_SOURCE_DEFAULTS) { 516 p_pmConceptsWriteToDefaults(*specs, fpa, chip, cell, concepts); 517 } 518 if (source & (PM_CONCEPT_SOURCE_PHU | PM_CONCEPT_SOURCE_HEADER)) { 519 p_pmConceptsWriteToHeader(*specs, fpa, chip, cell, concepts); 520 } 521 if (source & PM_CONCEPT_SOURCE_DATABASE) { 522 p_pmConceptsWriteToDatabase(*specs, fpa, chip, cell, config, concepts); 523 } 566 psTrace("psModules.concepts", 3, "Writing concepts (%p %p %p)\n", fpa, chip, cell); 567 568 psMetadata *format = conceptsCameraFormat(fpa, chip, cell); // Camera format 569 if (!format) { 570 psError(PS_ERR_UNKNOWN, false, "Unable to retrieve camera format."); 571 return false; 572 } 573 574 psMetadata *defaults = conceptsDefaults(format); // DEFAULTS configuration 575 psMetadata *translation = conceptsTranslation(format); // TRANSLATION configuration 576 psMetadata *database = conceptsDatabase(format); // DATABASE configuration 577 578 psMetadataIterator *iter = psMetadataIteratorAlloc(*specs, PS_LIST_HEAD, NULL); // Iterator 579 psMetadataItem *item = NULL; // Item from the specs metadata 580 while ((item = psMetadataGetAndIncrement(iter))) { 581 pmConceptSpec *spec = item->data.V; // The specification 582 psString name = item->name; // The concept name 583 584 psMetadataItem *concept = psMetadataLookup(concepts, name); // Concept to write 585 586 if (!p_pmConceptWriteToCells(cell, spec, concept, format) && 587 !p_pmConceptWriteToDefaults(fpa, chip, cell, spec, concept, format, defaults) && 588 !p_pmConceptWriteToHeader(fpa, chip, cell, spec, concept, format, translation) && 589 !p_pmConceptWriteToDatabase(fpa, chip, cell, config, spec, concept, format, database)) { 590 psTrace("psModules.concepts", 1, "Unable to write concept %s to any output", name); 591 } 592 } 593 psFree(iter); 524 594 525 595 return true; … … 527 597 528 598 529 bool pmConceptsWriteFPA(const pmFPA *fpa, pmConceptSource source,bool propagateDown, pmConfig *config)599 bool pmConceptsWriteFPA(const pmFPA *fpa, bool propagateDown, pmConfig *config) 530 600 { 531 601 PS_ASSERT_PTR_NON_NULL(fpa, false); 532 602 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications 533 603 psTrace("psModules.concepts", 5, "Writing FPA concepts: %p %p\n", conceptsFPA, fpa->concepts); 534 bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, source,config, fpa->concepts);604 bool success = conceptsWrite(&conceptsFPA, fpa, NULL, NULL, config, fpa->concepts); 535 605 if (propagateDown) { 536 606 psArray *chips = fpa->chips; // Array of chips … … 538 608 pmChip *chip = chips->data[i]; // Chip of interest 539 609 if (chip && !chip->hdu) { 540 success &= pmConceptsWriteChip(chip, source,false, true, config);610 success &= pmConceptsWriteChip(chip, false, true, config); 541 611 } 542 612 } … … 546 616 547 617 548 bool pmConceptsWriteChip(const pmChip *chip, pmConceptSource source, bool propagateUp, 549 bool propagateDown, pmConfig *config) 618 bool pmConceptsWriteChip(const pmChip *chip, bool propagateUp, bool propagateDown, pmConfig *config) 550 619 { 551 620 PS_ASSERT_PTR_NON_NULL(chip, false); … … 553 622 psTrace("psModules.concepts", 5, "Writing chip concepts: %p %p\n", conceptsChip, chip->concepts); 554 623 pmFPA *fpa = chip->parent; // FPA to which the chip belongs 555 bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, source,config, chip->concepts);624 bool success = conceptsWrite(&conceptsChip, fpa, chip, NULL, config, chip->concepts); 556 625 if (propagateUp && !fpa->hdu) { 557 626 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications 558 success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, source,config, fpa->concepts);627 success &= conceptsWrite(&conceptsFPA, fpa, chip, NULL, config, fpa->concepts); 559 628 } 560 629 if (propagateDown) { … … 563 632 pmCell *cell = cells->data[i]; // Cell of interest 564 633 if (cell && !cell->hdu) { 565 success &= pmConceptsWriteCell(cell, source,false, config);634 success &= pmConceptsWriteCell(cell, false, config); 566 635 } 567 636 } … … 571 640 572 641 573 bool pmConceptsWriteCell(const pmCell *cell, pmConceptSource source,bool propagateUp, pmConfig *config)642 bool pmConceptsWriteCell(const pmCell *cell, bool propagateUp, pmConfig *config) 574 643 { 575 644 PS_ASSERT_PTR_NON_NULL(cell, false); … … 579 648 pmFPA *fpa = chip->parent; // FPA to which the chip belongs 580 649 581 bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, source,config, cell->concepts);650 bool success = conceptsWrite(&conceptsCell, fpa, chip, cell, config, cell->concepts); 582 651 if (propagateUp) { 583 652 if (!chip->hdu) { 584 653 psMetadata *conceptsChip = pmConceptsSpecs(PM_FPA_LEVEL_CHIP); // Concept specifications 585 success &= conceptsWrite(&conceptsChip, fpa, chip, cell, source,config, chip->concepts);654 success &= conceptsWrite(&conceptsChip, fpa, chip, cell, config, chip->concepts); 586 655 if (!fpa->hdu) { 587 656 psMetadata *conceptsFPA = pmConceptsSpecs(PM_FPA_LEVEL_FPA); // Concept specifications 588 success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, source,config, fpa->concepts);657 success &= conceptsWrite(&conceptsFPA, fpa, chip, cell, config, fpa->concepts); 589 658 } 590 659 }
Note:
See TracChangeset
for help on using the changeset viewer.
