IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 16, 2010, 5:30:27 PM (16 years ago)
Author:
watersc1
Message:

merge of stack association and warp/stack/diff jpegs

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/ippTools/src/difftool.c

    r28056 r28375  
    4444static bool definewarpwarpMode(pxConfig *config);
    4545static bool definestackstackMode(pxConfig *config);
     46static bool tosummaryMode(pxConfig *config);
     47static bool addsummaryMode(pxConfig *config);
    4648static bool pendingcleanuprunMode(pxConfig *config);
    4749static bool pendingcleanupskyfileMode(pxConfig *config);
     
    9395        MODECASE(DIFFTOOL_MODE_DEFINEWARPWARP,        definewarpwarpMode);
    9496        MODECASE(DIFFTOOL_MODE_DEFINESTACKSTACK,      definestackstackMode);
     97        MODECASE(DIFFTOOL_MODE_TOSUMMARY,             tosummaryMode);
     98        MODECASE(DIFFTOOL_MODE_ADDSUMMARY,            addsummaryMode);
    9599        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPRUN,     pendingcleanuprunMode);
    96100        MODECASE(DIFFTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode);
     
    22502254}
    22512255
     2256static bool tosummaryMode(pxConfig *config) {
     2257  PS_ASSERT_PTR_NON_NULL(config, NULL);
     2258 
     2259  psMetadata *where = psMetadataAlloc();
     2260  PXOPT_COPY_S64(config->args, where, "-warp_id",    "diffSkyfile.warp_id", "==");
     2261  PXOPT_COPY_STR(config->args, where, "-tess_id",    "diffSkyfile.tess_id", "==");
     2262  PXOPT_COPY_STR(config->args, where, "-state",      "diffRun.state", "==");
     2263  PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs",  ">=");
     2264  PXOPT_COPY_TIME(config->args, where, "-dateobs_end",   "rawExp.dateobs",  "<=");
     2265  PXOPT_COPY_STR(config->args, where, "-filter",    "rawExp.filter", "LIKE");
     2266  PXOPT_COPY_S64(config->args, where, "-magicked", "diffSkyfile.magicked", "==");
     2267  pxAddLabelSearchArgs (config, where, "-label",   "diffRun.label", "LIKE");
     2268  pxAddLabelSearchArgs (config, where, "-data_group",   "diffRun.data_group", "LIKE");
     2269
     2270  PXOPT_LOOKUP_BOOL(all, config->args, "-all", false);
     2271
     2272  PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     2273  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     2274 
     2275  // find all rawImfiles matching the default query
     2276  psString query = pxDataGet("difftool_tosummary.sql");
     2277  if (!query) {
     2278    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     2279    return false;
     2280  }
     2281
     2282  // generate where strings for arguments that require extra processing
     2283  // beyond PXOPT_COPY*
     2284  psString where2 = NULL;
     2285  if (!pxmagicAddWhere(config, &where2, "diffSkyfile")) {
     2286    psError(psErrorCodeLast(), false, "pxMagicAddWhere failed");
     2287    return false;
     2288  }
     2289 
     2290  if (psListLength(where->list)) {
     2291    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     2292    psStringAppend(&query, " AND %s", whereClause);
     2293    psFree(whereClause);
     2294  } else if (!all && !where2) {
     2295    psError(PXTOOLS_ERR_CONFIG, true, "search parameters or -all are required");
     2296    return false;
     2297  }
     2298 
     2299  if (where2) {
     2300    if (psListLength(where->list)) {
     2301      psStringAppend(&query, " %s", where2);
     2302    } else {
     2303      psStringAppend(&query, " AND 1 %s", where2);
     2304    }
     2305  }
     2306  psFree(where);
     2307
     2308  // treat limit == 0 as "no limit"
     2309  if (limit) {
     2310    psString limitString = psDBGenerateLimitSQL(limit);
     2311    psStringAppend(&query, " %s", limitString);
     2312    psFree(limitString);
     2313  }
     2314 
     2315  if (!p_psDBRunQuery(config->dbh, query)) {
     2316    psError(PS_ERR_UNKNOWN, false, "database error");
     2317    psFree(query);
     2318    return false;
     2319  }
     2320  psFree(query);
     2321
     2322  psArray *output = p_psDBFetchResult(config->dbh);
     2323  if (!output) {
     2324    psErrorCode err = psErrorCodeLast();
     2325    switch (err) {
     2326    case PS_ERR_DB_CLIENT:
     2327      psError(PXTOOLS_ERR_SYS, false, "database error");
     2328    case PS_ERR_DB_SERVER:
     2329      psError(PXTOOLS_ERR_PROG, false, "database error");
     2330    default:
     2331      psError(PXTOOLS_ERR_PROG, false, "unknown error");
     2332    }
     2333   
     2334    return false;
     2335  }
     2336  if (!psArrayLength(output)) {
     2337    psTrace("difftool", PS_LOG_INFO, "no rows found");
     2338    psFree(output);
     2339    return true;
     2340  }
     2341 
     2342  if (psArrayLength(output)) {
     2343    // negative simple so the default is true
     2344    if (!ippdbPrintMetadatas(stdout, output, "diffRun", !simple)) {
     2345      psError(PS_ERR_UNKNOWN, false, "failed to print array");
     2346      psFree(output);
     2347      return false;
     2348    }
     2349  }
     2350 
     2351  psFree(output);
     2352  return(true);
     2353}
     2354static bool addsummaryMode(pxConfig *config) {
     2355  PS_ASSERT_PTR_NON_NULL(config, NULL);
     2356
     2357  PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false);
     2358  PXOPT_LOOKUP_STR(projection_cell, config->args, "-projection_cell", true, false);
     2359  PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", true, false);
     2360
     2361  psString query = pxDataGet("difftool_addsummary.sql");
     2362  if (!query) {
     2363    psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement");
     2364    return(false);
     2365  }
     2366  if (!p_psDBRunQueryF(config->dbh, query, diff_id, projection_cell, path_base)) {
     2367    psError(PS_ERR_UNKNOWN, false, "database error");
     2368    psFree(query);
     2369    return(false);
     2370  }
     2371  psS64 numUpdated = psDBAffectedRows(config->dbh);
     2372 
     2373  if (numUpdated != 1) {
     2374    psError(PS_ERR_UNKNOWN, false, "should have affected 1 row");
     2375    psFree(query);
     2376    return false;
     2377  }
     2378 
     2379  psFree(query);
     2380
     2381  // Print anything here?
     2382 
     2383  return(true);
     2384}
     2385
     2386
    22522387static bool pendingcleanuprunMode(pxConfig *config)
    22532388{
Note: See TracChangeset for help on using the changeset viewer.