Changeset 27192 for trunk/ippTools/src/chiptool.c
- Timestamp:
- Mar 4, 2010, 3:13:19 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/chiptool.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r26981 r27192 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); … … 77 78 switch (config->mode) { 78 79 MODECASE(CHIPTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 80 MODECASE(CHIPTOOL_MODE_DEFINECOPY, definecopyMode); 79 81 MODECASE(CHIPTOOL_MODE_UPDATERUN, updaterunMode); 80 82 MODECASE(CHIPTOOL_MODE_PENDINGIMFILE, pendingimfileMode); … … 120 122 } 121 123 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 124 // Queue exposures for chip processing 125 static bool queue_exposures(pxConfig *config, // Configuration 126 const psArray *exps, // Exposures information 127 const char *workdir, // Working directory, or NULL to inherit 128 const char *label, // Label, or NULL to inherit 129 const char *data_group, // Data group, or NULL to inherit 130 const char *dist_group, // Distribution group, or NULL to inherit 131 const char *reduction, // Reduction class, or NULL to inherit 132 const char *expgroup, // Exposure group 133 const char *dvodb, // DVO database, or NULL to inherit 134 const char *tess_id, // Tessellation identifier, or NULL to inherit 135 const char *end_stage, // End stage, or NULL to inherit 136 const char *note // Note 137 ) 138 { 199 139 // start a transaction so we don't end up with an exp without any associted 200 140 // imfiles 201 141 if (!psDBTransaction(config->dbh)) { 202 142 psError(PS_ERR_UNKNOWN, false, "database error"); 203 psFree(output);204 143 return false; 205 144 } 206 145 207 146 // 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];147 for (long i = 0; i < psArrayLength(exps); i++) { 148 psMetadata *md = exps->data[i]; 210 149 211 150 bool status; … … 220 159 221 160 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); 161 psError(PS_ERR_UNKNOWN, false, 162 "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, 163 label, exp_id); 224 164 return false; 225 165 } … … 229 169 # define GET_VALUE(PTYPE,CTYPE,VALUE,NAME) \ 230 170 PTYPE VALUE; \ 231 { bool status; \ 171 { \ 172 bool status; \ 232 173 VALUE = psMetadataLookup##CTYPE(&status, md, NAME); \ 233 174 if (!status) { \ 234 175 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for %s", NAME); \ 235 psFree(output); \236 176 return false; \ 237 } } 177 } \ 178 } 238 179 239 180 // loop over our list of exp_ids 240 for (long i = 0; i < psArrayLength( output); i++) {241 psMetadata *md = output->data[i];181 for (long i = 0; i < psArrayLength(exps); i++) { 182 psMetadata *md = exps->data[i]; 242 183 243 184 rawExpRow *row = rawExpObjectFromMetadata(md); 244 185 if (!row) { 245 186 psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun"); 246 psFree(output);247 187 return false; 248 188 } … … 259 199 if (!row->exp_id) { 260 200 psError(PS_ERR_UNKNOWN, false, "failed to find value for exp_id"); 261 psFree(output);262 201 return false; 263 202 } … … 284 223 psError(PS_ERR_UNKNOWN, false, 285 224 "failed to trying to queue exp_id: %" PRId64, exp_id); 225 return false; 226 } 227 } 228 229 if (!psDBCommit(config->dbh)) { 230 psError(PS_ERR_UNKNOWN, false, "database error"); 231 return false; 232 } 233 234 return true; 235 } 236 237 static bool definebyqueryMode(pxConfig *config) 238 { 239 PS_ASSERT_PTR_NON_NULL(config, NULL); 240 241 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 242 243 psMetadata *where = psMetadataAlloc(); 244 pxchipGetSearchArgs (config, where); // rawExp only 245 pxAddLabelSearchArgs (config, where, "-label", "newExp.label", "LIKE"); // define using newExp label 246 247 // psListLength(where->list) is at least 1 because exp_type defaults to "object" 248 // so we require a list longer than 1 entry 249 if ((psListLength(where->list) <= 1) && !psMetadataLookupBool(NULL, config->args, "-all")) { 250 psFree(where); 251 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 252 return false; 253 } 254 255 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); 256 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 257 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 258 PXOPT_LOOKUP_STR(expgroup, config->args, "-set_expgroup", false, false); 259 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 260 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 261 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 262 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 263 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 264 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 265 266 // default 267 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 268 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 269 270 // find the exp_id of all the exposures that we want to queue up. 271 psString query = pxDataGet("chiptool_find_rawexp.sql"); 272 if (!query) { 273 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 274 psFree(where); 275 return false; 276 } 277 278 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 279 psStringAppend(&query, " AND %s", whereClause); 280 281 psFree(whereClause); 282 psFree(where); 283 284 if (!p_psDBRunQuery(config->dbh, query)) { 285 psError(PS_ERR_UNKNOWN, false, "database error"); 286 psFree(query); 287 return false; 288 } 289 psFree(query); 290 291 psArray *output = p_psDBFetchResult(config->dbh); 292 if (!output) { 293 psError(PS_ERR_UNKNOWN, false, "database error"); 294 return false; 295 } 296 if (!psArrayLength(output)) { 297 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 298 psFree(output); 299 return true; 300 } 301 302 if (pretend) { 303 // negative simple so the default is true 304 if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) { 305 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 286 306 psFree(output); 287 307 return false; 288 308 } 309 psFree(output); 310 return true; 311 } 312 313 if (!queue_exposures(config, output, workdir, label, data_group, dist_group, reduction, expgroup, 314 dvodb, tess_id, end_stage, note)) { 315 psError(psErrorCodeLast(), false, "Unable to queue exposures for chip."); 316 psFree(output); 317 return false; 289 318 } 290 319 psFree(output); 291 320 292 if (!psDBCommit(config->dbh)) { 293 psError(PS_ERR_UNKNOWN, false, "database error"); 294 return false; 295 } 321 return true; 322 } 323 324 static bool definecopyMode(pxConfig *config) 325 { 326 PS_ASSERT_PTR_NON_NULL(config, NULL); 327 328 PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", false, false); 329 330 psMetadata *where = psMetadataAlloc(); 331 pxchipGetSearchArgs (config, where); // rawExp only 332 pxAddLabelSearchArgs (config, where, "-label", "chipOld.label", "LIKE"); 333 pxAddLabelSearchArgs (config, where, "-set_label", "chipNew.label", "LIKE"); 334 335 // psListLength(where->list) is at least 1 because exp_type defaults to "object" 336 // so we require a list longer than 1 entry 337 if ((psListLength(where->list) <= 1) && !psMetadataLookupBool(NULL, config->args, "-all")) { 338 psFree(where); 339 psError(PXTOOLS_ERR_CONFIG, false, "search parameters are required"); 340 return false; 341 } 342 343 PXOPT_LOOKUP_STR(workdir, config->args, "-set_workdir", true, false); 344 PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false); 345 PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false); 346 PXOPT_LOOKUP_STR(expgroup, config->args, "-set_expgroup", false, false); 347 PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false); 348 PXOPT_LOOKUP_STR(tess_id, config->args, "-set_tess_id", false, false); 349 PXOPT_LOOKUP_STR(end_stage, config->args, "-set_end_stage", false, false); 350 PXOPT_LOOKUP_STR(dist_group, config->args, "-set_dist_group", false, false); 351 PXOPT_LOOKUP_STR(data_group, config->args, "-set_data_group", false, false); 352 PXOPT_LOOKUP_STR(note, config->args, "-set_note", false, false); 353 354 // default 355 PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false); 356 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 357 358 // find the exp_id of all the exposures that we want to queue up. 359 psString query = pxDataGet("chiptool_definecopy.sql"); 360 if (!query) { 361 psError(PXTOOLS_ERR_SYS, false, "failed to retreive SQL statement"); 362 psFree(where); 363 return false; 364 } 365 366 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 367 psStringAppend(&query, " AND %s", whereClause); 368 369 psFree(whereClause); 370 psFree(where); 371 372 if (!p_psDBRunQuery(config->dbh, query)) { 373 psError(PS_ERR_UNKNOWN, false, "database error"); 374 psFree(query); 375 return false; 376 } 377 psFree(query); 378 379 psArray *output = p_psDBFetchResult(config->dbh); 380 if (!output) { 381 psError(PS_ERR_UNKNOWN, false, "database error"); 382 return false; 383 } 384 if (!psArrayLength(output)) { 385 psTrace("chiptool", PS_LOG_INFO, "no rows found"); 386 psFree(output); 387 return true; 388 } 389 390 if (pretend) { 391 // negative simple so the default is true 392 if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) { 393 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 394 psFree(output); 395 return false; 396 } 397 psFree(output); 398 return true; 399 } 400 401 if (!queue_exposures(config, output, workdir, label, data_group, dist_group, reduction, expgroup, 402 dvodb, tess_id, end_stage, note)) { 403 psError(psErrorCodeLast(), false, "Unable to queue exposures for chip."); 404 psFree(output); 405 return false; 406 } 407 psFree(output); 296 408 297 409 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
