IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36931


Ignore:
Timestamp:
Jun 20, 2014, 7:05:00 PM (12 years ago)
Author:
eugene
Message:

merge photcode rule changes from eam/ipp-20140610

Location:
tags/ipp-pv3-cr-20140614/psModules/src/config
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-pv3-cr-20140614/psModules/src/config

  • tags/ipp-pv3-cr-20140614/psModules/src/config/pmConfig.c

    r36375 r36931  
    965965                                  "Original replaced by -R option", newRule);
    966966        }
     967        psFree(camerasIter);
     968    }
     969
     970    // Look for command-line options for files to replace
     971    while ((argNum = psArgumentGet(*argc, argv, "-photcode-rule")) > 0) {
     972        psArgumentRemove(argNum, argc, argv);
     973        if (argNum >= *argc) {
     974            psError(PM_ERR_CONFIG, true,
     975                    "-photcode-rule provided without new rule.");
     976            psFree(config);
     977            return NULL;
     978        }
     979
     980        psString newrule = psStringCopy(argv[argNum]); // The filerule, to be modified
     981        psArgumentRemove(argNum, argc, argv);
     982
     983        psMetadata *cameras = psMetadataLookupMetadata(NULL, config->system, "CAMERAS"); // List of cameras
     984        if (!cameras) {
     985            psError(PM_ERR_CONFIG, false, "Unable to find CAMERAS in the site configuration.\n");
     986            return false;
     987        }
     988
     989        psMetadataIterator *camerasIter = psMetadataIteratorAlloc(cameras, PS_LIST_HEAD, NULL); // Iterator
     990        psMetadataItem *cameraItem;     // Item from iteration
     991        while ((cameraItem = psMetadataGetAndIncrement(camerasIter))) {
     992            // Silently ignore problems --- they will be caught later, because if the user wants the nominated
     993            // file and it's not available for that camera, then they will know.
     994
     995            if (cameraItem->type != PS_DATA_METADATA) {
     996                psTrace("psModules.config", 2,
     997                        "Entry %s in CAMERAS is not of type METADATA --- ignored.", cameraItem->name);
     998                continue;
     999            }
     1000            psMetadata *camera = cameraItem->data.md; // Camera configuration
     1001
     1002            psMetadataAddStr (camera, PS_LIST_TAIL, "PHOTCODE.RULE", PS_META_REPLACE, "original replaced by -photcode-rule option", newrule);
     1003        }
     1004        psFree(newrule);
    9671005        psFree(camerasIter);
    9681006    }
Note: See TracChangeset for help on using the changeset viewer.