MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/Tools/Simulation/Ocean/uMVS/AcousticResponder.cpp
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 at MIT 2001-2002 and Oxford 
00010 //   University 2003-2005. email: pnewman@robots.ox.ac.uk. 
00011 //      
00012 //   This file is part of a  MOOS Utility Component. 
00013 //        
00014 //   This program is free software; you can redistribute it and/or 
00015 //   modify it under the terms of the GNU General Public License as 
00016 //   published by the Free Software Foundation; either version 2 of the 
00017 //   License, or (at your option) any later version. 
00018 //          
00019 //   This program is distributed in the hope that it will be useful, 
00020 //   but WITHOUT ANY WARRANTY; without even the implied warranty of 
00021 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
00022 //   General Public License for more details. 
00023 //            
00024 //   You should have received a copy of the GNU General Public License 
00025 //   along with this program; if not, write to the Free Software 
00026 //   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 
00027 //   02111-1307, USA. 
00028 //
00030 
00031 // AcousticResponder.cpp: implementation of the CAcousticResponder class.
00032 //
00034 #ifdef _WIN32
00035     #pragma warning(disable : 4786)
00036 #endif
00037 
00038 
00039 #include "SimEntity.h"
00040 #include "AcousticResponder.h"
00041 
00043 // Construction/Destruction
00045 
00046 CAcousticResponder::CAcousticResponder()
00047 {
00048     m_dfTAT = 0.125;
00049     SetRxChan(ACOUSTIC_CHAN_CIF);
00050 
00051 }
00052 
00053 CAcousticResponder::~CAcousticResponder()
00054 {
00055 
00056 }
00057 
00058 
00059 bool CAcousticResponder::OnAcousticHit(CAcousticSignal & Signal,double dfTime)
00060 {
00061 #ifdef VERBOSE
00062     MOOSTrace("CAcousticResponder::OnAcousticHit on %s Signal[%d] from %s on Channel %d\n",
00063         GetFullName().c_str(),
00064         Signal.m_nID,
00065         Signal.GetSrcName().c_str(),
00066         Signal.GetChannel());
00067 #endif
00068 
00069     if(Listening(Signal.GetChannel()))
00070     {
00071 
00072         //this is a trap for self excitation..
00073         if(Signal.GetSrcName()==GetFullName())
00074             return false;
00075 
00076 
00077         Matrix NodePosAfterTAT;
00078 
00079         GetParent()->GetNodePosition(*this,
00080                                     GetTAT(),
00081                                     NodePosAfterTAT);
00082 
00083         CAcousticSignal ReplyPing(    NodePosAfterTAT(1,1),
00084                                     NodePosAfterTAT(2,1),
00085                                     NodePosAfterTAT(3,1),
00086                                     dfTime+GetTAT());
00087 
00088         ReplyPing.SetChannel(GetTxChannel());
00089 
00090         //here we set the src name to be something like "B1:TDR"
00091         ReplyPing.SetSrcName(GetFullName());
00092 
00093         m_pEnvironment->AddSignal(ReplyPing);
00094 
00095 #ifdef VERBOSE
00096         MOOSTrace("%s is pinged by Signal[%d] from %s on Chan[%d] and replies with Signal[%d] Chan[%d] \n",
00097             GetFullName().c_str(),
00098             Signal.m_nID,
00099             Signal.GetSrcName().c_str(),
00100             Signal.GetChannel(),
00101             ReplyPing.m_nID,
00102             ReplyPing.GetChannel());
00103 #endif
00104 
00105     }
00106 
00107     return true;
00108 }
00109 double CAcousticResponder::GetTAT()
00110 {
00111     return m_dfTAT;
00112 }
00113 
00114 bool CAcousticResponder::SetTAT(double dfTAT)
00115 {
00116     m_dfTAT = dfTAT;
00117 
00118     return true;
00119 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines