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("FreezeTestBehavior") {}
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   static std::string getClassDescription() {
00034     // This string will be shown by the HelpControl or by the tooltips of the Controller GUI
00035     return "A little demo of a Main process infinite loop freeze (yes, this hangs the AIBO)";
00036   }
00037   virtual std::string getDescription() const { return getClassDescription(); }
00038 };
00039 
00040 /*! @file
00041  * @brief Defines FreezeTestBehavior, demonstrates (lack of) blocking using serr to (not) pinpoint a crash
00042  * @author ejt (Creator)
00043  *
00044  * $Author: ejt $
00045  * $Name: tekkotsu-2_2_1 $
00046  * $Revision: 1.2 $
00047  * $State: Exp $
00048  * $Date: 2004/11/11 01:45:36 $
00049  */
00050 
00051 #endif

Tekkotsu v2.2.1
Generated Tue Nov 23 16:36:38 2004 by Doxygen 1.3.9.1