Changeset 864
- Timestamp:
- 12/13/09 16:59:59 (3 years ago)
- Location:
- branches/atorf/personal playground/NXCProfiler
- Files:
-
- 4 added
- 5 modified
- 1 copied
-
Analyzer (modified) (1 prop)
-
Analyzer/AnalyzeNXCProfile.py (modified) (3 diffs)
-
profiled MotorControl (modified) (1 prop)
-
profiled MotorControl/ControllerCore.nxc (modified) (20 diffs)
-
profiled MotorControl/MotorControl21.nxc (modified) (16 diffs)
-
profiled MotorControl/MotorControl21.prf (added)
-
profiled MotorControl/Profiler01.nxc (copied) (copied from branches/atorf/personal playground/NXCProfiler/Profiler01.nxc)
-
profiled MotorControl/TestProfiledMotorControl.m (added)
-
profiled MotorControl/doit1.bat (added)
-
profiled MotorControl/doit2.bat (added)
Legend:
- Unmodified
- Added
- Removed
-
branches/atorf/personal playground/NXCProfiler/Analyzer
-
Property
svn:ignore set
to
*.html
-
Property
svn:ignore set
to
-
branches/atorf/personal playground/NXCProfiler/Analyzer/AnalyzeNXCProfile.py
r862 r864 74 74 f = file(filename, "rb") 75 75 except (IOError, OSError): 76 print "Could not find or open input file "76 print "Could not find or open input file %s" % filename 77 77 sys.exit(1) 78 78 #end try … … 112 112 out.ElapsedTicks.append(tmpTicks) 113 113 out.AllSectionsTicks += tmpTicks 114 verbosePrint(" Executed=%d, Elapsed=%d, SameMs=%d" % (out.ExecutionCount[-1], out.ElapsedTicks[-1], out.ExecutionsSameMs[-1])) 114 115 #end for 115 116 except: … … 131 132 lines = f.readlines() 132 133 except (IOError, OSError): 133 print "Could not find, open or read input file "134 print "Could not find, open or read input file %s" % filename 134 135 f.close() 135 136 sys.exit(1) -
branches/atorf/personal playground/NXCProfiler/profiled MotorControl
-
Property
svn:ignore set
to
*.bak
AnalyzeNXCProfile.py
HTMLSnippets.py
*.html
-
Property
svn:ignore set
to
-
branches/atorf/personal playground/NXCProfiler/profiled MotorControl/ControllerCore.nxc
r863 r864 77 77 */ 78 78 79 PROFILER_BEGINSECTION(15); 79 80 80 81 //much simpler approach now... … … 104 105 Wait(300); 105 106 #endif 107 PROFILER_ENDSECTION(15); 106 108 return true; 107 109 }//end if … … 110 112 111 113 if (CurrentTick() >= timeoutTick) { 114 PROFILER_ENDSECTION(15); 112 115 break; 113 116 }//end if 114 117 }//end while 115 118 119 PROFILER_ENDSECTION(15); 116 120 return false; 117 121 … … 210 214 // - Absolute acceleration power during rampup (in discrete steps like 10, 20, etc) 211 215 212 216 PROFILER_BEGINSECTION(16); 213 217 // --- Some DECLARATIONS -- not all of them, this is timecritical 214 218 long i; … … 266 270 #endif 267 271 268 272 PROFILER_ENDSECTION(16); 273 PROFILER_BEGINSECTION(17); 274 269 275 // --- Declare and Initialize various variables 270 276 // * STAGE is RAMPUP … … 360 366 #endif 361 367 368 PROFILER_ENDSECTION(17); 369 362 370 // --- MAIN LOOP --------------------- 363 371 while(true) { 364 372 373 PROFILER_BEGINSECTION(18); 365 374 // * record time 366 375 loopStartTick = CurrentTick(); … … 412 421 if (SpeedLogIndex > SPEEDHISTORY-1) SpeedLogIndex = 0; 413 422 423 PROFILER_ENDSECTION(18); 424 414 425 415 426 // * if RAMPUP STAGE: … … 425 436 if (smoothstart) { 426 437 438 PROFILER_BEGINSECTION(19); 427 439 rampupLoopCount++; 428 440 // when rampup is done … … 466 478 }//end if 467 479 480 PROFILER_ENDSECTION(19); 481 468 482 } else { // no rampup 469 483 484 PROFILER_BEGINSECTION(20); 470 485 // full power right away 471 486 if (speedreg) { … … 481 496 482 497 curStage = STAGE_DRIVING; 498 499 PROFILER_ENDSECTION(20); 483 500 484 501 }//end if … … 496 513 //optimized, OLD: if ((curStage == STAGE_DRIVING) || (curStage == STAGE_RAMPUP)) { 497 514 if (curStage <= STAGE_DRIVING) { 515 516 PROFILER_BEGINSECTION(21); 517 498 518 #ifdef ENABLEDEBUGGING_LCD_SLOW_ANTIBUG 499 519 if (curStage == STAGE_DRIVING) { … … 554 574 }//end if 555 575 556 576 PROFILER_ENDSECTION(21); 557 577 558 578 }//end if … … 567 587 // . clip power and set 568 588 if (curStage == STAGE_BRAKING) { 589 590 PROFILER_BEGINSECTION(22); 591 569 592 #ifdef ENABLEDEBUGGING_LCD_SLOW_ANTIBUG 570 593 TextOut(0, DebugLinePos[port], "BRAKING:top "); … … 580 603 }//end if 581 604 #endif// - - - - - - - - - - 582 583 605 584 606 // TODO maybe replace this variable (dont use it) and do it inline? … … 671 693 #endif// - - - - - - - - - - 672 694 695 PROFILER_ENDSECTION(22); 696 673 697 }//end if 674 698 … … 682 706 #endif 683 707 708 PROFILER_BEGINSECTION(23); 684 709 waitEndTick = loopStartTick + LOOP_DURATION; //precalc loop-end 685 710 while (CurrentTick() < waitEndTick) { … … 733 758 734 759 }//end while (times out when static worst case looptime is over (~10 to 20ms) 760 PROFILER_ENDSECTION(23); 735 761 736 762 #ifdef ENABLEDEBUGGING_LCD_SLOW_ANTIBUG … … 756 782 #endif 757 783 758 784 PROFILER_BEGINSECTION(24); 759 785 // fast inner loop now! 760 786 // don't forget TIMEOUT or something, avoid possible lock up, … … 820 846 #endif 821 847 848 PROFILER_ENDSECTION(24); 849 822 850 //now there's a little time for debug... 823 851 #ifdef ENABLEDEBUGGING_ACOUSTIC … … 872 900 #endif 873 901 902 PROFILER_BEGINSECTION(25); 874 903 bool stoppedByDirectCmd = false; 875 904 stoppedByDirectCmd = _ADD_MOTORNAME(WaitUntilMotorStopped)(port); 905 PROFILER_ENDSECTION(25); 876 906 877 907 -
branches/atorf/personal playground/NXCProfiler/profiled MotorControl/MotorControl21.nxc
r863 r864 31 31 32 32 33 34 // SET UP THE PROFILER 35 // comment this out to silently disable profiling without any side effects! 36 #define PROFILER_ENABLE 37 // how many times did we use PROFILER_BEGINSECTION (and ENDSECTION) 38 #define PROFILER_MAXSECTIONS 27 39 // name of the binary results file we later analyze 40 #define PROFILER_RESULTSFILE "MotorControl21.prf" 41 // this does all the magic :-) 42 #include "Profiler01.nxc" 43 44 45 33 46 // *************** GLOBAL DEFINES 34 47 // important to be before includes, … … 478 491 task main(){ 479 492 493 PROFILER_START(); 494 PROFILER_BEGINSECTION(0); 495 480 496 // parameter initialization 481 497 string in = ""; … … 508 524 taskCrunning = false; 509 525 510 526 PROFILER_ENDSECTION(0); 527 PROFILER_BEGINSECTION(1); 511 528 DisplayMainScreen(); 512 529 //Wait(9000); 513 530 PROFILER_ENDSECTION(1); 531 532 PROFILER_BEGINSECTION(2); 514 533 // don't forget this 515 534 InitSpeedFromPosLUT(); 516 517 535 PROFILER_ENDSECTION(2); 536 537 538 PROFILER_BEGINSECTION(3); 518 539 // purge mailboxes to make sure, in case something is left over, 519 540 // I don't know... … … 540 561 #endif 541 562 563 PROFILER_ENDSECTION(3); 564 542 565 while(true){ 543 566 567 PROFILER_BEGINSECTION(4); 544 568 ReceiveRemoteString(INBOX, true, in); 569 PROFILER_ENDSECTION(4); 545 570 546 571 if(StrLen(in) > 0) { … … 554 579 #endif 555 580 556 581 PROFILER_BEGINSECTION(5); 557 582 // take first value, decide what to do... 558 583 tmp = SubStr(in, 0, 1); // pos 0 559 584 packetType = StrToNum(tmp); 585 PROFILER_ENDSECTION(5); 560 586 561 587 // main packet handler! … … 563 589 case PROTO_CONTROLLED_MOTORCMD: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 564 590 591 PROFILER_BEGINSECTION(6); 565 592 // parse... 566 593 tmp = SubStr(in, 1, 1); // pos 1 … … 575 602 tmp = SubStr(in, 11, 1); // pos 11 576 603 modebits = StrToNum(tmp); 604 PROFILER_ENDSECTION(6); 577 605 578 606 PROFILER_BEGINSECTION(7); 579 607 // process... 580 608 // power … … 601 629 smoothstart = false; 602 630 }//end if 631 PROFILER_ENDSECTION(7); 603 632 604 633 … … 606 635 if (port == 0) { // OUT_A 607 636 637 PROFILER_BEGINSECTION(8); 608 638 motorParamsA.power = power; 609 639 motorParamsA.tacholimit = angle; … … 617 647 TaskBusySignal(); 618 648 } // end if 649 PROFILER_ENDSECTION(8); 619 650 620 651 } else if (port == 1) { // OUT_B … … 700 731 break; 701 732 case PROTO_ISMOTORREADY: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 702 733 734 PROFILER_BEGINSECTION(9); 703 735 tmp = SubStr(in, 1, 1); // pos 1 704 736 port = StrToNum(tmp); 737 PROFILER_ENDSECTION(9); 705 738 739 PROFILER_BEGINSECTION(10); 706 740 // send answer string: portnum, then if ready or not 707 741 if (IsMotorReady(port)) { … … 710 744 tmp = StrCat(tmp, "0"); 711 745 }//end if 746 PROFILER_ENDSECTION(10); 747 748 PROFILER_BEGINSECTION(11); 712 749 SendMessage(OUTBOX, tmp); 750 PROFILER_ENDSECTION(11); 751 713 752 714 753 break; 715 754 case PROTO_CLASSIC_MOTORCMD: // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 716 755 756 PROFILER_BEGINSECTION(12); 717 757 // parse... 718 758 tmp = SubStr(in, 1, 1); // pos 1 … … 742 782 //% OUT_BC 0x05 743 783 //% OUT_ABC 0x06 784 PROFILER_ENDSECTION(12); 785 744 786 745 787 if (port <= 2) { … … 773 815 }//end switch 774 816 775 817 PROFILER_BEGINSECTION(13); 776 818 // if no current tacholimit and no new one, allow speed change 777 819 if ((MotorTachoLimit(port1) == 0) && (MotorTachoLimit(port2) == 0) && (angle == 0)) { … … 805 847 806 848 }//end if 807 849 PROFILER_ENDSECTION(13); 808 850 }//end if 809 851 … … 832 874 MotorOff(OUT_B); 833 875 MotorOff(OUT_C); 876 877 PROFILER_STOP(); 834 878 835 879 TextOut(5,LCD_LINE7, "EMERGENCY STOP ", false);
