IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 11, 2006, 4:33:50 PM (20 years ago)
Author:
jhoblitt
Message:

add mapPositionToDetRun()
simply -runs & unmask the iteration field

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/dettool.c

    r8291 r8293  
    4040static bool rerunMode(pxConfig *config);
    4141
     42static bool mapPositionToDetRun(psArray *mds);
    4243static psArray *validDetInputClassIds(pxConfig *config, const char *det_id);
    4344static psArray *searchInputImfiles(pxConfig *config, const char *det_id);
     
    308309
    309310    // map position -> det_id
    310     // but leave position in the metadata as ippdbPrintMetadatas() will strip it
    311     // for us
    312     for (long i = 0; i < psArrayLength(detRuns); i++) {
    313         bool status = false;
    314         psS32 position = psMetadataLookupS32(&status, detRuns->data[i], "position");
    315         if (!status) {
    316             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for position");
    317             psFree(detRuns);
    318             return false;
    319         }
    320         psMetadataAddS32(detRuns->data[i], PS_LIST_HEAD, "det_id", 0, NULL, position);
     311    if (!mapPositionToDetRun(detRuns)) {
     312        psError(PS_ERR_UNKNOWN, false, "failed to map position -> det_id");
     313        psFree(detRuns);
     314        return false;
    321315    }
    322316
     
    328322    }
    329323    psFree(detRuns);
     324
     325    return true;
     326}
     327
     328static bool mapPositionToDetRun(psArray *mds)
     329{
     330    PS_ASSERT_PTR_NON_NULL(mds, false);
     331
     332    for (long i = 0; i < psArrayLength(mds); i++) {
     333        bool status = false;
     334        psS32 position = psMetadataLookupS32(&status, mds->data[i], "position");
     335        if (!status) {
     336            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for position");
     337            psFree(mds);
     338            return false;
     339        }
     340        psMetadataAddS32(mds->data[i], PS_LIST_HEAD, "det_id", 0, NULL, position);
     341    }
    330342
    331343    return true;
     
    502514
    503515    // map position -> det_id
    504     // but leave position in the metadata as ippdbPrintMetadatas() will strip it
    505     // for us
    506     for (long i = 0; i < psArrayLength(detRuns); i++) {
    507         bool status = false;
    508         psS32 position = psMetadataLookupS32(&status, detRuns->data[i], "position");
    509         if (!status) {
    510             psError(PS_ERR_UNKNOWN, false, "failed to lookup value for position");
    511             psFree(detRuns);
    512             return false;
    513         }
    514         psMetadataAddS32(detRuns->data[i], PS_LIST_HEAD, "det_id", 0, NULL, position);
     516    if (!mapPositionToDetRun(detRuns)) {
     517        psError(PS_ERR_UNKNOWN, false, "failed to map position -> det_id");
     518        psFree(detRuns);
     519        return false;
    515520    }
    516521
     
    538543    }
    539544
    540     // XXX simplify this but just editing the psMetadata in the runs array
    541     // print imfile list
    542     psMetadata *output = psMetadataAlloc();
    543     for (long i = 0; i < psArrayLength(runs); i++) {
    544         psMetadata *run = runs->data[i];
    545         psMetadata *md = psMetadataAlloc();
    546         bool status = false;
    547         // we need to change "position" to "det_id"
    548         // lookup values
    549         psS32 det_id = psMetadataLookupS32(&status, run, "position");
    550         if (!status) {
    551             psError(PS_ERR_UNKNOWN, false,
    552                     "failed to lookup value for position");
    553             psFree(output);
    554             psFree(md);
    555             psFree(runs);
    556             return false;
    557         }
    558         psString det_type = psMetadataLookupStr(&status, run, "det_type");
    559         if (!status) {
    560             psError(PS_ERR_UNKNOWN, false,
    561                     "failed to lookup value for det_type");
    562             psFree(output);
    563             psFree(md);
    564             psFree(runs);
    565             return false;
    566         }
    567         // add values
    568         if (!psMetadataAddS32(md, PS_LIST_TAIL, "det_id", 0, NULL, det_id)) {
    569             psError(PS_ERR_UNKNOWN, false, "failed to add item det_id");
    570             psFree(output);
    571             psFree(md);
    572             psFree(runs);
    573             return false;
    574         }
    575         if (!psMetadataAddStr(md, PS_LIST_TAIL, "det_type", 0, NULL, det_type)) {
    576             psError(PS_ERR_UNKNOWN, false, "failed to add item det_type");
    577             psFree(output);
    578             psFree(md);
    579             psFree(runs);
    580             return false;
    581         }
    582         psMetadataAddMetadata(
    583             output, PS_LIST_TAIL, "detRun", PS_META_DUPLICATE_OK, NULL, md
    584         );
    585         psFree(md);
    586     }
    587 
    588     psFree(runs);
     545    // map position -> det_id
     546    if (!mapPositionToDetRun(runs)) {
     547        psError(PS_ERR_UNKNOWN, false, "failed to map position -> det_id");
     548        psFree(runs);
     549        return false;
     550    }
    589551
    590552    bool simple = false;
     
    599561
    600562    // negative simple so the default is true
    601     if (!ippdbPrintMetadata(stdout, output, !simple)) {
     563    if (!ippdbPrintMetadatas(stdout, runs, "detRun", !simple)) {
    602564        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    603         psFree(output);
    604         return false;
    605     }
     565        psFree(runs);
     566        return false;
     567    }
     568
     569    psFree(runs);
    606570
    607571    return true;
Note: See TracChangeset for help on using the changeset viewer.