/**
 * Callback when display is added to display manager.
 * @pre Must be in kernel controlling thread.
 * @note This function can only be called by the display manager
 *       functioning on behalf of a thread the holds the kernel
 *       reconfiguration lock.
 *       This guarantees that we are not rendering currently.
 *       We will most likely be waiting for a render trigger.
 */
void D3dDrawManager::addDisplay(DisplayPtr disp)
{
   vprASSERT(disp != NULL);    // Can't add a null display

   vprDEBUG(vrjDBG_DRAW_MGR, 0)
      << "========= vrj::D3dDrawManager::addDisplay: " << disp
      << std::endl << vprDEBUG_FLUSH;

   // -- Finish Simulator setup
   std::vector<vrj::Viewport*>::size_type num_vp(disp->getNumViewports());
   std::vector<vrj::Viewport*>::size_type i;

   for ( i = 0 ; i < num_vp ; ++i )
   {
      Viewport* vp = disp->getViewport(i);

      if (vp->isSimulator())
      {
         jccl::ConfigElementPtr vp_element = vp->getConfigElement();

         SimViewport* sim_vp(NULL);
         sim_vp = dynamic_cast<SimViewport*>(vp);
         vprASSERT(NULL != sim_vp);

         sim_vp->setDrawSimInterface(DrawSimInterfacePtr());

         // Create the simulator stuff
         vprASSERT(1 == vp_element->getNum("simulator_plugin") && "You must supply a simulator plugin.");

         // Create the simulator stuff
         jccl::ConfigElementPtr sim_element =
            vp_element->getProperty<jccl::ConfigElementPtr>("simulator_plugin");

         vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL)
            << "D3dDrawManager::addDisplay() creating simulator of type '"
            << sim_element->getID() << "'\n" << vprDEBUG_FLUSH;

         DrawSimInterfacePtr new_sim_i(
            D3dSimInterfaceFactory::instance()->createObject(sim_element->getID())
         );

         // XXX: Change this to an error once the new simulator loading code is
         // more robust.  -PH (4/13/2003)
         vprASSERT(NULL != new_sim_i.get() &&
                   "Failed to create draw simulator");
         sim_vp->setDrawSimInterface(new_sim_i);
         new_sim_i->initialize(sim_vp);
         new_sim_i->config(sim_element);
      }
   }

   // -- Create a window for new display
   // -- Store the window in the wins vector
   // Create the gl window object.  NOTE: The glPipe actually "creates" the opengl window and context later
   D3dWindow* new_win = new D3dWindow();
   new_win->configWindow(disp);                                            // Configure it
   mNewWins.push_back(new_win);                                         // Add to our local window list

   //vprASSERT(isValidWindow(new_win));      // Make sure it was added to draw manager
}
/**
 * Updates to the sampled data.
 *
 * @pre None.
 * @post Most recent value is copied over to temp area.
 */
