Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Platform/Aperios1.3.2/SystemCall.cpp

Go to the documentation of this file.
00001 /** 
00002 * @file  Platform/Aperios1.3.2/SystemCall.cpp
00003 *
00004 * Static class for system calls, aperios implementation.
00005 * @attention this is the Aperios implementation
00006 *
00007 * @author <A href=mailto:brunn@sim.informatik.tu-darmstadt.de>Ronnie Brunn</A>
00008 * @author <A href=mailto:risler@sim.informatik.tu-darmstadt.de>Max Risler</A>
00009 */
00010 
00011 #include <MCOOP.h>
00012 #include <AnalyzerAPI.h>
00013 #ifdef __GNUC__
00014 #include <ERA201D1.h>
00015 #endif
00016 #include <OPENR/OPower.h>
00017 #include <OPENR/OPENRAPI.h>
00018 #include "SystemCall.h"
00019 #include "GTAssert.h"
00020 
00021 unsigned long SystemCall::getCurrentSystemTime() {
00022   SystemTime sysTime;
00023   GetSystemTime(&sysTime);
00024   return (sysTime.seconds * 1000 + sysTime.useconds / 1000);
00025 }
00026 
00027 unsigned long SystemCall::getFreeMem()
00028 {
00029   size_t fmem;
00030   azrError err=AnalyzerGetSizeOfFreeMemory(&fmem);
00031   return (err==azrSUCCESS)?fmem:0;
00032 }
00033 
00034 unsigned char SystemCall::getRemainingPower()
00035 {
00036   OPowerStatus stat;
00037   VERIFY(OPENR::GetPowerStatus(&stat)==0);
00038   unsigned char percent=stat.remainingCapacity;
00039   if (stat.robotStatus & orsbEX_POWER_CONNECTED) percent=100;
00040   return percent;
00041 }
00042 
00043 void SystemCall::reboot()
00044 {
00045   OBootCondition cond(obcbBOOT_TIMER, 0, obcbttRELATIVE);
00046   VERIFY(OPENR::Shutdown(cond)==0);
00047 }
00048 
00049 void SystemCall::shutdown()
00050 {
00051   OBootCondition cond(0xFFFF);
00052   VERIFY(OPENR::Shutdown(cond)==0);
00053 }
00054 
00055 void SystemCall::getMacAddress(unsigned char address[6])
00056 {
00057 #ifdef __GNUC__
00058   EtherDriverGetMACAddressMsg msg;
00059   VERIFY(!ERA201D1_GetMACAddress(&msg));
00060   for(int i = 0; i < 6; ++i)
00061     address[i] = msg.address.octet[i];
00062 #else
00063   for(int i = 0; i < 6; ++i)
00064     address[i] = 0;
00065 #endif
00066 }
00067 
00068 RobotDesign::Design SystemCall::getRobotDesign()
00069 {
00070   static bool initialized = false;
00071   static RobotDesign::Design design;
00072 
00073   if (!initialized)
00074   {
00075     char robotDesign[20];
00076     VERIFY(OPENR::GetRobotDesign(robotDesign) == 0);
00077     if(!strcmp(robotDesign, "ERS-210"))
00078       design = RobotDesign::ERS210;
00079     else if(!strcmp(robotDesign, "ERS-7"))
00080       design = RobotDesign::ERS7;
00081     else
00082       design = RobotDesign::UNKNOWN;
00083     initialized = true;
00084   }
00085   return design;
00086 }
00087 
00088 /*
00089  * Change log :
00090  * 
00091  * $Log: SystemCall.cpp,v $
00092  * Revision 1.1.1.1  2004/05/22 17:23:40  cvsadm
00093  * created new repository GT2004_WM
00094  *
00095  * Revision 1.3  2004/01/05 17:08:25  risler
00096  * getRobotDesign optimized
00097  *
00098  * Revision 1.2  2003/12/31 12:21:25  roefer
00099  * getRobotDesign added
00100  *
00101  * Revision 1.1  2003/10/07 10:06:59  cvsadm
00102  * Created GT2004 (M.J.)
00103  *
00104  * Revision 1.1.1.1  2003/07/02 09:40:24  cvsadm
00105  * created new repository for the competitions in Padova from the 
00106  * tamara CVS (Tuesday 2:00 pm)
00107  *
00108  * removed unused solutions
00109  *
00110  * Revision 1.6  2003/05/05 14:56:42  dueffert
00111  * Greenhills doesn't seem to know about MAC adresses
00112  *
00113  * Revision 1.5  2003/05/05 11:57:30  dueffert
00114  * using <> for System includes
00115  *
00116  * Revision 1.4  2003/05/03 13:05:49  roefer
00117  * getMacAddress added
00118  *
00119  * Revision 1.3  2002/12/11 15:17:14  dueffert
00120  * getRemainingPower(), shutdown(), reboot() implemented
00121  *
00122  * Revision 1.2  2002/12/04 13:43:33  dueffert
00123  * getFreeMem() implemented
00124  *
00125  * Revision 1.1  2002/09/10 15:40:04  cvsadm
00126  * Created new project GT2003 (M.L.)
00127  * - Cleaned up the /Src/DataTypes directory
00128  * - Removed challenge related source code
00129  * - Removed processing of incoming audio data
00130  * - Renamed AcousticMessage to SoundRequest
00131  *
00132  * Revision 1.1.1.1  2002/05/10 12:40:18  cvsadm
00133  * Moved GT2002 Project from ute to tamara.
00134  *
00135  * Revision 1.4  2001/12/10 17:47:08  risler
00136  * change log added
00137  *
00138  */

Generated on Thu Sep 23 19:57:34 2004 for GT2004 by doxygen 1.3.6