MOOS 0.2375
|
00001 00002 // 00003 // MOOS - Mission Oriented Operating Suite 00004 // 00005 // A suit of Applications and Libraries for Mobile Robotics Research 00006 // Copyright (C) 2001-2005 Massachusetts Institute of Technology and 00007 // Oxford University. 00008 // 00009 // This software was written by Paul Newman and others 00010 // at MIT 2001-2002 and Oxford University 2003-2005. 00011 // email: pnewman@robots.ox.ac.uk. 00012 // 00013 // This file is part of a MOOS Instrument. 00014 // 00015 // This program is free software; you can redistribute it and/or 00016 // modify it under the terms of the GNU General Public License as 00017 // published by the Free Software Foundation; either version 2 of the 00018 // License, or (at your option) any later version. 00019 // 00020 // This program is distributed in the hope that it will be useful, 00021 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00023 // General Public License for more details. 00024 // 00025 // You should have received a copy of the GNU General Public License 00026 // along with this program; if not, write to the Free Software 00027 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00028 // 02111-1307, USA. 00029 // 00031 // BatteryDriver.h: interface for the CBatteryDriver class. 00032 // 00034 00035 #if !defined(AFX_BATTERYDRIVER_H__DD1ADDC7_1BB7_4CF2_A54E_961ED256C1E7__INCLUDED_) 00036 #define AFX_BATTERYDRIVER_H__DD1ADDC7_1BB7_4CF2_A54E_961ED256C1E7__INCLUDED_ 00037 00038 #if _MSC_VER > 1000 00039 #pragma once 00040 #endif // _MSC_VER > 1000 00041 00042 #ifdef _WIN32 00043 #pragma warning(disable : 4786) 00044 #endif 00045 00046 #include <string> 00047 using namespace std; 00048 00049 class CMOOSSerialPort; 00050 00051 class CBatteryDriver 00052 { 00053 public: 00054 virtual string GetCellsString(); 00055 virtual string GetCommentString(); 00056 virtual string GetErrorString(); 00057 00058 virtual bool Switch(bool bOn); 00059 virtual bool IsError(); 00060 class CBatteryStatus 00061 { 00062 public: 00063 enum Condition 00064 { 00065 UNKNOWN, 00066 SENSOR_ERROR, 00067 GOOD, 00068 LOW, 00069 BAD, 00070 DANGEROUS, 00071 }; 00072 00073 00074 public: 00075 Condition GetStatus(); 00076 bool Calculate(); 00077 double GetVoltage(); 00078 double GetPercentCharge(); 00079 string GetStatusAsString(); 00080 CBatteryStatus(); 00081 00082 double m_dfVoltage; 00083 double m_dfPercent; 00084 double m_dfFull; 00085 double m_dfEmpty; 00086 double m_dfLow; 00087 00088 string m_sError; 00089 Condition m_eStatus; 00090 00091 }; 00092 00093 CBatteryDriver(); 00094 virtual ~CBatteryDriver(); 00095 00096 00097 virtual bool Initialise()=0; 00098 virtual bool GetData()=0; 00099 bool GetStatus(CBatteryStatus & Status); 00100 bool SetSerialPort(CMOOSSerialPort * pPort); 00101 bool SetFullVolts(double dfVolts); 00102 bool SetEmptyVolts(double dfVolts); 00103 bool SetLowVolts(double dfVolts); 00104 protected: 00106 CMOOSSerialPort* m_pPort; 00107 CBatteryStatus m_Status; 00108 string m_sError; 00109 string m_sComment; 00110 00111 }; 00112 00113 #endif // !defined(AFX_BATTERYDRIVER_H__DD1ADDC7_1BB7_4CF2_A54E_961ED256C1E7__INCLUDED_)