Esempio n. 1
0
void ConfigManager::debugDumpPending(int debug_level)
{
   vprASSERT(1 == mPendingLock.test());
   vprDEBUG(vprDBG_ALL,debug_level)
      << clrSetNORM(clrGREEN)
      << "---- Pending list: " << mPendingConfig.size() << " items ----\n"
      << clrRESET << vprDEBUG_FLUSH;
   std::list<ConfigManager::PendingElement>::iterator current, end;
   current = getPendingBegin();
   end = getPendingEnd();

   while ( current != end )
   {
      ConfigElementPtr cur_element = (*current).mElement;

      if ( (*current).mType == PendingElement::ADD )
      {
         vprDEBUG_NEXT(vprDBG_ALL,debug_level) << "   ADD -->" << vprDEBUG_FLUSH;
      }
      else if ( (*current).mType == PendingElement::REMOVE )
      {
         vprDEBUG_NEXT(vprDBG_ALL,debug_level) << "REMOVE -->" << vprDEBUG_FLUSH;
      }

      vprDEBUG_CONT(vprDBG_ALL,debug_level)
         << cur_element->getName() << " type: " << cur_element->getID()
         << std::endl << vprDEBUG_FLUSH;
      current++;
   }
   vprDEBUG_NEXT(vprDBG_ALL,debug_level)
      << "----------------------------------\n" << vprDEBUG_FLUSH;
}
Esempio n. 2
0
// Sample data.
bool MotionStar::sample()
{
   bool retval;
   std::vector< gadget::PositionData > cur_samples(mMotionStar.getNumSensors());

   retval = false;

   if ( isActive() == false )
   {
      vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
         << clrSetNORM(clrRED) << "MotionStar ("
         << getAddressName() << ") NOT ACTIVE IN SAMPLE\n"
         << clrRESET << vprDEBUG_FLUSH;
   }
   else
   {
      try
      {
         mMotionStar.sample();

         // get an initial timestamp for this entire sample. we'll copy it into
         // each PositionData for this sample.
         if ( ! cur_samples.empty() )
         {
            cur_samples[0].setTime();

            // For each bird
            for ( unsigned int i = 0; i < mMotionStar.getNumSensors(); ++i )
            {
               // Get the index to the current read buffer
               cur_samples[i].setTime( cur_samples[0].getTime() );
               cur_samples[i].mPosData = mMotionStar.getDeviceData(i);
            }
         }

         // Add the current data as a sample
         addPositionSample(cur_samples);

         retval = true;
      }
      catch (...)
      {
         vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
            << clrOutNORM(clrRED, "gadget::MotionStar::sample() caught unknown exception")
            << std::endl << vprDEBUG_FLUSH;
         retval = false;
      }
   }

   return retval;
}
/// dumps the object's internal state
void D3dDrawManager::outStream(std::ostream& out)
{
   out << clrSetNORM(clrGREEN)
       << "========== D3dDrawManager: " << (void*)this << " ========="
       << clrRESET << std::endl
       << clrOutNORM(clrCYAN,"\tapp: ") << (void*)mApp << std::endl
       << clrOutNORM(clrCYAN,"\tWindow count: ") << mOpenWins.size()
       << std::endl << std::flush;

   for (unsigned int i = 0; i < mOpenWins.size(); i++)
   {
      vprASSERT(mOpenWins[i] != NULL);
      out << clrOutNORM(clrCYAN,"\tD3dWindow:\n") << *(mOpenWins[i]) << std::endl;
   }
   out << "=======================================" << std::endl;
}
Esempio n. 4
0
// Update to the sampled data.
void MotionStar::updateData()
{
   // If the device is not active, we cannot update the data.
   if ( isActive() == false )
   {
      vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
         << clrSetNORM(clrRED) << "MotionStar ("
         << getAddressName()
         << ") not active in updateData()\n" << clrRESET
         << vprDEBUG_FLUSH;
   }
   // Otherwise, go through with the update.
   else
   {
      swapPositionBuffers();
   }
}
Esempio n. 5
0
void ConfigManager::loadRemoteReconfig()
{
   vprASSERT(NULL == mReconfigIf &&
             "RTRC interface object already instantiated.");

   const std::string jccl_base_dir("JCCL_BASE_DIR");
   const std::string vj_base_dir("VJ_BASE_DIR");
   std::string base_dir;

   if ( ! vpr::System::getenv(jccl_base_dir, base_dir) )
   {
      if ( vpr::System::getenv(vj_base_dir, base_dir) )
      {
         vprDEBUG(jcclDBG_RECONFIG, vprDBG_WARNING_LVL)
            << "JCCL_BASE_DIR environment variable not set.\n"
            << vprDEBUG_FLUSH;
         vprDEBUG_NEXT(jcclDBG_RECONFIG, vprDBG_WARNING_LVL)
            << "Using VJ_BASE_DIR instead.\n" << vprDEBUG_FLUSH;
      }
      else
      {
         base_dir = JCCL_ROOT_DIR;

         vprDEBUG(jcclDBG_RECONFIG, vprDBG_WARNING_LVL)
            << "Neither JCCL_BASE_DIR nor VJ_BASE_DIR is set."
            << std::endl << vprDEBUG_FLUSH;
         vprDEBUG_NEXT(jcclDBG_RECONFIG, vprDBG_WARNING_LVL)
            << "Using default " << base_dir << " instead."
            << std::endl << vprDEBUG_FLUSH;
      }
   }

   const std::string no_rtrc_plugin("NO_RTRC_PLUGIN");
   std::string junk;

   // If the user has the environment variable NO_RTRC_PLUGIN set (to any
   // value), do not attempt to load the plug-in.
   if ( vpr::System::getenv(no_rtrc_plugin, junk) )
   {
      vprDEBUG(jcclDBG_RECONFIG, vprDBG_STATE_LVL)
         << "Remote reconfig plug-in loading disabled via NO_RTRC_PLUGIN."
         << std::endl << vprDEBUG_FLUSH;
      return;
   }

#if defined(JCCL_PLUGIN_LIBDIR_NAME)
   const std::string lib_dir_name(JCCL_PLUGIN_LIBDIR_NAME);
#else
   const std::string lib_dir_name("lib");
#endif
   
   const std::string jccl_subdir_base("jccl");
   // If versioning is enabled, then the name of the directory containing the
   // Sonix plug-ins must contain version information.
#if defined(JCCL_USE_VERSIONING)
   std::string jccl_ver_str;
   const std::string jccl_version("JCCL_VERSION");

   // If $JCCL_VERSION is set, use the value of that environment variable
   // as the version component of the plug-in subdirectory name. Otherwise,
   // use the compile-time value provided by JCCL_VERSION_DOT.
   if ( ! vpr::System::getenv(jccl_version, jccl_ver_str) )
   {
      jccl_ver_str = JCCL_VERSION_DOT;
   }

   std::string jccl_subdir(jccl_subdir_base + std::string("-") +
                             jccl_ver_str );

   // If versioning is not enabled, then the directory containing the
   // Jackal plug-ins will not incorporate version information.
#else
   std::string jccl_subdir(jccl_subdir_base);
#endif

   std::vector<fs::path> search_path(1);
   search_path[0] =
#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION == 3
      fs::path(base_dir)
#else
      fs::path(base_dir, fs::native)
#endif
         / lib_dir_name /
         std::string(jccl_subdir) / std::string("plugins");

#if defined(JCCL_DEBUG)
   // For a debug build, search in plugins/debug first.
   search_path.insert(search_path.begin(),
                      search_path[0] / std::string("debug"));
#endif

   // In the long run, we may not want to hard-code the base name of the
   // plug-in we load.  If we ever reach a point where we have multiple ways
   // of implementing remote run-time reconfiguration, we could have options
   // for which plug-in to load.
   const std::string reconfig_dso("corba_rtrc");
   mRemoteRtrcPlugin = vpr::LibraryLoader::findDSO(reconfig_dso, search_path);

   bool load_done(true);

   if ( mRemoteRtrcPlugin.get() != NULL )
   {
      vprASSERT(! mRemoteRtrcPlugin->isLoaded() &&
                "Plug-in should not already be loaded");
      vprDEBUG(jcclDBG_RECONFIG, vprDBG_CONFIG_STATUS_LVL)
         << "Loading library: " << std::setiosflags(std::ios::right)
         << std::setfill(' ') << std::setw(50) << mRemoteRtrcPlugin->getName()
         << std::resetiosflags(std::ios::right) << "     " << vprDEBUG_FLUSH;

      try
      {
         mRemoteRtrcPlugin->load();

         const std::string init_func_name("initPlugin");
         void* entry_point = mRemoteRtrcPlugin->findSymbol(init_func_name);

         if ( NULL != entry_point )
         {
            vprDEBUG_CONT(jcclDBG_RECONFIG, vprDBG_CONFIG_STATUS_LVL)
               << "[ " << clrSetNORM(clrGREEN) << "OK" << clrRESET << " ]\n"
               << vprDEBUG_FLUSH;

            jccl::RemoteReconfig* (*init_func)(jccl::ConfigManager*);

            // Cast the entry point function to the correct signature so that we
            // can call it.  All dynamically plug-ins must have an entry point
            // function that takes no argument and returns a pointer to an
            // implementation of the jccl::RemoteReconfig interface.
            init_func =
               (jccl::RemoteReconfig* (*)(jccl::ConfigManager*)) entry_point;

            // Call the entry point function.
            jccl::RemoteReconfig* plugin = (*init_func)(this);

            if ( NULL != plugin )
            {
               setRemoteReconfigPlugin(plugin);
            }
            else
            {
               load_done = false;
               vprDEBUG_CONT(jcclDBG_RECONFIG, vprDBG_CONFIG_STATUS_LVL)
                  << "[ " << clrSetNORM(clrRED) << "entry point call FAILED"
                  << clrRESET << " ]\n" << vprDEBUG_FLUSH;
            }
         }
         else
         {
            load_done = false;
            vprDEBUG_CONT(jcclDBG_RECONFIG, vprDBG_CONFIG_STATUS_LVL)
               << "[ " << clrSetNORM(clrRED) << "FAILED lookup" << clrRESET
               << " ]\n" << vprDEBUG_FLUSH;
         }
      }
      catch (vpr::Exception& ex)
      {
         load_done = false;
         vprDEBUG_CONT(jcclDBG_RECONFIG, vprDBG_CONFIG_STATUS_LVL)
            << "[ " << clrSetNORM(clrRED) << "FAILED" << clrRESET << " ]\n"
            << ex.what() << std::endl << vprDEBUG_FLUSH;
      }
   }
   else
   {
      load_done = false;
   }

   if ( ! load_done )
   {
      vprDEBUG(jcclDBG_RECONFIG, vprDBG_WARNING_LVL)
         << "Failed to load the remote run-time reconfiguration"
         << std::endl << vprDEBUG_FLUSH;
      vprDEBUG_NEXT(jcclDBG_RECONFIG, vprDBG_WARNING_LVL)
         << "plug-in. Remote run-time reconfiguration is disabled."
         << std::endl << vprDEBUG_FLUSH;
      vprDEBUG_NEXT(jcclDBG_RECONFIG, vprDBG_WARNING_LVL)
         << "(This is not a fatal error.)" << std::endl << vprDEBUG_FLUSH;

      // The plug-in is not usable, so we can unload it.
      if ( mRemoteRtrcPlugin.get() != NULL )
      {
         if ( mRemoteRtrcPlugin->isLoaded() )
         {
            mRemoteRtrcPlugin->unload();
         }

         mRemoteRtrcPlugin.reset();
      }
   }
}