void TrackdController::updateData()
{
   vprASSERT(mTrackdController != NULL && "Make sure that trackd controller has been initialized");
   vprASSERT((unsigned)mTrackdController->numButtons() <= mCurButtons.size());
   vprASSERT((unsigned)mTrackdController->numValuators() <= mCurValuators.size() );

   for (int i=0;i<mTrackdController->numButtons();i++)
   {
      mCurButtons[i] =
         static_cast<DigitalState::State>(mTrackdController->getButton(i));
      mCurButtons[i].setTime();
   }

   for (int j=0;j<mTrackdController->numValuators();j++)
   {
       mCurValuators[j] = mTrackdController->getValuator(j);
       mCurValuators[j].setTime();
   }

   addDigitalSample(mCurButtons);
   swapDigitalBuffers();

   addAnalogSample(mCurValuators);
   swapAnalogBuffers();
}
bool FastrakStandalone::getStationStatus(const vpr::Uint16 station)
{
   vprASSERT(station >= 1 && station <= 4 && "Station index must between 1-4");

   std::string data = boost::lexical_cast<std::string>(station) + "\r";
   sendCommand(Fastrak::Command::StationStatus, data);
   std::vector<vpr::Uint8> data_record;

   try
   {
      mSerialPort->read(data_record, 9, mReadTimeout);
   }
   catch (vpr::IOException&)
   {
      throw vpr::Exception("Failed to get station status.", VPR_LOCATION);
   }

   vprASSERT('2' == data_record[0]);
   vprASSERT('l' == data_record[2]);

   mStationStatus.resize(4, false);
   mStationStatus[0] = boost::lexical_cast<bool>(data_record[3]);
   mStationStatus[1] = boost::lexical_cast<bool>(data_record[4]);
   mStationStatus[2] = boost::lexical_cast<bool>(data_record[5]);
   mStationStatus[3] = boost::lexical_cast<bool>(data_record[6]);

   // Save the number of active stations.
   mNumActiveStations = std::count(mStationStatus.begin(), mStationStatus.end(), true);

   // Fastrak uses 1-4 indexes, but in memory we store as 0-3.
   return mStationStatus[station-1];
}
void ThreadPosix::setFunctor(const vpr::thread_func_t& functor)
{
   vprASSERT(! mRunning && "Thread already running.");
   vprASSERT(! functor.empty() && "Invalid functor.");

   mUserThreadFunctor = functor;
}
Exemple #5
0
bool User::config(jccl::ConfigElementPtr element)
{
   vprASSERT(element.get() != NULL);
   vprASSERT(element->getID() == "user");

   vprDEBUG_BEGIN(vrjDBG_KERNEL, vprDBG_STATE_LVL)
      << "vjUser::config: Creating a new user\n" << vprDEBUG_FLUSH;

   // Assign user id
   mUserId = mNextUserId++;

   // Setup user name
   mName = element->getName();

   // Initialize the head stuff
   std::string head_alias = element->getProperty<std::string>("head_position");
   mHead.init(head_alias);

   // Initialize interocular distance
   mInterocularDist = element->getProperty<float>("interocular_distance");

   if(mInterocularDist == 0.0f)
   {
      vprDEBUG(vrjDBG_KERNEL,vprDBG_CONFIG_LVL) << clrOutNORM(clrRED, "WARNING:") << "User: "******" has interocular distance is set to 0.0f.  This is probably not what you wanted.\n" << vprDEBUG_FLUSH;
   }

   vprDEBUG(vrjDBG_KERNEL,vprDBG_STATE_LVL) << "id: " << mUserId << "   Name:" << mName.c_str()
                           << "   head_positon:" << head_alias.c_str()
                           << "   interocular_distance:" << mInterocularDist
                           << std::endl << vprDEBUG_FLUSH;

   return true;
}
void ThreadSGI::setFunctor(const vpr::thread_func_t& functor)
{
   vprASSERT(! mRunning && "Thread already running");
   vprASSERT(! functor.empty());

   mUserThreadFunctor = functor;
}
/**
 * Updates to the sampled data.
 *
 * @pre None.
 * @post Most recent value is copied over to temp area.
 */
void TrackdController::updateData()
{
   vprASSERT(mTrackdController != NULL && "Make sure that trackd controller has been initialized");
   vprASSERT((unsigned)mTrackdController->numButtons() <= mCurButtons.size());
   vprASSERT((unsigned)mTrackdController->numValuators() <= mCurValuators.size() );

   for (int i=0;i<mTrackdController->numButtons();i++)
   {
      mCurButtons[i] = mTrackdController->getButton(i);
      mCurButtons[i].setTime();
   }

   for (int j=0;j<mTrackdController->numValuators();j++)
   {
       // TrackdController doesn't have a sample, so we do
       // normalization here...
       float f;
       this->normalizeMinToMax (mTrackdController->getValuator(j), f);
       mCurValuators[j] = f;
       mCurValuators[j].setTime();
   }

   addDigitalSample(mCurButtons);
   swapDigitalBuffers();

   addAnalogSample(mCurValuators);
   swapAnalogBuffers();
}
/**
 * Closes the given display.
 *
 * @pre disp is a display we know about.
 * @post disp has been removed from the list of displays
 *    (notifyDrawMgr == true) && (drawMgr != NULL) && (disp is active)
 *    ==> Draw manager has been told to clode the window for the display
 */
