Homepage Demos Overview Downloads Tutorials Reference
Credits

FreezeTestBehavior.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_FreezeTestBehavior_h_
00003 #define INCLUDED_FreezeTestBehavior_h_
00004 
00005 #include "Behaviors/BehaviorBase.h"
00006 #include "Wireless/Wireless.h"
00007 
00008 //! Demonstrates an infinite loop condition in the Main process
00009 class FreezeTestBehavior : public BehaviorBase {
00010 public:
00011   FreezeTestBehavior() : BehaviorBase() {}
00012   
00013   virtual void DoStart() {
00014     //call superclass first for housekeeping:
00015     BehaviorBase::DoStart();
00016 
00017     //now do your code:
00018     const unsigned int start=2500001;
00019     serr->printf("Now computing all primes greater than %d... (this might take... forever)\n",start-1);
00020     serr->printf("Motion process should be able to continue, but Main process will freeze.\n");
00021     for(unsigned int i=start;;i+=2) {
00022       unsigned int j=3;
00023       const unsigned int irt=(unsigned int)sqrt((double)i);
00024       for(; j<=irt; j++)
00025         if((i/j)*j==i)
00026           break;
00027       if(j==irt)
00028         serr->printf("%d is prime\n",i);
00029     }
00030     //Hate to break it to you, but we're never going to get here...
00031   }
00032   
00033   virtual std::string getName() const {
00034     // Name is used for menus, or debugging.
00035     return "FreezeTestBehavior";
00036   }
00037   
00038   static std::string getClassDescription() {
00039     // This string will be shown by the HelpControl or by the tooltips of the Controller GUI
00040     return "A little demo of a Main process infinite loop freeze (yes, this hangs the AIBO)";
00041   }
00042   
00043 };
00044 
00045 /*! @file
00046  * @brief Defines FreezeTestBehavior, demonstrates (lack of) blocking using serr to (not) pinpoint a crash
00047  * @author ejt (Creator)
00048  *
00049  * $Author: ejt $
00050  * $Name: tekkotsu-2_2 $
00051  * $Revision: 1.1 $
00052  * $State: Exp $
00053  * $Date: 2004/08/27 22:10:10 $
00054  */
00055 
00056 #endif

Tekkotsu v2.2
Generated Tue Oct 19 14:19:14 2004 by Doxygen 1.3.9.1