IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 17, 2009, 12:08:50 PM (17 years ago)
Author:
beaumont
Message:

merged with head

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptool.c

    r21521 r23352  
    4242static bool revertprocessedimfileMode(pxConfig *config);
    4343static bool updateprocessedimfileMode(pxConfig *config);
    44 static bool promoteexpMode(pxConfig *config);
     44static bool advanceexpMode(pxConfig *config);
    4545static bool blockMode(pxConfig *config);
    4646static bool maskedMode(pxConfig *config);
     
    8181        MODECASE(CHIPTOOL_MODE_REVERTPROCESSEDIMFILE,   revertprocessedimfileMode);
    8282        MODECASE(CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE,   updateprocessedimfileMode);
    83         MODECASE(CHIPTOOL_MODE_PROMOTEEXP,              promoteexpMode);
     83        MODECASE(CHIPTOOL_MODE_ADVANCEEXP,              advanceexpMode);
    8484        MODECASE(CHIPTOOL_MODE_BLOCK,                   blockMode);
    8585        MODECASE(CHIPTOOL_MODE_MASKED,                  maskedMode);
     
    239239    pxchipGetSearchArgs (config, where); // rawExp, chipRun
    240240    PXOPT_COPY_S64(config->args,  where, "-chip_id", "chipRun.chip_id", "==");
    241     PXOPT_COPY_STR(config->args,  where, "-label", "chipRun.label", "==");
     241    PXOPT_COPY_STR(config->args,  where, "-label",   "chipRun.label",   "==");
     242    PXOPT_COPY_STR(config->args,  where, "-state",   "chipRun.state",   "==");
    242243
    243244    if (!psListLength(where->list)
     
    10781079
    10791080
    1080 static bool promoteexpMode(pxConfig *config)
     1081static bool advanceexpMode(pxConfig *config)
    10811082{
    10821083    PS_ASSERT_PTR_NON_NULL(config, false);
     
    12561257bool exportrunMode(pxConfig *config)
    12571258{
    1258     PS_ASSERT_PTR_NON_NULL(config, NULL);
    1259 
    1260     PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true,  false);
    1261     PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
    1262     PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
    1263 
    1264     FILE *f = fopen (outfile, "w");
    1265     if (f == NULL) {
    1266         psError(PS_ERR_UNKNOWN, false, "failed to open output file");
    1267         return false;
    1268     }
    1269 
    1270     psMetadata *where = psMetadataAlloc();
    1271     PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
    1272 
    1273     // *** extract the chipRun in this section ***
    1274     psString query = pxDataGet("chiptool_export_run.sql");
     1259  typedef struct ExportTable {
     1260    char tableName[80];
     1261    char sqlFilename[80];
     1262  } ExportTable;
     1263 
     1264  int numExportTables = 3;
     1265
     1266  PS_ASSERT_PTR_NON_NULL(config, NULL);
     1267
     1268  PXOPT_LOOKUP_S64(det_id, config->args, "-chip_id", true,  false);
     1269  PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
     1270  PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
     1271
     1272  FILE *f = fopen (outfile, "w");
     1273  if (f == NULL) {
     1274    psError(PS_ERR_UNKNOWN, false, "failed to open output file");
     1275    return false;
     1276  }
     1277
     1278  psMetadata *where = psMetadataAlloc();
     1279  PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     1280
     1281  ExportTable tables [] = {
     1282    {"chipRun", "chiptool_export_run.sql"},
     1283    {"chipImfile", "chiptool_export_imfile.sql"},
     1284    {"chipProcessedImfile", "chiptool_export_processed_imfile.sql"},
     1285  };
     1286
     1287
     1288  for (int i=0; i < numExportTables; i++) {
     1289    psString query = pxDataGet(tables[i].sqlFilename);
    12751290    if (!query) {
    1276         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    1277         return false;
     1291      psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
     1292      return false;
    12781293    }
    12791294
    12801295    if (where && psListLength(where->list)) {
    1281         psString whereClause = psDBGenerateWhereSQL(where, NULL);
    1282         psStringAppend(&query, " %s", whereClause);
    1283         psFree(whereClause);
     1296      psString whereClause = psDBGenerateWhereSQL(where, NULL);
     1297      psStringAppend(&query, " %s", whereClause);
     1298      psFree(whereClause);
    12841299    }
    12851300
    12861301    // treat limit == 0 as "no limit"
    12871302    if (limit) {
    1288         psString limitString = psDBGenerateLimitSQL(limit);
    1289         psStringAppend(&query, " %s", limitString);
    1290         psFree(limitString);
     1303      psString limitString = psDBGenerateLimitSQL(limit);
     1304      psStringAppend(&query, " %s", limitString);
     1305      psFree(limitString);
    12911306    }
    12921307
    12931308    if (!p_psDBRunQuery(config->dbh, query)) {
    1294         psError(PS_ERR_UNKNOWN, false, "database error");
    1295         psFree(query);
    1296         return false;
     1309      psError(PS_ERR_UNKNOWN, false, "database error");
     1310      psFree(query);
     1311      return false;
    12971312    }
    12981313    psFree(query);
     
    13001315    psArray *output = p_psDBFetchResult(config->dbh);
    13011316    if (!output) {
    1302         psError(PS_ERR_UNKNOWN, false, "database error");
    1303         return false;
     1317      psError(PS_ERR_UNKNOWN, false, "database error");
     1318      return false;
    13041319    }
    13051320    if (!psArrayLength(output)) {
    1306         psTrace("chiptool", PS_LOG_INFO, "no rows found");
    1307         psFree(output);
    1308         return true;
     1321      psTrace("regtool", PS_LOG_INFO, "no rows found");
     1322      psFree(output);
     1323      return true;
    13091324    }
    13101325
    13111326    // we must write the export table in non-simple (true) format
    1312     if (!ippdbPrintMetadatas(f, output, "chipRun", true)) {
    1313         psError(PS_ERR_UNKNOWN, false, "failed to print array");
    1314         psFree(output);
    1315         return false;
     1327    if (!ippdbPrintMetadatas(f, output, tables[i].tableName, true)) {
     1328      psError(PS_ERR_UNKNOWN, false, "failed to print array");
     1329      psFree(output);
     1330      return false;
    13161331    }
    13171332    psFree(output);
    1318 
    1319     // *** extract the chipProcessedImfile entries in this section ***
    1320     query = pxDataGet("chiptool_export_imfiles.sql");
    1321     if (!query) {
    1322         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    1323         return false;
    1324     }
    1325 
    1326     if (where && psListLength(where->list)) {
    1327         psString whereClause = psDBGenerateWhereSQL(where, NULL);
    1328         psStringAppend(&query, " %s", whereClause);
    1329         psFree(whereClause);
    1330     }
    1331     psFree(where);
    1332 
    1333     // treat limit == 0 as "no limit"
    1334     if (limit) {
    1335         psString limitString = psDBGenerateLimitSQL(limit);
    1336         psStringAppend(&query, " %s", limitString);
    1337         psFree(limitString);
    1338     }
    1339 
    1340     if (!p_psDBRunQuery(config->dbh, query)) {
    1341         psError(PS_ERR_UNKNOWN, false, "database error");
    1342         psFree(query);
    1343         return false;
    1344     }
    1345     psFree(query);
    1346 
    1347     output = p_psDBFetchResult(config->dbh);
    1348     if (!output) {
    1349         psError(PS_ERR_UNKNOWN, false, "database error");
    1350         return false;
    1351     }
    1352     if (!psArrayLength(output)) {
    1353         psTrace("chiptool", PS_LOG_INFO, "no rows found");
    1354         psFree(output);
    1355         return true;
    1356     }
    1357 
    1358     // we must write the export table in non-simple (true) format
    1359     if (!ippdbPrintMetadatas(f, output, "chipProcessedImfiles", true)) {
    1360         psError(PS_ERR_UNKNOWN, false, "failed to print array");
    1361         psFree(output);
    1362         return false;
    1363     }
    1364     psFree(output);
    1365 
    1366     fclose (f);
    1367 
    1368     return true;
    1369 }
    1370 
     1333  }
     1334
     1335  fclose (f);
     1336
     1337  return true;
     1338}
    13711339
    13721340bool importrunMode(pxConfig *config)
    13731341{
    13741342  unsigned int nFail;
     1343 
     1344  int numImportTables = 2;
     1345 
     1346  char tables[2] [80] = {"chipImfile", "chipProcessedImfile"};
    13751347
    13761348  PS_ASSERT_PTR_NON_NULL(config, NULL);
     
    13831355  psMetadataPrint (stderr, input, 1);
    13841356
    1385   psMetadataItem *chipRunItem = psMetadataLookup (input, "chipRun");
    1386   psAssert (chipRunItem, "entry not in input?");
    1387   psAssert (chipRunItem->type == PS_DATA_METADATA_MULTI, "entry not multi?");
    1388  
    1389   psMetadataItem *chipRunEntry = psListGet (chipRunItem->data.list, 0);
    1390   assert (chipRunEntry);
    1391   assert (chipRunEntry->type == PS_DATA_METADATA);
    1392   chipRunRow *chipRun = chipRunObjectFromMetadata (chipRunEntry->data.md);
    1393   chipRunInsertObject (config->dbh, chipRun);
    1394 
    1395   // fprintf (stdout, "---- chip run ----\n");
    1396   // psMetadataPrint (stderr, chipRunEntry->data.md, 1);
    1397 
    1398   psMetadataItem *item = psMetadataLookup (input, "chipProcessedImfiles");
     1357  psMetadataItem *item = psMetadataLookup (input, "chipRun");
    13991358  psAssert (item, "entry not in input?");
    14001359  psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
    14011360
    1402   // XXX would be better to use the iterator?
    1403   for (int i = 0; i < item->data.list->n; i++) {
    1404     psMetadataItem *entry = psListGet (item->data.list, i);
    1405     assert (entry);
    1406     assert (entry->type == PS_DATA_METADATA);
    1407     chipProcessedImfileRow *chipProcessedImfile = chipProcessedImfileObjectFromMetadata (entry->data.md);
    1408     chipProcessedImfileInsertObject (config->dbh, chipProcessedImfile);
    1409 
    1410     // fprintf (stdout, "---- row %d ----\n", i);
    1411     // psMetadataPrint (stderr, entry->data.md, 1);
     1361  psMetadataItem *entry = psListGet (item->data.list, 0);
     1362  assert (entry);
     1363  assert (entry->type == PS_DATA_METADATA);
     1364  chipRunRow *chipRun = chipRunObjectFromMetadata (entry->data.md);
     1365  chipRunInsertObject (config->dbh, chipRun);
     1366
     1367  // fprintf (stdout, "---- chip run ----\n");
     1368  // psMetadataPrint (stderr, entry->data.md, 1);
     1369 
     1370  for (int i = 0; i < numImportTables; i++) {
     1371    psMetadataItem *item = psMetadataLookup (input, tables[i]);
     1372    psAssert (item, "entry not in input?");
     1373    psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
     1374 
     1375    switch (i) {
     1376      case 0:
     1377        for (int i = 0; i < item->data.list->n; i++) {
     1378          psMetadataItem *entry = psListGet (item->data.list, i);
     1379          assert (entry);
     1380          assert (entry->type == PS_DATA_METADATA);
     1381          chipImfileRow *chipImfile = chipImfileObjectFromMetadata (entry->data.md);
     1382          chipImfileInsertObject (config->dbh, chipImfile);
     1383
     1384          // fprintf (stdout, "---- row %d ----\n", i);
     1385          // psMetadataPrint (stderr, entry->data.md, 1);
     1386        }
     1387        break;
     1388       
     1389      case 1:
     1390        for (int i = 0; i < item->data.list->n; i++) {
     1391          psMetadataItem *entry = psListGet (item->data.list, i);
     1392          assert (entry);
     1393          assert (entry->type == PS_DATA_METADATA);
     1394          chipProcessedImfileRow *chipProcessedImfile = chipProcessedImfileObjectFromMetadata (entry->data.md);
     1395          chipProcessedImfileInsertObject (config->dbh, chipProcessedImfile);
     1396
     1397          // fprintf (stdout, "---- row %d ----\n", i);
     1398          // psMetadataPrint (stderr, entry->data.md, 1);
     1399        }
     1400        break;
     1401    }
    14121402  }
    14131403
Note: See TracChangeset for help on using the changeset viewer.