//## 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%3D86D43B008C.cm preserve=no
//	  %X% %Q% %Z% %W%
//## end module%3D86D43B008C.cm

//## begin module%3D86D43B008C.cp preserve=no
//## end module%3D86D43B008C.cp

//## Module: Radio%3D86D43B008C; Pseudo Package body
//## Source file: C:\Program Files\Rational\Rose\C++\source\Radio.cpp

//## begin module%3D86D43B008C.additionalIncludes preserve=no
//## end module%3D86D43B008C.additionalIncludes

//## begin module%3D86D43B008C.includes preserve=yes
//## end module%3D86D43B008C.includes

// Radio
#include "Radio.h"
//## begin module%3D86D43B008C.additionalDeclarations preserve=yes
//## end module%3D86D43B008C.additionalDeclarations


// Class Radio

//## begin Radio::aRadio%3D9AA2BD0154.attr preserve=no  private: static Radio {U}
Radio Radio::radios[NUMBER_OF_ROBOTS];
//## end Radio::aRadio%3D9AA2BD0154.attr

Radio::Radio()
  //## begin Radio::Radio%3D86D43B008C_const.hasinit preserve=no
  //## end Radio::Radio%3D86D43B008C_const.hasinit
  //## begin Radio::Radio%3D86D43B008C_const.initialization preserve=yes
  //## end Radio::Radio%3D86D43B008C_const.initialization
{
  //## begin Radio::Radio%3D86D43B008C_const.body preserve=yes
  //## end Radio::Radio%3D86D43B008C_const.body
}


Radio::~Radio()
{
  //## begin Radio::~Radio%3D86D43B008C_dest.body preserve=yes
  terminate();
  //## end Radio::~Radio%3D86D43B008C_dest.body
}



//## Other Operations (implementation)
Radio* Radio::getRadio ()
{
  //## begin Radio::getRadio%3D9AA29D0032.body preserve=yes
  return &radios[OSMachineID()];
  //## end Radio::getRadio%3D9AA29D0032.body
}

bool Radio::send (BYTE id, int byteCount, BYTE* message)
{
  //## begin Radio::send%3D9025140078.body preserve=yes
  if (RADIOSend(id, byteCount, message) == 0)
    return true; //ok
  else
    return false;
  //## end Radio::send%3D9025140078.body
}

int Radio::checkForMessages ()
{
  //## begin Radio::checkForMessages%3D9025560212.body preserve=yes
  return RADIOCheck();
  //## end Radio::checkForMessages%3D9025560212.body
}

void Radio::receive (BYTE* id, int* receivedBytes, BYTE* message)
{
  //## begin Radio::receive%3D9025690280.body preserve=yes
  RADIORecv(id, receivedBytes, message);
  //## end Radio::receive%3D9025690280.body
}

void Radio::getActiveRobots (bool active[])
{
  //## begin Radio::getActiveRobots%3D90256F0050.body preserve=yes
  RadioStatus radioStatus;
  RADIOGetStatus(&radioStatus);
  for (int i=0; i<MAXEYE; i++)
    active[i] = radioStatus.active[i];
  //## end Radio::getActiveRobots%3D90256F0050.body
}

bool Radio::initialize ()
{
  //## begin Radio::initialize%3D9025D502A8.body preserve=yes
  int resultCode = RADIOInit();
  if (resultCode != 0)
  {
    LCDPutString("Radio init. error\n");
    OSPanic(""); //really do that??
    return false;
  }
  return true;
  //## end Radio::initialize%3D9025D502A8.body
}

bool Radio::terminate ()
{
  //## begin Radio::terminate%3D9025E50078.body preserve=yes
  int resultCode = RADIOTerm();
  if (resultCode != 0)
  {
    LCDPutString("Radio term. error\n");
    OSPanic(""); //really do that??
    return false;
  }
  return true;
  //## end Radio::terminate%3D9025E50078.body
}

int Radio::getMyID ()
{
  //## begin Radio::getMyID%3D9BEB190276.body preserve=yes
  return OSMachineID();
  //## end Radio::getMyID%3D9BEB190276.body
}

// Additional Declarations
  //## begin Radio%3D86D43B008C.declarations preserve=yes
  int Radio::getCurrentMasterID ()
  {
    RadioStatus radioStatus;
    RADIOGetStatus(&radioStatus);
    return (int)radioStatus.master;
  }
  //## end Radio%3D86D43B008C.declarations

//## begin module%3D86D43B008C.epilog preserve=yes
//## end module%3D86D43B008C.epilog

