Changeset 27738 for trunk/ippTools/src/chiptool.c
- Timestamp:
- Apr 23, 2010, 11:20:24 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/chiptool.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r27391 r27738 60 60 static bool runstateMode(pxConfig *config); 61 61 static bool setimfiletoupdateMode(pxConfig *config); 62 static bool listrunMode(pxConfig *config); 62 63 63 64 # define MODECASE(caseName, func) \ … … 103 104 MODECASE(CHIPTOOL_MODE_RUNSTATE, runstateMode); 104 105 MODECASE(CHIPTOOL_MODE_SETIMFILETOUPDATE, setimfiletoupdateMode); 106 MODECASE(CHIPTOOL_MODE_LISTRUN, listrunMode); 105 107 default: 106 108 psAbort("invalid option (this should not happen)"); … … 699 701 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 700 702 PXOPT_LOOKUP_BOOL(faulted, config->args, "-faulted", false); 703 PXOPT_LOOKUP_BOOL(allfiles, config->args, "-allfiles", false); 704 if (allfiles) { 705 faulted = false; 706 } 701 707 702 708 psMetadata *where = psMetadataAlloc(); … … 740 746 // list only faulted rows 741 747 psStringAppend(&query, " %s", "AND chipProcessedImfile.fault != 0"); 742 } else {748 } else if (!allfiles) { 743 749 // don't list faulted rows 744 750 psStringAppend(&query, " %s", "AND chipProcessedImfile.fault = 0"); … … 1414 1420 } 1415 1421 1416 char *set_magicked_imfile = "";1417 char *set_magicked_run = "";1422 psString set_magicked_imfile = psStringCopy(""); 1423 psString set_magicked_run = psStringCopy(""); 1418 1424 if (!strcmp(data_state, "full")) { 1419 1425 // if (chipProcessedImfile.magicked < 0 and rawImfile.magicked = 0) leave magicked unchanged. This will … … 1421 1427 // otherwise copy magicked from the rawImfile 1422 1428 // Same thing for chipRun/rawExp 1423 set_magicked_imfile = "\n , chipProcessedImfile.magicked = IF((chipProcessedImfile.magicked < 0 AND rawImfile.magicked = 0), chipProcessedImfile.magicked, rawImfile.magicked)"; 1424 set_magicked_run = "\n , chipRun.magicked = IF((chipRun.magicked < 0 AND rawExp.magicked = 0), chipRun.magicked, rawExp.magicked)"; 1429 psStringAppend(&set_magicked_imfile, "\n , chipProcessedImfile.magicked = IF((chipProcessedImfile.magicked < 0" 1430 " AND rawImfile.magicked = 0), chipProcessedImfile.magicked, rawImfile.magicked)"); 1431 psStringAppend(&set_magicked_run, "\n , chipRun.magicked = IF((chipRun.magicked < 0 AND rawExp.magicked = 0), " 1432 " chipRun.magicked, rawExp.magicked)"); 1433 1425 1434 } else if (!strcmp(data_state, "cleaned") || !strcmp(data_state, "purged")) { 1426 1435 // if magicked is non-zero set it to -1 1427 set_magicked_imfile = "\n, chipProcessedImfile.magicked = IF(chipProcessedImfile.magicked = 0, 0, -1)"; 1428 set_magicked_run = "\n, chipRun.magicked = IF(chipRun.magicked = 0, 0, -1)"; 1436 // Once one imfile has been cleaned, the chipRun is no longer 'magicked' 1437 psStringAppend(&set_magicked_imfile, "\n, chipProcessedImfile.magicked = IF(chipProcessedImfile.magicked = 0, 0, -1)," 1438 " chipRun.magicked = IF(chipRun.magicked = 0, 0, -1)"); 1429 1439 } 1430 1440 … … 1440 1450 } 1441 1451 psFree(query); 1452 psFree(set_magicked_imfile); 1453 psFree(set_magicked_run); 1442 1454 if (psDBAffectedRows(config->dbh) < 1) { 1443 1455 psError(PS_ERR_UNKNOWN, false, "should have affected atleast 1 row"); … … 1757 1769 return true; 1758 1770 } 1771 1772 static bool listrunMode(pxConfig *config) 1773 { 1774 PS_ASSERT_PTR_NON_NULL(config, NULL); 1775 1776 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1777 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1778 PXOPT_LOOKUP_BOOL(pstamp_order, config->args, "-pstamp_order", false); 1779 1780 psMetadata *where = psMetadataAlloc(); 1781 pxchipGetSearchArgs (config, where); // chipRun, chipProcessedImfile, rawExp 1782 PXOPT_COPY_S64(config->args, where, "-chip_id", "chipRun.chip_id", "=="); 1783 PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "=="); 1784 PXOPT_COPY_STR(config->args, where, "-state", "chipRun.state", "=="); 1785 pxAddLabelSearchArgs (config, where, "-label", "chipRun.label", "LIKE"); 1786 pxAddLabelSearchArgs (config, where, "-data_group", "chipRun.data_group", "LIKE"); 1787 pxAddLabelSearchArgs (config, where, "-dist_group", "chipRun.dist_group", "LIKE"); 1788 PXOPT_COPY_S64(config->args, where, "-magicked", "chipRun.magicked", "=="); 1789 1790 psString where2 = NULL; 1791 pxmagicAddWhere(config, &where2, "chipRun"); 1792 // add cuts on ra and decl if supplied 1793 if (!pxspaceAddWhere(config, &where2, "rawExp")) { 1794 psError(psErrorCodeLast(), false, "pxSpaceAddWhere failed"); 1795 return false; 1796 } 1797 1798 psString query = pxDataGet("chiptool_listrun.sql"); 1799 if (!query) { 1800 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1801 return false; 1802 } 1803 1804 if (psListLength(where->list)) { 1805 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1806 psStringAppend(&query, " WHERE %s %s", whereClause, where2 ? where2 : ""); 1807 psFree(whereClause); 1808 } else if (psMetadataLookupBool(NULL, config->args, "-all") || where2) { 1809 psStringAppend(&query, " WHERE chipRun.chip_id IS NOT NULL %s", where2 ? where2 : ""); 1810 } else { 1811 psFree(where); 1812 psError(PXTOOLS_ERR_CONFIG, false, "search parameters (or -all) are required"); 1813 return false; 1814 } 1815 psFree(where); 1816 1817 if (pstamp_order) { 1818 // put runs in order of exposure id with newest chip Runs first 1819 // The postage stamp parser depends on this behavior 1820 psStringAppend(&query, "\nORDER by exp_id, chip_id DESC"); 1821 } 1822 1823 // treat limit == 0 as "no limit" 1824 if (limit) { 1825 psString limitString = psDBGenerateLimitSQL(limit); 1826 psStringAppend(&query, " %s", limitString); 1827 psFree(limitString); 1828 } 1829 1830 if (!p_psDBRunQuery(config->dbh, query)) { 1831 psError(PS_ERR_UNKNOWN, false, "database error"); 1832 psFree(query); 1833 return false; 1834 } 1835 psFree(query); 1836 1837 psArray *output = p_psDBFetchResult(config->dbh); 1838 if (!output) { 1839 psError(PS_ERR_UNKNOWN, false, "database error"); 1840 return false; 1841 } 1842 if (!psArrayLength(output)) { 1843 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 1844 psFree(output); 1845 return true; 1846 } 1847 1848 // negative simple so the default is true 1849 if (!ippdbPrintMetadatas(stdout, output, "chipRun", !simple)) { 1850 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1851 psFree(output); 1852 return false; 1853 } 1854 1855 psFree(output); 1856 1857 return true; 1858 }
Note:
See TracChangeset
for help on using the changeset viewer.
