IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 2, 2007, 12:42:55 PM (19 years ago)
Author:
jhoblitt
Message:

add camQueueChipID and use it where appropriate

File:
1 edited

Legend:

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

    r12184 r12188  
    2929#include "pxdata.h"
    3030#include "chiptool.h"
     31#include "camtool.h"
    3132
    3233static bool queuerawexpMode(pxConfig *config);
     
    4142static chipProcessedImfileRow *chipPendingToProcessedImfile(pxConfig *config, chipPendingImfileRow *imfile);
    4243static chipProcessedExpRow *chipPendingToProcessedExp(pxConfig *config, chipPendingExpRow *pendingExp);
    43 static camPendingExpRow *chipPendingTocamPendingExp(pxConfig *config, chipPendingExpRow *pendingExp);
    4444static bool chipProcessedCompleteExp(pxConfig *config);
    4545
     
    748748    for (long i = 0; i < psArrayLength(output); i++) {
    749749        psMetadata *row = output->data[i];
     750
    750751        // convert metadata into a chipPendingExp object
    751         chipPendingExpRow *object = chipPendingExpObjectFromMetadata(row);
    752         // do both *Exp type conversion first so we don't insert one and then
    753         // have to rollback the change as the 2nd failed
     752        chipPendingExpRow *pendingExp = chipPendingExpObjectFromMetadata(row);
     753        if (!pendingExp) {
     754            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipPendingExp");
     755            psFree(output);
     756            return false;
     757        }
     758
    754759        // convert chipPendingExp object into a chipProcesseExp object
    755         chipProcessedExpRow *processedExp = chipPendingToProcessedExp(config, object);
     760        chipProcessedExpRow *processedExp = chipPendingToProcessedExp(config, pendingExp);
    756761        if (!processedExp) {
    757762            psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingExp to chipProcessedExp");
    758             psFree(object);
    759             psFree(output);
    760             return false;
    761         }
    762         // convert chipPendingExp object into a camPendingExp object
    763         camPendingExpRow *pendingExp = chipPendingTocamPendingExp(config, object);
    764         if (!processedExp) {
    765             psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingExp to camPendingExp");
     763            psFree(pendingExp);
     764            psFree(output);
     765            return false;
     766        }
     767
     768        // delete the chipPendingExp object from the database
     769        if (!chipPendingExpDeleteObject(config->dbh, pendingExp)) {
     770            // there must be atleast 1 Imfile to get this far
     771            psError(PS_ERR_UNKNOWN, false, "database error");
    766772            psFree(processedExp);
    767             psFree(object);
    768             psFree(output);
    769             return false;
    770         }
     773            psFree(pendingExp);
     774            psFree(output);
     775            return false;
     776        }
     777        psFree(pendingExp);
     778
    771779        // insert chipProccessedExp object into the database
    772780        if (!chipProcessedExpInsertObject(config->dbh, processedExp)) {
    773781            psError(PS_ERR_UNKNOWN, false, "database error");
    774782            psFree(processedExp);
    775             psFree(pendingExp);
    776             psFree(object);
    777             psFree(output);
    778             return false;
    779         }
     783            psFree(output);
     784            return false;
     785        }
     786
     787        // camQueueChipID() can only be run after the chipProcessedExp entry
     788        // has been inserted.
     789        // queue the chip_id in the camPendingExp table
     790        if (!camQueueChipID(config,
     791                    processedExp->chip_id,
     792                    processedExp->label,
     793                    processedExp->recipe,
     794                    processedExp->expgroup,
     795                    processedExp->dvodb
     796        )) {
     797            // rollback
     798            if (!psDBRollback(config->dbh)) {
     799                psError(PS_ERR_UNKNOWN, false, "database error");
     800            }
     801            psError(PS_ERR_UNKNOWN, false, "failed to queue camPendingExp");
     802            psFree(processedExp);
     803            psFree(output);
     804            return false;
     805        }
     806
    780807        psFree(processedExp);
    781         // insert camPendingExp object into the database
    782         if (!camPendingExpInsertObject(config->dbh, pendingExp)) {
    783             psError(PS_ERR_UNKNOWN, false, "database error");
    784             psFree(pendingExp);
    785             psFree(object);
    786             psFree(output);
    787             return false;
    788         }
    789         psFree(pendingExp);
    790         // delete the chipPendingExp object from the database
    791         if (!chipPendingExpDeleteObject(config->dbh, object)) {
    792             // there must be atleast 1 Imfile to get this far
    793             psError(PS_ERR_UNKNOWN, false, "database error");
    794             psFree(object);
    795             psFree(output);
    796             return false;
    797         }
    798         psFree(object);
    799808    }
    800809
     
    875884        pendingExp->guide_id,
    876885        pendingExp->label,
     886        pendingExp->recipe,
    877887        pendingExp->expgroup,
    878888        pendingExp->dvodb
    879889    );
    880890}
    881 
    882 
    883 static camPendingExpRow *chipPendingTocamPendingExp(pxConfig *config, chipPendingExpRow *pendingExp)
    884 {
    885     PS_ASSERT_PTR_NON_NULL(pendingExp, NULL);
    886 
    887     return camPendingExpRowAlloc(
    888         0,                      // cam version, assigned by db
    889         pendingExp->chip_id,
    890         pendingExp->label,
    891         pendingExp->expgroup,
    892         pendingExp->dvodb
    893     );
    894 }
Note: See TracChangeset for help on using the changeset viewer.