Changeset 18991 for branches/eam_branch_20080719/ippTools/src/dettool.c
- Timestamp:
- Aug 8, 2008, 5:08:29 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080719/ippTools/src/dettool.c
r18643 r18991 39 39 static detInputExpRow *rawDetrenTodetInputExpRow(rawExpRow *rawExp, psS64 det_id, psS32 iteration); 40 40 static psS32 incrementIteration(pxConfig *config, psS64 det_id); 41 static bool isValidMode(pxConfig *config, const char *mode);42 41 43 42 # define MODECASE(caseName, func) \ … … 77 76 MODECASE(DETTOOL_MODE_PROCESSEDIMFILE, processedimfileMode); 78 77 MODECASE(DETTOOL_MODE_REVERTPROCESSEDIMFILE, revertprocessedimfileMode); 78 MODECASE(DETTOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileMode); 79 79 MODECASE(DETTOOL_MODE_PENDINGCLEANUP_PROCESSEDIMFILE, pendingcleanup_processedimfileMode); 80 80 MODECASE(DETTOOL_MODE_DONECLEANUP_PROCESSEDIMFILE, donecleanup_processedimfileMode); … … 84 84 MODECASE(DETTOOL_MODE_PROCESSEDEXP, processedexpMode); 85 85 MODECASE(DETTOOL_MODE_REVERTPROCESSEDEXP, revertprocessedexpMode); 86 MODECASE(DETTOOL_MODE_UPDATEPROCESSEDEXP, updateprocessedexpMode); 86 87 MODECASE(DETTOOL_MODE_PENDINGCLEANUP_PROCESSEDEXP, pendingcleanup_processedexpMode); 87 88 MODECASE(DETTOOL_MODE_DONECLEANUP_PROCESSEDEXP, donecleanup_processedexpMode); … … 91 92 MODECASE(DETTOOL_MODE_STACKED, stackedMode); 92 93 MODECASE(DETTOOL_MODE_REVERTSTACKED, revertstackedMode); 94 MODECASE(DETTOOL_MODE_UPDATESTACKED, updatestackedMode); 93 95 MODECASE(DETTOOL_MODE_PENDINGCLEANUP_STACKED, pendingcleanup_stackedMode); 94 96 MODECASE(DETTOOL_MODE_DONECLEANUP_STACKED, donecleanup_stackedMode); … … 98 100 MODECASE(DETTOOL_MODE_NORMALIZEDSTAT, normalizedstatMode); 99 101 MODECASE(DETTOOL_MODE_REVERTNORMALIZEDSTAT, revertnormalizedstatMode); 102 MODECASE(DETTOOL_MODE_UPDATENORMALIZEDSTAT, updatenormalizedstatMode); 100 103 MODECASE(DETTOOL_MODE_PENDINGCLEANUP_NORMALIZEDSTAT, pendingcleanup_normalizedstatMode); 101 104 MODECASE(DETTOOL_MODE_DONECLEANUP_NORMALIZEDSTAT, donecleanup_normalizedstatMode); … … 105 108 MODECASE(DETTOOL_MODE_NORMALIZEDIMFILE, normalizedimfileMode); 106 109 MODECASE(DETTOOL_MODE_REVERTNORMALIZEDIMFILE, revertnormalizedimfileMode); 110 MODECASE(DETTOOL_MODE_UPDATENORMALIZEDIMFILE, updatenormalizedimfileMode); 107 111 MODECASE(DETTOOL_MODE_PENDINGCLEANUP_NORMALIZEDIMFILE, pendingcleanup_normalizedimfileMode); 108 112 MODECASE(DETTOOL_MODE_DONECLEANUP_NORMALIZEDIMFILE, donecleanup_normalizedimfileMode); … … 112 116 MODECASE(DETTOOL_MODE_NORMALIZEDEXP, normalizedexpMode); 113 117 MODECASE(DETTOOL_MODE_REVERTNORMALIZEDEXP, revertnormalizedexpMode); 118 MODECASE(DETTOOL_MODE_UPDATENORMALIZEDEXP, updatenormalizedexpMode); 114 119 MODECASE(DETTOOL_MODE_PENDINGCLEANUP_NORMALIZEDEXP, pendingcleanup_normalizedexpMode); 115 120 MODECASE(DETTOOL_MODE_DONECLEANUP_NORMALIZEDEXP, donecleanup_normalizedexpMode); … … 119 124 MODECASE(DETTOOL_MODE_RESIDIMFILE, residimfileMode); 120 125 MODECASE(DETTOOL_MODE_REVERTRESIDIMFILE,revertresidimfileMode); 126 MODECASE(DETTOOL_MODE_UPDATERESIDIMFILE, updateresidimfileMode); 121 127 MODECASE(DETTOOL_MODE_PENDINGCLEANUP_RESIDIMFILE, pendingcleanup_residimfileMode); 122 128 MODECASE(DETTOOL_MODE_DONECLEANUP_RESIDIMFILE, donecleanup_residimfileMode); … … 174 180 175 181 psMetadata *where = psMetadataAlloc(); 176 PXOPT_COPY_S TR(config->args, where, "-exp_id", "exp_id", "==");182 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); 177 183 PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "=="); 178 184 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); … … 688 694 689 695 690 PXOPT_LOOKUP_S TR(det_id, config->args, "-det_id", true, false); // required696 PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); // required 691 697 PXOPT_LOOKUP_STR(det_type, config->args, "-set_det_type", false, false); // optional 692 698 PXOPT_LOOKUP_STR(mode, config->args, "-set_mode", false, false); // optional … … 724 730 { 725 731 psMetadata *where = psMetadataAlloc(); 726 psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", (psS64)atoll(det_id));732 psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", det_id); 727 733 detRuns = detRunSelectRowObjects(config->dbh, where, 0); 728 734 psFree(where); … … 734 740 // sanity check the result... we should have only found one det_id 735 741 if (psArrayLength(detRuns) != 1) { 736 psAbort("found more then one detRun matching det_id %" PRId64 " (this should not happen)", (psS64)atoll(det_id));742 psAbort("found more then one detRun matching det_id %" PRId64 " (this should not happen)", det_id); 737 743 return false; // unreachable 738 744 } … … 905 911 psFree(time_filter); 906 912 907 if (!p_psDBRunQuery(config->dbh, query, (psS64)newDet_id, (psS64)atoll(det_id))) {913 if (!p_psDBRunQuery(config->dbh, query, (psS64)newDet_id, det_id)) { 908 914 psError(PS_ERR_UNKNOWN, false, "database error"); 909 915 psFree(query); … … 953 959 psMetadata *where = psMetadataAlloc(); 954 960 PXOPT_COPY_STR(config->args, where, "-det_type", "det_type", "=="); 955 PXOPT_COPY_S TR(config->args, where, "-det_id", "det_id", "==");961 PXOPT_COPY_S64(config->args, where, "-det_id", "det_id", "=="); 956 962 957 963 PXOPT_COPY_STR(config->args, where, "-inst", "camera", "=="); … … 1118 1124 1119 1125 psMetadata *where = psMetadataAlloc(); 1120 PXOPT_COPY_S TR(config->args, where, "-det_id", "det_id", "==");1126 PXOPT_COPY_S64(config->args, where, "-det_id", "det_id", "=="); 1121 1127 PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "=="); 1122 1128 PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "=="); … … 1221 1227 PS_ASSERT_PTR_NON_NULL(config, false); 1222 1228 1223 PXOPT_LOOKUP_S TR(det_id, config->args, "-det_id", true, false); // required1229 PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); // required 1224 1230 PXOPT_LOOKUP_BOOL(again, config->args, "-again", false); 1225 1231 PXOPT_LOOKUP_STR(state, config->args, "-state", false, false); … … 1237 1243 if (state) { 1238 1244 // set detRun.state to state 1239 return setDetRunState(config, (psS64)atoll(det_id), state);1245 return setDetRunState(config, det_id, state); 1240 1246 } 1241 1247 1242 1248 // else 1243 1249 // -again 1244 if (!startNewIteration(config, (psS64)atoll(det_id))) {1250 if (!startNewIteration(config, det_id)) { 1245 1251 psError(PS_ERR_UNKNOWN, false, "failed to start new iteration"); 1246 1252 return false; … … 1363 1369 1364 1370 // det_id is required 1365 PXOPT_LOOKUP_S TR(det_id, config->args, "-det_id", true, false);1371 PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); 1366 1372 1367 1373 // we have to support multipe exp_ids … … 1408 1414 1409 1415 // add the det_id & iteration == 0 to the where clause 1410 if (!psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", 1411 (psS64)atoll(det_id))) { 1416 if (!psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", det_id)) { 1412 1417 psError(PS_ERR_UNKNOWN, false, "failed to add item det_id"); 1413 1418 psFree(where); … … 1446 1451 1447 1452 // up the detRuns iteration count 1448 psS32 newIteration = incrementIteration(config, (psS64)atoll(det_id));1453 psS32 newIteration = incrementIteration(config, det_id); 1449 1454 if (!newIteration) { 1450 1455 // rollback … … 1470 1475 } 1471 1476 // invalid exp_id 1472 psError(PS_ERR_UNKNOWN, false, "exp_id %s is invalid for det_id % s",1477 psError(PS_ERR_UNKNOWN, false, "exp_id %s is invalid for det_id %" PRId64, 1473 1478 (char *)mItem->data.V, det_id); 1474 1479 psFree(iter); … … 1477 1482 } 1478 1483 detInputExpRow *newInputExp = detInputExpRowAlloc( 1479 (psS64)atoll(det_id),1484 det_id, 1480 1485 newIteration, 1481 1486 inputExp->exp_id, … … 1536 1541 PXOPT_LOOKUP_TIME(use_begin, config->args, "-use_begin", false, false); 1537 1542 PXOPT_LOOKUP_TIME(use_end, config->args, "-use_end", false, false); 1538 PXOPT_LOOKUP_S TR(parent, config->args, "-parent", false, false);1543 PXOPT_LOOKUP_S64(parent, config->args, "-parent", false, false); 1539 1544 PXOPT_LOOKUP_STR(label, config->args, "-label", false, false); 1540 1545 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); … … 1574 1579 solang_max, 1575 1580 label, // label 1576 parent ? (psS64)atoll(parent) : 01581 parent 1577 1582 )) { 1578 1583 psError(PS_ERR_UNKNOWN, false, "database error"); … … 1625 1630 PS_ASSERT_PTR_NON_NULL(config, false); 1626 1631 1627 PXOPT_LOOKUP_S TR(det_id, config->args, "-det_id", true, false); // required1632 PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); // required 1628 1633 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); // required 1629 1634 PXOPT_LOOKUP_STR(uri, config->args, "-uri", true, false); // required … … 1639 1644 1640 1645 if (!detRegisteredImfileInsert(config->dbh, 1641 (psS64)atoll(det_id),1646 det_id, 1642 1647 0, // the iteration is fixed at 0 1643 1648 class_id, … … 1727 1732 } 1728 1733 1729 static bool isValidMode(pxConfig *config, const char *mode) 1734 bool isValidDataState (const char *data_state) { 1735 1736 // check that state is a valid string value 1737 if (!strncmp(data_state, "run", 4)) return true; 1738 if (!strncmp(data_state, "stop", 5)) return true; 1739 if (!strncmp(data_state, "drop", 5)) return true; 1740 if (!strncmp(data_state, "register", 4)) return true; 1741 1742 psError(PS_ERR_UNKNOWN, true, "invalid data state: %s", data_state); 1743 return false; 1744 } 1745 1746 bool isValidMode(pxConfig *config, const char *mode) 1730 1747 { 1731 1748 PS_ASSERT_PTR_NON_NULL(config, false); … … 1746 1763 } 1747 1764 1765 1766 bool setProcessedImfileDataState(pxConfig *config, psS64 det_id, psS64 exp_id, const char *class_id, const char *data_state) 1767 { 1768 PS_ASSERT_PTR_NON_NULL(config, false); 1769 PS_ASSERT_PTR_NON_NULL(data_state, false); 1770 PS_ASSERT_PTR_NON_NULL(class_id, false); 1771 1772 if (!isValidDataState (data_state)) return false; 1773 1774 char *query = "UPDATE detProcessedImfile SET data_state = '%s'" 1775 " WHERE det_id = %" PRId64 1776 " AND exp_id = %" PRId64 1777 " AND class_id = '%s'"; 1778 if (!p_psDBRunQuery(config->dbh, query, data_state, det_id, exp_id, class_id)) { 1779 psError(PS_ERR_UNKNOWN, false, 1780 "failed to change state for det_id %" PRId64 ", exp_id %" PRId64 ", class_id %s", 1781 det_id, exp_id, class_id); 1782 return false; 1783 } 1784 1785 return true; 1786 } 1787 1788 bool setProcessedExpDataState(pxConfig *config, psS64 det_id, psS64 exp_id, const char *data_state) 1789 { 1790 PS_ASSERT_PTR_NON_NULL(config, false); 1791 PS_ASSERT_PTR_NON_NULL(data_state, false); 1792 1793 if (!isValidDataState (data_state)) return false; 1794 1795 char *query = "UPDATE detProcessedExp SET data_state = '%s'" 1796 " WHERE det_id = %" PRId64 1797 " AND exp_id = %" PRId64; 1798 if (!p_psDBRunQuery(config->dbh, query, data_state, det_id, exp_id)) { 1799 psError(PS_ERR_UNKNOWN, false, 1800 "failed to change state for det_id %" PRId64 ", exp_id %" PRId64, 1801 det_id, exp_id); 1802 return false; 1803 } 1804 1805 return true; 1806 } 1807 1808 1809 bool setStackedImfileDataState(pxConfig *config, psS64 det_id, psS32 iteration, const char *data_state) 1810 { 1811 PS_ASSERT_PTR_NON_NULL(config, false); 1812 PS_ASSERT_PTR_NON_NULL(data_state, false); 1813 1814 if (!isValidDataState (data_state)) return false; 1815 1816 char *query = "UPDATE detStackedImfile SET data_state = '%s'" 1817 " WHERE det_id = %" PRId64 1818 " AND iteration = %" PRId32; 1819 if (!p_psDBRunQuery(config->dbh, query, data_state, det_id, iteration)) { 1820 psError(PS_ERR_UNKNOWN, false, 1821 "failed to change state for det_id %" PRId64 ", iteration %" PRId32, 1822 det_id, iteration); 1823 return false; 1824 } 1825 1826 return true; 1827 } 1828 1829 bool setNormStatImfileDataState(pxConfig *config, psS64 det_id, psS32 iteration, const char *class_id, const char *data_state) 1830 { 1831 PS_ASSERT_PTR_NON_NULL(config, false); 1832 PS_ASSERT_PTR_NON_NULL(class_id, false); 1833 PS_ASSERT_PTR_NON_NULL(data_state, false); 1834 1835 if (!isValidDataState (data_state)) return false; 1836 1837 char *query = "UPDATE detNormalizedStatImfile SET data_state = '%s'" 1838 " WHERE det_id = %" PRId64 1839 " AND iteration = %" PRId32 1840 " AND class_id = %s"; 1841 if (!p_psDBRunQuery(config->dbh, query, data_state, det_id, iteration)) { 1842 psError(PS_ERR_UNKNOWN, false, 1843 "failed to change state for det_id %" PRId64 ", iteration %" PRId32, 1844 det_id, iteration); 1845 return false; 1846 } 1847 1848 return true; 1849 } 1850 1851 bool setNormImfileDataState(pxConfig *config, psS64 det_id, psS32 iteration, const char *class_id, const char *data_state) 1852 { 1853 PS_ASSERT_PTR_NON_NULL(config, false); 1854 PS_ASSERT_PTR_NON_NULL(class_id, false); 1855 PS_ASSERT_PTR_NON_NULL(data_state, false); 1856 1857 if (!isValidDataState (data_state)) return false; 1858 1859 char *query = "UPDATE detNormalizedImfile SET data_state = '%s'" 1860 " WHERE det_id = %" PRId64 1861 " AND iteration = %" PRId32 1862 " AND class_id = %s"; 1863 if (!p_psDBRunQuery(config->dbh, query, data_state, det_id, iteration, class_id)) { 1864 psError(PS_ERR_UNKNOWN, false, 1865 "failed to change state for det_id %" PRId64 ", iteration %" PRId32 " class %s", 1866 det_id, iteration, class_id); 1867 return false; 1868 } 1869 1870 return true; 1871 } 1872 1873 bool setNormExpDataState(pxConfig *config, psS64 det_id, psS32 iteration, const char *data_state) 1874 { 1875 PS_ASSERT_PTR_NON_NULL(config, false); 1876 PS_ASSERT_PTR_NON_NULL(data_state, false); 1877 1878 if (!isValidDataState (data_state)) return false; 1879 1880 char *query = "UPDATE detNormalizedExp SET data_state = '%s'" 1881 " WHERE det_id = %" PRId64 1882 " AND iteration = %" PRId32; 1883 if (!p_psDBRunQuery(config->dbh, query, data_state, det_id, iteration)) { 1884 psError(PS_ERR_UNKNOWN, false, 1885 "failed to change state for det_id %" PRId64 ", iteration %" PRId32, 1886 det_id, iteration); 1887 return false; 1888 } 1889 1890 return true; 1891 } 1892 1893 bool setResidImfileDataState(pxConfig *config, psS64 det_id, psS32 iteration, psS64 exp_id, const char *class_id, const char *data_state) 1894 { 1895 PS_ASSERT_PTR_NON_NULL(config, false); 1896 PS_ASSERT_PTR_NON_NULL(data_state, false); 1897 PS_ASSERT_PTR_NON_NULL(class_id, false); 1898 1899 if (!isValidDataState (data_state)) return false; 1900 1901 char *query = "UPDATE detResidImfile SET data_state = '%s'" 1902 " WHERE det_id = %" PRId64 1903 " AND iteration = %" PRId32 1904 " AND exp_id = %" PRId64 1905 " AND class_id = '%s'"; 1906 if (!p_psDBRunQuery(config->dbh, query, data_state, det_id, iteration, exp_id, class_id)) { 1907 psError(PS_ERR_UNKNOWN, false, 1908 "failed to change state for det_id %" PRId64 ", iteration %" PRId32 ", exp_id %" PRId64 ", class_id %s", 1909 det_id, iteration, exp_id, class_id); 1910 return false; 1911 } 1912 1913 return true; 1914 } 1915 1916 bool setResidExpDataState(pxConfig *config, psS64 det_id, psS32 iteration, psS64 exp_id, const char *data_state) 1917 { 1918 PS_ASSERT_PTR_NON_NULL(config, false); 1919 PS_ASSERT_PTR_NON_NULL(data_state, false); 1920 1921 if (!isValidDataState (data_state)) return false; 1922 1923 char *query = "UPDATE detResidExp SET data_state = '%s'" 1924 " WHERE det_id = %" PRId64 1925 " AND iteration = %" PRId32 1926 " AND exp_id = %" PRId64; 1927 if (!p_psDBRunQuery(config->dbh, query, data_state, det_id, iteration, exp_id)) { 1928 psError(PS_ERR_UNKNOWN, false, 1929 "failed to change state for det_id %" PRId64 ", iteration %" PRId32 ", exp_id %" PRId64, 1930 det_id, iteration, exp_id); 1931 return false; 1932 } 1933 1934 return true; 1935 } 1748 1936 1749 1937 #if 0
Note:
See TracChangeset
for help on using the changeset viewer.
