IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 21, 2011, 11:11:16 AM (15 years ago)
Author:
watersc1
Message:

Update to LAP code.

File:
1 edited

Legend:

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

    r31827 r32422  
    3030static bool updateexpMode(pxConfig *config);
    3131
     32static bool diffcheckMode(pxConfig *config);
     33
    3234static bool inactiveexpMode(pxConfig *config);
    3335
     
    6264    MODECASE(LAPTOOL_MODE_UPDATEEXP,     updateexpMode);
    6365
     66    MODECASE(LAPTOOL_MODE_DIFFCHECK,     diffcheckMode);
     67   
    6468    MODECASE(LAPTOOL_MODE_INACTIVEEXP,   inactiveexpMode);
    6569  default:
     
    276280  PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "==");
    277281
     282  psMetadata *chipWhere = psMetadataAlloc();
     283  PXOPT_COPY_S64(config->args, chipWhere, "-seq_id", "lapRun.seq_id", "==");
     284 
    278285  // This seems unnecessarily clunky.
    279286  if (!all_obsmode) {
     
    296303  }
    297304
     305  psString chipWhereClause = psDBGenerateWhereConditionSQL(chipWhere,NULL);
    298306  if (whereClause) {
    299307    psStringSubstitute(&query,whereClause,"@WHERE@");
    300308  }
     309  if (chipWhereClause) {
     310    psStringSubstitute(&query,chipWhereClause,"@CHIPWHERE@");
     311  }
    301312  psFree(where);
     313  psFree(chipWhere);
    302314
    303315  // Fetch exposures
     
    755767}
    756768
    757 
    758    
     769static bool diffcheckMode(pxConfig *config)
     770{
     771  PS_ASSERT_PTR_NON_NULL(config, false);
     772  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     773 
     774  psMetadata *where = psMetadataAlloc();
     775  PXOPT_COPY_S64(config->args, where, "-lap_id", "lapRun.lap_id", "==");
     776  PXOPT_COPY_S64(config->args, where, "-exp_id",  "exp_id", "==");
     777  PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     778  PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     779  PXOPT_COPY_S64(config->args, where, "-seq_id",  "seq_id", "==");
     780  PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
     781
     782  psString query = pxDataGet("laptool_WSdiff_check.sql");
     783  if (!query) {
     784    psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement");
     785    return(false);
     786  }
     787 
     788  if (psListLength(where->list)) {
     789    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     790    psStringPrepend(&whereClause, "\n AND ");
     791    psStringSubstitute(&query,whereClause,"@WHERE@");
     792    psFree(whereClause);
     793  }
     794
     795  if (!p_psDBRunQuery(config->dbh, query)) {
     796    psError(PS_ERR_UNKNOWN, false, "database error");
     797    psFree(query);
     798    return false;
     799  }
     800  psFree(query);
     801
     802  psArray *output = p_psDBFetchResult(config->dbh);
     803  if (!output) {
     804    psErrorCode err = psErrorCodeLast();
     805    switch (err) {
     806    case PS_ERR_DB_CLIENT:
     807      psError(PXTOOLS_ERR_SYS, false, "database error");
     808    case PS_ERR_DB_SERVER:
     809      psError(PXTOOLS_ERR_PROG, false, "database error");
     810    default:
     811      psError(PXTOOLS_ERR_PROG, false, "unknown error %d",err);
     812    }
     813
     814    return false;
     815  }
     816  if (!psArrayLength(output)) {
     817    psTrace("laptool", PS_LOG_INFO, "no rows found");
     818    psFree(output);
     819    return true;
     820  }
     821
     822  if (psArrayLength(output)) {
     823    if (!ippdbPrintMetadatas(stdout, output, "lapRunWarpStackSkycells", !simple)) {
     824      psError(PS_ERR_UNKNOWN, false, "failed to print array");
     825      psFree(output);
     826      return false;
     827    }
     828  }
     829
     830  psFree(output);
     831  return(true);
     832}   
    759833
    760834static bool inactiveexpMode(pxConfig *config)
Note: See TracChangeset for help on using the changeset viewer.