sem.h

Go to the documentation of this file.
00001 /**
00002 \file    sem.h
00003 \brief   GNSS core 'c' function library: SEM format almanacs.
00004 \author  Glenn D. MacGougan (GDM)
00005 \date    2006-11-10
00006 \since   2005-08-14
00007 
00008 \b "LICENSE INFORMATION" \n
00009 Copyright (c) 2007, refer to 'author' doxygen tags \n
00010 All rights reserved. \n
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided the following conditions are met: \n
00014 
00015 - Redistributions of source code must retain the above copyright
00016   notice, this list of conditions and the following disclaimer. \n
00017 - Redistributions in binary form must reproduce the above copyright
00018   notice, this list of conditions and the following disclaimer in the
00019   documentation and/or other materials provided with the distribution. \n
00020 - The name(s) of the contributor(s) may not be used to endorse or promote 
00021   products derived from this software without specific prior written 
00022   permission. \n
00023 
00024 THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS 
00025 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
00026 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027 DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
00028 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00029 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00030 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
00031 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00032 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
00033 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
00034 SUCH DAMAGE.
00035 */
00036 
00037 #ifndef _C_SEM_H_
00038 #define _C_SEM_H_
00039 
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043 
00044 #include "basictypes.h"
00045 
00046 
00047 /// \brief  A limited set of satellite orbit parameters that is used to 
00048 ///         calculate GPS satellite positions and velocities. In the 
00049 ///         ephemeris structure below, the parameters for computing 
00050 ///         satellite clock corrections are also included.
00051 /// 
00052 /// \author   Glenn D. MacGougan (GDM)
00053 /// \date     2006-11-10
00054 /// \since    2005-08-15
00055 /// 
00056 /// \remarks
00057 /// (1) Struct packaging: compatible with 4 and 8 byte packing \n
00058 /// (2) The af0 and af1 parameters are typically from low precision sources like the true broadcast
00059 ///     GPS almanacs. The af0 and af1 parameters are preferred from ephemeris download as they have
00060 ///     higher precision. \n
00061 /// 
00062 /// \b REFERENCES \n
00063 /// [1] http://www.navcen.uscg.gov/gps/almanacs.htm
00064 /// 
00065 typedef struct
00066 {
00067   unsigned       toa;                        //!< almanac time of applicability (reference time)               [s]
00068   unsigned short week;                       //!< 10 bit gps week 0-1023 (user must account for week rollover) [week]    
00069   unsigned short prn;                        //!< GPS prn number                                               []  
00070   unsigned short reserved;                   //!< reserved
00071   unsigned short svn;                        //!< Satellite vehicle number                                     []
00072   unsigned char  ura;                        //!< User Range Accuracy lookup code,                             [0-15], see p. 83 GPSICD200C, 0 is excellent, 15 is use at own risk
00073   unsigned char  health;                     //!< 0=healthy, unhealthy otherwise                               [], subframe 4 and 5, page 25 six-bit health code
00074   unsigned char  config_code;                //!< configuration code                                           [], if >=9 Anti-Spoofing is on
00075   
00076   // this inicator is not part of the SEM standard but is added by the user if known
00077   unsigned char  is_af0_af1_high_precision;  //!< indicates precision of af0 and af1 [1=high precision,0=low precision] (22&16 bits, ephemeris source) vs (11&11 bits, almanac source), 0 is typical for most SEM sources
00078     
00079   double ecc;      //!< eccentricity                                                 []
00080   double i0;       //!< orbital inclination at reference time                        [rad]
00081   double omegadot; //!< rate of right ascension                                      [rad/s]
00082   double sqrta;    //!< square root of the semi-major axis                           [m^(1/2)]
00083   double omega0;   //!< longitude of ascending node of orbit plane at weekly epoch   [rad]
00084   double w;        //!< argument of perigee                                          [rad]
00085   double m0;       //!< mean anomaly at reference time                               [rad]
00086   double af0;      //!< polynomial clock correction coefficient (clock bias)         [s],   Note: parameters from ephemeris preferred vs almanac (22 vs 11 bits)
00087   double af1;      //!< polynomial clock correction coefficient (clock drift)        [s/s], Note: parameters from ephemeris preferred vs almanac (16 vs 11 bits)
00088     
00089 } SEM_structAlmanac;  
00090   
00091 
00092 /// Load an array of SEM format almanac structs from the ASCII file path specified.
00093 ///   
00094 /// \author   Glenn D. MacGougan (GDM)
00095 /// \date     2006-11-10
00096 /// \since    2005-08-14
00097 /// \return   TRUE(1) if successful, FALSE(0) otherwise
00098 /// 
00099 BOOL SEM_ReadAlmanacDataFromFile(
00100   const char* semFilePath,    //!< path to the input SEM ASCII file
00101   SEM_structAlmanac* alm,     //!< pointer to an array of SEM almanac structs
00102   unsigned char  max_to_read, //!< length of the array
00103   unsigned char* number_read  //!< number of almanac items read
00104   );
00105 
00106 
00107 /// Write an array of SEM format almanac structs to the ASCII file path specified.
00108 ///   
00109 /// \author   Glenn D. MacGougan (GDM)
00110 /// \date     2006-11-10
00111 /// \since    2005-08-15
00112 /// \return   TRUE(1) if successful, FALSE(0) otherwise
00113 /// 
00114 BOOL SEM_WriteAlmanacDataToFile(
00115   const char* semFilePath,       //!< path to the output SEM ASCII file
00116   SEM_structAlmanac* alm,        //!< pointer to an array of SEM almanac structs
00117   unsigned char number_to_write  //!< length of the array
00118   );
00119 
00120 
00121 /// Print a SEM format almanac struct to buffer supplied.
00122 ///   
00123 /// \author   Glenn D. MacGougan (GDM)
00124 /// \date     2006-11-10
00125 /// \since    2005-08-15
00126 /// \return   TRUE(1) if successful, FALSE(0) otherwise
00127 /// 
00128 BOOL SEM_WriteSingleAlmanacElementToBuffer(
00129   SEM_structAlmanac alm,    //!< SEM almanac struct
00130   char* buffer,              //!< buffer to write the SEM struct information
00131   unsigned short bufferSize  //!< size of the buffer, must be greater than 1024 bytes
00132   );
00133 
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137 
00138 
00139 #endif // _C_SEM_H_