int DisplayManager::closeDisplay(DisplayPtr disp, bool notifyDrawMgr)
{
   vprASSERT(isMemberDisplay(disp));       // Make sure that display actually exists

   vprDEBUG(vrjDBG_DISP_MGR, vprDBG_STATE_LVL)
      << "[vrj::DisplayManager::closeDisplay()] Closing display named '"
      << disp->getName() << "'" << std::endl << vprDEBUG_FLUSH;

   // Notify the draw manager to get rid of it
   // Note: if it is not active, then the draw manager doesn't know about it
   if ((notifyDrawMgr) && (mDrawManager != NULL) && (disp->isActive()))
   {
      mDrawManager->removeDisplay(disp);
   }

   // Remove it from local data structures
   size_t num_before_close = mActiveDisplays.size() + mInactiveDisplays.size();
   mActiveDisplays.erase( std::remove(mActiveDisplays.begin(), mActiveDisplays.end(), disp),
                          mActiveDisplays.end());
   mInactiveDisplays.erase( std::remove(mInactiveDisplays.begin(), mInactiveDisplays.end(), disp),
                            mInactiveDisplays.end());
   vprASSERT(num_before_close == (1+mActiveDisplays.size() + mInactiveDisplays.size()));
   boost::ignore_unused_variable_warning(num_before_close);

   return 1;
}
void Digital::readObject(vpr::ObjectReader* reader)
{
      //std::cout << "[Remote Input Manager] In Digital read" << std::endl;
   vprASSERT(reader->attribExists("rim.timestamp.delta"));
   vpr::Uint64 delta = reader->getAttrib<vpr::Uint64>("rim.timestamp.delta");

      // ASSERT if this data is really not Digital Data
   reader->beginTag(Digital::getInputTypeName());
   reader->beginAttribute(gadget::tokens::DataTypeAttrib);
      vpr::Uint16 temp = reader->readUint16();
   reader->endAttribute();

   // XXX: Should there be error checking for the case when vprASSERT()
   // is compiled out?  -PH 8/21/2003
   vprASSERT(temp==MSG_DATA_DIGITAL && "[Remote Input Manager]Not Digital Data");
   boost::ignore_unused_variable_warning(temp);

   std::vector<DigitalData> dataSample;

   unsigned numDigitalDatas;
   vpr::Uint32 value;
   vpr::Uint64 timeStamp;
   DigitalData temp_digital_data;

   reader->beginAttribute(gadget::tokens::SampleBufferLenAttrib);
      unsigned numVectors = reader->readUint16();
   reader->endAttribute();

   //std::cout << "Stable Digital Buffer Size: "  << numVectors << std::endl;
   mDigitalSamples.lock();
   for ( unsigned i=0;i<numVectors;i++ )
   {
      reader->beginTag(gadget::tokens::BufferSampleTag);
      reader->beginAttribute(gadget::tokens::BufferSampleLenAttrib);
         numDigitalDatas = reader->readUint16();
      reader->endAttribute();

      dataSample.clear();
      for ( unsigned j=0;j<numDigitalDatas;j++ )
      {
         reader->beginTag(gadget::tokens::DigitalValue);
         reader->beginAttribute(gadget::tokens::TimeStamp);
            timeStamp = reader->readUint64();    // read Time Stamp vpr::Uint64
         reader->endAttribute();
         value = reader->readUint32();           // read Digital Data(int)
         reader->endTag();

         temp_digital_data.setDigital(value);
         temp_digital_data.setTime(vpr::Interval(timeStamp + delta,vpr::Interval::Usec));
         dataSample.push_back(temp_digital_data);
      }
      mDigitalSamples.addSample(dataSample);
      reader->endTag();
   }
   mDigitalSamples.unlock();
   mDigitalSamples.swapBuffers();

   reader->endTag();
}
void FastrakStandalone::processDataRecord(std::vector<vpr::Uint8>& dataRecord)
{
   unsigned int single_bird_data_size = 28 + 5;

   // For each station
   // - Get matrix from data format
   for(unsigned int i=0; i < mNumActiveStations; ++i)
   {
      unsigned int data_offset = (single_bird_data_size*i);
      vprASSERT(dataRecord[data_offset] == '0');
      unsigned int station_index = boost::lexical_cast<unsigned int>(dataRecord[data_offset+1]);
      //std::cout << "Station: " << station_index << std::endl;
      vprASSERT(station_index >= 1 && station_index <= 4 && "Invalid station index.");
      vprASSERT(dataRecord[data_offset+2] == ' ');

      // Position and orientation offsets into data buffer.
      unsigned int pos_offset = data_offset + 3;
      unsigned int ori_offset = data_offset + 3 + 12;

      gmtl::Vec3f pos;
      gmtl::Quatf ori;

      // Get position values.
      pos[0] = getFloatValue(&dataRecord[pos_offset]);
      pos[1] = getFloatValue(&dataRecord[pos_offset+4]);
      pos[2] = getFloatValue(&dataRecord[pos_offset+8]);

      // Convert translation into meters.
      if (Fastrak::INCHES == mUnits)
      {
         pos *= 0.0254f;
      }
      else
      {
         pos *= 0.01f;
      }

      // Get quaternion for orientation.
      // NOTE: Fastrak returns quaternions as (W,X,Y,Z) and gmtl
      //       stores them as (X,Y,Z,W)
      ori[3] = getFloatValue(&dataRecord[ori_offset]);
      ori[0] = getFloatValue(&dataRecord[ori_offset+4]);
      ori[1] = getFloatValue(&dataRecord[ori_offset+8]);
      ori[2] = getFloatValue(&dataRecord[ori_offset+12]);

      // Create a gmtl::Matrix for easy storage.
      gmtl::Matrix44f position;
      gmtl::setRot(position, ori);
      gmtl::setTrans(position, pos);

      vprASSERT(4 == mStationData.size());
      mStationData[station_index] = position;
   }
}
// Look for items in the active list that don't have their dependencies filled
// anymore.
//
// POST: Any elements in active with dependencies not filled are added to the
//       the pending list. (A remove and an add are added to the pending).
// RETURNS: The number of lost dependencies found.
int ConfigManager::scanForLostDependencies()
{
   vprASSERT(0 == mActiveLock.test());
   // We can't hold the lock upon entry

   vpr::DebugOutputGuard og(vprDBG_ALL, vprDBG_CONFIG_LVL,
                            "ConfigManager::scanForLostDependencies()\n",
                            "ConfigManager::scanForLostDependencies() done.\n");

   DependencyManager* dep_mgr = DependencyManager::instance();
   std::vector<ConfigElementPtr> elements;
   int num_lost_deps(0);

   // NOTE: can't hold this lock because the isSatisfied routines make
   // use of the activeLock as well
   // NOTE: Make the copy of the elements so that we can iterate without
   // fear of active changing
   mActiveLock.acquire();
   elements = mActiveConfig.vec();   // Get a copy of the elements
   mActiveLock.release();

   // Now test them
   for ( unsigned int i=0;i<elements.size();i++ )
   {
      if ( !dep_mgr->isSatisfied(elements[i]) )     // We are not satisfied
      {
         vprDEBUG_NEXT(vprDBG_ALL, vprDBG_WARNING_LVL)
            << elements[i]->getName()
            << " type: " << elements[i]->getID()
            << " has lost dependencies.\n" << vprDEBUG_FLUSH;

         num_lost_deps++;              // Keep a count of the number lost deps found

         // Add the pending removal
         PendingElement pending;
         pending.mType = PendingElement::REMOVE;
         pending.mElement = elements[i];
         
         vprASSERT(1 == mPendingLock.test());
         addPending(pending);

         // Add the pending re-addition
//         ConfigElementPtr copy_of_element;          // Need a copy so that the remove can delete the element
//         copy_of_element = new ConfigElement(*elements[i]);
         pending.mType = PendingElement::ADD;
         pending.mElement = elements[i];//copy_of_element;
         
         vprASSERT(1 == mPendingLock.test());
         addPending(pending);                   // Add the add item
      }
   }

   return num_lost_deps;
}
void GlWindow::setViewport(float xo, float yo, float xSize, float ySize)
{
   vprASSERT( ((xo+xSize) <= 1.0f) && "X viewport sizes are out of range");
   vprASSERT( ((yo+ySize) <= 1.0f) && "Y viewport sizes are out of range");

   unsigned ll_x = unsigned(xo * float(mWindowWidth));
   unsigned ll_y = unsigned(yo * float(mWindowHeight));
   unsigned x_size = unsigned(xSize * float(mWindowWidth));
   unsigned y_size = unsigned(ySize * float(mWindowHeight));

   glViewport(ll_x, ll_y, x_size, y_size);
}
 /**
  * Updates to the sampled data.
  *
  * @pre None.
  * @post Most recent value is copied over to temp area
  */
 void TrackdSensor::updateData()
 {
    vprASSERT(mTrackdSensors != NULL && "Make sure that trackd sensors has been initialized");
    vprASSERT((unsigned)mTrackdSensors->numSensors() <= mCurSensorValues.size());

    for(int i=0;i<mTrackdSensors->numSensors();i++)
    {
       mCurSensorValues[i].mPosData = mTrackdSensors->getSensorPos(i);
       mCurSensorValues[i].setTime();
    }

    // Update the data buffer
    addPositionSample(mCurSensorValues);
    swapPositionBuffers();
 }
