IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6670


Ignore:
Timestamp:
Mar 21, 2006, 5:17:21 PM (20 years ago)
Author:
jhoblitt
Message:

partial implementation of pzsearch -copydone

Location:
trunk/ippTools/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/pxtools.h

    r6668 r6670  
    4747    char *class_id;
    4848    char *uri;
     49    psMetadata *args;
    4950    psMetadata *where;
    5051} pxConfig;
     
    129130p2DoneExpRow *p2pendingToDoneExp(p2PendingExpRow *pendingExp);
    130131
     132bool pzPendingFramePrint(FILE *stream, pxConfig *config, psArray *frames);
     133psArray *pzPendingFrameSearch(pxConfig *config);
     134
    131135bool rawScienceFramePrint(FILE *stream, pxConfig *config, psArray *frames);
    132136psArray *rawScienceFrameSearch(pxConfig *config);
  • trunk/ippTools/src/pztool.c

    r6669 r6670  
    77static bool copydoneMode(pxConfig *config);
    88bool summitExpPrint(FILE *stream, summitExpRow *summitExp);
     9psArray *pzsearchPendingImfiles(pxConfig *config);
     10bool pzsearchFlushPendingExp(pxConfig *config);
    911
    1012int main(int argc, char **argv)
     
    8991    PS_ASSERT_PTR_NON_NULL(config, false);
    9092
    91     psArray *new = pzPendingFrameSearch(config);
    92     if (!new) {
     93    psArray *pending = pzPendingFrameSearch(config);
     94    if (!pending) {
    9395        psError(PS_ERR_UNKNOWN, false, "no pzPendingFrames found");
    9496        return false;
    9597    }
    96 
    97     bool status = pzPendingFramePrint(stdout, config, new);
    98     if (!status) {
     98    if (!pzPendingFramePrint(stdout, config, pending)) {
    9999        psError(PS_ERR_UNKNOWN, false, "pzPendingFramePrint() failed");
    100100        return false;
     
    107107{
    108108    PS_ASSERT_PTR_NON_NULL(config, false);
     109
     110    // we don't have to operate on complete frames here as it's ok to start
     111    // downloading the imfiles before the exp has been registered
     112    psArray *pending = pzsearchPendingImfiles(config);
     113    if (!pending) {
     114        psError(PS_ERR_UNKNOWN, false, "no pzPendingImfiles found");
     115        return false;
     116    }
     117
     118    // XXX start transaction
     119
     120    for (long i = 0; i < pending->n; i++) {
     121        pzPendingImfileRow *pendingImfile = pending->data[i];
     122        newImfileRow *newImfile = newImfileRowAlloc(
     123            pendingImfile->exp_id,
     124            pendingImfile->class,
     125            pendingImfile->class_id,
     126            // XXX get this from the CLI
     127            pendingImfile->uri
     128        );
     129
     130        if (!newImfileInsertObject(config->dbh, newImfile)) {
     131            psError(PS_ERR_UNKNOWN, false, "dbh access failed");
     132            return false;
     133        }
     134    }
     135
     136    if (pzPendingImfileDeleteRowObjects(config->dbh, pending, MAX_ROWS)
     137        < 0) {
     138            psError(PS_ERR_UNKNOWN, false, "dbh access failed");
     139            return false;
     140    }
     141
     142    // XXX commit transaction
     143
     144    // check for completed exps
     145    if (!pzsearchFlushPendingExp(config)) {
     146        psError(PS_ERR_UNKNOWN, false, "pzsearchFlushPendingExp() failed");
     147        return false;
     148    }
     149
     150    return true;
    109151}
    110152
     
    124166    return true;
    125167}
     168
     169psArray *pzsearchPendingImfiles(pxConfig *config)
     170{
     171    PS_ASSERT_PTR_NON_NULL(config, NULL);
     172
     173    psArray *imfiles = pzPendingImfileSelectRowObjects(config->dbh,
     174        config->where, MAX_ROWS);
     175    if (!imfiles) {
     176        psError(PS_ERR_UNKNOWN, false, "no pzPendingImfile rows found");
     177
     178        return NULL;
     179    }
     180
     181    return imfiles;
     182}
     183
     184bool pzsearchFlushPendingExp(pxConfig *config)
     185{
     186    PS_ASSERT_PTR_NON_NULL(config, false);
     187
     188    return true;
     189}
  • trunk/ippTools/src/pztoolConfig.c

    r6659 r6670  
    4545        "indicate that an image file has been downloaded", "");
    4646
    47     // -pending search
    48     /*
    49     psMetadata *pendingArgs = psMetadataAlloc();
    50     psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_id",  0,
     47    // -copydone search
     48    psMetadata *copydoneArgs = psMetadataAlloc();
     49    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-exp_id",  0,
    5150        "define exposure ID", "");
    52     psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-inst",  0,
    53         "define camera of interest", "");
    54     psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-telescope",  0,
    55         "define camera of interest", "");
    56     psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-exp_type",  0,
     51    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class",  0,
    5752        "define class", "");
    58     psMetadataAddStr(pendingArgs, PS_LIST_TAIL, "-class",  0,
    59         "define class", "");
    60     */
     53    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class_id",  0,
     54        "define class_id", "");
     55    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-suri",  0,
     56        "define storage uri", "");
    6157
    6258    bool argErr = false;
     
    7369        printf("Usage: %s <mode> [<options>]\n\n", argv[0]);
    7470        printf(" <mode> : -seen | -pending | -copydone\n\n");
    75         /*
    76         fprintf (stdout, "-pending ");
    77         psArgumentHelp(pendingArgs);
    78         fprintf (stdout, "-update ");
    79         psArgumentHelp(updateArgs);
    80         */
     71        fprintf (stdout, "-copydone ");
     72        psArgumentHelp(copydoneArgs);
    8173        psFree(args);
    82         /*
    83         psFree(pendingArgs);
    84         psFree(updateArgs);
    85         */
     74        psFree(copydoneArgs);
    8675        exit(EXIT_FAILURE);
    8776    }
     77
     78    psFree(copydoneArgs);
    8879
    8980    // XXX why is "" being returned when -[foo] isn't specified?
     
    9384    }
    9485
    95     /*
    96     switch (config->mode) {
    97         bool status;
    98         case PX_MODE_PENDING:
    99             // -exp_id
    100             config->exp_id = psMetadataLookupStr(&status, args, "-exp_id");
    101             psMemIncrRefCounter(config->exp_id);
    102             EMPTY_TO_NULL_STRING(config->exp_id);
    103             // -inst
    104             config->camera_name = psMetadataLookupStr(&status, args, "-inst");
    105             psMemIncrRefCounter(config->camera_name);
    106             EMPTY_TO_NULL_STRING(config->camera_name);
    107             // -telescope
    108             config->camera_name = psMetadataLookupStr(&status, args,
    109                 "-telescope");
    110             psMemIncrRefCounter(config->telescope);
    111             EMPTY_TO_NULL_STRING(config->telescope);
    112             // -exp_type
    113             config->class = psMetadataLookupStr(&status, args, "-exp_type");
    114             psMemIncrRefCounter(config->exp_type);
    115             EMPTY_TO_NULL_STRING(config->exp_type);
    116             // -class
    117             config->class = psMetadataLookupStr(&status, args, "-class");
    118             psMemIncrRefCounter(config->class);
    119             EMPTY_TO_NULL_STRING(config->class);
    120             break;
    121         case PX_MODE_UPDATE:
    122             // -exp_id
    123             config->exp_id = psMetadataLookupStr(&status, args, "-exp_id");
    124             psMemIncrRefCounter(config->exp_id);
    125             EMPTY_TO_NULL_STRING(config->exp_id);
    126             // -filter
    127             config->filter = psMetadataLookupStr(&status, args, "-filter");
    128             psMemIncrRefCounter(config->filter);
    129             EMPTY_TO_NULL_STRING(config->filter);
     86    config->args = args;
    13087
    131             break;
    132         default:
    133             psAbort(argv[0], "invalid option (this should not happen)");
    134     }
    135     */
    136 
    137     psFree(args);
    138     /*
    139     psFree(pendingArgs);
    140     psFree(updateArgs);
    141     */
    142 
    143 
     88if (config->mode == PX_MODE_COPYDONE) {
    14489    psMetadata *where = psMetadataAlloc();
    14590
    146     /*
    147     if (config->camera_name != NULL) {
    148         if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==",
    149             config->camera_name)) {
    150             psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
     91    bool status;
     92    psString str;
     93    if ((str = psMetadataLookupStr(&status, args, "-exp_id"))) {
     94        if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", str)) {
     95            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
    15196            psFree(where);
    15297            return NULL;
    15398        }
    15499    }
    155     if (config->filter != NULL) {
    156         psMetadataAddStr(where, PS_LIST_TAIL, "filter", 0, "==",
    157             config->filter);
     100    if ((str = psMetadataLookupStr(&status, args, "-class"))) {
     101        if (!psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==", str)) {
     102            psError(PS_ERR_UNKNOWN, false, "failed to add item class");
     103            psFree(where);
     104            return NULL;
     105        }
    158106    }
    159     if (config->exp_id != NULL) {
    160         psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==",
    161             config->exp_id);
     107    if ((str = psMetadataLookupStr(&status, args, "-class_id"))) {
     108        if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", str)) {
     109            psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");
     110            psFree(where);
     111            return NULL;
     112        }
    162113    }
    163     if (config->class != NULL) {
    164         psMetadataAddStr(where, PS_LIST_TAIL, "class", 0, "==",
    165             config->class);
    166     }
    167     if (config->class_id != NULL) {
    168         psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",
    169              config->class_id);
    170     }
    171     */
    172 
    173     /*
    174     // psMetadataConfig does not support times yet
    175     if (!psTimeIsZero(config->start) && !psTimeIsZero(config->stop)) {
    176         psMetadataAddTime (where, PS_LIST_TAIL, "TIME_START", 0, "<", config->stop);
    177         psMetadataAddTime (where, PS_LIST_TAIL, "TIME_STOP", 0, ">", config->start);
    178     }
    179     */
    180114
    181115    if (where->list->n < 1) {
     
    183117        where = NULL;
    184118    }
    185 
    186119    config->where = where;
    187 
    188 
    189     // add the input and output images to the args list
    190     //psMetadataAddStr (args, PS_LIST_TAIL, "-output", 0, "Name of the output image", argv[1]);
     120}
    191121
    192122    // define Database handle, if used
Note: See TracChangeset for help on using the changeset viewer.