00001
00002
00003
00004
00005
00006
00007
00008
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
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138