yuma.h

Go to the documentation of this file.
00001 /**
00002 \file    yuma.h
00003 \brief   GNSS core 'c' function library: YUMA format almanacs.
00004 \author  Glenn D. MacGougan (GDM)
00005 \date    2007-11-29
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_YUMA_H_
00038 #define _C_YUMA_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 calculate GPS satellite 
00048 /// positions and velocities. In the ephemeris structure below, the parameters for computing 
00049 /// satellite clock corrections are also included.
00050 /// 
00051 /// \author   Glenn D. MacGougan (GDM)
00052 /// \date     2005-08-14
00053 /// \since    2005-08-14
00054 /// 
00055 /// \remarks
00056 /// (1) Struct packaging: compatible with 4 and 8 byte packing \n
00057 /// (2) The af0 and af1 parameters are typically from low precision sources like the true broadcast
00058 ///     GPS almanacs. The af0 and af1 parameters are preferred from ephemeris download as they have
00059 ///     higher precision. \n
00060 /// 
00061 /// \b REFERENCES \n
00062 /// [1] http://www.navcen.uscg.gov/gps/almanacs.htm \n
00063 /// 
00064 typedef struct
00065 {
00066   unsigned short    reserved1;       //!< reserved
00067   unsigned short    week;            //!< 10 bit gps week 0-1023 (user must account for week rollover) [week]    
00068   unsigned short    prn;             //!< GPS prn number                                               []
00069   unsigned char     health;          //!< 0=healthy, unhealthy otherwise                               []
00070   
00071   /// This indicates precision of af0 and af1.
00072   /// [1=high precision,0=low precision] (22&16 bits, ephemeris source) vs (11&11 bits, almanac source)
00073   /// 0 is typical for most YUMA sources.
00074   /// This inicator is not part of the standard but is added by the user if known.
00075   unsigned char     is_af0_af1_high_precision;
00076   
00077   double ecc;                        //!< eccentricity                                                 []
00078   double toa;                        //!< time of applicability                                        [s]
00079   double i0;                         //!< orbital inclination at reference time                        [rad]
00080   double omegadot;                   //!< rate of right ascension                                      [rad/s]
00081   double sqrta;                      //!< square root of the semi-major axis                           [m^(1/2)]
00082   double omega0;                     //!< longitude of ascending node of orbit plane at weekly epoch   [rad]
00083   double w;                          //!< argument of perigee                                          [rad]
00084   double m0;                         //!< mean anomaly at reference time                               [rad]
00085   double af0;                        //!< polynomial clock correction coefficient (clock bias)         [s],   Note: parameters from ephemeris preferred vs almanac (22 vs 11 bits)
00086   double af1;                        //!< polynomial clock correction coefficient (clock drift)        [s/s], Note: parameters from ephemeris preferred vs almanac (16 vs 11 bits)
00087 
00088 } YUMA_structAlmanac;  
00089   
00090 
00091 /// \brief    Load an array of YUMA format almanac structs from the ASCII file path specified.
00092 ///   
00093 /// \author   Glenn D. MacGougan (GDM)
00094 /// \date     2005-08-14
00095 /// \since    2005-08-14
00096 /// \return   TRUE(1) if successful, FALSE(0) otherwise
00097 /// 
00098 BOOL YUMA_ReadAlmanacDataFromFile(
00099   const char* yumaFilePath,   //!< path to the input YUMA ASCII file
00100   YUMA_structAlmanac* alm,    //!< pointer to an array of YUMA almanac structs
00101   unsigned char  max_to_read, //!< length of the array
00102   unsigned char* number_read  //!< number of almanac items read
00103   );
00104 
00105 
00106 /// \brief    Write an array of YUMA format almanac structs to the ASCII file path specified.
00107 ///   
00108 /// \author   Glenn D. MacGougan (GDM)
00109 /// \date     2005-08-14
00110 /// \since    2005-08-14
00111 /// \return   TRUE(1) if successful, FALSE(0) otherwise
00112 /// 
00113 BOOL YUMA_WriteAlmanacDataToFile(
00114   const char* yumaFilePath,      //!< path to the output YUMA ASCII file
00115   YUMA_structAlmanac* alm,       //!< pointer to an array of YUMA almanac structs
00116   unsigned char number_to_write  //!< length of the array
00117   );
00118 
00119 
00120 /// \brief    Print a YUMA format almanac struct to buffer supplied.
00121 ///   
00122 /// \author   Glenn D. MacGougan (GDM)
00123 /// \date     2005-08-15
00124 /// \since    2005-08-15
00125 /// \return   TRUE(1) if successful, FALSE(0) otherwise
00126 /// 
00127 BOOL YUMA_WriteSingleAlmanacElementToBuffer(
00128   YUMA_structAlmanac alm,   //!< YUMA almanac struct
00129   char* buffer,             //!< buffer to write the YUMA struct information
00130   unsigned short bufferSize //!< size of the buffer, must be greater than 1024 bytes
00131   );
00132 
00133 #ifdef __cplusplus
00134 }
00135 #endif
00136 
00137 
00138 #endif // _C_YUMA_H_