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   if (stat.robotStatus & orsbPAUSE)
00041   {
00042     shutdown();
00043   }
00044   return percent;
00045 }
00046 
00047 void SystemCall::reboot()
00048 {
00049   OBootCondition cond(obcbBOOT_TIMER, 0, obcbttRELATIVE);
00050   VERIFY(OPENR::Shutdown(cond)==0);
00051 }
00052 
00053 void SystemCall::shutdown()
00054 {
00055   OBootCondition cond(0xFFFF);
00056   VERIFY(OPENR::Shutdown(cond)==0);
00057   char* tmp;
00058   tmp = etherStatusStr(0);
00059 
00060 }
00061 
00062 void SystemCall::getMacAddress(unsigned char address[6])
00063 {
00064 #ifdef __GNUC__
00065   EtherDriverGetMACAddressMsg msg;
00066   VERIFY(!ERA201D1_GetMACAddress(&msg));
00067   for(int i = 0; i < 6; ++i)
00068     address[i] = msg.address.octet[i];
00069 #else
00070   for(int i = 0; i < 6; ++i)
00071     address[i] = 0;
00072 #endif
00073 }
00074 
00075 RobotDesign::Design SystemCall::getRobotDesign()
00076 {
00077   static bool initialized = false;
00078   static RobotDesign::Design design;
00079 
00080   if (!initialized)
00081   {
00082     char robotDesign[20];
00083     VERIFY(OPENR::GetRobotDesign(robotDesign) == 0);
00084     if(!strcmp(robotDesign, "ERS-210"))
00085       design = RobotDesign::ERS210;
00086     else if(!strcmp(robotDesign, "ERS-7"))
00087       design = RobotDesign::ERS7;
00088     else
00089       design = RobotDesign::UNKNOWN;
00090     initialized = true;
00091   }
00092   return design;
00093 }

Generated on Mon Mar 20 22:00:00 2006 for GT2005 by doxygen 1.3.6