AshtechEPB.cpp

Go to the documentation of this file.
00001 #pragma ident "$Id: AshtechEPB.cpp 824 2007-10-10 14:21:58Z ocibu $"
00002 
00003 //============================================================================
00004 //
00005 //  This file is part of GPSTk, the GPS Toolkit.
00006 //
00007 //  The GPSTk is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU Lesser General Public License as published
00009 //  by the Free Software Foundation; either version 2.1 of the License, or
00010 //  any later version.
00011 //
00012 //  The GPSTk is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU Lesser General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU Lesser General Public
00018 //  License along with GPSTk; if not, write to the Free Software Foundation,
00019 //  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //  
00021 //  Copyright 2004, The University of Texas at Austin
00022 //
00023 //============================================================================
00024 
00025 //============================================================================
00026 //
00027 //This software developed by Applied Research Laboratories at the University of
00028 //Texas at Austin, under contract to an agency or agencies within the U.S. 
00029 //Department of Defense. The U.S. Government retains all rights to use,
00030 //duplicate, distribute, disclose, or release this software. 
00031 //
00032 //Pursuant to DoD Directive 523024 
00033 //
00034 // DISTRIBUTION STATEMENT A: This software has been approved for public 
00035 //                           release, distribution is unlimited.
00036 //
00037 //=============================================================================
00038 
00039 #include "StringUtils.hpp"
00040 #include "BinUtils.hpp"
00041 
00042 #include "AshtechEPB.hpp"
00043 #include "AshtechStream.hpp"
00044 
00045 using namespace std;
00046 
00047 namespace gpstk
00048 {
00049    const char* AshtechEPB::myId = "EPB";
00050 
00051    //---------------------------------------------------------------------------
00052    void AshtechEPB::reallyGetRecord(FFStream& ffs)
00053       throw(std::exception, FFStreamError, EndOfFile)
00054    {
00055       AshtechStream& stream=dynamic_cast<AshtechStream&>(ffs);
00056 
00057       // make sure the object is reset before starting the search
00058       clear(fmtbit | lenbit | crcbit);
00059       string& rawData = stream.rawData;
00060 
00061       // If this object doesn't have an id set yet, assume that the streams
00062       // most recent read id is what we need to be
00063       if (id == "" && rawData.size()>=10 && 
00064           rawData.substr(0,7) == preamble)
00065          id = rawData.substr(7,3);
00066 
00067       // If that didn't work, or this is object is not of the right type,
00068       // then give up.
00069       if (id == "" || !checkId(id))
00070          return;
00071 
00072       readBody(stream);
00073    }
00074 
00075    //---------------------------------------------------------------------------
00076    void AshtechEPB::decode(const std::string& data)
00077       throw(std::exception, FFStreamError)
00078    {
00079       using BinUtils::decodeVar;
00080       using gpstk::StringUtils::asInt;
00081 
00082       string str(data);
00083 
00084       if (str.length() == 138)
00085       {
00086          ascii = false;
00087          header      = str.substr(0,11); str.erase(0,11);
00088          prn         = asInt(str.substr(0,2));
00089          str.erase(0,3);
00090 
00091          for (int s=1; s<=3; s++)
00092             for (int w=1; w<=10; w++)
00093                word[s][w] = decodeVar<uint32_t>(str);
00094 
00095          unsigned cksum = decodeVar<uint16_t>(str);
00096          clear(ios_base::goodbit);
00097       }
00098    }
00099 
00100    //---------------------------------------------------------------------------
00101    void AshtechEPB::dump(ostream& out) const throw()
00102    {
00103       ostringstream oss;
00104       using gpstk::StringUtils::asString;
00105       using gpstk::StringUtils::leftJustify;
00106 
00107       AshtechData::dump(out);
00108       oss << getName() << "0:" << " prn:" << prn << endl;
00109 
00110       oss << setfill('0') << hex;
00111       for (int s=1; s<=3; s++)
00112       {
00113          for (int w=1; w<=10; w++)
00114          {
00115             if ((w % 5) == 1)
00116                oss << getName() << s*2+w/5-1 << ": ";
00117             oss << setw(8) << uppercase << word[s][w] << "  ";
00118             if ((w % 5) == 0)
00119                oss << endl;
00120          }
00121       }
00122 
00123       out << oss.str() << flush;
00124    }
00125 } // namespace gpstk

Generated on Thu Jul 29 03:30:51 2010 for GPS ToolKit Software Library by  doxygen 1.3.9.1