DVLdataClass.cpp
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, LABUST, UNIZG-FER
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the LABUST nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *********************************************************************/
00034 #include <labust/navigation/DVLdataClass.h>
00035 #include <labust/navigation/NavQuestMessages.hpp>
00036 using namespace labust::navigation;
00037 
00038 
00039 DVLdataClass::DVLdataClass(void){};
00040 
00041 DVLdataClass::~DVLdataClass(void){};
00042 
00043 void DVLdataClass::parsDVL(const std::string& str)
00044 {
00045         //LABUST::DVLdataClass DVLoutput;   // class declaration
00046         std::string sname, sname1;
00047         int index = 0;
00048 
00049         sname = str;
00050 
00051         if (!(str.compare(0, 8, "$#NQ.RES")))
00052         {
00053                 //cout << "To je NQ1 poruka" << endl;
00054                 std::stringstream converter;
00055                 index = sname.find(" ");
00056                 Header = sname.substr(0, index); // Header
00057                 //skipped error code
00058                 sname = sname.substr(index + 1);
00059                 index = sname.find(" ");
00060 
00061                 sname = sname.substr(index + 1);
00062                 index = sname.find(" ");
00063                 sname1 = sname.substr(0, index);
00064                 converter << sname1;
00065                 converter >> Beam1Valid;
00066                 converter.clear();
00067 
00068                 sname = sname.substr(index + 1);
00069                 index = sname.find(" ");
00070                 sname1 = sname.substr(0, index);
00071                 converter << sname1;
00072                 converter >> Beam2Valid;
00073                 converter.clear();
00074 
00075                 sname = sname.substr(index + 1);
00076                 index = sname.find(" ");
00077                 sname1 = sname.substr(0, index);
00078                 converter << sname1;
00079                 converter >> Beam3Valid;
00080                 converter.clear();
00081 
00082                 sname = sname.substr(index + 1);
00083                 index = sname.find(" ");
00084                 sname1 = sname.substr(0, index);
00085                 converter << sname1;
00086                 converter >> Beam4Valid;
00087                 converter.clear();
00088 
00089                 sname = sname.substr(index + 1);
00090                 index = sname.find(" ");
00091                 sname1 = sname.substr(0, index);
00092                 converter << sname1;
00093                 converter >> Altitude1;
00094                 converter.clear();
00095 
00096                 sname = sname.substr(index + 1);
00097                 index = sname.find(" ");
00098                 sname1 = sname.substr(0, index);
00099                 converter << sname1;
00100                 converter >> Altitude2;
00101                 converter.clear();
00102 
00103                 sname = sname.substr(index + 1);
00104                 index = sname.find(" ");
00105                 sname1 = sname.substr(0, index);
00106                 converter << sname1;
00107                 converter >> Altitude3;
00108                 converter.clear();
00109 
00110                 sname = sname.substr(index + 1);
00111                 index = sname.find(" ");
00112                 sname1 = sname.substr(0, index);
00113                 converter << sname1;
00114                 converter >> Altitude4;
00115                 converter.clear();
00116 
00117                 // BottomRadVelocity for each beam, skip
00118                 // WaterRadVelocity for each beam, skip
00119                 // WaterVelocityQuality value: 0-50, 0 - water velocity not valid, 50- perfect, skip
00120                 for (int j = 0; j < 13; j++)
00121                 { // SKip 12 fields
00122                         sname = sname.substr(index + 1);
00123                         index = sname.find(" ");
00124                 }
00125 
00126                 // Instrument DVL.VelocityX,DVL.VelocityY,DVL.VelocityZ and Type (bottom, water, invalid)
00127                 sname1 = sname.substr(0, index);
00128                 converter << sname1; // VelocityX forward speed, forward positive
00129                 converter >> VelocityX;
00130                 converter.clear();
00131 
00132                 sname = sname.substr(index + 1);
00133                 index = sname.find(" ");
00134                 sname1 = sname.substr(0, index);
00135                 converter << sname1;
00136                 converter >> VelocityY; // VelocityY lateral speed, port positive
00137                 converter.clear();
00138 
00139                 sname = sname.substr(index + 1);
00140                 index = sname.find(" ");
00141                 sname1 = sname.substr(0, index);
00142                 converter << sname1;
00143                 converter >> VelocityZ; // VelocityZ forward speed, up positive
00144                 converter.clear();
00145 
00146                 sname = sname.substr(index + 1);
00147                 index = sname.find(" ");
00148                 sname1 = sname.substr(0, index);
00149                 if (sname1 == "1")
00150                         VelocityType = "Bottom";
00151                 else
00152                 {
00153                         if (sname1 == "2")
00154                                 VelocityType = "Water";
00155                         else
00156                                 VelocityType = "Invalid";
00157                 }
00158 
00159                 // Earth DVL.Velocities and Type (bottom, water, invalid)
00160                 sname = sname.substr(index + 1);
00161                 index = sname.find(" ");
00162                 sname1 = sname.substr(0, index);
00163                 converter << sname1;
00164                 converter >> VelocityNorth;
00165                 converter.clear();
00166 
00167                 sname = sname.substr(index + 1);
00168                 index = sname.find(" ");
00169                 sname1 = sname.substr(0, index);
00170                 converter << sname1;
00171                 converter >> VelocityEast;
00172                 converter.clear();
00173 
00174                 sname = sname.substr(index + 1);
00175                 index = sname.find(" ");
00176                 sname1 = sname.substr(0, index);
00177                 converter << sname1;
00178                 converter >> VelocityDown;
00179                 converter.clear();
00180 
00181                 sname = sname.substr(index + 1);
00182                 index = sname.find(" ");
00183                 sname1 = sname.substr(0, index);
00184                 if (sname1 == "1")
00185                         VelocityEarthType = "Bottom";
00186                 else
00187                 {
00188                         if (sname1 == "2")
00189                                 VelocityEarthType = "Water";
00190                         else
00191                                 VelocityEarthType = "Invalid";
00192                 }
00193 
00194                 // Instrument Current.Velocities and Type (bottom, water, invalid)
00195                 sname = sname.substr(index + 1);
00196                 index = sname.find(" ");
00197                 sname1 = sname.substr(0, index);
00198                 converter << sname1;
00199                 converter >> VelocityCurrentX;
00200                 converter.clear();
00201 
00202                 sname = sname.substr(index + 1);
00203                 index = sname.find(" ");
00204                 sname1 = sname.substr(0, index);
00205                 converter << sname1;
00206                 converter >> VelocityCurrentY;
00207                 converter.clear();
00208 
00209                 sname = sname.substr(index + 1);
00210                 index = sname.find(" ");
00211                 sname1 = sname.substr(0, index);
00212                 converter << sname1;
00213                 converter >> VelocityCurrentZ;
00214                 converter.clear();
00215 
00216                 sname = sname.substr(index + 1);
00217                 index = sname.find(" ");
00218                 sname1 = sname.substr(0, index);
00219                 if (sname1 == "1")
00220                         VelocityCurrentType = "Botom";
00221                 else
00222                 {
00223                         if (sname1 == "2")
00224                                 VelocityCurrentType = "Water";
00225                         else
00226                                 VelocityCurrentType = "Invalid";
00227                 }
00228 
00229                 // Instrument Current.Velocities and Type (bottom, water, invalid)
00230                 sname = sname.substr(index + 1);
00231                 index = sname.find(" ");
00232                 sname1 = sname.substr(0, index);
00233                 converter << sname1;
00234                 converter >> VelocityCurrentNorth;
00235                 converter.clear();
00236 
00237                 sname = sname.substr(index + 1);
00238                 index = sname.find(" ");
00239                 sname1 = sname.substr(0, index);
00240                 converter << sname1;
00241                 converter >> VelocityCurrentEast;
00242                 converter.clear();
00243 
00244                 sname = sname.substr(index + 1);
00245                 index = sname.find(" ");
00246                 sname1 = sname.substr(0, index);
00247                 converter << sname1;
00248                 converter >> VelocityCurrentDown;
00249                 converter.clear();
00250 
00251                 sname = sname.substr(index + 1);
00252                 index = sname.find(" ");
00253                 sname1 = sname.substr(0, index);
00254                 if (sname1 == "1")
00255                         VelocityCurrentEarthType = "Bottom";
00256                 else
00257                 {
00258                         if (sname1 == "2")
00259                                 VelocityCurrentEarthType = "Water";
00260                         else
00261                                 VelocityCurrentEarthType = "Invalid";
00262                 }
00263 
00264                 sname = sname.substr(index + 1);
00265                 index = sname.find(" ");
00266                 sname1 = sname.substr(0, index);
00267                 converter << sname1;
00268                 converter >> Roll;
00269                 converter.clear();
00270 
00271                 sname = sname.substr(index + 1);
00272                 index = sname.find(" ");
00273                 sname1 = sname.substr(0, index);
00274                 converter << sname1;
00275                 converter >> Pitch;
00276                 converter.clear();
00277 
00278                 sname = sname.substr(index + 1);
00279                 index = sname.find(" ");
00280                 sname1 = sname.substr(0, index);
00281                 converter << sname1;
00282                 converter >> Heading;
00283                 converter.clear();
00284 
00285                 sname = sname.substr(index + 1);
00286                 index = sname.find(" ");
00287                 sname1 = sname.substr(0, index);
00288                 converter << sname1;
00289                 converter >> Altitude;
00290                 converter.clear();
00291 
00292                 sname = sname.substr(index + 1);
00293                 index = sname.find(" ");
00294                 sname1 = sname.substr(0, index);
00295                 converter << sname1;
00296                 converter >> Temperature;
00297                 converter.clear();
00298 
00299                 sname = sname.substr(index + 1);
00300                 index = sname.find(" ");
00301                 sname1 = sname.substr(0, index);
00302                 converter << sname1;
00303                 converter >> Press;
00304                 converter.clear();
00305 
00306                 sname = sname.substr(index + 1);
00307                 index = sname.find(" ");
00308                 sname1 = sname.substr(0, index);
00309                 converter << sname1;
00310                 converter >> Salinity;
00311                 converter.clear();
00312 
00313                 sname = sname.substr(index + 1);
00314                 index = sname.find(" ");
00315                 sname1 = sname.substr(0, index);
00316                 converter << sname1;
00317                 converter >> SoundVelocity;
00318                 converter.clear();
00319 
00320         }
00321 
00322         if (!(str.compare(0, 3, ":SA")))
00323         {
00324                 std::stringstream converter;
00325                 index = sname.find(",");
00326                 sname1 = sname.substr(0, index);
00327                 Header = sname1;
00328 
00329                 sname = sname.substr(index + 1);
00330                 index = sname.find(",");
00331                 sname1 = sname.substr(0, index);
00332                 converter << sname1;
00333                 converter >> Pitch; // positive for nose up
00334                 converter.clear();
00335 
00336                 sname = sname.substr(index + 1);
00337                 index = sname.find(",");
00338                 sname1 = sname.substr(0, index);
00339                 converter << sname1;
00340                 converter >> Roll;
00341                 converter.clear();
00342 
00343                 sname = sname.substr(index + 1);
00344                 converter << sname;
00345                 converter >> Heading;
00346                 converter.clear();
00347         }
00348 
00349         if (!(str.compare(0, 3, ":TS")))
00350         {
00351                 std::stringstream converter;
00352                 index = sname.find(",");
00353                 sname1 = sname.substr(0, index);
00354                 Header = sname1;
00355                 sname = sname.substr(index + 1);
00356 
00357                 // Skip first two fields representing date&time, NOT USED
00358                 index = sname.find(",");
00359                 sname = sname.substr(index + 1);
00360                 index = sname.find(",");
00361                 sname = sname.substr(index + 1);
00362 
00363                 index = sname.find(",");
00364                 sname1 = sname.substr(0, index);
00365                 converter << sname1;
00366                 converter >> Temperature;
00367                 converter.clear();
00368 
00369                 sname = sname.substr(index + 1);
00370                 index = sname.find(",");
00371                 sname1 = sname.substr(0, index);
00372                 converter << sname1;
00373                 converter >> Press;
00374                 converter.clear();
00375 
00376                 sname = sname.substr(index + 1);
00377                 converter << sname;
00378                 converter >> SoundVelocity;
00379                 converter.clear();
00380         }
00381 
00382         if (!(str.compare(0, 3, ":WI")))
00383         {
00384                 std::stringstream converter;
00385                 index = sname.find(",");
00386                 sname1 = sname.substr(0, index);
00387                 Header = sname1;
00388                 sname = sname.substr(index + 1);
00389 
00390                 index = sname.find(",");
00391                 sname1 = sname.substr(0, index);
00392                 converter << sname1;
00393                 converter >> VelocityCurrentX;
00394                 converter.clear();
00395 
00396                 sname = sname.substr(index + 1);
00397                 index = sname.find(",");
00398                 sname1 = sname.substr(0, index);
00399                 converter << sname1;
00400                 converter >> VelocityCurrentY;
00401                 converter.clear();
00402 
00403                 sname = sname.substr(index + 1);
00404                 index = sname.find(",");
00405                 sname1 = sname.substr(0, index);
00406                 converter << sname1;
00407                 converter >> VelocityCurrentZ;
00408                 converter.clear();
00409 
00410                 // Skip one field, NOT USED
00411                 index = sname.find(",");
00412                 sname = sname.substr(index + 1);
00413 
00414                 sname = sname.substr(index + 1,1);
00415                 VelocityCurrentType = sname;
00416         }
00417 
00418         if (!(str.compare(0, 3, ":BI")))
00419         {
00420                 std::stringstream converter;
00421                 index = sname.find(",");
00422                 sname1 = sname.substr(0, index);
00423                 Header = sname1;
00424                 sname = sname.substr(index + 1);
00425 
00426                 index = sname.find(",");
00427                 sname1 = sname.substr(0, index);
00428                 converter << sname1;
00429                 converter >> VelocityX;
00430                 converter.clear();
00431 
00432                 sname = sname.substr(index + 1);
00433                 index = sname.find(",");
00434                 sname1 = sname.substr(0, index);
00435                 converter << sname1;
00436                 converter >> VelocityY;
00437 
00438                 converter.clear();
00439 
00440                 sname = sname.substr(index + 1);
00441                 index = sname.find(",");
00442                 sname1 = sname.substr(0, index);
00443                 converter << sname1;
00444                 converter >> VelocityZ;
00445                 converter.clear();
00446 
00447                 // Skip one field, NOT USED
00448                 index = sname.find(",");
00449                 sname = sname.substr(index + 1);
00450 
00451                 sname = sname.substr(index + 1,1);
00452                 VelocityType = sname;
00453         }
00454 
00455         if (!(str.compare(0, 3, ":BD")))
00456         {
00457                 std::stringstream converter;
00458                 index = sname.find(",");
00459                 sname1 = sname.substr(0, index);
00460                 Header = sname1;
00461                 sname = sname.substr(index + 1);
00462                 // Skip first 3 fields, NOT USED
00463                 index = sname.find(",");
00464                 sname = sname.substr(index + 1);
00465                 index = sname.find(",");
00466                 sname = sname.substr(index + 1);
00467                 index = sname.find(",");
00468                 sname = sname.substr(index + 1);
00469 
00470                 index = sname.find(",");
00471                 sname1 = sname.substr(0, index);
00472                 converter << sname1;
00473                 converter >> Altitude;
00474                 converter.clear();
00475         }
00476 
00477         //std::cout<<str<<" "<<Header<<std::endl;
00478 
00479 }


navquest_dvl
Author(s): Gyula Nagy
autogenerated on Thu Jul 10 2014 10:34:00