2012-01-16 22:01:29 +00:00
/*!
* \ file gnss_satellite . cc
* \ brief Implementation of the Gnss_Satellite class
* \ author Carles Fernandez - Prades , 2012. cfernandez ( at ) cttc . es
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*
2015-01-08 18:49:59 +00:00
* Copyright ( C ) 2010 - 2015 ( see AUTHORS file for a list of contributors )
2012-01-16 22:01:29 +00:00
*
* GNSS - SDR is a software defined Global Navigation
* Satellite Systems receiver
*
* This file is part of GNSS - SDR .
*
* GNSS - SDR is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
2014-09-14 17:08:32 +00:00
* ( at your option ) any later version .
2012-01-16 22:01:29 +00:00
*
* GNSS - SDR is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with GNSS - SDR . If not , see < http : //www.gnu.org/licenses/>.
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
2012-01-19 07:35:49 +00:00
2012-01-16 22:01:29 +00:00
# include "gnss_satellite.h"
# include <glog/logging.h>
Gnss_Satellite : : Gnss_Satellite ( )
{
Gnss_Satellite : : reset ( ) ;
}
2014-09-14 17:08:32 +00:00
Gnss_Satellite : : Gnss_Satellite ( const std : : string & system_ , unsigned int PRN_ )
2012-01-16 22:01:29 +00:00
{
Gnss_Satellite : : reset ( ) ;
Gnss_Satellite : : set_system ( system_ ) ;
Gnss_Satellite : : set_PRN ( PRN_ ) ;
Gnss_Satellite : : set_block ( system_ , PRN_ ) ;
}
Gnss_Satellite : : ~ Gnss_Satellite ( )
{ }
void Gnss_Satellite : : reset ( )
{
2014-09-14 17:08:32 +00:00
system_set = { " GPS " , " GLONASS " , " SBAS " , " Galileo " , " Beidou " } ;
2012-01-27 18:01:17 +00:00
satelliteSystem [ " GPS " ] = " G " ;
satelliteSystem [ " GLONASS " ] = " R " ;
satelliteSystem [ " SBAS " ] = " S " ;
satelliteSystem [ " Galileo " ] = " E " ;
2014-09-14 17:08:32 +00:00
satelliteSystem [ " Beidou " ] = " C " ;
2012-01-16 22:01:29 +00:00
PRN = 0 ;
system = std : : string ( " " ) ;
block = std : : string ( " " ) ;
2012-01-19 07:35:49 +00:00
rf_link = 0 ;
2012-01-16 22:01:29 +00:00
}
2012-01-19 07:35:49 +00:00
std : : ostream & operator < < ( std : : ostream & out , const Gnss_Satellite & sat ) // output
{
//std::string psystem = sat::get_system()
out < < sat . get_system ( ) < < " PRN " < < sat . get_PRN ( ) < < " (Block " < < sat . get_block ( ) < < " ) " ;
return out ;
}
bool operator = = ( const Gnss_Satellite & sat1 , const Gnss_Satellite & sat2 )
{
bool equal = false ;
if ( sat1 . get_system ( ) . compare ( sat2 . get_system ( ) ) = = 0 )
{
if ( sat1 . get_PRN ( ) = = ( sat2 . get_PRN ( ) ) )
{
equal = true ;
}
}
return equal ;
}
2012-01-16 22:01:29 +00:00
2012-01-20 23:28:11 +00:00
/*
Gnss_Satellite & Gnss_Satellite : : operator = ( const Gnss_Satellite & rhs ) {
// Only do assignment if RHS is a different object from this.
if ( this ! = & rhs ) {
// Deallocate, allocate new space, copy values...
const std : : string system_ = rhs . get_system ( ) ;
const unsigned int PRN_ = rhs . get_PRN ( ) ;
const std : : string block_ = rhs . get_block ( ) ;
// const signed int rf_link_ = 0;
this - > set_system ( system_ ) ;
this - > set_PRN ( PRN_ ) ;
this - > set_block ( system_ , PRN_ ) ;
//this.rf_link = rf_link_;
}
return * this ;
} */
2012-01-16 22:01:29 +00:00
2014-09-14 17:08:32 +00:00
void Gnss_Satellite : : set_system ( const std : : string & system_ )
2012-01-16 22:01:29 +00:00
{
// Set the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Compass"}
std : : set < std : : string > : : iterator it = system_set . find ( system_ ) ;
if ( it ! = system_set . end ( ) )
{
system = system_ ;
}
else
{
2014-09-14 17:08:32 +00:00
DLOG ( INFO ) < < " System " < < system_ < < " is not defined {GPS, GLONASS, SBAS, Galileo, Beidou}. Initialization? " ;
2012-01-16 22:01:29 +00:00
system = std : : string ( " " ) ;
}
}
void Gnss_Satellite : : set_PRN ( unsigned int PRN_ )
{
// Set satellite's PRN
if ( system . compare ( " " ) = = 0 )
{
2012-01-20 23:28:11 +00:00
DLOG ( INFO ) < < " Trying to define PRN while system is not defined " ;
2012-01-16 22:01:29 +00:00
PRN = 0 ;
}
if ( system . compare ( " GPS " ) = = 0 )
{
2013-10-25 16:07:24 +00:00
if ( PRN_ < 1 or PRN_ > 32 )
2012-01-16 22:01:29 +00:00
{
2012-01-20 23:28:11 +00:00
DLOG ( INFO ) < < " This PRN is not defined " ;
2012-01-16 22:01:29 +00:00
PRN = 0 ;
}
else
{
PRN = PRN_ ;
}
}
else if ( system . compare ( " Glonass " ) = = 0 )
{
2013-10-25 16:07:24 +00:00
if ( PRN_ < 1 or PRN_ > 24 )
2012-01-16 22:01:29 +00:00
{
2012-01-20 23:28:11 +00:00
DLOG ( INFO ) < < " This PRN is not defined " ;
2012-01-16 22:01:29 +00:00
PRN = 0 ;
}
else
{
PRN = PRN_ ;
}
}
else if ( system . compare ( " SBAS " ) = = 0 )
{
if ( PRN_ = = 122 ) { PRN = PRN_ ; } // WAAS Inmarsat 3F4 (AOR-W)
else if ( PRN_ = = 134 ) { PRN = PRN_ ; } // WAAS Inmarsat 3F3 (POR)
else if ( PRN_ = = 120 ) { PRN = PRN_ ; } // EGNOS AOR-E Broadcast satellite http://www.egnos-pro.esa.int/index.html
else if ( PRN_ = = 124 ) { PRN = PRN_ ; } // EGNOS ESA ARTEMIS used for EGNOS Operations
else if ( PRN_ = = 126 ) { PRN = PRN_ ; } // EGNOS IOR-W currently used by Industry to perform various tests on the system.
else
{
2012-01-20 23:28:11 +00:00
DLOG ( INFO ) < < " This PRN is not defined " ;
2012-01-16 22:01:29 +00:00
PRN = 0 ;
}
}
else if ( system . compare ( " Galileo " ) = = 0 )
2013-10-25 16:07:24 +00:00
{
if ( PRN_ < 1 or PRN_ > 36 )
{
DLOG ( INFO ) < < " This PRN is not defined " ;
PRN = 0 ;
}
else
2012-01-16 22:01:29 +00:00
{
2013-10-25 16:07:24 +00:00
PRN = PRN_ ;
2012-01-16 22:01:29 +00:00
}
2013-10-25 16:07:24 +00:00
}
2012-01-16 22:01:29 +00:00
else
{
2012-01-20 23:28:11 +00:00
DLOG ( INFO ) < < " System " < < system < < " is not defined " ;
2012-01-16 22:01:29 +00:00
PRN = 0 ;
}
}
2012-01-19 07:35:49 +00:00
unsigned int Gnss_Satellite : : get_PRN ( ) const
2012-01-16 22:01:29 +00:00
{
// Get satellite's PRN
unsigned int PRN_ ;
PRN_ = PRN ;
return PRN_ ;
}
2012-01-19 07:35:49 +00:00
std : : string Gnss_Satellite : : get_system ( ) const
2012-01-16 22:01:29 +00:00
{
2014-09-14 17:08:32 +00:00
// Get the satellite system {"GPS", "GLONASS", "SBAS", "Galileo", "Beidou"}
2012-01-16 22:01:29 +00:00
std : : string system_ ;
system_ = system ;
return system_ ;
}
2012-01-27 18:01:17 +00:00
std : : string Gnss_Satellite : : get_system_short ( ) const
{
2012-01-31 00:03:08 +00:00
// Get the satellite system {"G", "R", "S", "E", "C"}
2012-01-27 18:01:17 +00:00
return satelliteSystem . at ( system ) ;
}
2012-01-16 22:01:29 +00:00
2012-01-19 07:35:49 +00:00
std : : string Gnss_Satellite : : get_block ( ) const
2012-01-16 22:01:29 +00:00
{
// Get the satellite block
std : : string block_ ;
block_ = block ;
return block_ ;
}
2014-09-14 17:08:32 +00:00
void Gnss_Satellite : : set_block ( const std : : string & system_ , unsigned int PRN_ )
2012-01-16 22:01:29 +00:00
{
if ( system_ . compare ( " GPS " ) = = 0 )
{
switch ( PRN_ )
{
// info from http://www.navcen.uscg.gov/?Do=constellationStatus
case 1 :
block = std : : string ( " IIF " ) ; //Plane D
break ;
case 2 :
block = std : : string ( " IIR " ) ; //Plane D
break ;
case 3 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIF " ) ; //Plane E
2012-01-16 22:01:29 +00:00
break ;
case 4 :
block = std : : string ( " IIA " ) ; //Plane D
break ;
case 5 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIR-M " ) ; //Plane E
2012-01-16 22:01:29 +00:00
break ;
case 6 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIF " ) ; //Plane D
2012-01-16 22:01:29 +00:00
break ;
case 7 :
block = std : : string ( " IIR-M " ) ; //Plane A
break ;
case 8 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " UNKNOWN " ) ; // Decommissioned
2012-01-16 22:01:29 +00:00
break ;
case 9 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIF " ) ; //Plane F
2012-01-16 22:01:29 +00:00
break ;
case 10 :
block = std : : string ( " IIA " ) ; //Plane E
break ;
case 11 :
block = std : : string ( " IIR " ) ; //Plane D
break ;
case 12 :
block = std : : string ( " IIR-M " ) ; //Plane B
break ;
case 13 :
block = std : : string ( " IIR " ) ; //Plane F
break ;
case 14 :
block = std : : string ( " IIR " ) ; //Plane F
break ;
case 15 :
block = std : : string ( " IIR-M " ) ; //Plane F
break ;
case 16 :
block = std : : string ( " IIR " ) ; //Plane B
break ;
case 17 :
block = std : : string ( " IIR-M " ) ; //Plane C
break ;
case 18 :
block = std : : string ( " IIR " ) ; //Plane E
break ;
case 19 :
block = std : : string ( " IIR " ) ; //Plane D
break ;
case 20 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIR " ) ; //Plane B
2012-01-16 22:01:29 +00:00
break ;
case 21 :
block = std : : string ( " IIR " ) ; //Plane D
break ;
case 22 :
block = std : : string ( " IIR " ) ; //Plane E
break ;
case 23 :
block = std : : string ( " IIR " ) ; //Plane F
break ;
case 24 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIF " ) ; //Plane A
2012-01-16 22:01:29 +00:00
break ;
case 25 :
block = std : : string ( " IIF " ) ; //Plane B
break ;
case 26 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIF " ) ; //Plane B
2012-01-16 22:01:29 +00:00
break ;
case 27 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIF " ) ; //Plane C
2012-01-16 22:01:29 +00:00
break ;
case 28 :
block = std : : string ( " IIR " ) ; //Plane B
break ;
case 29 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIR-M " ) ; //Plane C
2012-01-16 22:01:29 +00:00
break ;
case 30 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IIF " ) ; //Plane A
2012-01-16 22:01:29 +00:00
break ;
case 31 :
block = std : : string ( " IIR-M " ) ; //Plane A
break ;
case 32 :
block = std : : string ( " IIA " ) ; //Plane E
break ;
default :
block = std : : string ( " Unknown " ) ;
}
}
if ( system_ . compare ( " Glonass " ) = = 0 )
{
switch ( PRN_ )
{
// info from http://www.sdcm.ru/smglo/grupglo?version=eng&site=extern
2012-01-19 07:35:49 +00:00
// See also http://www.glonass-center.ru/en/GLONASS/
2012-01-16 22:01:29 +00:00
case 1 :
block = std : : string ( " 1 " ) ; //Plane 1
2012-01-19 07:35:49 +00:00
rf_link = 1 ;
2012-01-16 22:01:29 +00:00
break ;
case 2 :
block = std : : string ( " -4 " ) ; //Plane 1
2012-01-19 07:35:49 +00:00
rf_link = - 4 ;
2012-01-16 22:01:29 +00:00
break ;
case 3 :
block = std : : string ( " 5 " ) ; //Plane 1
2012-01-19 07:35:49 +00:00
rf_link = 5 ;
2012-01-16 22:01:29 +00:00
break ;
case 4 :
block = std : : string ( " 6 " ) ; //Plane 1
2012-01-19 07:35:49 +00:00
rf_link = 6 ;
2012-01-16 22:01:29 +00:00
break ;
case 5 :
block = std : : string ( " 1 " ) ; //Plane 1
2012-01-19 07:35:49 +00:00
rf_link = 1 ;
2012-01-16 22:01:29 +00:00
break ;
case 6 :
block = std : : string ( " -4 " ) ; //Plane 1
2012-01-19 07:35:49 +00:00
rf_link = - 4 ;
2012-01-16 22:01:29 +00:00
break ;
case 7 :
block = std : : string ( " 5 " ) ; //Plane 1
2012-01-19 07:35:49 +00:00
rf_link = 5 ;
2012-01-16 22:01:29 +00:00
break ;
case 8 :
block = std : : string ( " 6 " ) ; //Plane 1
2012-01-19 07:35:49 +00:00
rf_link = 6 ;
2012-01-16 22:01:29 +00:00
break ;
case 9 :
block = std : : string ( " -2 " ) ; //Plane 2
2012-01-19 07:35:49 +00:00
rf_link = - 2 ;
2012-01-16 22:01:29 +00:00
break ;
case 10 :
block = std : : string ( " -7 " ) ; //Plane 2
2012-01-19 07:35:49 +00:00
rf_link = - 7 ;
2012-01-16 22:01:29 +00:00
break ;
case 11 :
block = std : : string ( " 0 " ) ; //Plane 2
2012-01-19 07:35:49 +00:00
rf_link = 0 ;
2012-01-16 22:01:29 +00:00
break ;
case 12 :
block = std : : string ( " -1 " ) ; //Plane 2
2012-01-19 07:35:49 +00:00
rf_link = - 1 ;
2012-01-16 22:01:29 +00:00
break ;
case 13 :
block = std : : string ( " -2 " ) ; //Plane 2
2012-01-19 07:35:49 +00:00
rf_link = - 2 ;
2012-01-16 22:01:29 +00:00
break ;
case 14 :
block = std : : string ( " -7 " ) ; //Plane 2
2012-01-19 07:35:49 +00:00
rf_link = - 7 ;
2012-01-16 22:01:29 +00:00
break ;
case 15 :
block = std : : string ( " 0 " ) ; //Plane 2
2012-01-19 07:35:49 +00:00
rf_link = 0 ;
2012-01-16 22:01:29 +00:00
break ;
case 16 :
block = std : : string ( " -1 " ) ; //Plane 2
2012-01-19 07:35:49 +00:00
rf_link = - 1 ;
2012-01-16 22:01:29 +00:00
break ;
case 17 :
block = std : : string ( " 4 " ) ; //Plane 3
2012-01-19 07:35:49 +00:00
rf_link = 4 ;
2012-01-16 22:01:29 +00:00
break ;
case 18 :
block = std : : string ( " -3 " ) ; //Plane 3
2012-01-19 07:35:49 +00:00
rf_link = - 3 ;
2012-01-16 22:01:29 +00:00
break ;
case 19 :
block = std : : string ( " 3 " ) ; //Plane 3
2012-01-19 07:35:49 +00:00
rf_link = 3 ;
2012-01-16 22:01:29 +00:00
break ;
case 20 :
block = std : : string ( " 2 " ) ; //Plane 3
2012-01-19 07:35:49 +00:00
rf_link = 2 ;
2012-01-16 22:01:29 +00:00
break ;
case 21 :
block = std : : string ( " 4 " ) ; //Plane 3
2012-01-19 07:35:49 +00:00
rf_link = 4 ;
2012-01-16 22:01:29 +00:00
break ;
case 22 :
block = std : : string ( " -3 " ) ; //Plane 3
2012-01-19 07:35:49 +00:00
rf_link = - 3 ;
2012-01-16 22:01:29 +00:00
break ;
case 23 :
block = std : : string ( " 3 " ) ; //Plane 3
2012-01-19 07:35:49 +00:00
rf_link = 3 ;
2012-01-16 22:01:29 +00:00
break ;
case 24 :
block = std : : string ( " 2 " ) ; //Plane 3
2012-01-19 07:35:49 +00:00
rf_link = 2 ;
2012-01-16 22:01:29 +00:00
break ;
default :
block = std : : string ( " Unknown " ) ;
}
}
if ( system_ . compare ( " SBAS " ) = = 0 )
{
switch ( PRN_ )
{
case 122 :
block = std : : string ( " WAAS " ) ; // WAAS Inmarsat 3F4 (AOR-W)
break ;
case 134 :
block = std : : string ( " WAAS " ) ; // WAAS Inmarsat 3F3 (POR)
break ;
case 120 :
block = std : : string ( " EGNOS " ) ; // EGNOS AOR-E Broadcast satellite http://www.egnos-pro.esa.int/index.html
2012-01-31 00:03:08 +00:00
break ;
2012-01-16 22:01:29 +00:00
case 124 :
block = std : : string ( " EGNOS " ) ; // EGNOS ESA ARTEMIS used for EGNOS Operations
break ;
case 126 :
block = std : : string ( " EGNOS " ) ; // EGNOS IOR-W currently used by Industry to perform various tests on the system.
break ;
default :
block = std : : string ( " Unknown " ) ;
}
}
if ( system_ . compare ( " Galileo " ) = = 0 )
{
2015-05-16 09:53:44 +00:00
// Check http://en.wikipedia.org/wiki/List_of_Galileo_satellites
2012-01-16 22:01:29 +00:00
switch ( PRN_ )
{
case 11 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IOV-PFM " ) ; // PFM, the ProtoFlight Model (GSAT0101), launched from French Guiana at 10:30 GMT on October 21, 2011
2012-01-16 22:01:29 +00:00
break ;
2012-01-19 07:35:49 +00:00
case 12 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IOV-FM2 " ) ; // Galileo In-Orbit Validation (IOV) satellite FM2 (Flight Model 2) also known as GSAT0102, from French Guiana at 10:30 GMT on October 21, 2011
2012-01-31 00:03:08 +00:00
break ;
2013-01-28 23:50:09 +00:00
case 19 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IOV-FM3 " ) ; // Galileo In-Orbit Validation (IOV) satellite FM3 (Flight Model 3), launched on October 12, 2012
2013-01-28 23:50:09 +00:00
break ;
case 20 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " IOV-FM4 " ) ; // Galileo In-Orbit Validation (IOV) satellite FM4 (Flight Model 4), launched on October 12, 2012. Unavailable.
2014-12-03 23:58:58 +00:00
break ;
case 18 :
2015-05-16 09:53:44 +00:00
block = std : : string ( " FOC-FM1 " ) ; // Galileo Full Operational Capability (FOC) satellite FM1, launched into incorrect orbit on August 22, 2014.
break ;
case 14 :
block = std : : string ( " FOC-FM2 " ) ; // Galileo Full Operational Capability (FOC) satellite FM2, launched into incorrect orbit on August 22, 2014.
break ;
case 26 :
block = std : : string ( " FOC-FM3 " ) ; // Galileo Full Operational Capability (FOC) satellite FM3, launched on March 27, 2015.
break ;
case 22 :
block = std : : string ( " FOC-FM4 " ) ; // Galileo Full Operational Capability (FOC) satellite FM4, launched on March 27, 2015.
2013-01-28 23:50:09 +00:00
break ;
2012-01-16 22:01:29 +00:00
default :
2013-10-25 16:07:24 +00:00
block = std : : string ( " Unknown(Simulated) " ) ;
2012-01-16 22:01:29 +00:00
}
}
}