Changeset 8661 for trunk/ippTools/src/chiptool.c
- Timestamp:
- Aug 28, 2006, 2:21:28 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/chiptool.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r8658 r8661 12 12 static bool pendingimfileMode(pxConfig *config); 13 13 static bool addprocessedimfileMode(pxConfig *config); 14 static p2DoneImfileRow *p2pendingToDoneImfile(pxConfig *config, p2PendingImfileRow *imfile); 14 static p2ProcessedImfileRow *p2pendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile); 15 static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp); 15 16 16 17 # define MODECASE(caseName, func) \ … … 70 71 { 71 72 PS_ASSERT_PTR_NON_NULL(config, NULL); 73 #if 0 72 74 73 75 psArray *rawFrames = rawScienceFrameSearch(config); … … 132 134 } 133 135 136 #endif 134 137 return true; 135 138 } 139 136 140 137 141 static bool pendingimfileMode(pxConfig *config) … … 166 170 static bool addprocessedimfileMode(pxConfig *config) 167 171 { 168 PS_ASSERT_PTR_NON_NULL(config, NULL); 169 170 // -uri is always required 171 bool status = false; 172 psString uri = psMetadataLookupStr(&status, config->args, "-uri"); 173 if (!status) { 174 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 175 return NULL; 176 } 177 if (!uri) { 178 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 179 return NULL; 180 } 181 // get exp_id/class/class_id/uri from the CLI 172 PS_ASSERT_PTR_NON_NULL(config, false); 173 174 // select * from p2ProcessedImfiles 175 // where 176 // exp_id & class_id are not in p2PendingImfile 177 182 178 // add the completed imfile to 183 // the p2 DoneImfile tables179 // the p2ProcessedeImfile tables 184 180 // remove corresponding entries from the 185 181 // p2PendingImfile table 186 182 // check to see if any p2PendingExps have no 187 183 // associated p2PendingImfiles 188 // if so move the p2PendingExp(s) to p2DoneExp 184 // if so move the p2PendingExp(s) to p2ProcessedExp 185 186 psString query = psStringCopy( 187 "SELECT DISTINCT" 188 " p2PendingImfile.*" 189 " FROM p2PendingImfile " 190 " LEFT JOIN p2ProcessedImfile" 191 " USING(exp_id, class_id)" 192 " WHERE" 193 " p2ProcessedImfile.exp_id IS NULL" 194 " AND p2ProcessedImfile.class_id IS NULL" 195 ); 196 { 197 psMetadata *where = psMetadataAlloc(); 198 bool status = false; 199 psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id"); if (!status) { 200 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id"); 201 psFree(query); 202 return false; 203 } 204 if (exp_id) { 205 if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) { 206 psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id"); 207 psFree(where); 208 psFree(query); 209 return false; 210 } 211 } 212 psString class_id = psMetadataLookupStr(&status, config->args, "-class_id"); 213 if (!status) { 214 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -class_id"); 215 psFree(query); 216 return false; 217 } 218 if (class_id) { 219 if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==", class_id)) { 220 psError(PS_ERR_UNKNOWN, false, "failed to add item class_id"); 221 psFree(where); 222 psFree(query); 223 return false; 224 } 225 } 226 227 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "p2PendingImfile"); 228 psFree(where) 229 if (whereClaus) { 230 psStringAppend(&query, " AND %s", whereClause); 231 psFree(whereClause); 232 } 233 } 234 235 if (!p_psDBRunQuery(config->dbh, query)) { 236 psError(PS_ERR_UNKNOWN, false, "database error"); 237 psFree(query); 238 return false; 239 } 240 psFree(query); 241 242 psArray *output = p_psDBFetchResult(config->dbh); 243 if (!output) { 244 // XXX check psError here 245 psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found"); 246 return false; 247 } 189 248 190 249 // find pending … … 205 264 // insert into done 206 265 for (long i = 0; i < psArrayLength(pendingImfiles); i++) { 207 p2 DoneImfileRow *imfile = p2pendingToDoneImfile(config, pendingImfiles->data[0]);266 p2ProcessedImfileRow *imfile = p2pendingToProcessedImfile(config, pendingImfiles->data[0]); 208 267 if (!imfile) { 209 268 // rollback … … 211 270 psError(PS_ERR_UNKNOWN, false, "database error"); 212 271 } 213 psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingImfile to p2 DoneImfile");272 psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingImfile to p2ProcessedImfile"); 214 273 psFree(pendingImfiles); 215 274 return false; 216 275 } 217 if (!p2 DoneImfileInsertObject(config->dbh, imfile)) {276 if (!p2ProcessedImfileInsertObject(config->dbh, imfile)) { 218 277 // rollback 219 278 if (!psDBRollback(config->dbh)) { … … 280 339 } 281 340 282 p2 DoneExpRow *doneExp = p2pendingToDoneExp(pendingExp);341 p2ProcessedExpRow *doneExp = p2PendingToProcessedExp(config, pendingExp); 283 342 if (!doneExp) { 284 343 // rollback … … 286 345 psError(PS_ERR_UNKNOWN, false, "database error"); 287 346 } 288 psError(PS_ERR_UNKNOWN, false, "p2PendingExp -> p2 DoneExp failed");347 psError(PS_ERR_UNKNOWN, false, "p2PendingExp -> p2ProcessedExp failed"); 289 348 psFree(pendingExps); 290 349 return false; 291 350 } 292 if (!p2 DoneExpInsertObject(config->dbh, doneExp)) {351 if (!p2ProcessedExpInsertObject(config->dbh, doneExp)) { 293 352 // rollback 294 353 if (!psDBRollback(config->dbh)) { … … 308 367 psFree(pendingExps); 309 368 310 // point of no return for p2PendingImfile -> p2 DoneImfile311 // point of no return for p2PendingExp -> p2 DoneExp369 // point of no return for p2PendingImfile -> p2ProcessedImfile 370 // point of no return for p2PendingExp -> p2ProcessedExp 312 371 if (!psDBCommit(config->dbh)) { 313 372 psError(PS_ERR_UNKNOWN, false, "database error"); … … 330 389 } 331 390 332 // XXX the filename layout is defined by this code 333 static p2DoneImfileRow *p2pendingToDoneImfile(pxConfig *config, p2PendingImfileRow *imfile) 391 static p2ProcessedImfileRow *p2pendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile) 334 392 { 335 393 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 340 398 if (!status) { 341 399 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -uri"); 342 return NULL;400 return false; 343 401 } 344 402 if (!uri) { 345 403 psError(PS_ERR_UNKNOWN, true, "-uri is required"); 346 return NULL; 347 } 348 349 return p2DoneImfileRowAlloc( 404 return false; 405 } 406 407 psString recipe = psMetadataLookupStr(&status, config->args, "-recip"); 408 if (!status) { 409 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -recip"); 410 return false; 411 } 412 if (!recipe) { 413 psError(PS_ERR_UNKNOWN, true, "-recip is required"); 414 return false; 415 } 416 417 psF64 bg = psMetadataLookupF64(&status, config->args, "-bg"); 418 if (!status) { 419 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg"); 420 return false; 421 } 422 if (isnan(bg)) { 423 psError(PS_ERR_UNKNOWN, true, "-bg is required"); 424 return false; 425 } 426 427 psF64 bg_stdev = psMetadataLookupF64(&status, config->args, "-bg_stdev"); 428 if (!status) { 429 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_stdev"); 430 return false; 431 } 432 if (isnan(bg_stdev)) { 433 psError(PS_ERR_UNKNOWN, true, "-bg_stdev is required"); 434 return false; 435 } 436 437 psF64 bg_mean_stdev = psMetadataLookupF64(&status, config->args, "-bg_mean_stdev"); 438 if (!status) { 439 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -bg_mean_stdev"); 440 return false; 441 } 442 if (isnan(bg_mean_stdev)) { 443 psError(PS_ERR_UNKNOWN, true, "-bg_mean_stdev is required"); 444 return false; 445 } 446 447 // optional 448 psString b1_uri = psMetadataLookupStr(&status, config->args, "-b1_uri"); 449 if (!status) { 450 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b1_uri"); 451 return false; 452 } 453 454 psString b2_uri = psMetadataLookupStr(&status, config->args, "-b2_uri"); 455 if (!status) { 456 psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -b2_uri"); 457 return false; 458 } 459 460 return p2ProcessedImfileRowAlloc( 350 461 imfile->exp_id, 351 462 imfile->class_id, 352 463 uri, 353 "my recipe", // recipe 464 recipe, 465 bg, 466 bg_stdev, 467 bg_mean_stdev, 468 b1_uri, 469 b2_uri, 354 470 imfile->p1_version, 355 471 imfile->p2_version 356 472 ); 357 473 } 474 475 static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp) 476 { 477 PS_ASSERT_PTR_NON_NULL(pendingExp, NULL); 478 479 return p2ProcessedExpRowAlloc( 480 pendingExp->exp_id, 481 "my recipe", 482 pendingExp->p1_version, 483 pendingExp->p2_version 484 ); 485 }
Note:
See TracChangeset
for help on using the changeset viewer.