BOOL ExtensionLoaderWGL::wglQueryMaxSwapGroupsNV(HDC hdc, GLuint* maxGroups,
                                                 GLuint* maxBarriers)
{
   vprASSERT(mWglFuncs->wglQueryMaxSwapGroupsNV != NULL &&
             "Attemped to call unsupported extension.");
   return mWglFuncs->wglQueryMaxSwapGroupsNV(hdc, maxGroups, maxBarriers);
}
/**
 * Adds the element to the configuration.
 *
 * @pre configCanHandle(element) == true
 * @post (display of same name already loaded) ==> old display closed, new one opened<br>
 *       (display is new) ==> (new display is added)<br>
 *       Draw Manager is notified of the display change.
 */
bool DisplayManager::configAddDisplay(jccl::ConfigElementPtr element)
{
   vprASSERT(configCanHandle(element)); // We must be able to handle it first of all

   vprDEBUG_BEGIN(vrjDBG_DISP_MGR,vprDBG_STATE_LVL) << "------- DisplayManager::configAddDisplay -------\n" << vprDEBUG_FLUSH;

   // Find out if we already have a window of this name
   // If so, then close it before we open a new one of the same name
   // This basically allows re-configuration of a window
   DisplayPtr cur_disp = findDisplayNamed(element->getName());
   if (cur_disp != NULL)                         // We have an old display
   {
      vprDEBUG(vrjDBG_DISP_MGR,vprDBG_CONFIG_LVL) << "Removing old window: " << cur_disp->getName().c_str() << vprDEBUG_FLUSH;
      closeDisplay(cur_disp,true);              // Close the display and notify the draw manager to close the window
   }

   // --- Add a display (of the correct type) ---- //
   if (element->getID() == std::string("display_window"))       // Display window
   {
      DisplayPtr newDisp = Display::create();      // Create the display
      newDisp->config(element);
      addDisplay(newDisp,true);                    // Add it
      vprDEBUG(vrjDBG_DISP_MGR,vprDBG_STATE_LVL) << "Adding display: " << newDisp->getName().c_str() << std::endl << vprDEBUG_FLUSH;
      vprDEBUG(vrjDBG_DISP_MGR,vprDBG_STATE_LVL) << "Display: "  << newDisp << std::endl << vprDEBUG_FLUSH;
   }

   vprDEBUG_END(vrjDBG_DISP_MGR,vprDBG_STATE_LVL) << "------- DisplayManager::configAddDisplay Done. --------\n" << vprDEBUG_FLUSH;
   return true;
}
/**
 * Removes the element from the current configuration.
 * @pre configCanHandle(element) == true
 */
