/** * Is it a display configuration element? * * @return true if we have a display config element; false if we don't. */ bool DisplayManager::configCanHandle(jccl::ConfigElementPtr element) { return ( (element->getID() == std::string("surfaceDisplay")) || (element->getID() == std::string("simDisplay")) || (element->getID() == std::string("display_system")) || (element->getID() == std::string("display_window")) ); }
// Return true if: // It is recognized device, proxy, or alias. bool InputManager::configCanHandle(jccl::ConfigElementPtr element) { // NEED TO FIX!!!! return ( (DeviceFactory::instance()->recognizeDevice(element) && !cluster::ClusterManager::instance()->recognizeRemoteDeviceConfig(element)) || ProxyFactory::instance()->recognizeProxy(element) || recognizeProxyAlias(element) || (element->getID() == std::string("display_system")) || (element->getID() == std::string("input_manager")) || (element->getID() == std::string("gadget_logger")) ); }
/** * 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; }
bool ClusterDepChecker::depSatisfied(jccl::ConfigElementPtr element) { if (element->getID() == ClusterNetwork::getClusterNodeElementType()) { // Machine Specific elements should have no dependencies since we are // simply inserting the child elements into the pending list. This is // to fix errors like the embedded keyboard window in a DisplayWindow // would always create a dependancy loop. debugOutDependencies( element, vprDBG_WARNING_LVL ); return true; } /* else if (cluster::ClusterManager::instance()->recognizeRemoteDeviceConfig(element)) { // Remote devices should have no dependencies since we are not actually // configuring anything, we are only creating a data structure that we // can determine without any other elements. // Virtual devices should not have any dependencies. // RemoteDeviceConfig has only two dependencies // - deivceHost exists in Active List // - Node exists and is connected // - Remote Device needs to be configured bool pass = true; jccl::ConfigManager* cfg_mgr = jccl::ConfigManager::instance(); // device_host exists in active configuration std::string device_host = element->getProperty<std::string>( "device_host" ); gadget::NodePtr node = cluster::ClusterManager::instance()->getNetwork()->getNodeByName( device_host ); if (!cfg_mgr->isElementInActiveList(device_host) || NULL == node) { pass = false; } else if (gadget::Node::DISCONNECTED == node->getStatus()) { pass = false; node->setStatus( gadget::Node::PENDING ); } else if (gadget::Node::PENDING == node->getStatus() || gadget::Node::NEWCONNECTION == node->getStatus()) { // Wait until we are fully connected. pass = false; } return pass; } */ else { vprDEBUG(gadgetDBG_RIM, vprDBG_CRITICAL_LVL) << "ERROR, Something is seriously wrong, we should never get here\n" << vprDEBUG_FLUSH; return true; } }
void SignalGrabStrategy::configure(jccl::ConfigElementPtr elt) { vprASSERT(elt->getID() == getElementType()); const unsigned int req_cfg_version(1); // Check for correct version of plugin configuration. if ( elt->getVersion() < req_cfg_version ) { std::stringstream msg; msg << "Configuration of SignalGrabStrategy failed. Required config " << "element version is " << req_cfg_version << ", but element '" << elt->getName() << "' is version " << elt->getVersion(); throw PluginException(msg.str(), VRKIT_LOCATION); } const std::string choose_btn_prop("choose_button_nums"); const std::string grab_btn_prop("grab_button_nums"); const std::string release_btn_prop("release_button_nums"); mChooseBtn.configure(elt->getProperty<std::string>(choose_btn_prop), mWandInterface); mGrabBtn.configure(elt->getProperty<std::string>(grab_btn_prop), mWandInterface); mReleaseBtn.configure(elt->getProperty<std::string>(release_btn_prop), mWandInterface); // Determine if grab and release are activated using the same button // sequence. This indicates that the grab/release operation is a toggle // and must be handled differently than if the two operations are // separate. mGrabReleaseToggle = mGrabBtn == mReleaseBtn; }
/** * Removes a proxy aliases in config database. * @pre none * @post (alias not in list) ==> returns = false<br> * (alias is in list) ==> (alias is removed from list) returns true */ bool InputManager::removeProxyAlias(jccl::ConfigElementPtr element) { vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL, std::string("gadget::InputManager::removeProxyAlias\n"), std::string("...done removing alias.\n")); vprASSERT(element->getID() == "alias"); std::string alias_name, proxy_name; // The string of the alias, name of proxy to pt to alias_name = element->getName(); if(mProxyAliases.end() == mProxyAliases.find(alias_name)) { vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED,"ERROR:") << "gadget::InputManager::RemoveProxyAlias: Alias: " << alias_name << " cannot find proxy: " << proxy_name.c_str() << std::endl << vprDEBUG_FLUSH; return false; } mProxyAliases.erase(alias_name); vprDEBUG(gadgetDBG_INPUT_MGR,vprDBG_CONFIG_LVL) << " alias:" << alias_name.c_str() << " index:" << mProxyAliases[proxy_name] << " has been removed." << std::endl << vprDEBUG_FLUSH; return true; }
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; }
/** * 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 MultiObjectGrabStrategy::configure(jccl::ConfigElementPtr elt) { vprASSERT(elt->getID() == getElementType()); const unsigned int req_cfg_version(1); // Check for correct version of plugin configuration. if ( elt->getVersion() < req_cfg_version ) { std::stringstream msg; msg << "Configuration of MultiObjectGrabStrategy failed. Required " << "config element version is " << req_cfg_version << ", but element '" << elt->getName() << "' is version " << elt->getVersion(); throw PluginException(msg.str(), VRKIT_LOCATION); } const std::string choose_btn_prop("choose_button_nums"); const std::string grab_btn_prop("grab_button_nums"); const std::string release_btn_prop("release_button_nums"); mChooseBtn.configure(elt->getProperty<std::string>(choose_btn_prop), mWandInterface); mGrabBtn.configure(elt->getProperty<std::string>(grab_btn_prop), mWandInterface); mReleaseBtn.configure(elt->getProperty<std::string>(release_btn_prop), mWandInterface); }
/** * Removes the element from the current configuration. */ bool InputManager::configRemove(jccl::ConfigElementPtr element) { vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL, std::string("InputManager: Removing config...\n"), std::string("done removing config.\n")); vprASSERT(configCanHandle(element)); bool ret_val = false; // Flag to return success // NEED TO FIX!!!! if (cluster::ClusterManager::instance()->recognizeRemoteDeviceConfig(element)) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CONFIG_LVL) << "InputManager can not handle remote devices, we must use Remote Input Manager." << vprDEBUG_FLUSH; ret_val = false; } else if(DeviceFactory::instance()->recognizeDevice(element)) { ret_val = removeDevice(element); } else if(recognizeProxyAlias(element)) { ret_val = removeProxyAlias(element); } else if(ProxyFactory::instance()->recognizeProxy(element)) { ret_val = removeProxy(element); } else if(element->getID() == std::string("display_system")) { mDisplaySystemElement.reset(); // Keep track of the display system element ret_val = true; // We successfully configured. // This tell processPending to remove it to the active config } else { ret_val = false; } if(ret_val) { resetAllDevicesAndProxies(); updateAllDevices(); // Update all the input data updateAllProxies(); // Update all the input data BaseDeviceInterface::refreshAllInterfaces(); // Refresh all the device interface handles vprDEBUG(gadgetDBG_INPUT_MGR,vprDBG_VERB_LVL) << "InputManager::configRemove(): Updated all data" << std::endl << vprDEBUG_FLUSH; } return ret_val; // Return the success flag if we added at all }
int ProxyFactory::findConstructor(jccl::ConfigElementPtr element) { std::string element_type(element->getID()); for(unsigned i=0;i<mConstructors.size();i++) { if(mConstructors[i]->getElementType() == element_type) { return i; } } return -1; }
/** * Loads the specified proxy. */ ProxyPtr ProxyFactory::loadProxy(jccl::ConfigElementPtr element) { vprASSERT(recognizeProxy(element)); int index = findConstructor(element); boost::shared_ptr<ProxyConstructorBase> constructor = mConstructors[index]; vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL) << "[gadget::ProxyFactory::loadProxy] Loading proxy: " << element->getID() << " with: " << typeid(*constructor).name() << std::endl << vprDEBUG_FLUSH; ProxyPtr new_proxy = constructor->createProxy(element); return new_proxy; }
/** * Configures proxy aliases in config database. * @pre none * @post (alias not already in list) ==> Alias is added to proxyAlias list<br> * (alias was already is list) ==> Alias is set to point to the new proxy instead */ bool InputManager::configureProxyAlias(jccl::ConfigElementPtr element) { vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL, std::string("gadget::InputManager: Configuring proxy alias\n"), std::string("...done configuring alias.\n")); vprASSERT(element->getID() == "alias"); std::string alias_name, proxy_name; // The string of the alias, name of proxy to pt to alias_name = element->getName(); proxy_name = element->getProperty<std::string>("proxy"); addProxyAlias(alias_name, proxy_name); return true; }
/** * Removes the element from the current configuration. * * @pre configCanHandle(element) == true * @return success */ bool DisplayManager::configRemoveDisplay(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::configRemoveDisplay -------\n" << vprDEBUG_FLUSH; bool success_flag(false); if (element->getID() == std::string("display_window")) // It is a display { DisplayPtr remove_disp = findDisplayNamed(element->getName()); if (remove_disp != NULL) { closeDisplay(remove_disp, true); // Remove it success_flag = true; } } vprDEBUG_END(vrjDBG_DISP_MGR,vprDBG_STATE_LVL) << "------- DisplayManager::configRemoveDisplay done. --------\n" << vprDEBUG_FLUSH; return success_flag; }
GridPtr Grid::init(jccl::ConfigElementPtr cfgElt) { vprASSERT(cfgElt->getID() == std::string("grid")); const unsigned int req_cfg_version(1); // Check for correct version of plugin configuration. if ( cfgElt->getVersion() < req_cfg_version ) { std::ostringstream msg; msg << "Failed to configure grid '" << cfgElt->getName() << "'. Required config element version is " << req_cfg_version << ", but this element is version " << cfgElt->getVersion(); throw PluginException(msg.str(), VRKIT_LOCATION); } mName = cfgElt->getName(); const std::string size_prop("size"); const std::string granularity_prop("granularity"); const std::string color_prop("color"); const std::string corner_prop("corner"); const std::string corner_pos_prop("corner_position"); const std::string orient_prop("orientation"); const OSG::Real32 width = cfgElt->getProperty<OSG::Real32>(size_prop, 0); const OSG::Real32 height = cfgElt->getProperty<OSG::Real32>(size_prop, 1); if ( width <= 0.0f || height <= 0.0f ) { std::ostringstream msg_stream; msg_stream << "Invalid grid dimensions " << width << "x" << height; throw PluginException(msg_stream.str(), VRKIT_LOCATION); } const float granularity = cfgElt->getProperty<float>(granularity_prop); if ( granularity <= 0.0f ) { std::ostringstream msg_stream; msg_stream << "Invalid grid cell granularity " << granularity; throw PluginException(msg_stream.str(), VRKIT_LOCATION); } OSG::Real32 red = cfgElt->getProperty<OSG::Real32>(color_prop, 0); OSG::Real32 green = cfgElt->getProperty<OSG::Real32>(color_prop, 1); OSG::Real32 blue = cfgElt->getProperty<OSG::Real32>(color_prop, 2); if ( red < 0.0f || red > 1.0f ) { std::cerr << "WARNING: Invalid red color value " << red << " in config element '" << cfgElt->getName() << "'" << std::endl; red = 0.0f; } if ( green < 0.0f || green > 1.0f ) { std::cerr << "WARNING: Invalid green color value " << green << " in config element '" << cfgElt->getName() << "'" << std::endl; green = 0.0f; } if ( blue < 0.0f || blue > 1.0f ) { std::cerr << "WARNING: Invalid blue color value " << blue << " in config element '" << cfgElt->getName() << "'" << std::endl; blue = 0.0f; } unsigned int corner_val = cfgElt->getProperty<unsigned int>(corner_prop); Corner corner; if ( 0 <= corner_val && corner_val <= 3 ) { corner = static_cast<Corner>(corner_val); } else { std::ostringstream msg_stream; msg_stream << "Invalid corner value " << corner_val << "; must be one of 0, 1, 2, or 3"; throw PluginException(msg_stream.str(), VRKIT_LOCATION); } const OSG::Vec3f corner_pos( cfgElt->getProperty<float>(corner_pos_prop, 0), cfgElt->getProperty<float>(corner_pos_prop, 1), cfgElt->getProperty<float>(corner_pos_prop, 2) ); OSG::Quaternion rot; rot.setValue( gmtl::Math::deg2Rad(cfgElt->getProperty<float>(orient_prop, 0)), gmtl::Math::deg2Rad(cfgElt->getProperty<float>(orient_prop, 1)), gmtl::Math::deg2Rad(cfgElt->getProperty<float>(orient_prop, 2)) ); initGeometry(width, height, granularity, corner, corner_pos, rot, OSG::Color3f(red, green, blue)); return shared_from_this(); }
// We need to handle Machine Specific elements because in reality they have no // dependencies. bool ClusterDepChecker::canHandle(jccl::ConfigElementPtr element) { return (element->getID() == ClusterNetwork::getClusterNodeElementType()); // || //cluster::ClusterManager::instance()->recognizeRemoteDeviceConfig( element )); }
bool InputManager::configureInputManager(jccl::ConfigElementPtr element) { bool have_bad_elt = (element->getID() != std::string("input_manager")); vprASSERT(!have_bad_elt); if(have_bad_elt) { return false; } bool ret_val = false; vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL, std::string("Handling input_manager element:\n"), std::string("-- end state -- \n")); // Keep this up to date with the version of the element definition we're // expecting to handle. const unsigned int cur_version(2); // If the element version is less than cur_version, we will not try to // proceed. Instead, we'll print an error message and return false so // that the Config Manager knows this element wasn't consumed. if ( element->getVersion() < cur_version ) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutBOLD(clrRED, "ERROR") << ": [gadget::InputManager::configureInputManager()] Element named '" << element->getName() << "'" << std::endl << vprDEBUG_FLUSH; vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << "is version " << element->getVersion() << ", but we require at least version " << cur_version << std::endl << vprDEBUG_FLUSH; vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << "Ignoring this element and moving on." << std::endl << vprDEBUG_FLUSH; ret_val = false; } // We got the right version of the config element and can proceed. else { const std::string driver_path_prop_name("driver_path"); const int path_count(element->getNum(driver_path_prop_name)); std::vector<fs::path> search_path(path_count); for ( unsigned int i = 0; i < search_path.size(); ++i ) { std::string temp_str = vpr::replaceEnvVars(element->getProperty<std::string>(driver_path_prop_name, i)); try { search_path[i] = fs::path(temp_str, fs::native); } catch(fs::filesystem_error& fsEx) { vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED, "ERROR") << ": [gadget::InputManager::configureInputManager()] File " << "system exception caught while converting\n" << vprDEBUG_FLUSH; vprDEBUG_NEXT(vprDBG_ERROR, vprDBG_CRITICAL_LVL) << "'" << temp_str << "'\n" << vprDEBUG_FLUSH; vprDEBUG_NEXT(vprDBG_ERROR, vprDBG_CRITICAL_LVL) << "to a Boost.Filesystem path.\n" << vprDEBUG_FLUSH; vprDEBUG_NEXT(vprDBG_ERROR, vprDBG_CRITICAL_LVL) << fsEx.what() << std::endl << vprDEBUG_FLUSH; } } // Append a default driver search path to search_path. const fs::path default_search_dir = gadget::getDefaultPluginRoot() / std::string("drivers"); vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_VERB_LVL) << "[gadget::InputManager::configureInputManager()] Appending " << "default search path '" << default_search_dir.native_directory_string() << "'\n" << vprDEBUG_FLUSH; #if defined(GADGET_DEBUG) // For a debug build, search in the debug subdirectory of // default_search_dir before looking in default_search_dir. search_path.push_back(default_search_dir / std::string("debug")); #endif search_path.push_back(default_search_dir); // --- Load device driver dsos -- // // - Load individual drivers const std::string driver_prop_name("driver"); const std::string get_version_func("getGadgeteerVersion"); const std::string driver_init_func("initDevice"); int driver_count = element->getNum(driver_prop_name); std::string driver_dso_name; for ( int i = 0; i < driver_count; ++i ) { driver_dso_name = element->getProperty<std::string>(driver_prop_name, i); if ( ! driver_dso_name.empty() ) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL) << "[gadget::InputManager::configureInputManager()] Loading " << "driver DSO '" << driver_dso_name << "'\n" << vprDEBUG_FLUSH; vpr::LibraryPtr dso = vpr::LibraryLoader::findDSO(driver_dso_name, search_path); if ( dso.get() != NULL ) { try { VersionCheckCallable version_functor; vpr::LibraryLoader::callEntryPoint(dso, get_version_func, version_functor); DriverInitCallable init_functor(this); vpr::LibraryLoader::callEntryPoint(dso, driver_init_func, init_functor); mLoadedDrivers.push_back(dso); } catch (gadget::PluginVersionException& ex) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutBOLD(clrRED, "ERROR") << ": Version mismatch while loading driver DSO '" << driver_dso_name << "'\n" << vprDEBUG_FLUSH; vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << "This driver will not be usable.\n" << vprDEBUG_FLUSH; vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << ex.getExtendedDescription() << std::endl << vprDEBUG_FLUSH; } catch (vpr::Exception& ex) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutBOLD(clrRED, "ERROR") << ": Failed to load driver DSO '" << driver_dso_name << "'\n" << vprDEBUG_FLUSH; vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << "This driver will not be usable.\n" << vprDEBUG_FLUSH; vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << ex.what() << std::endl << vprDEBUG_FLUSH; } } else { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutBOLD(clrRED, "ERROR") << ": Failed to find driver DSO '" << driver_dso_name << "'\n" << vprDEBUG_FLUSH; } } } // - Load driver directory const std::string dir_prop_name("driver_scan_path"); int dir_count = element->getNum(dir_prop_name); std::string driver_dir; #if defined(VPR_OS_Windows) const std::string driver_ext("dll"); #elif defined(VPR_OS_Darwin) const std::string driver_ext("dylib"); #else const std::string driver_ext("so"); #endif for ( int i = 0; i < dir_count; ++i ) { driver_dir = vpr::replaceEnvVars(element->getProperty<std::string>(dir_prop_name, i)); // The vpr::LibraryFinder will throw an exception if driver_dir is // (somehow) an invalid path. try { fs::path drv_path(driver_dir, fs::native); if ( fs::exists(drv_path) ) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << "[gadget::InputManager::configureInputManager()] " << "Searching for driver DSOs in '" << driver_dir << "'\n" << vprDEBUG_FLUSH; vpr::LibraryFinder finder(driver_dir, driver_ext); vpr::LibraryFinder::LibraryList libs = finder.getLibraries(); VersionCheckCallable version_functor; DriverInitCallable init_functor(this); for ( vpr::LibraryFinder::LibraryList::iterator lib = libs.begin(); lib != libs.end(); ++lib ) { try { vpr::LibraryLoader::callEntryPoint(*lib, get_version_func, version_functor); vpr::LibraryLoader::callEntryPoint(*lib, driver_init_func, init_functor); mLoadedDrivers.push_back(*lib); } catch (vpr::Exception& ex) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutBOLD(clrRED, "ERROR") << ": Failed to load driver DSO '" << (*lib)->getName() << "'\n" << vprDEBUG_FLUSH; vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << "This driver will not be usable.\n" << vprDEBUG_FLUSH; vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << ex.what() << std::endl << vprDEBUG_FLUSH; } } } else { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutBOLD(clrYELLOW, "WARNING") << ": [gadget::InputManager::configureInputManager()] " << "Invalid directory for driver DSOs: " << driver_dir << std::endl << vprDEBUG_FLUSH; } } catch(fs::filesystem_error& fsEx) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED, "ERROR") << ": [gadget::InputManager::configureInputManager()] File " << "system exception caught!\n" << vprDEBUG_FLUSH; vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << fsEx.what() << std::endl << vprDEBUG_FLUSH; } } ret_val = true; } return ret_val; }
// Just call the base class constructor void SurfaceProjection::config(jccl::ConfigElementPtr element) { vprASSERT(element->getID() == "surface_viewport"); Projection::config(element); // Call base class config first }
bool SurfaceViewport::config(jccl::ConfigElementPtr element) { vprASSERT(element.get() != NULL); vprASSERT(element->getID() == "surface_viewport"); // Call base class config if ( ! Viewport::config(element) ) { return false; } bool result(true); mType = SURFACE; // Read in the corners mLLCorner.set(element->getProperty<float>("lower_left_corner", 0), element->getProperty<float>("lower_left_corner", 1), element->getProperty<float>("lower_left_corner", 2)); mLRCorner.set(element->getProperty<float>("lower_right_corner", 0), element->getProperty<float>("lower_right_corner", 1), element->getProperty<float>("lower_right_corner", 2)); mURCorner.set(element->getProperty<float>("upper_right_corner", 0), element->getProperty<float>("upper_right_corner", 1), element->getProperty<float>("upper_right_corner", 2)); mULCorner.set(element->getProperty<float>("upper_left_corner", 0), element->getProperty<float>("upper_left_corner", 1), element->getProperty<float>("upper_left_corner", 2)); mCornerUpdateMode = static_cast<CornerUpdateMode>(element->getProperty<int>("auto_corner_update", 0)); // Calculate the rotation and the pts // calculateSurfaceRotation(); // calculateCornersInBaseFrame(); // Get info about being tracked mTracked = element->getProperty<bool>("tracked"); if(mTracked) { mTrackerProxyName = element->getProperty<std::string>("tracker_proxy"); } // Create Projection objects // NOTE: The -'s are because we are measuring distance to // the left(bottom) which is opposite the normal axis direction //vjMatrix rot_inv; //rot_inv.invert(mSurfaceRotation); SurfaceProjectionPtr left_proj; SurfaceProjectionPtr right_proj; if(!mTracked) { left_proj = SurfaceProjection::create(mLLCorner, mLRCorner, mURCorner, mULCorner); right_proj = SurfaceProjection::create(mLLCorner, mLRCorner, mURCorner, mULCorner); } else { left_proj = TrackedSurfaceProjection::create(mLLCorner, mLRCorner, mURCorner, mULCorner, mTrackerProxyName); right_proj = TrackedSurfaceProjection::create(mLLCorner, mLRCorner, mURCorner, mULCorner, mTrackerProxyName); } try { left_proj->validateCorners(); right_proj->validateCorners(); // NOTE: Even if the corner validation above failed, we still proceed with // setting up mLeftProj and mRightProj. This is because other code is not // written to handle the case of a viewport having no projections. This // could definitely be improved. mLeftProj = left_proj; mRightProj = right_proj; // Configure the projections mLeftProj->config(element); mLeftProj->setEye(Projection::LEFT); mLeftProj->setViewport(shared_from_this()); mRightProj->config(element); mRightProj->setEye(Projection::RIGHT); mRightProj->setViewport(shared_from_this()); } catch (InvalidSurfaceException& ex) { vprDEBUG(vrjDBG_DISP_MGR, vprDBG_CRITICAL_LVL) << clrOutBOLD(clrRED, "ERROR") << ": The surface defined by the viewport named\n" << vprDEBUG_FLUSH; vprDEBUG_NEXT(vrjDBG_DISP_MGR, vprDBG_CRITICAL_LVL) << " '" << element->getName() << "' is invalid!\n" << vprDEBUG_FLUSH; vprDEBUG_NEXT(vrjDBG_DISP_MGR, vprDBG_CRITICAL_LVL) << ex.what() << std::endl << vprDEBUG_FLUSH; result = false; } return result; }
/** * Is it a proxy alias. */ bool recognizeProxyAlias(jccl::ConfigElementPtr element) { return (element->getID() == "alias"); }
bool AbstractNetworkManager::recognizeClusterMachineConfig(jccl::ConfigElementPtr element) { return (element->getID() == getClusterNodeElementType()); }
void ModeHarnessPlugin::configure(jccl::ConfigElementPtr elt) { vprASSERT(elt->getID() == getElementType()); const unsigned int req_cfg_version(2); // Check for correct version of plugin configuration. if ( elt->getVersion() < req_cfg_version ) { std::stringstream msg; msg << "Configuration of ModeHarnessPlugin failed. Required config " << "element version is " << req_cfg_version << ", but element '" << elt->getName() << "' is version " << elt->getVersion(); throw PluginException(msg.str(), VRKIT_LOCATION); } const std::string component_path_prop("component_path"); const std::string default_component_prop("default_component"); const std::string component_prop("component"); const std::string plugin_prop("plugin"); const std::string signal_prop("signal"); const std::string active_component_prop("active_component"); // Set up two default search paths: // 1. Relative path to './plugins/mode' // 2. VRKIT_BASE_DIR/lib/vrkit/plugins/mode // // In all of the above cases, the 'debug' subdirectory is searched first if // this is a debug build (i.e., when VRKIT_DEBUG is defined and _DEBUG is // not). std::vector<std::string> component_path = plugin::getDefaultSearchPath("mode"); const unsigned int num_plugin_paths(elt->getNum(component_path_prop)); for ( unsigned int i = 0; i < num_plugin_paths; ++i ) { std::string dir = elt->getProperty<std::string>(component_path_prop, i); component_path.push_back(vpr::replaceEnvVars(dir)); } mDefaultComponentName = elt->getProperty<std::string>(default_component_prop); const unsigned int num_comps(elt->getNum(component_prop)); for ( unsigned int i = 0; i < num_comps; ++i ) { jccl::ConfigElementPtr comp_elt = elt->getProperty<jccl::ConfigElementPtr>(component_prop, i); mComponentInfo.push_back( ComponentInfo(comp_elt->getName(), comp_elt->getProperty<std::string>(plugin_prop)) ); } const unsigned int num_signals(elt->getNum(signal_prop)); for ( unsigned int i = 0; i < num_signals; ++i ) { jccl::ConfigElementPtr signal_elt = elt->getProperty<jccl::ConfigElementPtr>(signal_prop, i); mSignalDefs.push_back( SignalDef(signal_elt->getName(), signal_elt->getProperty<std::string>(active_component_prop)) ); } std::vector<vpr::LibraryPtr> modules = plugin::findModules(component_path); std::for_each(modules.begin(), modules.end(), boost::bind(&ModeHarnessPlugin::registerModule, this, _1)); }
bool CorbaPerfPlugin::configCanHandle(jccl::ConfigElementPtr element) { return element->getID() == std::string("corba_performance_monitor"); }
void SlideMoveStrategy::configure(jccl::ConfigElementPtr cfgElt) { vprASSERT(cfgElt->getID() == getElementType()); const unsigned int req_cfg_version(2); if ( cfgElt->getVersion() < req_cfg_version ) { std::stringstream msg; msg << "Configuration of SlideMoveStrategy failed. Required config " << "element version is " << req_cfg_version << ", but element '" << cfgElt->getName() << "' is version " << cfgElt->getVersion(); throw PluginException(msg.str(), VRKIT_LOCATION); } const std::string slide_target_prop("slide_target"); const std::string analog_input_prop("analog_input"); const std::string forward_value_prop("forward_slide_value"); const std::string slide_epsilon_prop("slide_epsilon"); const unsigned int slide_target = cfgElt->getProperty<unsigned int>(slide_target_prop); if ( slide_target == 0 || slide_target == 1 ) { mSlideTarget = static_cast<SlideTarget>(slide_target); } else { VRKIT_STATUS << "ERROR: Invalid slide target identifier " << slide_target << std::endl; } const int analog_num = cfgElt->getProperty<int>(analog_input_prop); // -1 disables sliding. Otherwise, the analog number must be in the range // 0 <= analog_num < 4. if ( analog_num == -1 || 0 <= analog_num && analog_num < 4 ) { mAnalogNum = analog_num; } else { VRKIT_STATUS << "ERROR: Analog input index (" << analog_num << ") given!\n" << "This must be -1 (to disable) or in the range [0, 4)." << std::endl; } const float fwd_val = cfgElt->getProperty<float>(forward_value_prop); if ( fwd_val == 0.0f || fwd_val == 1.0f ) { mForwardValue = fwd_val; } else { VRKIT_STATUS << "ERROR: Invalid forward sliding value (" << fwd_val << ") given!\n" << "This must be either 0.0 or 1.0" << std::endl; } const float eps = cfgElt->getProperty<float>(slide_epsilon_prop); if ( eps >= 0.0f ) { mSlideEpsilon = eps; } else { VRKIT_STATUS << "ERROR: Slide epsilon must be non-negative!" << std::endl; } }
/** * Can the handler handle the given element? * @return true if we can handle it; false if not. */ bool SoundManagerSonix::configCanHandle(jccl::ConfigElementPtr element) { return std::string("sound_manager_sonix") == element->getID(); }
void ClusterDepChecker::debugOutDependencies(jccl::ConfigElementPtr element, const int dbg_lvl) { vprDEBUG_NEXT_BEGIN( vprDBG_ALL, dbg_lvl ) << "---- Dependencies for " << element->getName() << " (type: " << element->getID() << ") ----\n" << vprDEBUG_FLUSH; if (element->getID() == ClusterNetwork::getClusterNodeElementType()) { // Machine Specific element should have no dependencies since we are // simply inserting the child elements into the pending list. vprDEBUG_NEXT( vprDBG_ALL, dbg_lvl ) << "0: " << "Host node's ConfigElement" << " ==> " << vprDEBUG_FLUSH; vprDEBUG_CONT( vprDBG_ALL, dbg_lvl ) << "none.\n" << vprDEBUG_FLUSH; } /* else if (cluster::ClusterManager::instance()->recognizeRemoteDeviceConfig( element )) { std::string device_host = element->getProperty<std::string>( "device_host"); gadget::NodePtr node = cluster::ClusterManager::instance()->getNetwork()->getNodeByName( device_host ); vprDEBUG_NEXT( vprDBG_ALL, dbg_lvl ) << "1: " << "Device node's ConfigElement" << " ==> " << vprDEBUG_FLUSH; jccl::ConfigManager* cfg_mgr = jccl::ConfigManager::instance(); if (!cfg_mgr->isElementInActiveList( device_host ) || NULL == node) { vprDEBUG_CONT( vprDBG_ALL, dbg_lvl ) << "not in active list.\n" << vprDEBUG_FLUSH; } else { vprDEBUG_CONT( vprDBG_ALL, dbg_lvl ) << "in active list.\n" << vprDEBUG_FLUSH; } vprDEBUG_NEXT( vprDBG_ALL, dbg_lvl ) << "2: " << "Device host connection status" << " ==> " << vprDEBUG_FLUSH; if (gadget::Node::DISCONNECTED == node->getStatus()) { vprDEBUG_CONT( vprDBG_ALL, dbg_lvl ) << "disconnected.\n" << vprDEBUG_FLUSH; } else if (gadget::Node::PENDING == node->getStatus()) { vprDEBUG_CONT( vprDBG_ALL, dbg_lvl ) << "pending.\n" << vprDEBUG_FLUSH; } else if (gadget::Node::NEWCONNECTION == node->getStatus()) { vprDEBUG_CONT( vprDBG_ALL, dbg_lvl ) << "new connection.\n" << vprDEBUG_FLUSH; } } */ vprDEBUG_CONT_END( vprDBG_ALL, dbg_lvl ) << std::endl << vprDEBUG_FLUSH; }
void WandInterface::configure(jccl::ConfigElementPtr elt) { vprASSERT(elt->getID() == getElementType()); const unsigned int req_cfg_version(1); if ( elt->getVersion() < req_cfg_version ) { std::ostringstream msg; msg << "Configuration of WandInterface failed. Required config " << "element version is " << req_cfg_version << ", but element '" << elt->getName() << "' is version " << elt->getVersion(); throw Exception(msg.str(), VRKIT_LOCATION); } const std::string pos_name_prop("position_name"); const std::string digital_name_prop("digital_name"); const std::string analog_name_prop("analog_name"); const std::string wand_name = elt->getProperty<std::string>(pos_name_prop); if ( wand_name.empty() ) { throw Exception("Empty wand name is not allowed", VRKIT_LOCATION); } mWandInterface.init(wand_name); const unsigned int num_digitals(elt->getNum(digital_name_prop)); if ( num_digitals > 0 ) { mButtonInterfaces.resize(num_digitals); for ( unsigned int d = 0; d < num_digitals; ++d ) { const std::string digital_name = elt->getProperty<std::string>(digital_name_prop, d); if ( digital_name.empty() ) { mButtonInterfaces.clear(); std::ostringstream msg_stream; msg_stream << "Empty digital name (index " << d << ") is not allowed"; throw Exception(msg_stream.str(), VRKIT_LOCATION); } mButtonInterfaces[d].init(digital_name); } } const unsigned int num_analogs(elt->getNum(analog_name_prop)); if ( num_analogs > 0 ) { mAnalogInterfaces.resize(num_analogs); for ( unsigned int a = 0; a < num_analogs; ++a ) { const std::string analog_name = elt->getProperty<std::string>(analog_name_prop, a); if ( analog_name.empty() ) { mAnalogInterfaces.clear(); std::ostringstream msg_stream; msg_stream << "Empty analog name (index " << a << ") is not allowed"; throw Exception(msg_stream.str(), VRKIT_LOCATION); } mAnalogInterfaces[a].init(analog_name); } } }