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 // BluefinBatteryDriverV2.h: interface for the CBluefinBatteryDriverV2 class. 00032 // 00034 00035 #if !defined(AFX_BLUEFINBATTERYDRIVERV2_H__1CA91A09_950F_4DF3_9192_698F350F2145__INCLUDED_) 00036 #define AFX_BLUEFINBATTERYDRIVERV2_H__1CA91A09_950F_4DF3_9192_698F350F2145__INCLUDED_ 00037 00038 #if _MSC_VER > 1000 00039 #pragma once 00040 #endif // _MSC_VER > 1000 00041 00042 #include <map> 00043 using namespace std; 00044 00045 #include "BatteryDriver.h" 00046 #define CELLS_PER_PACK 8 00047 class CBluefinBatteryDriverV2 : public CBatteryDriver 00048 { 00049 public: 00050 00051 enum Status 00052 { 00053 OFF, 00054 ON, 00055 CHARGING, 00056 BALANCING, 00057 }; 00058 00059 00060 class CBatteryPack 00061 { 00062 public: 00063 class CCell 00064 { 00065 public: 00066 double m_dfVoltage; 00067 }; 00068 00069 CCell m_Cells[CELLS_PER_PACK]; 00070 00071 int m_nPackAddress; 00072 double m_dfVoltage; 00073 Status m_eState; 00074 string m_sState; 00075 string m_sError; 00076 string m_sComment; 00077 bool m_bIgnore; 00078 00079 }; 00080 typedef map<int,CBatteryPack> BATTERY_MAP; 00081 00082 public: 00083 00084 CBluefinBatteryDriverV2(); 00085 virtual ~CBluefinBatteryDriverV2(); 00086 00087 virtual string GetCellsString(); 00088 virtual string GetErrorString(); 00089 virtual string GetCommentString(); 00090 00091 virtual bool IsError(); 00092 bool Switch(bool bOn); 00093 protected: 00094 string GetStateAsString(); 00095 bool QueryCellsState(CBatteryPack & rPack); 00096 bool ProcessStateString(CBatteryPack & rPack,string sState); 00097 bool SwitchPack(CBatteryPack & rPack, bool bOn); 00098 bool QueryBattery(CBatteryPack & rPack); 00099 bool WriteAndRead(string sOut, string & sReply,double dfTimeOut=-1.0,bool bNoTerm = false); 00100 bool DiscoverAndMakeBatteries(); 00101 virtual bool Initialise(); 00102 virtual bool GetData(); 00103 BATTERY_MAP m_BatteryMap; 00104 bool m_bEchoing; 00105 00106 }; 00107 00108 #endif // !defined(AFX_BLUEFINBATTERYDRIVERV2_H__1CA91A09_950F_4DF3_9192_698F350F2145__INCLUDED_)