IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7239


Ignore:
Timestamp:
May 26, 2006, 5:14:47 PM (20 years ago)
Author:
jhoblitt
Message:

implement procMode() support for -chip

File:
1 edited

Legend:

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

    r7205 r7239  
    426426    // I.e., when all of the same class_id for the input exposures have been
    427427    // processed.  This should be done after detStackedImfiles are masked so we
    428     // don't have to doen this check unless we have to.
     428    // don't have to do this check unless we have to.
    429429    if (psMetadataLookupBool(&status, config->args, "-chip")) {
     430        // get a count of raw imfiles per class_id
    430431        psArray *rawImfiles = searchInputImfiles(config, det_id);
    431 
    432 
    433 
    434 
    435         psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
    436         return false;
     432        if (!rawImfiles) {
     433            psError(PS_ERR_UNKNOWN, false, "no rawImfile row founds");
     434            return false;
     435        }
     436
     437        psHash *raw_counts = psHashAlloc(psArrayLength(rawImfiles));
     438        for (long i = 0; i < psArrayLength(rawImfiles); i++) {
     439            // check to see if the key already exists
     440            psU32 *count = psHashLookup(
     441                raw_counts,
     442                ((rawImfileRow *)rawImfiles->data[i])->class_id
     443            );
     444            if (count) {
     445                ++(*count);
     446            } else {
     447                psU32 *count = psAlloc(sizeof(psU32));
     448                *count = 1;
     449                psHashAdd(raw_counts,
     450                    ((rawImfileRow *)rawImfiles->data[i])->class_id, count
     451                );
     452                psFree(count);
     453            }
     454        }
     455#if 0
     456        {
     457            printf("raw counts:\n");
     458            psList *keys  = psHashKeyList(raw_counts);
     459            psListIterator *iter = psListIteratorAlloc(keys, 0, false);
     460            char *key = NULL;
     461            while ((key = psListGetAndIncrement(iter))) {
     462                psU32 *count = psHashLookup(raw_counts, key);
     463                printf("%s: %d\n", key, *count);
     464            }
     465            psFree(iter);
     466            psFree(keys);
     467        }
     468#endif
     469
     470        // get a count of processed imfiles per class_id
     471        psHash *processed_counts = psHashAlloc(psArrayLength(processedImfiles));
     472        for (long i = 0; i < psArrayLength(processedImfiles); i++) {
     473            // check to see if the key already exists
     474            psU32 *count = psHashLookup(
     475                processed_counts,
     476                ((detProcessedImfileRow *)processedImfiles->data[i])->class_id
     477            );
     478            if (count) {
     479                ++(*count);
     480            } else {
     481                psU32 *count = psAlloc(sizeof(psU32));
     482                *count = 1;
     483                psHashAdd(processed_counts,
     484            ((detProcessedImfileRow *)processedImfiles->data[i])->class_id,
     485                count
     486                );
     487                psFree(count);
     488            }
     489        }
     490#if 0
     491        {
     492            printf("processed counts:\n");
     493            psList *keys  = psHashKeyList(processed_counts);
     494            psListIterator *iter = psListIteratorAlloc(keys, 0, false);
     495            char *key = NULL;
     496            while ((key = psListGetAndIncrement(iter))) {
     497                psU32 *count = psHashLookup(processed_counts, key);
     498                printf("%s: %d\n", key, *count);
     499            }
     500            psFree(iter);
     501            psFree(keys);
     502        }
     503#endif
     504
     505        // compare the two class_id counts for any mismatched counts
     506        psList *keys  = psHashKeyList(processed_counts);
     507        psListIterator *iter = psListIteratorAlloc(keys, 0, false);
     508        char *key = NULL;
     509        while ((key = psListGetAndIncrement(iter))) {
     510            psU32 *pcount = psHashLookup(processed_counts, key);
     511            psU32 *rcount = psHashLookup(raw_counts, key);
     512            if (*pcount != *rcount) {
     513                psError(PS_ERR_UNKNOWN, false,
     514                    "class_id %s - processed: %u raw: %u ",
     515                    key, *pcount, *rcount
     516                );
     517                // iterate through processedImfiles and remove *ALL* enteries
     518                // with the mismatched class_id
     519                for (long i = 0; i < psArrayLength(processedImfiles); i++) {
     520                    if (((detProcessedImfileRow *)processedImfiles->data[i])->class_id) {
     521                        psArrayRemove(processedImfiles, processedImfiles->data[i]);
     522                        --i;
     523                    }
     524                }
     525
     526            }
     527        }
     528        psFree(iter);
     529        psFree(keys);
     530
     531        psFree(raw_counts);
     532        psFree(processed_counts);
    437533    }
    438534
Note: See TracChangeset for help on using the changeset viewer.