示例#1
0
    void SpicePosition::init() {
        erract_c("SET", 0, (char*)"IGNORE");

        const char * k = "../cfg/kernels.furnsh";
        furnsh_c(k);

        std::vector<std::string> ks;
        kernels(ks);

        for (std::vector<std::string>::iterator i = ks.begin(); i != ks.end(); i++) {
            getbodies(*i);
        }



        for (BodyConstantsConstIterator it = m_bodies.begin(); it != m_bodies.end(); it++) {
            EphemeridesInterval & interval = m_intervals[(*it)->id()];
            getinterval(ks, (*it)->id(), interval);

            if (it == m_bodies.begin()) {
                m_interval.a = interval.a;
                m_interval.b = interval.b;
            } else {
                m_interval.a = std::max(m_interval.a, interval.a);
                m_interval.b = std::min(m_interval.b, interval.b);
            }
        }

        m_interval.a += 100;
        m_interval.b -= 100;

        char timea[1000], timeb[1000];

        timout_c (m_interval.a, "YYYY ::TDB", sizeof(timea), timea);
        timout_c (m_interval.b, "YYYY ::TDB", sizeof(timeb), timeb);

        erract_c("SET", 0, (char*)"DEFAULT");
    }
示例#2
0
/** \param[in] mu_central_body gravitational parameter of the central attracting body [m^3/sec^2]
 * \param[in] mu_self gravitational parameter of the body [m^3/sec^2]
 * \param[in] radius body radius [m]
 * \param[in] safe_radius body safe radius [m]
 * \param[in] name body name
*/
spice::spice(const std::string & target, 
	const std::string & observer, 
	const std::string & reference_frame, 
	const std::string & aberrations,
	double mu_central_body, 
	double mu_self, 
	double radius, 
	double safe_radius  
	) : base(mu_central_body, mu_self, radius, safe_radius, target + ", " + observer + ", " + reference_frame), 
	m_target(target), 
	m_observer(observer), 
	m_reference_frame(reference_frame), 
	m_aberrations(aberrations)
{	
	/// Transferring error handling from SPICE to kep_toolbox
	erract_c("SET",0,const_cast<char*>("RETURN") ) ;
}
示例#3
0
  /** 
   * This method looks for any naif errors that might have occurred. It 
   * then compares the error to a list of known naif errors and converts
   * the error into an iException.
   * 
   * @param resetNaif True if the NAIF error status should be reset (naif calls valid)
   */
  void NaifStatus::CheckErrors(bool resetNaif) {
    if(!initialized) {
      SpiceChar returnAct[32] = "RETURN";
      SpiceChar printAct[32] = "NONE";
      erract_c ( "SET", sizeof(returnAct), returnAct); // Reset action to return
      errprt_c ( "SET", sizeof(printAct), printAct);   // ... and print nothing
      initialized = true;
    }

    // Do nothing if NAIF didn't fail
    //getmsg_c("", 0, NULL);
    if(!failed_c()) return;

    // This method has been documented with the information provided
    //   from the NAIF documentation at:
    //    naif/cspice61/packages/cspice/doc/html/req/error.html


    // This message is a character string containing a very terse, usually 
    // abbreviated, description of the problem. The message is a character 
    // string of length not more than 25 characters. It always has the form:
    // SPICE(...)
    // Short error messages used in CSPICE are CONSTANT, since they are 
    // intended to be used in code. That is, they don't contain any data which 
    // varies with the specific instance of the error they indicate.
    // Because of the brief format of the short error messages, it is practical 
    // to use them in a test to determine which type of error has occurred. 
    const int SHORT_DESC_LEN = 26;
    SpiceChar naifShort[SHORT_DESC_LEN];
    getmsg_c("SHORT", SHORT_DESC_LEN, naifShort);

    // This message may be up to 1840 characters long. The CSPICE error handling 
    // mechanism makes no use of its contents. Its purpose is to provide human-readable 
    // information about errors. Long error messages generated by CSPICE routines often 
    // contain data relevant to the specific error they describe.
    const int LONG_DESC_LEN = 1841;
    SpiceChar naifLong[LONG_DESC_LEN];
    getmsg_c("LONG", LONG_DESC_LEN, naifLong);

    // Search for known naif errors...
    iString errMsg;

    Pvl error;
    PvlGroup errorDescription("ErrorDescription");
    errorDescription.AddKeyword(PvlKeyword("ShortMessage", naifShort));
    errorDescription.AddKeyword(PvlKeyword("LongMessage", naifLong));
    error.AddGroup(errorDescription);

    PvlTranslationManager trans(error, "$base/translations/NaifErrors.trn");

    try {
      errMsg = trans.Translate("ShortMessage");
    }
    catch(iException &e) {
      e.Clear();
      errMsg = "An unknown NAIF error has been encountered.";
    }

    try {
      errMsg += " " + trans.Translate("LongMessage");
    }
    catch(iException &e) {
      e.Clear();
    }

    // Now process the error
    if(resetNaif) {
      reset_c();
    }

    errMsg += " The short explanation ";
    errMsg += "provided by NAIF is [" + iString(naifShort) + "]. "; 
    errMsg += "The Naif error is [" + iString(naifLong) + "]";

    throw iException::Message(iException::Spice, errMsg, _FILEINFO_);
  }
示例#4
0
void zzerrorinit(void)

/*

-Brief_I/O

   None.

-Detailed_Input

   None.

-Detailed_Output

   None.

-Parameters

   None.

-Exceptions

   None.

-Files

   None.

-Particulars

   Initializes the error subsystem to the "RETURN" state, sets
   the error output device to NULL (no output).

   Call this routine prior to calling zzerror.

-Examples

   Expected use, check failed, return the error string:
   
      /.
      Initialize the error system to RETURN/NULL
      ./
      zzerrorinit();

         ... CSPICE calls ...
   
      /.
      Check for a failure, return the error string if
      failed_c returns true.
      ./ 
      if( failed_c() )
         {
         error_str = zzerror( index );
         
         /.
         Return the error string traceback to
         the calling program.
         ./
         error_return( error_str );
         }

-Restrictions

   None.

-Literature_References

   None.

-Author_and_Institution

   E. D. Wright    (JPL)

-Version

   CSPICE 1.0.0 17-OCT-2005 (EDW)

      Initial release to CSPICE

-Index_Entries

   set error system return mode

-&
*/
   {
    
   static SpiceBoolean     first = SPICETRUE;

   /*
   Prevent repeated executions of code with the 'first' flag.
   */
   if ( first )
      {

      /*
      Explicitly set the error subsystem to return mode, the 
      error output device to NULL.
      */

      erract_c("SET", (SpiceInt) sizeof("RETURN"), "RETURN");
      errdev_c("SET", (SpiceInt) sizeof("NULL")  , "NULL"  );

      }

   }