IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 24, 2013, 1:37:30 PM (13 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20130509
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130509

  • branches/eam_branches/ipp-20130509/ippTools/src

  • branches/eam_branches/ipp-20130509/ippTools/src/camtool.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20130509/ippTools/src/camtoolConfig.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/eam_branches/ipp-20130509/ippTools/src/chiptool.c

    r34766 r35594  
    269269
    270270    PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false);
    271     PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);
     271    PXOPT_LOOKUP_STR(label, config->args, "-set_label", true, false);
    272272    PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false);
    273273    PXOPT_LOOKUP_STR(expgroup, config->args, "-set_expgroup", false, false);
     
    298298    psFree(where);
    299299
     300    psString labelHook = NULL;
    300301    if (unique) {
    301       psStringAppend(&query, "AND chip_id IS NULL");
     302      psStringAppend(&labelHook, "\nAND chipRun.label = '%s'", label);
     303      psStringAppend(&query, " AND chip_id IS NULL");
    302304    }
    303305   
    304     if (!p_psDBRunQuery(config->dbh, query)) {
     306    if (!p_psDBRunQueryF(config->dbh, query, labelHook ? labelHook : "")) {
    305307        psError(PS_ERR_UNKNOWN, false, "database error");
    306308        psFree(query);
  • branches/eam_branches/ipp-20130509/ippTools/src/chiptoolConfig.c

    r34766 r35594  
    5252
    5353    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir",  0,            "define workdir (required)", NULL);
    54     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label",  0,            "define label", NULL);
     54    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_label",  0,            "define label (required)", NULL);
    5555    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_reduction",  0,            "define reduction class", NULL);
    5656    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_expgroup",  0,            "define exposure group", NULL);
  • branches/eam_branches/ipp-20130509/ippTools/src/laptool.c

    r35308 r35594  
    2222// Run level
    2323static bool definerunMode(pxConfig *config);
     24static bool definerunbyreleaseMode(pxConfig *config);
    2425static bool pendingrunMode(pxConfig *config);
    2526static bool updaterunMode(pxConfig *config);
     27
    2628// Exposure level
    2729static bool pendingexpMode(pxConfig *config);
     
    6466   
    6567    MODECASE(LAPTOOL_MODE_DEFINERUN,     definerunMode);
     68    MODECASE(LAPTOOL_MODE_DEFINERUNBYRELEASE, definerunbyreleaseMode);
    6669    MODECASE(LAPTOOL_MODE_PENDINGRUN,    pendingrunMode);
    6770    MODECASE(LAPTOOL_MODE_UPDATERUN,     updaterunMode);
     
    401404}
    402405
     406static bool definerunbyreleaseMode(pxConfig *config)
     407{
     408  PS_ASSERT_PTR_NON_NULL(config, false);
     409
     410  PXOPT_LOOKUP_S64(seq_id,          config->args, "-seq_id",          true, false);
     411  PXOPT_LOOKUP_STR(projection_cell, config->args, "-projection_cell", true, false);
     412  PXOPT_LOOKUP_STR(tess_id,         config->args, "-tess_id",         true, false);
     413  PXOPT_LOOKUP_STR(filter,          config->args, "-filter",          true, false);
     414  PXOPT_LOOKUP_STR(label,           config->args, "-label",           false, false);
     415  PXOPT_LOOKUP_STR(dist_group,      config->args, "-dist_group",      false, false);
     416  PXOPT_LOOKUP_S64(rel_id,          config->args, "-rel_id",          false, false);
     417  PXOPT_LOOKUP_STR(rel_name,        config->args, "-release_name",    false, false);
     418  PXOPT_LOOKUP_BOOL(simple,         config->args, "-simple",          false);
     419
     420  // Validate config
     421  if ((!rel_name)&&(!rel_id)) {
     422    // Die here.
     423  }
     424 
     425  lapRunRow *run = lapRunRowAlloc(0, // lap_id
     426                                  seq_id,
     427                                  tess_id,
     428                                  projection_cell,
     429                                  filter,
     430                                  "registered", // state
     431                                  label,
     432                                  dist_group,
     433                                  NULL, // registered
     434                                  0,    // fault
     435                                  INT64_MAX,    // quick_sass_id
     436                                  INT64_MAX     // final_sass_id
     437                                  );
     438  if (!run) {
     439    psError(PS_ERR_UNKNOWN, false, "failed to alloc lapRun object");
     440    return(true);
     441  }
     442
     443  if (!psDBTransaction(config->dbh)) {
     444    psError(PS_ERR_UNKNOWN, false, "database error");
     445    return(false);
     446  }
     447   
     448  if (!lapRunInsertObject(config->dbh, run)) {
     449    if (!psDBRollback(config->dbh)) {
     450      psError(PS_ERR_UNKNOWN, false, "database error");
     451    }
     452    psError(PS_ERR_UNKNOWN, false, "database error");
     453    psFree(run);
     454    return(false);
     455  }
     456
     457  if (!lapRunPrintObject(stdout, run, !simple)) {
     458    if (!psDBRollback(config->dbh)) {
     459      psError(PS_ERR_UNKNOWN, false, "database error");
     460    }
     461    psError(PS_ERR_UNKNOWN, false, "failed to print object");
     462    psFree(run);
     463    return(false);
     464  }
     465
     466  psS64 lap_id = psDBLastInsertID(config->dbh);
     467
     468  psString query = pxDataGet("laptool_definerunbyrelease.sql");
     469  if (!query) {
     470    if (!psDBRollback(config->dbh)) {
     471      psError(PS_ERR_UNKNOWN, false, "database error");
     472    }
     473    psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement");
     474    return(false);
     475  }
     476 
     477  // Add constraints
     478  psMetadata *relWhere = psMetadataAlloc();
     479  PXOPT_COPY_STR(config->args, relWhere, "-filter",       "rawExp.filter", "==");
     480  PXOPT_COPY_STR(config->args, relWhere, "-release_name", "ippRelease.release_name", "==");
     481  PXOPT_COPY_S64(config->args, relWhere, "-rel_id",       "ippRelease.rel_id", "==");
     482  PXOPT_COPY_TIME(config->args, relWhere, "-dateobs_begin", "rawExp.dateobs", ">=");
     483  PXOPT_COPY_TIME(config->args, relWhere, "-dateobs_end", "rawExp.dateobs", "<=");
     484  PXOPT_COPY_RADEC(config->args, relWhere, "-ra_min", "rawExp.ra", ">=");
     485  PXOPT_COPY_RADEC(config->args, relWhere, "-ra_max", "rawExp.ra", "<");
     486  PXOPT_COPY_RADEC(config->args, relWhere, "-decl_min", "rawExp.decl", ">=");
     487  PXOPT_COPY_RADEC(config->args, relWhere, "-decl_max", "rawExp.decl", "<");
     488
     489  psMetadata *lapWhere = psMetadataAlloc();
     490  PXOPT_COPY_S64(config->args, lapWhere, "-seq_id",       "lapRun.seq_id", "==");
     491  PXOPT_COPY_STR(config->args, lapWhere, "-filter",       "lapRun.filter", "==");
     492
     493  psString relWhereClause = psDBGenerateWhereConditionSQL(relWhere,NULL);
     494  psString lapWhereClause = psDBGenerateWhereConditionSQL(lapWhere,NULL);
     495
     496  if (relWhereClause) {
     497    psStringSubstitute(&query,relWhereClause,"@RELWHERE@");
     498  }
     499  if (lapWhereClause) {
     500    psStringSubstitute(&query,lapWhereClause,"@LAPWHERE@");
     501  }
     502  psFree(relWhere);
     503  psFree(lapWhere);
     504
     505  // Fetch exposures
     506  if (!p_psDBRunQuery(config->dbh, query)) {
     507    if (!psDBRollback(config->dbh)) {
     508      psError(PS_ERR_UNKNOWN, false, "database error");
     509    }
     510
     511    psError(PS_ERR_UNKNOWN, false, "database error");
     512    psFree(query);
     513    return(false);
     514  }
     515  psFree(query);
     516
     517  psArray *output = p_psDBFetchResult(config->dbh);
     518  if (!output) {
     519    if (!psDBRollback(config->dbh)) {
     520      psError(PS_ERR_UNKNOWN, false, "database error");
     521    }
     522
     523    psError(PS_ERR_UNKNOWN, false, "database error");
     524    return(false);
     525  }
     526  if (!psArrayLength(output)) {
     527    if (!psDBRollback(config->dbh)) {
     528      psError(PS_ERR_UNKNOWN, false, "database error");
     529    }
     530
     531    psTrace("laptool", PS_LOG_INFO, "no rows found");
     532    psFree(output);
     533    return(true);
     534  }
     535
     536  // Insert the exposure data
     537  for (long i = 0; i < output->n; i++) {
     538    psMetadata *row = output->data[i]; // Row from select
     539    // Add default values from this run:
     540    psMetadataAddS64(row, PS_LIST_TAIL, "lap_id", 0, "", lap_id);
     541    psMetadataAddS64(row, PS_LIST_TAIL, "pair_id", 0, "", INT64_MAX);
     542    psMetadataAddStr(row, PS_LIST_TAIL, "data_state", 0, "", "new");
     543    lapExpRow *lapExp = lapExpObjectFromMetadata(row);
     544    lapExp->lap_id = lap_id;
     545
     546    if (!lapExpInsertObject(config->dbh,lapExp)) {
     547      if (!lapExpPrintObject(stdout, lapExp, !simple)) {
     548        if (!psDBRollback(config->dbh)) {
     549          psError(PS_ERR_UNKNOWN, false, "database error");
     550        }
     551        psError(PS_ERR_UNKNOWN, false, "failed to print object");
     552        psFree(run);
     553        return false;
     554      }
     555     
     556      if (!psDBRollback(config->dbh)) {
     557        psError(PS_ERR_UNKNOWN, false, "database error");
     558      }
     559      psError(PS_ERR_UNKNOWN, false, "database error");
     560      psFree(output);
     561      psFree(lapExp);
     562      return(false);
     563    }
     564  }
     565
     566  // point of no return
     567  if (!psDBCommit(config->dbh)) {
     568    psError(PS_ERR_UNKNOWN, false, "database error");
     569    return false;
     570  }
     571
     572 
     573  psFree(output);
     574  return(true); 
     575}
     576
     577
     578 
     579 
     580                   
    403581static bool pendingrunMode(pxConfig *config)
    404582{
  • branches/eam_branches/ipp-20130509/ippTools/src/laptool.h

    r35308 r35594  
    1313  LAPTOOL_MODE_LISTSEQUENCE,
    1414  LAPTOOL_MODE_DEFINERUN,
     15  LAPTOOL_MODE_DEFINERUNBYRELEASE,
    1516  LAPTOOL_MODE_PENDINGRUN,
    1617  LAPTOOL_MODE_UPDATERUN,
  • branches/eam_branches/ipp-20130509/ippTools/src/laptoolConfig.c

    r35308 r35594  
    5757  ADD_OPT(Str, definerunArgs, "-label",                       "define the label used", NULL);
    5858  ADD_OPT(Str, definerunArgs, "-dist_group",                  "define the distribution group for this data", NULL);
    59 
     59 
    6060  psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-obsmode", PS_META_DUPLICATE_OK, "search by obsmode", NULL);
    6161  ADD_OPT(Bool,definerunArgs, "-all_obsmode",                 "use all science obsmodes", false);
    6262 
    6363  ADD_OPT(Bool,definerunArgs, "-simple",                      "use the simple output format", false);
     64
     65  // -definerunbyrelease
     66  psMetadata *definerunbyreleaseArgs = psMetadataAlloc();
     67  ADD_OPT(S64, definerunbyreleaseArgs, "-seq_id",             "define the LAP sequence for this run (required)", 0);
     68  ADD_OPT(Str, definerunbyreleaseArgs, "-projection_cell",    "define the projection cell for this run (required)", NULL);
     69  ADD_OPT(Str, definerunbyreleaseArgs, "-tess_id",            "define the tessellation used (required)", NULL);
     70  ADD_OPT(Str, definerunbyreleaseArgs, "-filter",             "define the filter used (required)", NULL);
     71  ADD_OPT(Str, definerunbyreleaseArgs, "-label",              "define the label used", NULL);
     72  ADD_OPT(Str, definerunbyreleaseArgs, "-dist_group",         "define the distribution group for this data", NULL);
     73  ADD_OPT(S64, definerunbyreleaseArgs, "-rel_id",             "define the release to copy", 0);
     74  ADD_OPT(Str, definerunbyreleaseArgs, "-release_name",       "define the release to copy", NULL);
     75 
     76  ADD_OPT(Bool, definerunbyreleaseArgs, "-simple",            "use the simple output format", false);
     77  psMetadataAddTime(definerunbyreleaseArgs, PS_LIST_TAIL, "-dateobs_begin",      0, "search for exposures by time (>=)", NULL);
     78  psMetadataAddTime(definerunbyreleaseArgs, PS_LIST_TAIL, "-dateobs_end",        0, "search for exposures by time (<=)", NULL);
     79  psMetadataAddF64(definerunbyreleaseArgs,  PS_LIST_TAIL, "-ra_min",             0, "search by min RA (degrees) ", NAN);
     80  psMetadataAddF64(definerunbyreleaseArgs,  PS_LIST_TAIL, "-ra_max",             0, "search by max RA (degrees) ", NAN);
     81  psMetadataAddF64(definerunbyreleaseArgs,  PS_LIST_TAIL, "-decl_min",           0, "search by min DEC (degrees)", NAN);
     82  psMetadataAddF64(definerunbyreleaseArgs,  PS_LIST_TAIL, "-decl_max",           0, "search by max DEC (degrees)", NAN);
    6483 
    6584  // -pendingrun
     
    204223  PXOPT_ADD_MODE("-listsequence",            "", LAPTOOL_MODE_LISTSEQUENCE,     listsequenceArgs);
    205224  PXOPT_ADD_MODE("-definerun",               "", LAPTOOL_MODE_DEFINERUN,        definerunArgs);
     225  PXOPT_ADD_MODE("-definerunbyrelease",      "", LAPTOOL_MODE_DEFINERUNBYRELEASE, definerunbyreleaseArgs);
    206226  PXOPT_ADD_MODE("-pendingrun",              "", LAPTOOL_MODE_PENDINGRUN,       pendingrunArgs);
    207227  PXOPT_ADD_MODE("-listrun",                 "", LAPTOOL_MODE_PENDINGRUN,       listrunArgs);
  • branches/eam_branches/ipp-20130509/ippTools/src/magictool.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.