00001 /* 00002 MobileRobots Advanced Robotics Interface for Applications (ARIA) 00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC 00004 Copyright (C) 2006, 2007 MobileRobots Inc. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 If you wish to redistribute ARIA under different terms, contact 00021 MobileRobots for information about a commercial version of ARIA at 00022 robots@mobilerobots.com or 00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481 00024 */ 00025 00026 00027 #ifndef ARSYSTEMSTATUS_H 00028 #define ARSYSTEMSTATUS_H 00029 00030 #include "Aria.h" 00031 00032 class ArSystemStatusRefreshThread; 00033 00042 class ArSystemStatus { 00043 public: 00044 00050 AREXPORT static void startPeriodicUpdate(int refreshFrequency = 5000); 00051 00054 AREXPORT static void stopPeriodicUpdate(); 00055 00057 AREXPORT static void runRefreshThread(int refreshFrequency = 5000) { 00058 startPeriodicUpdate(refreshFrequency); 00059 } 00060 00069 AREXPORT static double getCPU(); 00070 00077 AREXPORT static double getCPUPercent(); 00078 00080 AREXPORT static std::string getCPUPercentAsString(); 00081 00083 AREXPORT static unsigned long getUptime(); 00084 00086 AREXPORT static double getUptimeHours(); 00087 00089 AREXPORT static std::string getUptimeHoursAsString(); 00090 00092 AREXPORT static ArRetFunctor<double>* getCPUPercentFunctor(); 00093 00095 AREXPORT static ArRetFunctor<double>* getUptimeHoursFunctor(); 00096 00097 00098 00101 AREXPORT static int getWirelessLinkQuality(); 00102 00105 AREXPORT static int getWirelessLinkSignal(); 00106 00109 AREXPORT static int getWirelessLinkNoise(); 00110 00113 AREXPORT static int getWirelessDiscardedPackets(); 00114 00118 AREXPORT static int getWirelessDiscardedPacketsBecauseNetConflict(); 00119 00120 AREXPORT static ArRetFunctor<int>* getWirelessLinkQualityFunctor(); 00121 AREXPORT static ArRetFunctor<int>* getWirelessLinkNoiseFunctor(); 00122 AREXPORT static ArRetFunctor<int>* getWirelessLinkSignalFunctor(); 00123 00125 AREXPORT static void invalidate(); 00126 00128 AREXPORT static void refresh() { } 00129 private: 00130 00131 00132 static ArMutex ourCPUMutex; 00133 static double ourCPU; 00134 static unsigned long ourUptime; 00135 static unsigned long ourLastCPUTime; 00136 static ArTime ourLastCPURefreshTime; 00137 static ArGlobalRetFunctor<double> ourGetCPUPercentCallback; 00138 static ArGlobalRetFunctor<double> ourGetUptimeHoursCallback; 00139 00140 static ArMutex ourWirelessMutex; 00141 static int ourLinkQuality, ourLinkSignal, ourLinkNoise, 00142 ourDiscardedTotal, ourDiscardedDecrypt, ourDiscardedConflict; 00143 static ArGlobalRetFunctor<int> ourGetWirelessLinkQualityCallback; 00144 static ArGlobalRetFunctor<int> ourGetWirelessLinkNoiseCallback; 00145 static ArGlobalRetFunctor<int> ourGetWirelessLinkSignalCallback; 00146 00147 static void refreshCPU(); 00148 static void refreshWireless(); 00149 00150 00151 static ArSystemStatusRefreshThread* ourPeriodicUpdateThread; 00152 static bool ourShouldRefreshWireless; 00153 static bool ourShouldRefreshCPU; 00154 00155 }; 00156 00157 #endif