MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/Instruments/Ocean/iRelay/RelayBoard.h
Go to the documentation of this file.
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 // RelayBoard.h: interface for the CRelayBoard class.
00032 //
00034 
00035 #if !defined(AFX_RELAYBOARD_H__08DA8EE7_D800_4E09_96E6_474109ECA588__INCLUDED_)
00036 #define AFX_RELAYBOARD_H__08DA8EE7_D800_4E09_96E6_474109ECA588__INCLUDED_
00037 
00038 #if _MSC_VER > 1000
00039 #pragma once
00040 #endif // _MSC_VER > 1000
00041 
00042 typedef std::map<std::string, int> RELAY_FUNCTION_2_CHECK_MAP;
00043 typedef std::map<std::string, int> RELAY_FUNCTION_2_TOGGLE_MAP;
00044 typedef std::map<std::string, int> INPUT_NAME_2_INT_MAP;
00045 
00046 enum RelayToggleName
00047 {
00048     RELAY0_TOGGLE = 1,
00049     RELAY1_TOGGLE = RELAY0_TOGGLE << 1,
00050     RELAY2_TOGGLE = RELAY0_TOGGLE << 2,
00051     RELAY3_TOGGLE = RELAY0_TOGGLE << 3,
00052     RELAY4_TOGGLE = RELAY0_TOGGLE << 4,
00053     RELAY5_TOGGLE = RELAY0_TOGGLE << 5,
00054     RELAY6_TOGGLE = RELAY0_TOGGLE << 6,
00055     RELAY7_TOGGLE = RELAY0_TOGGLE << 7,
00056 };
00057 
00058 enum RelayCheckName
00059 {
00060     RELAY0,
00061     RELAY1,
00062     RELAY2,
00063     RELAY3,
00064     RELAY4,
00065     RELAY5,
00066     RELAY6,
00067     RELAY7,
00068 };
00069 
00070 
00071 enum InputName
00072 {
00073     INPUT0,
00074     INPUT1,
00075     INPUT2,
00076     INPUT3,
00077 };
00078 
00079 enum RelayState
00080 {
00081     LO,
00082     HI,
00083 };
00084 
00085 
00086 class CRelayBoard : public CMOOSInstrument
00087 {
00088 public:
00089 
00090 
00091     
00092     RELAY_FUNCTION_2_TOGGLE_MAP  m_RelayToggleMap;
00093      RELAY_FUNCTION_2_CHECK_MAP   m_RelayCheckMap;
00094     INPUT_NAME_2_INT_MAP         m_InputNameMap;
00095            
00096     std::string m_sRECORDING;
00097     std::string m_sRECORD;
00098     std::string m_sSTOPPED; 
00099     std::string m_sSTOP; 
00100     std::string m_sON; 
00101     std::string m_sOFF;
00102     std::string m_sCAMERA_POWER;
00103     std::string m_sBOARD_POWER;
00104     std::string m_sVCR_POWER;
00105     std::string m_sLIGHT_POWER;
00106     std::string m_sLIGHT;
00107     std::string m_sDARK;
00108 
00109     bool UpdateRelay(CMOOSMsg &Msg);
00110     bool Stop();
00111     bool Record();
00112     bool IsPowered(std::string sRelay);
00113 
00114     CRelayBoard();
00115     virtual ~CRelayBoard();
00116 
00117     protected:
00118         bool ShowRelayBoardStatus();
00119         int CheckAllRelayStates();
00120         bool ToggleRelaySwitch(std::string sRelay, std::string sDesiredState);
00121         bool InitialiseSensor();
00122         bool Iterate();
00123         bool OnNewMail(MOOSMSG_LIST &NewMail);
00124         bool OnConnectToServer();
00125         bool OnStartUp();
00126         bool GetData();
00127         bool PublishData();
00128         bool SetRelayHi(short val);
00129            bool SetRelayLo(short val);
00130         int CheckRelayState(short val);
00131         int CheckInputState(short val);
00132 
00133 };
00134 
00135 #endif // !defined(AFX_RELAYBOARD_H__08DA8EE7_D800_4E09_96E6_474109ECA588__INCLUDED_)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines