Changeset 12024 for trunk/ippTools/src/chiptool.c
- Timestamp:
- Feb 23, 2007, 3:41:56 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/chiptool.c (modified) (34 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/chiptool.c
r11997 r12024 1 1 /* 2 * p2tool.c2 * chiptool.c 3 3 * 4 4 * Copyright (C) 2006 Joshua Hoblitt … … 38 38 static bool unblockMode(pxConfig *config); 39 39 40 static p2ProcessedImfileRow *p2PendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile);41 static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp);42 static p3PendingExpRow *p2PendingToP3PendingExp(pxConfig *config, p2PendingExpRow *pendingExp);43 static bool p2ProcessedCompleteExp(pxConfig *config);40 static chipProcessedImfileRow *chipPendingToProcessedImfile(pxConfig *config, chipPendingImfileRow *imfile); 41 static chipProcessedExpRow *chipPendingToProcessedExp(pxConfig *config, chipPendingExpRow *pendingExp); 42 static camPendingExpRow *chipPendingTocamPendingExp(pxConfig *config, chipPendingExpRow *pendingExp); 43 static bool chipProcessedCompleteExp(pxConfig *config); 44 44 45 45 # define MODECASE(caseName, func) \ … … 166 166 // XXX this does not work!!! 167 167 psString query = psStringCopy( 168 "INSERT INTO p2PendingExp\n"168 "INSERT INTO chipPendingExp\n" 169 169 " SElECT\n" 170 170 " exp_tag,\n" 171 171 " 'my recipe',\n" // recipe 172 " 255\n" // p1_version173 " 255\n" // p2_version172 " 255\n" // guide_version 173 " 255\n" // chip_version 174 174 " %s\n" 175 175 " FROM rawExp" 176 " LEFT JOIN p2ProcessedExp"176 " LEFT JOIN chipProcessedExp" 177 177 " USING(exp_tag)" 178 178 " WHERE" … … 200 200 if (!psArrayLength(output)) { 201 201 // XXX check psError here 202 psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");202 psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found"); 203 203 psFree(output); 204 204 return false; … … 220 220 221 221 // XXX does this need to be constrained so that it won't return any results 222 // if a match p2PendingExp hasn't been registered?222 // if a match chipPendingExp hasn't been registered? 223 223 psString query = psStringCopy( 224 224 "SELECT" 225 " p2PendingImfile.*,"225 " chipPendingImfile.*," 226 226 " rawExp.camera," 227 227 " rawExp.workdir" 228 " FROM p2PendingImfile"229 " JOIN p2PendingExp"228 " FROM chipPendingImfile" 229 " JOIN chipPendingExp" 230 230 " USING(exp_tag)" 231 231 " JOIN rawExp" 232 232 " USING(exp_tag)" 233 " LEFT JOIN p2Mask"234 " ON p2PendingExp.label = p2Mask.label"233 " LEFT JOIN chipMask" 234 " ON chipPendingExp.label = chipMask.label" 235 235 " WHERE" 236 " p2Mask.label IS NULL"236 " chipMask.label IS NULL" 237 237 ); 238 238 239 239 if (config->where) { 240 psString whereClause = psDBGenerateWhereConditionSQL(config->where, " p2PendingImfile");240 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipPendingImfile"); 241 241 psStringAppend(&query, " AND %s", whereClause); 242 242 psFree(whereClause); … … 264 264 if (!psArrayLength(output)) { 265 265 // XXX check psError here 266 psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");266 psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found"); 267 267 psFree(output); 268 268 return true; … … 280 280 281 281 // negative simple so the default is true 282 if (!ippdbPrintMetadatas(stdout, output, " p2PendingImfile", !simple)) {282 if (!ippdbPrintMetadatas(stdout, output, "chipPendingImfile", !simple)) { 283 283 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 284 284 psFree(output); … … 296 296 PS_ASSERT_PTR_NON_NULL(config, false); 297 297 298 // select * from p2ProcessedImfiles298 // select * from chipProcessedImfiles 299 299 // where 300 // exp_tag & class_id are not in p2PendingImfile300 // exp_tag & class_id are not in chipPendingImfile 301 301 302 302 // add the completed imfile to 303 // the p2ProcessedeImfile tables303 // the chipProcessedeImfile tables 304 304 // remove corresponding entries from the 305 // p2PendingImfile table306 // check to see if any p2PendingExps have no307 // associated p2PendingImfiles308 // if so move the p2PendingExp(s) to p2ProcessedExp305 // chipPendingImfile table 306 // check to see if any chipPendingExps have no 307 // associated chipPendingImfiles 308 // if so move the chipPendingExp(s) to chipProcessedExp 309 309 310 310 psString query = psStringCopy( 311 311 "SELECT DISTINCT" 312 " p2PendingImfile.*"313 " FROM p2PendingImfile "314 " LEFT JOIN p2ProcessedImfile"312 " chipPendingImfile.*" 313 " FROM chipPendingImfile " 314 " LEFT JOIN chipProcessedImfile" 315 315 " USING(exp_tag, class_id)" 316 316 " WHERE" 317 " p2ProcessedImfile.exp_tag IS NULL"318 " AND p2ProcessedImfile.class_id IS NULL"317 " chipProcessedImfile.exp_tag IS NULL" 318 " AND chipProcessedImfile.class_id IS NULL" 319 319 ); 320 320 { … … 349 349 } 350 350 351 psString whereClause = psDBGenerateWhereConditionSQL(config->where, " p2PendingImfile");351 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipPendingImfile"); 352 352 psFree(where); 353 353 if (whereClause) { … … 371 371 if (!psArrayLength(output)) { 372 372 // XXX check psError here 373 psError(PS_ERR_UNKNOWN, false, "no p2PendingImfile rows found");373 psError(PS_ERR_UNKNOWN, false, "no chipPendingImfile rows found"); 374 374 psFree(output); 375 375 return false; … … 384 384 } 385 385 386 // insert into p2ProcessedImfile387 // remove p2PendingImfile entry386 // insert into chipProcessedImfile 387 // remove chipPendingImfile entry 388 388 for (long i = 0; i < psArrayLength(output); i++) { 389 389 psMetadata *row = output->data[i]; 390 // convert metadata into a p2PendingImfile object391 p2PendingImfileRow *object = p2PendingImfileObjectFromMetadata(row);392 // convert p2PendingImfile object into a p2ProcessedImfile object393 p2ProcessedImfileRow *imfile = p2PendingToProcessedImfile(config, object);390 // convert metadata into a chipPendingImfile object 391 chipPendingImfileRow *object = chipPendingImfileObjectFromMetadata(row); 392 // convert chipPendingImfile object into a chipProcessedImfile object 393 chipProcessedImfileRow *imfile = chipPendingToProcessedImfile(config, object); 394 394 if (!imfile) { 395 395 // rollback … … 397 397 psError(PS_ERR_UNKNOWN, false, "database error"); 398 398 } 399 psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingImfile to p2ProcessedImfile");399 psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingImfile to chipProcessedImfile"); 400 400 psFree(object); 401 401 psFree(output); 402 402 return false; 403 403 } 404 // insert p2ProccessedImfile object into the database405 if (! p2ProcessedImfileInsertObject(config->dbh, imfile)) {404 // insert chipProccessedImfile object into the database 405 if (!chipProcessedImfileInsertObject(config->dbh, imfile)) { 406 406 // rollback 407 407 if (!psDBRollback(config->dbh)) { … … 415 415 } 416 416 psFree(imfile); 417 // delete the p2PendingImfile object from the database418 if (! p2PendingImfileDeleteObject(config->dbh, object)) {417 // delete the chipPendingImfile object from the database 418 if (!chipPendingImfileDeleteObject(config->dbh, object)) { 419 419 // there must be atleast 1 Imfile to get this far 420 420 // rollback … … 437 437 // migration can't happen. 438 438 439 if (! p2ProcessedCompleteExp(config)) {439 if (!chipProcessedCompleteExp(config)) { 440 440 // rollback 441 441 if (!psDBRollback(config->dbh)) { … … 446 446 } 447 447 448 // point of no return for p2PendingImfile -> p2ProcessedImfile449 // point of no return for p2PendingExp -> p2ProcessedExp448 // point of no return for chipPendingImfile -> chipProcessedImfile 449 // point of no return for chipPendingExp -> chipProcessedExp 450 450 if (!psDBCommit(config->dbh)) { 451 451 psError(PS_ERR_UNKNOWN, false, "database error"); … … 475 475 476 476 // XXX does this need to be constrained so that it won't return any results 477 // if a match p2PendingExp hasn't been registered?477 // if a match chipPendingExp hasn't been registered? 478 478 psString query = psStringCopy( 479 479 "SELECT" 480 " p2ProcessedImfile.*,"480 " chipProcessedImfile.*," 481 481 " rawExp.camera," 482 482 " rawExp.workdir" 483 " FROM p2ProcessedImfile"483 " FROM chipProcessedImfile" 484 484 " JOIN rawExp" 485 485 " USING(exp_tag)" 486 486 " WHERE " 487 " p2ProcessedImfile.exp_tag is NOT NULL" // bogus test -- just here so there there is a 'WHERE' stmt to append conditionals too487 " chipProcessedImfile.exp_tag is NOT NULL" // bogus test -- just here so there there is a 'WHERE' stmt to append conditionals too 488 488 ); 489 489 490 490 if (config->where) { 491 psString whereClause = psDBGenerateWhereConditionSQL(config->where, " p2ProcessedImfile");491 psString whereClause = psDBGenerateWhereConditionSQL(config->where, "chipProcessedImfile"); 492 492 psStringAppend(&query, " AND %s", whereClause); 493 493 psFree(whereClause); … … 496 496 if (faulted) { 497 497 // list only faulted rows 498 psStringAppend(&query, " %s", "AND p2ProcessedImfile.fault != 0");498 psStringAppend(&query, " %s", "AND chipProcessedImfile.fault != 0"); 499 499 } else { 500 500 // don't list faulted rows 501 psStringAppend(&query, " %s", "AND p2ProcessedImfile.fault = 0");501 psStringAppend(&query, " %s", "AND chipProcessedImfile.fault = 0"); 502 502 } 503 503 … … 523 523 if (!psArrayLength(output)) { 524 524 // XXX check psError here 525 psError(PS_ERR_UNKNOWN, false, "no p2ProcessedImfile rows found");525 psError(PS_ERR_UNKNOWN, false, "no chipProcessedImfile rows found"); 526 526 psFree(output); 527 527 return true; … … 539 539 540 540 // negative simple so the default is true 541 if (!ippdbPrintMetadatas(stdout, output, " p2ProcessedImfile", !simple)) {541 if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) { 542 542 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 543 543 psFree(output); … … 562 562 } 563 563 564 if (!pxSetFaultCode(config->dbh, " p2ProcessedImfile", config->where, code)) {564 if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", config->where, code)) { 565 565 psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag"); 566 566 return false; … … 586 586 } 587 587 588 if (! p2MaskInsert(config->dbh, label)) {588 if (!chipMaskInsert(config->dbh, label)) { 589 589 psError(PS_ERR_UNKNOWN, false, "database error"); 590 590 return false; … … 599 599 PS_ASSERT_PTR_NON_NULL(config, false); 600 600 601 psString query = psStringCopy("SELECT * FROM p2Mask");601 psString query = psStringCopy("SELECT * FROM chipMask"); 602 602 603 603 if (!p_psDBRunQuery(config->dbh, query)) { … … 615 615 if (!psArrayLength(output)) { 616 616 // XXX check psError here 617 psError(PS_ERR_UNKNOWN, false, "no p2Mask rows found");617 psError(PS_ERR_UNKNOWN, false, "no chipMask rows found"); 618 618 psFree(output); 619 619 return true; … … 631 631 632 632 // negative simple so the default is true 633 if (!ippdbPrintMetadatas(stdout, output, " p2Mask", !simple)) {633 if (!ippdbPrintMetadatas(stdout, output, "chipMask", !simple)) { 634 634 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 635 635 psFree(output); … … 658 658 } 659 659 660 char *query = "DELETE FROM p2Mask WHERE label = '%s'";660 char *query = "DELETE FROM chipMask WHERE label = '%s'"; 661 661 662 662 if (!p_psDBRunQuery(config->dbh, query, label)) { … … 670 670 671 671 672 static bool p2ProcessedCompleteExp(pxConfig *config)672 static bool chipProcessedCompleteExp(pxConfig *config) 673 673 { 674 674 PS_ASSERT_PTR_NON_NULL(config, false); 675 675 676 // look for completed p2PendingExp677 // migrate them to p2ProccessedExp & p3PendingExp678 679 // select * from p2PendingExp680 // where exp_tag is not in p2ProcessedExp681 // where exp_tag is not in p2PendingImfile682 // where the number of entries in p2ProccessedImfile matches the .imfiles676 // look for completed chipPendingExp 677 // migrate them to chipProccessedExp & camPendingExp 678 679 // select * from chipPendingExp 680 // where exp_tag is not in chipProcessedExp 681 // where exp_tag is not in chipPendingImfile 682 // where the number of entries in chipProccessedImfile matches the .imfiles 683 683 // entry in rawExp 684 684 psString query = psStringCopy( 685 685 "SELECT DISTINCT" 686 " p2PendingExp.*,"686 " chipPendingExp.*," 687 687 " rawExp.imfiles," 688 " p2ProcessedImfile.class_id"689 " FROM p2PendingExp"688 " chipProcessedImfile.class_id" 689 " FROM chipPendingExp" 690 690 " JOIN rawExp" 691 " ON p2PendingExp.exp_tag = rawExp.exp_tag"692 " LEFT JOIN p2ProcessedExp"693 " ON p2PendingExp.exp_tag = p2ProcessedExp.exp_tag"694 " LEFT JOIN p2PendingImfile"695 " ON p2PendingExp.exp_tag = p2PendingImfile.exp_tag"696 " LEFT JOIN p2ProcessedImfile"697 " ON p2PendingExp.exp_tag = p2ProcessedImfile.exp_tag"691 " ON chipPendingExp.exp_tag = rawExp.exp_tag" 692 " LEFT JOIN chipProcessedExp" 693 " ON chipPendingExp.exp_tag = chipProcessedExp.exp_tag" 694 " LEFT JOIN chipPendingImfile" 695 " ON chipPendingExp.exp_tag = chipPendingImfile.exp_tag" 696 " LEFT JOIN chipProcessedImfile" 697 " ON chipPendingExp.exp_tag = chipProcessedImfile.exp_tag" 698 698 " WHERE" 699 " p2ProcessedExp.exp_tag IS NULL"700 " AND p2PendingImfile.exp_tag IS NULL"701 " AND p2ProcessedImfile.exp_tag IS NOT NULL"699 " chipProcessedExp.exp_tag IS NULL" 700 " AND chipPendingImfile.exp_tag IS NULL" 701 " AND chipProcessedImfile.exp_tag IS NOT NULL" 702 702 " GROUP BY" 703 " p2PendingExp.exp_tag"704 " HAVING rawExp.imfiles = COUNT( p2ProcessedImfile.class_id)"703 " chipPendingExp.exp_tag" 704 " HAVING rawExp.imfiles = COUNT(chipProcessedImfile.class_id)" 705 705 ); 706 706 … … 719 719 if (!psArrayLength(output)) { 720 720 // XXX check psError here 721 psError(PS_ERR_UNKNOWN, false, "no p2PendingExp rows found");721 psError(PS_ERR_UNKNOWN, false, "no chipPendingExp rows found"); 722 722 psFree(output); 723 723 return true; 724 724 } 725 725 726 // insert into p2ProcessedExp727 // insert into p3PendingExp728 // remove p2PendingExp entry726 // insert into chipProcessedExp 727 // insert into camPendingExp 728 // remove chipPendingExp entry 729 729 for (long i = 0; i < psArrayLength(output); i++) { 730 730 psMetadata *row = output->data[i]; 731 // convert metadata into a p2PendingExp object732 p2PendingExpRow *object = p2PendingExpObjectFromMetadata(row);731 // convert metadata into a chipPendingExp object 732 chipPendingExpRow *object = chipPendingExpObjectFromMetadata(row); 733 733 // do both *Exp type conversion first so we don't insert one and then 734 734 // have to rollback the change as the 2nd failed 735 // convert p2PendingExp object into a p2ProcesseExp object736 p2ProcessedExpRow *processedExp = p2PendingToProcessedExp(config, object);735 // convert chipPendingExp object into a chipProcesseExp object 736 chipProcessedExpRow *processedExp = chipPendingToProcessedExp(config, object); 737 737 if (!processedExp) { 738 psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingExp to p2ProcessedExp");738 psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingExp to chipProcessedExp"); 739 739 psFree(object); 740 740 psFree(output); 741 741 return false; 742 742 } 743 // convert p2PendingExp object into a p3PendingExp object744 p3PendingExpRow *pendingExp = p2PendingToP3PendingExp(config, object);743 // convert chipPendingExp object into a camPendingExp object 744 camPendingExpRow *pendingExp = chipPendingTocamPendingExp(config, object); 745 745 if (!processedExp) { 746 psError(PS_ERR_UNKNOWN, false, "failed to convert p2PendingExp to p3PendingExp");746 psError(PS_ERR_UNKNOWN, false, "failed to convert chipPendingExp to camPendingExp"); 747 747 psFree(processedExp); 748 748 psFree(object); … … 750 750 return false; 751 751 } 752 // insert p2ProccessedExp object into the database753 if (! p2ProcessedExpInsertObject(config->dbh, processedExp)) {752 // insert chipProccessedExp object into the database 753 if (!chipProcessedExpInsertObject(config->dbh, processedExp)) { 754 754 psError(PS_ERR_UNKNOWN, false, "database error"); 755 755 psFree(processedExp); … … 760 760 } 761 761 psFree(processedExp); 762 // insert p3PendingExp object into the database763 if (! p3PendingExpInsertObject(config->dbh, pendingExp)) {762 // insert camPendingExp object into the database 763 if (!camPendingExpInsertObject(config->dbh, pendingExp)) { 764 764 psError(PS_ERR_UNKNOWN, false, "database error"); 765 765 psFree(pendingExp); … … 769 769 } 770 770 psFree(pendingExp); 771 // delete the p2PendingExp object from the database772 if (! p2PendingExpDeleteObject(config->dbh, object)) {771 // delete the chipPendingExp object from the database 772 if (!chipPendingExpDeleteObject(config->dbh, object)) { 773 773 // there must be atleast 1 Imfile to get this far 774 774 psError(PS_ERR_UNKNOWN, false, "database error"); … … 786 786 787 787 788 static p2ProcessedImfileRow *p2PendingToProcessedImfile(pxConfig *config, p2PendingImfileRow *imfile)788 static chipProcessedImfileRow *chipPendingToProcessedImfile(pxConfig *config, chipPendingImfileRow *imfile) 789 789 { 790 790 PS_ASSERT_PTR_NON_NULL(config, NULL); … … 850 850 } 851 851 852 return p2ProcessedImfileRowAlloc(852 return chipProcessedImfileRowAlloc( 853 853 imfile->exp_tag, 854 imfile-> p2_version,855 imfile-> p1_version,854 imfile->chip_version, 855 imfile->guide_version, 856 856 imfile->class_id, 857 857 recipe, … … 867 867 868 868 869 static p2ProcessedExpRow *p2PendingToProcessedExp(pxConfig *config, p2PendingExpRow *pendingExp)869 static chipProcessedExpRow *chipPendingToProcessedExp(pxConfig *config, chipPendingExpRow *pendingExp) 870 870 { 871 871 PS_ASSERT_PTR_NON_NULL(pendingExp, NULL); 872 872 873 return p2ProcessedExpRowAlloc(873 return chipProcessedExpRowAlloc( 874 874 pendingExp->exp_tag, 875 pendingExp-> p2_version,876 pendingExp-> p1_version,875 pendingExp->chip_version, 876 pendingExp->guide_version, 877 877 pendingExp->label, 878 878 pendingExp->expgroup, … … 882 882 883 883 884 static p3PendingExpRow *p2PendingToP3PendingExp(pxConfig *config, p2PendingExpRow *pendingExp)884 static camPendingExpRow *chipPendingTocamPendingExp(pxConfig *config, chipPendingExpRow *pendingExp) 885 885 { 886 886 PS_ASSERT_PTR_NON_NULL(pendingExp, NULL); 887 887 888 return p3PendingExpRowAlloc(888 return camPendingExpRowAlloc( 889 889 pendingExp->exp_tag, 890 0x0, // p3version891 pendingExp-> p2_version,890 0x0, // cam version 891 pendingExp->chip_version, 892 892 pendingExp->label, 893 893 pendingExp->expgroup,
Note:
See TracChangeset
for help on using the changeset viewer.
