Esempio n. 1
0
VALUE unload(int argc, VALUE *argv, VALUE self) {
  sigset_t old_mask = block_signals();

  unload_c(StringValuePtr(argv[0]));
  
  restore_signals(old_mask);
  
  if(spice_error(SHORT)) return Qfalse;

  return Qtrue;
}
Esempio n. 2
0
static VALUE unload(VALUE self, VALUE kernel) {
  sigset_t old_mask = block_signals();

  unload_c(StringValuePtr(kernel));
  
  restore_signals(old_mask);
  
  if(spice_error(SPICE_ERROR_SHORT)) return Qfalse;

  return Qtrue;
}
Esempio n. 3
0
 /**
  * @brief Unloads all kernels if they were loaded when found
  */
 void Kernels::Unload() {
     if (_furnish) {
        for (unsigned int i = 0 ; i < _kernels.size() ; i++) {
          KernelFiles kfiles = _kernels[i].getNames();
          for (unsigned int k = 0 ; k < kfiles.size() ; k++) {
            Filename f(kfiles[k]); 
            string kernName(f.Expanded());
            unload_c(kernName.c_str());
          }
        }
     }
     return;
 }
Esempio n. 4
0
 /**
  * Destroys the Spice object
  */
  Spice::~Spice () {
    NaifStatus::CheckErrors();

    if (p_bodyRotation != 0) delete p_bodyRotation;
    if (p_instrumentRotation != 0) delete p_instrumentRotation;
    if (p_instrumentPosition != 0) delete p_instrumentPosition;
    if (p_sunPosition != 0) delete p_sunPosition;

    // Unload the kernels (TODO: Can this be done faster)
    for (unsigned int i=0; i<p_kernels.size(); i++) {
      Isis::Filename file(p_kernels[i]);
      string fileName(file.Expanded());
      unload_c(fileName.c_str());
    }

    NaifStatus::CheckErrors();
  }
Esempio n. 5
0
 /**
  * @brief Unloads a kernel from the NAIF kernel pool
  *
  * This method will unload a NAIF kernel from the kernel pool.  If the
  * internal load state does not indicate it is loaded, there will be no
  * activity performed.
  *
  * The file must also be tagged as manageable by this object.  Certain
  * conditions will affect the manageability of a NAIF kernel in this object.
  * See the class documentation for details.  In the situation of the file
  * being tagged as unmanageable, the load state never changes.  Use
  * UpdateLoadStatus() to determine its true load state.
  *
  * There is good chance that a NAIF kernel may no longer be loaded in the
  * pool.  This is particularly a real possibility as a side effect of this
  * class.  Errors are, therefore, ignored when encountered attempting to
  * unload a kernel file.  The state is then set to a unloaded condition.
  *
  * @param kfile
  *
  * @return bool
  */
 bool Kernels::UnLoad(KernelFile &kfile) {
   //  If its loaded assume its a loaded NAIF kernel and unload it
   bool wasLoaded(false);
   if (kfile.loaded) {
     if (kfile.managed) {
        NaifStatus::CheckErrors();
        try {
          unload_c(kfile.fullpath.toAscii().data());
          NaifStatus::CheckErrors();
        }
        catch (IException &) {
          // Errors are trapped and ignored.  It may be unloaded by other source
        }
        kfile.loaded = false;
        wasLoaded = true;
     }
   }
   return (wasLoaded);
 }
Esempio n. 6
0
 /**
  * This method creates an internal cache of spacecraft and sun positions over a
  * specified time range. The SPICE kernels are then immediately unloaded. This
  * allows multiple instances of the Spice object to be created as the NAIF
  * toolkit can clash if multiple sets of SPICE kernels are loaded. Note that
  * the cache size is specified as an argument. Therefore, times requested via
  * SetEphemerisTime which are not directly loaded in the cache will be
  * interpolated.
  *
  * @param startTime Starting ephemeris time to cache
  *
  * @param endTime Ending ephemeris time to cache
  *
  * @param size Size of the cache.
  *
  * @throws Isis::iException::Programmer
  */
  void Spice::CreateCache (double startTime, double endTime, int cacheSize, double tol) {
    NaifStatus::CheckErrors();

    // Check for errors
    if (cacheSize <= 0) {
      string msg = "Argument cacheSize must be greater than zero";
      throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_);
    }

    if (startTime > endTime) {
      string msg = "Argument startTime must be less than or equal to endTime";
      throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_);
    }

    if (p_cacheSize > 0) {
      string msg = "A cache has already been created";
      throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_);
    }

    if(cacheSize == 1 && (p_startTimePadding != 0 || p_endTimePadding != 0)) {
      string msg = "This instrument does not support time padding";
      throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_);
    }

    double avgTime = (startTime + endTime) / 2.0;
    ComputeSolarLongitude(avgTime);

    // Cache everything
    if (!p_bodyRotation->IsCached()) {
      int bodyRotationCacheSize = cacheSize;
      if (cacheSize > 2) bodyRotationCacheSize = 2;
      p_bodyRotation->LoadCache(startTime-p_startTimePadding, endTime+p_endTimePadding, bodyRotationCacheSize);
    }

    if (p_instrumentRotation->GetSource() < SpiceRotation::Memcache) {
      if (cacheSize > 3) p_instrumentRotation->MinimizeCache( SpiceRotation::Yes );
      p_instrumentRotation->LoadCache(startTime-p_startTimePadding, endTime+p_endTimePadding, cacheSize);
    }

    if (!p_instrumentPosition->IsCached()) {
      p_instrumentPosition->LoadCache(startTime-p_startTimePadding, endTime+p_endTimePadding, cacheSize);
      if (cacheSize > 3) p_instrumentPosition->Memcache2HermiteCache(tol);
    }

    if (!p_sunPosition->IsCached()) {
      int sunPositionCacheSize = cacheSize;
      if (cacheSize > 2) sunPositionCacheSize = 2;
      p_sunPosition->LoadCache(startTime-p_startTimePadding, endTime+p_endTimePadding, sunPositionCacheSize);
    }

    // Save the time and cache size
    p_startTime = startTime;
    p_endTime = endTime;
    p_cacheSize = cacheSize;
    p_et = -DBL_MAX;

    // Unload the kernels (TODO: Can this be done faster)
    for (unsigned int i=0; i<p_kernels.size(); i++) {
      Isis::Filename file(p_kernels[i]);
      string fileName(file.Expanded());
      unload_c(fileName.c_str());
    }
    p_kernels.clear();

    NaifStatus::CheckErrors();
  }