Changeset 27517 for branches/eam_branches/20100225/ippTools/src/chiptool.c
- Timestamp:
- Mar 29, 2010, 3:55:49 PM (16 years ago)
- Location:
- branches/eam_branches/20100225
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippTools/src/chiptool.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20100225
- Property svn:mergeinfo changed
-
branches/eam_branches/20100225/ippTools/src/chiptool.c
r26981 r27517 36 36 37 37 static bool definebyqueryMode(pxConfig *config); 38 static bool definecopyMode(pxConfig *config); 38 39 static bool updaterunMode(pxConfig *config); 39 40 static bool pendingimfileMode(pxConfig *config); … … 58 59 static bool importrunMode(pxConfig *config); 59 60 static bool runstateMode(pxConfig *config); 61 static bool setimfiletoupdateMode(pxConfig *config); 60 62 61 63 # define MODECASE(caseName, func) \ … … 77 79 switch (config->mode) { 78 80 MODECASE(CHIPTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 81 MODECASE(CHIPTOOL_MODE_DEFINECOPY, definecopyMode); 79 82 MODECASE(CHIPTOOL_MODE_UPDATERUN, updaterunMode); 80 83 MODECASE(CHIPTOOL_MODE_PENDINGIMFILE, pendingimfileMode); … … 99 102 MODECASE(CHIPTOOL_MODE_IMPORTRUN, importrunMode); 100 103 MODECASE(CHIPTOOL_MODE_RUNSTATE, runstateMode); 104 MODECASE(CHIPTOOL_MODE_SETIMFILETOUPDATE, setimfiletoupdateMode); 101 105 default: 102 106 psAbort("invalid option (this should not happen)"); … … 120 124 } 121 125 122 123 static bool definebyqueryMode(pxConfig *config) 124 { 125 PS_ASSERT_PTR_NON_NULL(config, NULL); 126 127 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 128 129 psMetadata *where = psMetadataAlloc(); 130 pxchipGetSearchArgs (config, where); // rawExp only 131 pxAddLabelSearchArgs (config, where, "-label", "newExp.label", "LIKE"); // define using newExp label 132 133 // psListLength(where->list) is at least 1 because exp_type defaults to "object" 134 // so we require a list longer than 1 entry 135 if ((psListLength(where->list) <= 1) && !psMetadataLookupBool(NULL, config->args, "-all")) { 136 psFree(where); 137 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 138 return false; 139 } 140 141 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); 142 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 143 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 144 PXOPT_LOOKUP_STR(expgroup, config->args, "-set_expgroup", false, false); 145 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 146 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 147 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 148 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 149 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 150 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 151 152 // default 153 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 154 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 155 156 // find the exp_id of all the exposures that we want to queue up. 157 psString query = pxDataGet("chiptool_find_rawexp.sql"); 158 if (!query) { 159 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 160 psFree(where); 161 return false; 162 } 163 164 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 165 psStringAppend(&query, " AND %s", whereClause); 166 167 psFree(whereClause); 168 psFree(where); 169 170 if (!p_psDBRunQuery(config->dbh, query)) { 171 psError(PS_ERR_UNKNOWN, false, "database error"); 172 psFree(query); 173 return false; 174 } 175 psFree(query); 176 177 psArray *output = p_psDBFetchResult(config->dbh); 178 if (!output) { 179 psError(PS_ERR_UNKNOWN, false, "database error"); 180 return false; 181 } 182 if (!psArrayLength(output)) { 183 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 184 psFree(output); 185 return true; 186 } 187 188 if (pretend) { 189 // negative simple so the default is true 190 if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) { 191 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 192 psFree(output); 193 return false; 194 } 195 psFree(output); 196 return true; 197 } 198 126 // Queue exposures for chip processing 127 static bool queue_exposures(pxConfig *config, // Configuration 128 const psArray *exps, // Exposures information 129 const char *workdir, // Working directory, or NULL to inherit 130 const char *label, // Label, or NULL to inherit 131 const char *data_group, // Data group, or NULL to inherit 132 const char *dist_group, // Distribution group, or NULL to inherit 133 const char *reduction, // Reduction class, or NULL to inherit 134 const char *expgroup, // Exposure group 135 const char *dvodb, // DVO database, or NULL to inherit 136 const char *tess_id, // Tessellation identifier, or NULL to inherit 137 const char *end_stage, // End stage, or NULL to inherit 138 const char *note // Note 139 ) 140 { 199 141 // start a transaction so we don't end up with an exp without any associted 200 142 // imfiles 201 143 if (!psDBTransaction(config->dbh)) { 202 144 psError(PS_ERR_UNKNOWN, false, "database error"); 203 psFree(output);204 145 return false; 205 146 } 206 147 207 148 // if end_stage is warp (or NULL), check for valid tess_id 208 for (long i = 0; i < psArrayLength( output); i++) {209 psMetadata *md = output->data[i];149 for (long i = 0; i < psArrayLength(exps); i++) { 150 psMetadata *md = exps->data[i]; 210 151 211 152 bool status; … … 220 161 221 162 if (!status) { 222 psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id); 223 psFree(output); 163 psError(PS_ERR_UNKNOWN, false, 164 "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, 165 label, exp_id); 224 166 return false; 225 167 } … … 229 171 # define GET_VALUE(PTYPE,CTYPE,VALUE,NAME) \ 230 172 PTYPE VALUE; \ 231 { bool status; \ 173 { \ 174 bool status; \ 232 175 VALUE = psMetadataLookup##CTYPE(&status, md, NAME); \ 233 176 if (!status) { \ 234 177 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", NAME); \ 235 psFree(output); \236 178 return false; \ 237 } } 179 } \ 180 } 238 181 239 182 // loop over our list of exp_ids 240 for (long i = 0; i < psArrayLength( output); i++) {241 psMetadata *md = output->data[i];183 for (long i = 0; i < psArrayLength(exps); i++) { 184 psMetadata *md = exps->data[i]; 242 185 243 186 rawExpRow *row = rawExpObjectFromMetadata(md); 244 187 if (!row) { 245 188 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun"); 246 psFree(output);247 189 return false; 248 190 } … … 259 201 if (!row->exp_id) { 260 202 psError(PS_ERR_UNKNOWN, false, "failed to find value for exp_id"); 261 psFree(output);262 203 return false; 263 204 } … … 284 225 psError(PS_ERR_UNKNOWN, false, 285 226 "failed to trying to queue exp_id: %" PRId64, exp_id); 227 return false; 228 } 229 } 230 231 if (!psDBCommit(config->dbh)) { 232 psError(PS_ERR_UNKNOWN, false, "database error"); 233 return false; 234 } 235 236 return true; 237 } 238 239 static bool definebyqueryMode(pxConfig *config) 240 { 241 PS_ASSERT_PTR_NON_NULL(config, NULL); 242 243 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 244 245 psMetadata *where = psMetadataAlloc(); 246 pxchipGetSearchArgs (config, where); // rawExp only 247 pxAddLabelSearchArgs (config, where, "-label", "newExp.label", "LIKE"); // define using newExp label 248 249 // psListLength(where->list) is at least 1 because exp_type defaults to "object" 250 // so we require a list longer than 1 entry 251 if ((psListLength(where->list) <= 1) && !psMetadataLookupBool(NULL, config->args, "-all")) { 252 psFree(where); 253 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 254 return false; 255 } 256 257 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); 258 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 259 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 260 PXOPT_LOOKUP_STR(expgroup, config->args, "-set_expgroup", false, false); 261 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 262 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 263 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 264 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 265 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 266 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 267 268 // default 269 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 270 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 271 272 // find the exp_id of all the exposures that we want to queue up. 273 psString query = pxDataGet("chiptool_find_rawexp.sql"); 274 if (!query) { 275 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 276 psFree(where); 277 return false; 278 } 279 280 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 281 psStringAppend(&query, " AND %s", whereClause); 282 283 psFree(whereClause); 284 psFree(where); 285 286 if (!p_psDBRunQuery(config->dbh, query)) { 287 psError(PS_ERR_UNKNOWN, false, "database error"); 288 psFree(query); 289 return false; 290 } 291 psFree(query); 292 293 psArray *output = p_psDBFetchResult(config->dbh); 294 if (!output) { 295 psError(PS_ERR_UNKNOWN, false, "database error"); 296 return false; 297 } 298 if (!psArrayLength(output)) { 299 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 300 psFree(output); 301 return true; 302 } 303 304 if (pretend) { 305 // negative simple so the default is true 306 if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) { 307 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 286 308 psFree(output); 287 309 return false; 288 310 } 311 psFree(output); 312 return true; 313 } 314 315 if (!queue_exposures(config, output, workdir, label, data_group, dist_group, reduction, expgroup, 316 dvodb, tess_id, end_stage, note)) { 317 psError(psErrorCodeLast(), false, "Unable to queue exposures for chip."); 318 psFree(output); 319 return false; 289 320 } 290 321 psFree(output); 291 322 292 if (!psDBCommit(config->dbh)) { 293 psError(PS_ERR_UNKNOWN, false, "database error"); 294 return false; 295 } 323 return true; 324 } 325 326 static bool definecopyMode(pxConfig *config) 327 { 328 PS_ASSERT_PTR_NON_NULL(config, NULL); 329 330 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 331 332 psMetadata *where = psMetadataAlloc(); 333 pxchipGetSearchArgs (config, where); // rawExp only 334 pxAddLabelSearchArgs (config, where, "-label", "chipOld.label", "LIKE"); 335 336 // psListLength(where->list) is at least 1 because exp_type defaults to "object" 337 // so we require a list longer than 1 entry 338 if ((psListLength(where->list) <= 1) && !psMetadataLookupBool(NULL, config->args, "-all")) { 339 psFree(where); 340 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 341 return false; 342 } 343 344 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); 345 PXOPT_LOOKUP_STR(label, config->args, "-set_label", true, false); 346 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 347 PXOPT_LOOKUP_STR(expgroup, config->args, "-set_expgroup", false, false); 348 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 349 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 350 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 351 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 352 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 353 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 354 355 // default 356 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 357 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 358 359 // find the exp_id of all the exposures that we want to queue up. 360 psString query = pxDataGet("chiptool_definecopy.sql"); 361 if (!query) { 362 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 363 psFree(where); 364 return false; 365 } 366 367 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 368 psStringAppend(&query, " AND %s", whereClause); 369 370 psFree(whereClause); 371 psFree(where); 372 373 if (!p_psDBRunQueryF(config->dbh, query, label)) { 374 psError(PS_ERR_UNKNOWN, false, "database error"); 375 psFree(query); 376 return false; 377 } 378 psFree(query); 379 380 psArray *output = p_psDBFetchResult(config->dbh); 381 if (!output) { 382 psError(PS_ERR_UNKNOWN, false, "database error"); 383 return false; 384 } 385 if (!psArrayLength(output)) { 386 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 387 psFree(output); 388 return true; 389 } 390 391 if (pretend) { 392 // negative simple so the default is true 393 if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) { 394 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 395 psFree(output); 396 return false; 397 } 398 psFree(output); 399 return true; 400 } 401 402 if (!queue_exposures(config, output, workdir, label, data_group, dist_group, reduction, expgroup, 403 dvodb, tess_id, end_stage, note)) { 404 psError(psErrorCodeLast(), false, "Unable to queue exposures for chip."); 405 psFree(output); 406 return false; 407 } 408 psFree(output); 296 409 297 410 return true; … … 317 430 return false; 318 431 } 319 psString query = psStringCopy("UPDATE chipRun JOIN rawExp USING(exp_id) ");432 psString query = psStringCopy("UPDATE chipRun JOIN rawExp USING(exp_id) -- join hook %s\n"); 320 433 321 434 // pxUpdateRun gets parameters from config->args and updates 322 bool result = pxUpdateRun(config, where, &query, "chipRun", true);435 bool result = pxUpdateRun(config, where, &query, "chipRun", "chip_id", "chipProcessedImfile", true); 323 436 if (!result) { 324 437 psError(psErrorCodeLast(), false, "pxUpdateRun failed"); … … 1609 1722 return true; 1610 1723 } 1724 1725 // a very specfic function to queue a cleaned chipProcessedImfile to be updated 1726 static bool setimfiletoupdateMode(pxConfig *config) 1727 { 1728 PS_ASSERT_PTR_NON_NULL(config, NULL); 1729 1730 PXOPT_LOOKUP_S64(chip_id, config->args, "-chip_id", true, false); 1731 PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", false, false); 1732 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 1733 1734 psString query = pxDataGet("chiptool_setimfiletoupdate.sql"); 1735 if (!query) { 1736 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 1737 return false; 1738 } 1739 1740 psString setHook = psStringCopy(""); 1741 if (label) { 1742 psStringAppend(&setHook, "\n , chipRun.label = '%s'", label); 1743 } 1744 1745 if (class_id) { 1746 psStringAppend(&query, " AND (chipProcessedImfile.class_id = '%s')", class_id); 1747 } 1748 1749 if (!p_psDBRunQueryF(config->dbh, query, setHook, chip_id)) { 1750 psError(PS_ERR_UNKNOWN, false, "database error"); 1751 return false; 1752 } 1753 1754 psFree(setHook); 1755 psFree(query); 1756 1757 return true; 1758 }
Note:
See TracChangeset
for help on using the changeset viewer.
