- Timestamp:
- Mar 17, 2009, 12:08:50 PM (17 years ago)
- Location:
- branches/cnb_branches/cnb_branch_20090301
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippTools/src/chiptool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/cnb_branches/cnb_branch_20090301
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk merged eligible /branches/eam_branches/eam_branch_20090303 23158-23228
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/cnb_branches/cnb_branch_20090301/ippTools/src/chiptool.c
r21521 r23352 42 42 static bool revertprocessedimfileMode(pxConfig *config); 43 43 static bool updateprocessedimfileMode(pxConfig *config); 44 static bool promoteexpMode(pxConfig *config);44 static bool advanceexpMode(pxConfig *config); 45 45 static bool blockMode(pxConfig *config); 46 46 static bool maskedMode(pxConfig *config); … … 81 81 MODECASE(CHIPTOOL_MODE_REVERTPROCESSEDIMFILE, revertprocessedimfileMode); 82 82 MODECASE(CHIPTOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileMode); 83 MODECASE(CHIPTOOL_MODE_ PROMOTEEXP, promoteexpMode);83 MODECASE(CHIPTOOL_MODE_ADVANCEEXP, advanceexpMode); 84 84 MODECASE(CHIPTOOL_MODE_BLOCK, blockMode); 85 85 MODECASE(CHIPTOOL_MODE_MASKED, maskedMode); … … 239 239 pxchipGetSearchArgs (config, where); // rawExp, chipRun 240 240 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", "=="); 242 243 243 244 if (!psListLength(where->list) … … 1078 1079 1079 1080 1080 static bool promoteexpMode(pxConfig *config)1081 static bool advanceexpMode(pxConfig *config) 1081 1082 { 1082 1083 PS_ASSERT_PTR_NON_NULL(config, false); … … 1256 1257 bool exportrunMode(pxConfig *config) 1257 1258 { 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); 1275 1290 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; 1278 1293 } 1279 1294 1280 1295 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); 1284 1299 } 1285 1300 1286 1301 // treat limit == 0 as "no limit" 1287 1302 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); 1291 1306 } 1292 1307 1293 1308 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; 1297 1312 } 1298 1313 psFree(query); … … 1300 1315 psArray *output = p_psDBFetchResult(config->dbh); 1301 1316 if (!output) { 1302 psError(PS_ERR_UNKNOWN, false, "database error");1303 return false;1317 psError(PS_ERR_UNKNOWN, false, "database error"); 1318 return false; 1304 1319 } 1305 1320 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; 1309 1324 } 1310 1325 1311 1326 // 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; 1316 1331 } 1317 1332 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 } 1371 1339 1372 1340 bool importrunMode(pxConfig *config) 1373 1341 { 1374 1342 unsigned int nFail; 1343 1344 int numImportTables = 2; 1345 1346 char tables[2] [80] = {"chipImfile", "chipProcessedImfile"}; 1375 1347 1376 1348 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 1383 1355 psMetadataPrint (stderr, input, 1); 1384 1356 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"); 1399 1358 psAssert (item, "entry not in input?"); 1400 1359 psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?"); 1401 1360 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 } 1412 1402 } 1413 1403
Note:
See TracChangeset
for help on using the changeset viewer.
