IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 23, 2007, 3:41:56 PM (19 years ago)
Author:
jhoblitt
Message:

s/p0/reg/g
s/p1/guide/g
s/p2/chip/g
s/p6/stack/g
s/p5/diff/g
s/p4/warp/g
s/p3/cam/g

File:
1 edited

Legend:

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

    r11997 r12024  
    11/*
    2  * p2tool.c
     2 * chiptool.c
    33 *
    44 * Copyright (C) 2006  Joshua Hoblitt
     
    3838static bool unblockMode(pxConfig *config);
    3939
    40 static p2ProcessedImfileRow *p2PendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile);
    41 static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp);
    42 static p3PendingExpRow *p2PendingToP3PendingExp(pxConfig *config, p2PendingExpRow *pendingExp);
    43 static bool p2ProcessedCompleteExp(pxConfig *config);
     40static chipProcessedImfileRow *chipPendingToProcessedImfile(pxConfig *config, chipPendingImfileRow *imfile);
     41static chipProcessedExpRow *chipPendingToProcessedExp(pxConfig *config, chipPendingExpRow *pendingExp);
     42static camPendingExpRow *chipPendingTocamPendingExp(pxConfig *config, chipPendingExpRow *pendingExp);
     43static bool chipProcessedCompleteExp(pxConfig *config);
    4444
    4545# define MODECASE(caseName, func) \
     
    166166    // XXX this does not work!!!
    167167    psString query = psStringCopy(
    168             "INSERT INTO p2PendingExp\n"
     168            "INSERT INTO chipPendingExp\n"
    169169            "   SElECT\n"
    170170            "       exp_tag,\n"
    171171            "       'my recipe',\n"  // recipe
    172             "       255\n"         // p1_version
    173             "       255\n"         // p2_version
     172            "       255\n"         // guide_version
     173            "       255\n"         // chip_version
    174174            "       %s\n"
    175175            "   FROM rawExp"
    176             "   LEFT JOIN p2ProcessedExp"
     176            "   LEFT JOIN chipProcessedExp"
    177177            "       USING(exp_tag)"
    178178            "   WHERE"
     
    200200    if (!psArrayLength(output)) {
    201201        // XXX check psError here
    202         psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");
     202        psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found");
    203203        psFree(output);
    204204        return false;
     
    220220
    221221    // XXX does this need to be constrained so that it won't return any results
    222     // if a match p2PendingExp hasn't been registered?
     222    // if a match chipPendingExp hasn't been registered?
    223223    psString query = psStringCopy(
    224224            "SELECT"
    225             "   p2PendingImfile.*,"
     225            "   chipPendingImfile.*,"
    226226            "   rawExp.camera,"
    227227            "   rawExp.workdir"
    228             " FROM p2PendingImfile"
    229             " JOIN p2PendingExp"
     228            " FROM chipPendingImfile"
     229            " JOIN chipPendingExp"
    230230            "   USING(exp_tag)"
    231231            " JOIN rawExp"
    232232            "   USING(exp_tag)"
    233             " LEFT JOIN p2Mask"
    234             "   ON p2PendingExp.label = p2Mask.label"
     233            " LEFT JOIN chipMask"
     234            "   ON chipPendingExp.label = chipMask.label"
    235235            " WHERE"
    236             "   p2Mask.label IS NULL"
     236            "   chipMask.label IS NULL"
    237237        );
    238238
    239239    if (config->where) {
    240         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p2PendingImfile");
     240        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipPendingImfile");
    241241        psStringAppend(&query, " AND %s", whereClause);
    242242        psFree(whereClause);
     
    264264    if (!psArrayLength(output)) {
    265265        // XXX check psError here
    266         psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");
     266        psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found");
    267267        psFree(output);
    268268        return true;
     
    280280
    281281    // negative simple so the default is true
    282     if (!ippdbPrintMetadatas(stdout, output, "p2PendingImfile", !simple)) {
     282    if (!ippdbPrintMetadatas(stdout, output, "chipPendingImfile", !simple)) {
    283283        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    284284        psFree(output);
     
    296296    PS_ASSERT_PTR_NON_NULL(config, false);
    297297
    298     // select * from p2ProcessedImfiles
     298    // select * from chipProcessedImfiles
    299299    // where
    300     // exp_tag & class_id are not in p2PendingImfile
     300    // exp_tag & class_id are not in chipPendingImfile
    301301
    302302    // add the completed imfile to
    303     // the p2ProcessedeImfile tables
     303    // the chipProcessedeImfile tables
    304304    // remove corresponding entries from the
    305     // p2PendingImfile table
    306     // check to see if any p2PendingExps have no
    307     // associated p2PendingImfiles
    308     // if so move the p2PendingExp(s) to p2ProcessedExp
     305    // chipPendingImfile table
     306    // check to see if any chipPendingExps have no
     307    // associated chipPendingImfiles
     308    // if so move the chipPendingExp(s) to chipProcessedExp
    309309
    310310    psString query = psStringCopy(
    311311        "SELECT DISTINCT"
    312         "   p2PendingImfile.*"
    313         " FROM p2PendingImfile "
    314         " LEFT JOIN p2ProcessedImfile"
     312        "   chipPendingImfile.*"
     313        " FROM chipPendingImfile "
     314        " LEFT JOIN chipProcessedImfile"
    315315        "   USING(exp_tag, class_id)"
    316316        " WHERE"
    317         "  p2ProcessedImfile.exp_tag IS NULL"
    318         "  AND p2ProcessedImfile.class_id IS NULL"
     317        "  chipProcessedImfile.exp_tag IS NULL"
     318        "  AND chipProcessedImfile.class_id IS NULL"
    319319        );
    320320    {
     
    349349        }
    350350
    351         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p2PendingImfile");
     351        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipPendingImfile");
    352352        psFree(where);
    353353        if (whereClause) {
     
    371371    if (!psArrayLength(output)) {
    372372        // XXX check psError here
    373         psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");
     373        psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found");
    374374        psFree(output);
    375375        return false;
     
    384384    }
    385385
    386     // insert into p2ProcessedImfile
    387     // remove p2PendingImfile entry
     386    // insert into chipProcessedImfile
     387    // remove chipPendingImfile entry
    388388    for (long i = 0; i < psArrayLength(output); i++) {
    389389        psMetadata *row = output->data[i];
    390         // convert metadata into a p2PendingImfile object
    391         p2PendingImfileRow *object = p2PendingImfileObjectFromMetadata(row);
    392         // convert p2PendingImfile object into a p2ProcessedImfile object
    393         p2ProcessedImfileRow *imfile = p2PendingToProcessedImfile(config, object);
     390        // convert metadata into a chipPendingImfile object
     391        chipPendingImfileRow *object = chipPendingImfileObjectFromMetadata(row);
     392        // convert chipPendingImfile object into a chipProcessedImfile object
     393        chipProcessedImfileRow *imfile = chipPendingToProcessedImfile(config, object);
    394394        if (!imfile) {
    395395            // rollback
     
    397397                psError(PS_ERR_UNKNOWN, false, "database error");
    398398            }
    399             psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingImfile to p2ProcessedImfile");
     399            psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingImfile to chipProcessedImfile");
    400400            psFree(object);
    401401            psFree(output);
    402402            return false;
    403403        }
    404         // insert p2ProccessedImfile object into the database
    405         if (!p2ProcessedImfileInsertObject(config->dbh, imfile)) {
     404        // insert chipProccessedImfile object into the database
     405        if (!chipProcessedImfileInsertObject(config->dbh, imfile)) {
    406406            // rollback
    407407            if (!psDBRollback(config->dbh)) {
     
    415415        }
    416416        psFree(imfile);
    417         // delete the p2PendingImfile object from the database
    418         if (!p2PendingImfileDeleteObject(config->dbh, object)) {
     417        // delete the chipPendingImfile object from the database
     418        if (!chipPendingImfileDeleteObject(config->dbh, object)) {
    419419            // there must be atleast 1 Imfile to get this far
    420420            // rollback
     
    437437    // migration can't happen.
    438438
    439     if (!p2ProcessedCompleteExp(config)) {
     439    if (!chipProcessedCompleteExp(config)) {
    440440        // rollback
    441441        if (!psDBRollback(config->dbh)) {
     
    446446    }
    447447
    448     // point of no return for p2PendingImfile -> p2ProcessedImfile
    449     // point of no return for p2PendingExp -> p2ProcessedExp
     448    // point of no return for chipPendingImfile -> chipProcessedImfile
     449    // point of no return for chipPendingExp -> chipProcessedExp
    450450    if (!psDBCommit(config->dbh)) {
    451451        psError(PS_ERR_UNKNOWN, false, "database error");
     
    475475
    476476    // XXX does this need to be constrained so that it won't return any results
    477     // if a match p2PendingExp hasn't been registered?
     477    // if a match chipPendingExp hasn't been registered?
    478478    psString query = psStringCopy(
    479479            "SELECT"
    480             "   p2ProcessedImfile.*,"
     480            "   chipProcessedImfile.*,"
    481481            "   rawExp.camera,"
    482482            "   rawExp.workdir"
    483             " FROM p2ProcessedImfile"
     483            " FROM chipProcessedImfile"
    484484            " JOIN rawExp"
    485485            "   USING(exp_tag)"
    486486            " WHERE "
    487             "   p2ProcessedImfile.exp_tag is NOT NULL" // bogus test -- just here so there there is a 'WHERE' stmt to append conditionals too
     487            "   chipProcessedImfile.exp_tag is NOT NULL" // bogus test -- just here so there there is a 'WHERE' stmt to append conditionals too
    488488        );
    489489
    490490    if (config->where) {
    491         psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p2ProcessedImfile");
     491        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipProcessedImfile");
    492492        psStringAppend(&query, " AND %s", whereClause);
    493493        psFree(whereClause);
     
    496496    if (faulted) {
    497497        // list only faulted rows
    498         psStringAppend(&query, " %s", "AND p2ProcessedImfile.fault != 0");
     498        psStringAppend(&query, " %s", "AND chipProcessedImfile.fault != 0");
    499499    } else {
    500500        // don't list faulted rows
    501         psStringAppend(&query, " %s", "AND p2ProcessedImfile.fault = 0");
     501        psStringAppend(&query, " %s", "AND chipProcessedImfile.fault = 0");
    502502    }
    503503
     
    523523    if (!psArrayLength(output)) {
    524524        // XXX check psError here
    525         psError(PS_ERR_UNKNOWN, false, "no p2ProcessedImfile rows found");
     525        psError(PS_ERR_UNKNOWN, false, "no chipProcessedImfile rows found");
    526526        psFree(output);
    527527        return true;
     
    539539
    540540    // negative simple so the default is true
    541     if (!ippdbPrintMetadatas(stdout, output, "p2ProcessedImfile", !simple)) {
     541    if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) {
    542542        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    543543        psFree(output);
     
    562562    }
    563563
    564     if (!pxSetFaultCode(config->dbh, "p2ProcessedImfile", config->where, code)) {
     564    if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", config->where, code)) {
    565565        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    566566        return false;
     
    586586    }
    587587
    588     if (!p2MaskInsert(config->dbh, label)) {
     588    if (!chipMaskInsert(config->dbh, label)) {
    589589        psError(PS_ERR_UNKNOWN, false, "database error");
    590590        return false;
     
    599599    PS_ASSERT_PTR_NON_NULL(config, false);
    600600
    601     psString query = psStringCopy("SELECT * FROM p2Mask");
     601    psString query = psStringCopy("SELECT * FROM chipMask");
    602602
    603603    if (!p_psDBRunQuery(config->dbh, query)) {
     
    615615    if (!psArrayLength(output)) {
    616616        // XXX check psError here
    617         psError(PS_ERR_UNKNOWN, false, "no p2Mask rows found");
     617        psError(PS_ERR_UNKNOWN, false, "no chipMask rows found");
    618618        psFree(output);
    619619        return true;
     
    631631
    632632    // negative simple so the default is true
    633     if (!ippdbPrintMetadatas(stdout, output, "p2Mask", !simple)) {
     633    if (!ippdbPrintMetadatas(stdout, output, "chipMask", !simple)) {
    634634        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    635635        psFree(output);
     
    658658    }
    659659
    660     char *query = "DELETE FROM p2Mask WHERE label = '%s'";
     660    char *query = "DELETE FROM chipMask WHERE label = '%s'";
    661661
    662662    if (!p_psDBRunQuery(config->dbh, query, label)) {
     
    670670
    671671
    672 static bool p2ProcessedCompleteExp(pxConfig *config)
     672static bool chipProcessedCompleteExp(pxConfig *config)
    673673{
    674674    PS_ASSERT_PTR_NON_NULL(config, false);
    675675
    676     // look for completed p2PendingExp
    677     // migrate them to p2ProccessedExp & p3PendingExp
    678 
    679     // select * from p2PendingExp
    680     // where exp_tag is not in p2ProcessedExp
    681     // where exp_tag is not in p2PendingImfile
    682     // where the number of entries in p2ProccessedImfile matches the .imfiles
     676    // look for completed chipPendingExp
     677    // migrate them to chipProccessedExp & camPendingExp
     678
     679    // select * from chipPendingExp
     680    // where exp_tag is not in chipProcessedExp
     681    // where exp_tag is not in chipPendingImfile
     682    // where the number of entries in chipProccessedImfile matches the .imfiles
    683683    // entry in rawExp
    684684    psString query = psStringCopy(
    685685        "SELECT DISTINCT"
    686         "   p2PendingExp.*,"
     686        "   chipPendingExp.*,"
    687687        "   rawExp.imfiles,"
    688         "   p2ProcessedImfile.class_id"
    689         " FROM p2PendingExp"
     688        "   chipProcessedImfile.class_id"
     689        " FROM chipPendingExp"
    690690        " JOIN rawExp"
    691         "   ON p2PendingExp.exp_tag = rawExp.exp_tag"
    692         " LEFT JOIN p2ProcessedExp"
    693         "   ON p2PendingExp.exp_tag = p2ProcessedExp.exp_tag"
    694         " LEFT JOIN p2PendingImfile"
    695         "   ON p2PendingExp.exp_tag = p2PendingImfile.exp_tag"
    696         " LEFT JOIN p2ProcessedImfile"
    697         "   ON p2PendingExp.exp_tag = p2ProcessedImfile.exp_tag"
     691        "   ON chipPendingExp.exp_tag = rawExp.exp_tag"
     692        " LEFT JOIN chipProcessedExp"
     693        "   ON chipPendingExp.exp_tag = chipProcessedExp.exp_tag"
     694        " LEFT JOIN chipPendingImfile"
     695        "   ON chipPendingExp.exp_tag = chipPendingImfile.exp_tag"
     696        " LEFT JOIN chipProcessedImfile"
     697        "   ON chipPendingExp.exp_tag = chipProcessedImfile.exp_tag"
    698698        " WHERE"
    699         "  p2ProcessedExp.exp_tag IS NULL"
    700         "  AND p2PendingImfile.exp_tag IS NULL"
    701         "  AND p2ProcessedImfile.exp_tag IS NOT NULL"
     699        "  chipProcessedExp.exp_tag IS NULL"
     700        "  AND chipPendingImfile.exp_tag IS NULL"
     701        "  AND chipProcessedImfile.exp_tag IS NOT NULL"
    702702        " GROUP BY"
    703         "   p2PendingExp.exp_tag"
    704         " HAVING rawExp.imfiles = COUNT(p2ProcessedImfile.class_id)"
     703        "   chipPendingExp.exp_tag"
     704        " HAVING rawExp.imfiles = COUNT(chipProcessedImfile.class_id)"
    705705        );
    706706
     
    719719    if (!psArrayLength(output)) {
    720720        // XXX check psError here
    721         psError(PS_ERR_UNKNOWN, false, "no p2PendingExp rows found");
     721        psError(PS_ERR_UNKNOWN, false, "no chipPendingExp rows found");
    722722        psFree(output);
    723723        return true;
    724724    }
    725725
    726     // insert into p2ProcessedExp
    727     // insert into p3PendingExp
    728     // remove p2PendingExp entry
     726    // insert into chipProcessedExp
     727    // insert into camPendingExp
     728    // remove chipPendingExp entry
    729729    for (long i = 0; i < psArrayLength(output); i++) {
    730730        psMetadata *row = output->data[i];
    731         // convert metadata into a p2PendingExp object
    732         p2PendingExpRow *object = p2PendingExpObjectFromMetadata(row);
     731        // convert metadata into a chipPendingExp object
     732        chipPendingExpRow *object = chipPendingExpObjectFromMetadata(row);
    733733        // do both *Exp type conversion first so we don't insert one and then
    734734        // have to rollback the change as the 2nd failed
    735         // convert p2PendingExp object into a p2ProcesseExp object
    736         p2ProcessedExpRow *processedExp = p2PendingToProcessedExp(config, object);
     735        // convert chipPendingExp object into a chipProcesseExp object
     736        chipProcessedExpRow *processedExp = chipPendingToProcessedExp(config, object);
    737737        if (!processedExp) {
    738             psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingExp to p2ProcessedExp");
     738            psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingExp to chipProcessedExp");
    739739            psFree(object);
    740740            psFree(output);
    741741            return false;
    742742        }
    743         // convert p2PendingExp object into a p3PendingExp object
    744         p3PendingExpRow *pendingExp = p2PendingToP3PendingExp(config, object);
     743        // convert chipPendingExp object into a camPendingExp object
     744        camPendingExpRow *pendingExp = chipPendingTocamPendingExp(config, object);
    745745        if (!processedExp) {
    746             psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingExp to p3PendingExp");
     746            psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingExp to camPendingExp");
    747747            psFree(processedExp);
    748748            psFree(object);
     
    750750            return false;
    751751        }
    752         // insert p2ProccessedExp object into the database
    753         if (!p2ProcessedExpInsertObject(config->dbh, processedExp)) {
     752        // insert chipProccessedExp object into the database
     753        if (!chipProcessedExpInsertObject(config->dbh, processedExp)) {
    754754            psError(PS_ERR_UNKNOWN, false, "database error");
    755755            psFree(processedExp);
     
    760760        }
    761761        psFree(processedExp);
    762         // insert p3PendingExp object into the database
    763         if (!p3PendingExpInsertObject(config->dbh, pendingExp)) {
     762        // insert camPendingExp object into the database
     763        if (!camPendingExpInsertObject(config->dbh, pendingExp)) {
    764764            psError(PS_ERR_UNKNOWN, false, "database error");
    765765            psFree(pendingExp);
     
    769769        }
    770770        psFree(pendingExp);
    771         // delete the p2PendingExp object from the database
    772         if (!p2PendingExpDeleteObject(config->dbh, object)) {
     771        // delete the chipPendingExp object from the database
     772        if (!chipPendingExpDeleteObject(config->dbh, object)) {
    773773            // there must be atleast 1 Imfile to get this far
    774774            psError(PS_ERR_UNKNOWN, false, "database error");
     
    786786
    787787
    788 static p2ProcessedImfileRow *p2PendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile)
     788static chipProcessedImfileRow *chipPendingToProcessedImfile(pxConfig *config, chipPendingImfileRow *imfile)
    789789{
    790790    PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    850850    }
    851851
    852     return p2ProcessedImfileRowAlloc(
     852    return chipProcessedImfileRowAlloc(
    853853        imfile->exp_tag,
    854         imfile->p2_version,
    855         imfile->p1_version,
     854        imfile->chip_version,
     855        imfile->guide_version,
    856856        imfile->class_id,
    857857        recipe,
     
    867867
    868868
    869 static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp)
     869static chipProcessedExpRow *chipPendingToProcessedExp(pxConfig *config, chipPendingExpRow *pendingExp)
    870870{
    871871    PS_ASSERT_PTR_NON_NULL(pendingExp, NULL);
    872872 
    873     return p2ProcessedExpRowAlloc(
     873    return chipProcessedExpRowAlloc(
    874874        pendingExp->exp_tag,
    875         pendingExp->p2_version,
    876         pendingExp->p1_version,
     875        pendingExp->chip_version,
     876        pendingExp->guide_version,
    877877        pendingExp->label,
    878878        pendingExp->expgroup,
     
    882882
    883883
    884 static p3PendingExpRow *p2PendingToP3PendingExp(pxConfig *config, p2PendingExpRow *pendingExp)
     884static camPendingExpRow *chipPendingTocamPendingExp(pxConfig *config, chipPendingExpRow *pendingExp)
    885885{
    886886    PS_ASSERT_PTR_NON_NULL(pendingExp, NULL);
    887887
    888     return p3PendingExpRowAlloc(
     888    return camPendingExpRowAlloc(
    889889        pendingExp->exp_tag,
    890         0x0,        // p3 version
    891         pendingExp->p2_version,
     890        0x0,        // cam version
     891        pendingExp->chip_version,
    892892        pendingExp->label,
    893893        pendingExp->expgroup,
Note: See TracChangeset for help on using the changeset viewer.