bool DisplayManager::configRemove(jccl::ConfigElementPtr element)
{
   vprASSERT(configCanHandle(element));

   const std::string element_type(element->getID());

   if ( (element_type == std::string("surfaceDisplay")) ||
        (element_type == std::string("simDisplay")) )
   {
      vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
         << "Element of type: " << element_type
         << " is no longer supported.  Use display_window type instead.\n"
         << vprDEBUG_FLUSH;
      return false;
   }
   else if (element_type == std::string("display_window"))
   {
      return configRemoveDisplay(element);
   }
   else if (element_type == std::string("display_system"))
   {
      // XXX: Put signal here to tell draw manager to lookup new stuff
      mDisplaySystemElement.reset();   // Keep track of the display system element
      return true;                     // We successfully configured.
                                       // This tell processPending to remove it to the active config
   }
   else
   {
      return false;
   }

}
void ConfigManager::refreshPendingList()
{
   vprASSERT(0 == mPendingCountMutex.test());
   mPendingCountMutex.acquire();
   mPendingCheckCount = 0;
   mPendingCountMutex.release();
}
Exemple #18
0
unsigned __stdcall vprThreadFunctorFunction(void* arg)
{
   vpr::thread_func_t& func = *((vpr::thread_func_t*) arg);
   vprASSERT(! func.empty());
   func();
   return 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;
}
Exemple #20
0
// Set this thread's priority.
void ThreadPosix::setPrio(VPRThreadPriority prio)
{
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
   sched_param_t sched_param;
   sched_param.sched_priority = vprThreadPriorityToPOSIX(prio);

   const int result = pthread_setschedparam(mThread, SCHED_RR, &sched_param);

   if ( EINVAL == result || ENOTSUP == result )
   {
      std::ostringstream msg_stream;
      msg_stream << "Invalid priority value " << sched_param.sched_priority;
      throw vpr::IllegalArgumentException(msg_stream.str(), VPR_LOCATION);
   }
   else if ( ESRCH == result )
   {
      throw vpr::IllegalArgumentException(
         "Cannot set priority for invalid thread", VPR_LOCATION
      );
   }

   vprASSERT(result == 0);
#else
   boost::ignore_unused_variable_warning(prio);
   std::cerr << "vpr::ThreadPosix::setPrio(): Not supported\n";
#endif
}
// Add an item to the active configuration
// NOTE: This DOES NOT process the element it just places it into the active
//       configuration list.
// PRE: Current list must NOT be locked.
void ConfigManager::addActive(ConfigElementPtr element)
{
   vprASSERT(0 == mActiveLock.test());
   lockActive();
   mActiveConfig.vec().push_back(element);
   unlockActive();
}
Exemple #22
0
void ThreadPosix::join(void** status)
{
   const int result = pthread_join(mThread, status);

   if ( EINVAL == result )
   {
      throw vpr::IllegalArgumentException("Cannot join an unjoinable thread",
                                          VPR_LOCATION);
   }
   else if ( ESRCH == result )
   {
      throw vpr::IllegalArgumentException("Cannot join an invalid thread",
                                          VPR_LOCATION);
   }
   else if ( EDEADLK == result )
   {
      throw vpr::DeadlockException("Deadlock detected when joining thread",
                                   VPR_LOCATION);
   }

   vprASSERT(result == 0);

   if ( mCaughtException )
   {
      throw mException;
   }
}
Exemple #23
0
// Get this thread's priority.
BaseThread::VPRThreadPriority ThreadPosix::getPrio() const
{
#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING
   int policy;
   sched_param_t fifo_sched_param;

   const int result = pthread_getschedparam(mThread, &policy,
                                            &fifo_sched_param);

   if ( ESRCH == result )
   {
      throw vpr::IllegalArgumentException(
         "Cannot query priority for invalid thread", VPR_LOCATION
      );
   }

   vprASSERT(result == 0);

   return posixThreadPriorityToVPR(fifo_sched_param.sched_priority);
#else
   std::cerr << "vpr::ThreadPosix::getPrio(): Not supported\n";

   return VPR_PRIORITY_NORMAL;
#endif
}
// Erase an item from the list.
// PRE: Active list must be locked && item must be in list.
// POST: list = old(list).erase(item) && item is invalid.
void ConfigManager::removeActive(const std::string& elementName)
{
   vprASSERT(0 == mActiveLock.test());
   lockActive();
   mActiveConfig.remove(elementName);
   unlockActive();
}
bool DataGloveUltraWireless::config(jccl::ConfigElementPtr e)
{
   vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL)
      << "*** DataGloveUltraWireless::config() ***" << std::endl << vprDEBUG_FLUSH;

   if(! (Input::config(e) && Analog::config(e) && Command::config(e) ) )
   {
      return false;
   }

   mPortName = e->getProperty<std::string>("port");
   mBaudRate = e->getProperty<int>("baud");
   mPortAEnabled = e->getProperty<bool>("port_a_enabled");
   mPortBEnabled = e->getProperty<bool>("port_b_enabled");

   mGlove.setGestureThresholds(
      e->getProperty<float>("gesture_upper_threshold"),
      e->getProperty<float>("gesture_lower_threshold") );

   mGlove.setAutoRangeReset(
      e->getProperty<bool>("auto_range_reset") );

   vprASSERT(mThread == NULL);      // This should have been set by Input(c)
   return true;
}
Exemple #26
0
RegistryEntryPtr
Registry::findNewestVersionEntry(const std::string& moduleName) const
{
   vprASSERT(moduleName.find(plugin::Info::getSeparator()) == std::string::npos);

   std::priority_queue<
      RegistryEntryPtr, std::vector<RegistryEntryPtr>,
      is_version_less<RegistryEntry>
   > queue;

   typedef registry_type::const_iterator iter_type;
   for ( iter_type i = mRegistry.begin(); i != mRegistry.end(); ++i )
   {
      if ( boost::algorithm::starts_with((*i).first, moduleName) )
      {
         queue.push((*i).second);
      }
   }

   RegistryEntryPtr entry;

   if ( ! queue.empty() )
   {
      entry = queue.top();
   }

   return entry;
}
BOOL ExtensionLoaderWGL::wglQuerySwapGroupNV(HDC hdc, GLuint* group,
                                             GLuint* barrier)
{
   vprASSERT(mWglFuncs->wglQuerySwapGroupNV != NULL &&
             "Attemped to call unsupported extension.");
   return mWglFuncs->wglQuerySwapGroupNV(hdc, group, barrier);
}
bool InputWindowXWin::startSampling()
{
   if (mThread != NULL)
   {
      vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL)
         << clrOutNORM(clrRED,"ERROR")
         << ": gadget::InputWindowXWin: startSampling called, when already sampling.\n"
         << vprDEBUG_FLUSH;
      vprASSERT(false);
   }

   bool started(false);
   mExitFlag = false;
   
   // Create a new thread to handle the control
   try
   {
      mThread = new vpr::Thread(boost::bind(&InputWindowXWin::controlLoop,
                                            this));
      started = true;
   }
   catch (vpr::Exception& ex)
   {
      vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
         << clrOutBOLD(clrRED, "ERROR")
         << ": Failed to spawn thread for X11 input window driver!\n"
         << vprDEBUG_FLUSH;
      vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL)
         << ex.what() << std::endl << vprDEBUG_FLUSH;
   }

   return started;
}
SemaphorePosix::~SemaphorePosix()
{
   // ---- Delete the semaphore --- //
#ifdef VPR_USE_NAMED_SEMAPHORE
   const int result = sem_close(mSema);
   vprASSERT(result == 0);

   sem_unlink(mSemaFile);
   std::free(mSemaFile);
#else
   const int result = sem_destroy(mSema);
   vprASSERT(result == 0);

   std::free(mSema);
#endif
}
BOOL ExtensionLoaderWGL::wglQueryFrameCountNV(HDC hdc, /*int screen,*/
                                              GLuint* count)
{
   vprASSERT(mWglFuncs->wglQueryFrameCountNV != NULL &&
             "Attemped to call unsupported extension.");
   return mWglFuncs->wglQueryFrameCountNV(hdc, /*screen,*/ count);
}