//## begin module%1.4%.codegen_version preserve=yes
//   Read the documentation to learn more about C++ code generator
//   versioning.
//## end module%1.4%.codegen_version

//## begin module%3D86D3480028.cm preserve=no
//	  %X% %Q% %Z% %W%
//## end module%3D86D3480028.cm

//## begin module%3D86D3480028.cp preserve=no
//## end module%3D86D3480028.cp

//## Module: Starter%3D86D3480028; Pseudo Package body
//## Source file: C:\Program Files\Rational\Rose\C++\source\Starter.cpp

//## begin module%3D86D3480028.additionalIncludes preserve=no
//## end module%3D86D3480028.additionalIncludes

//## begin module%3D86D3480028.includes preserve=yes
//## end module%3D86D3480028.includes

// Starter
#include "Starter.h"
//## begin module%3D86D3480028.additionalDeclarations preserve=yes
//## end module%3D86D3480028.additionalDeclarations


// Class Starter

//## begin Starter::READY%3D9ABDF20078.attr preserve=no  private: static int {UC} 0
const int Starter::READY = 0;
//## end Starter::READY%3D9ABDF20078.attr

//## begin Starter::RUNNING%3D9ABE350046.attr preserve=no  private: static int {UC} 1
const int Starter::RUNNING = 1;
//## end Starter::RUNNING%3D9ABE350046.attr

Starter::Starter()
  //## begin Starter::Starter%3D86D3480028_const.hasinit preserve=no
      : state(-1)
  //## end Starter::Starter%3D86D3480028_const.hasinit
  //## begin Starter::Starter%3D86D3480028_const.initialization preserve=yes
  //## end Starter::Starter%3D86D3480028_const.initialization
{
  //## begin Starter::Starter%3D86D3480028_const.body preserve=yes
  state = READY;
  broadcaster = &g_broadcaster; //see Starter.h for explanation why we assign a global broadcaster instance to Starter::broadcaster
  sir = SIR::getSIR();
  commander = &g_commander; //see Starter.h for explanation why we assign a global commander instance to Starter::commander
  //## end Starter::Starter%3D86D3480028_const.body
}



//## Other Operations (implementation)
void Starter::startClustering ()
{
  //## begin Starter::startClustering%3D901FC402D0.body preserve=yes
  if (state == READY)
  {
	//the starting order: first provide sensor information, then activate a behavior (behaviors depend on sensors), then start broadcasting (broadcasting depends on ...)
	sir->ready();
	commander->ready();
//	broadcaster->ready();
	state = RUNNING;
  }
  //## end Starter::startClustering%3D901FC402D0.body
}

void Starter::stopClustering ()
{
  //## begin Starter::stopClustering%3D901FEF0046.body preserve=yes
  //the pausing order: at last stop sensor information, before that deactivate behaviors (behaviors depend on sensors), first stop broadcasting (broadcasting depends on ...)
  if (state == RUNNING)
  {
//	broadcaster->suspend();
	commander->suspend();
	sir->suspend();
  state = -1;
  }
  //## end Starter::stopClustering%3D901FEF0046.body
}


// Additional Declarations
  //## begin Starter%3D86D3480028.declarations preserve=yes
  //## end Starter%3D86D3480028.declarations

//## begin module%3D86D3480028.epilog preserve=yes
//## end module%3D86D3480028.epilog
