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 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; }
/** * 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; }
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; }
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); }
/** * 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")) ); }
bool Flock::config(jccl::ConfigElementPtr e) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL) << "Flock::Flock(jccl::ConfigElementPtr)\n" << vprDEBUG_FLUSH; // read in Position's config stuff, // --> this will be the port and baud fields if(! (Input::config(e) && Position::config(e))) { return false; } // Keep this up to date with the version of the element definition we're // expecting to handle. const unsigned int cur_version(2); bool status(true); // 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 ( e->getVersion() < cur_version ) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutBOLD(clrRED, "ERROR") << " [Flock] Element named '" << e->getName() << "'" << std::endl << vprDEBUG_FLUSH; vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << "is version " << e->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; status = false; } else { // keep FlockStandalone's port and baud members in sync with Input's port // and baud members. mFlockOfBirds.setPort( e->getProperty<std::string>("port") ); mFlockOfBirds.setBaudRate( e->getProperty<int>("baud") ); // Set mFlockOfBirds with the config info. mFlockOfBirds.setHemisphere( (BIRD_HEMI) e->getProperty<int>("hemisphere") ); mFlockOfBirds.setMasterAddress( e->getProperty<unsigned>("master_address") ); mFlockOfBirds.setAddressingMode( (::Flock::AddressingMode) e->getProperty<int>("addressing_mode") ); mFlockOfBirds.setFilterType( (BIRD_FILT) e->getProperty<int>("filter") ); // mFlockOfBirds.setOutputFormat(::Flock::Output::PositionQuaternion); // Default to pos quaternion } return status; }
bool CyberGlove::config(jccl::ConfigElementPtr e) { if(! (Input::config(c) && Glove::config(c) )) { return false; } vprASSERT(mThread == NULL); // This should have been set by Input(c) mPortName = e->getProperty<std::string>("port"); mBaudRate = e->getProperty<int>("baud"); char* home_dir = e->getProperty("calibration_dir").cstring(); if (home_dir != NULL) { mCalDir = new char [strlen(home_dir) + 1]; strcpy(mCalDir,home_dir); } std::string glove_pos_proxy = e->getProperty("glove_position"); // Get the name of the pos_proxy if(glove_pos_proxy == std::string("")) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED, "ERROR:") << " Cyberglove has no posProxy." << std::endl << vprDEBUG_FLUSH; return false; } // init glove proxy interface /* XXX: Doesn't appear to be used int proxy_index = gadget::InputManager::instance()->getProxyIndex(glove_pos_proxy); if(proxy_index != -1) { mGlovePos[0] = gadget::InputManager::instance()->->getPosProxy(proxy_index); } else { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED, "ERROR:") << " CyberGlove::CyberGlove: Can't find posProxy." << std::endl << std::endl << vprDEBUG_FLUSH; } */ mGlove = new CyberGloveBasic( mCalDir, mPortName, mBaudRate ); 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; } }
/** * Check if the device factory or proxy factory can handle the element. */ bool InputManager::configureProxy(jccl::ConfigElementPtr element) { std::string proxy_name = element->getFullName(); vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL, std::string("gadget::InputManager::configureProxy: Named: ") + proxy_name + std::string("\n"), std::string("done configuring proxy\n")); Proxy* new_proxy; // Tell the factory to load the proxy // NOTE: The config for the proxy registers it with the input manager new_proxy = ProxyFactory::instance()->loadProxy(element); // Check for success if(NULL == new_proxy) { vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED,"ERROR:") << " gadget::InputManager::configureProxy: Proxy construction failed:" << proxy_name << std::endl << vprDEBUG_FLUSH; return false; } vprASSERT(proxy_name == new_proxy->getName()); // -- Add to proxy table if(false == addProxy(new_proxy)) { return false; } 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; } }
/** * 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; }
void DisplayManager::setDisplaySystemElement(jccl::ConfigElementPtr elt) { if ( elt->getVersion() < 3 ) { vprDEBUG(vrjDBG_DISP_MGR, vprDBG_WARNING_LVL) << clrOutBOLD(clrYELLOW, "WARNING") << ": Display system element '" << elt->getName() << "'" << std::endl; vprDEBUG_NEXTnl(vrjDBG_DISP_MGR, vprDBG_WARNING_LVL) << " is out of date.\n"; vprDEBUG_NEXTnl(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL) << " Expected version 3 but found version " << elt->getVersion() << ". Pipe\n"; vprDEBUG_NEXTnl(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL) << " configurations will not work.\n" << vprDEBUG_FLUSH; } mDisplaySystemElement = elt; }
/** Add the pending elm to the configuration. * @pre configCanHandle (elm) == true. * @return true iff elm was successfully added to configuration. */ bool RIMPlugin::configAdd(jccl::ConfigElementPtr elm) { vprASSERT(ClusterManager::instance()->recognizeRemoteDeviceConfig(elm)); vprASSERT(ClusterManager::instance()->isClusterActive()); std::string device_name = elm->getName(); vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_STATUS_LVL) << clrOutBOLD(clrCYAN,"[RIMPlugin] ") << "Adding device: " << device_name << std::endl << vprDEBUG_FLUSH; vprASSERT(cluster::ClusterManager::instance()->isClusterActive() && "RIM called in non-cluster mode."); bool master = cluster::ClusterManager::instance()->isMaster(); bool result(false); // If we are the master, configure the device and tell all slaves to prepare // virtual devices. if (master) { vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_STATUS_LVL) << clrOutBOLD(clrMAGENTA, "[RemoteInputManager]") << "Configuring device on master node: " << device_name << std::endl << vprDEBUG_FLUSH; gadget::InputManager::instance()->configureDevice(elm); gadget::InputPtr input_device = gadget::InputManager::instance()->getDevice(device_name); if ( input_device != NULL ) { result = addDeviceServer(device_name, input_device); DeviceServerPtr device_server = getDeviceServer(device_name); vprASSERT(NULL != device_server.get() && "Must have device server."); const vpr::Uint16 dev_type_id(input_device->getTypeId()); const vpr::GUID& temp_guid(device_server->getId()); DeviceAckPtr device_ack = DeviceAck::create(mHandlerGUID, temp_guid, device_name, dev_type_id, true); vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_STATUS_LVL) << clrOutBOLD(clrMAGENTA, "[RemoteInputManager]") << "Sending device ack [" << device_name << "] to all cluster nodes." << std::endl << vprDEBUG_FLUSH; cluster::ClusterManager::instance()->getNetwork()->sendToAll(device_ack); } } else { vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_STATUS_LVL) << clrOutBOLD(clrMAGENTA, "[RemoteInputManager]") << "Configuring device on slave node: " << device_name << std::endl << vprDEBUG_FLUSH; result = true; } return result; }
bool SimAnalog::config(jccl::ConfigElementPtr element) { //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::config()\n"<< vprDEBUG_FLUSH; if (! (Input::config(element) && Analog::config(element) && SimInput::config(element)) ) { return false; } std::vector<jccl::ConfigElementPtr> key_inc_list, key_dec_list; int key_count = element->getNum("increment_keypress"); for ( int i = 0; i < key_count; ++i ) { key_inc_list.push_back(element->getProperty<jccl::ConfigElementPtr>("increment_keypress", i)); } key_count = element->getNum("decrement_keypress"); for ( int i = 0; i < key_count; ++i ) { key_dec_list.push_back(element->getProperty<jccl::ConfigElementPtr>("decrement_keypress", i)); } mSimKeysUp = readKeyList(key_inc_list); mSimKeysDown = readKeyList(key_dec_list); mAnaStep = element->getProperty<float>("delta"); mInitialValue = element->getProperty<float>("initial_value"); // Initialize all the data to the inital_value size_t num_pairs = mSimKeysUp.size(); mAnaData = std::vector<AnalogData>(num_pairs); for (size_t i=0; i<num_pairs; ++i) { mAnaData[i].setValue(mInitialValue); } mAutoReturn = element->getProperty<bool>("auto_return"); 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; }
/** * 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 }
bool CorbaPerfPlugin::configAdd(jccl::ConfigElementPtr element) { const unsigned int min_def_version(2); if ( element->getVersion() < min_def_version ) { vprDEBUG(jcclDBG_PLUGIN, vprDBG_WARNING_LVL) << clrOutBOLD(clrYELLOW, "WARNING") << ": Element named '" << element->getName() << "'" << std::endl; vprDEBUG_NEXTnl(jcclDBG_PLUGIN, vprDBG_WARNING_LVL) << "is version " << element->getVersion() << ", but we expect at least version " << min_def_version << ".\n"; vprDEBUG_NEXTnl(jcclDBG_PLUGIN, vprDBG_WARNING_LVL) << "Default values will be used for some settings.\n" << vprDEBUG_FLUSH; } // If the ORB is already running, we need to shut it down first. One big // reason for doing this is to release the resources (memory and so on) // allocated previously. if ( mInterface != NULL || mCorbaManager != NULL ) { vprDEBUG(vrjDBG_PLUGIN, vprDBG_STATE_LVL) << "[CorbaPerfPlugin::configAdd()] Attempting to shut down " << "existing CORBA instance.\n" << vprDEBUG_FLUSH; // stopCorba() will call disable() if we are still in the enabled state. stopCorba(); } // We'll ignore the return value for now. startCorba() prints out enough // warning information on its own if something goes wrong. this->startCorba(element->getProperty<std::string>("endpoint_addr"), element->getProperty<vpr::Uint16>("endpoint_port")); return true; }
/** Add the pending element to the configuration. * @pre configCanHandle (element) == true. * @return true iff element was successfully added to configuration. */ bool RIMPlugin::configAdd(jccl::ConfigElementPtr element) { // XXX: We may still use this to handle the configuration // of clustered RIM connections. if ( ClusterManager::instance()->recognizeRemoteDeviceConfig(element) ) { std::string device_host = element->getProperty<std::string>("device_host"); gadget::Node* node = ClusterManager::instance()->getNetwork()->getNodeByName(device_host); std::string device_name = element->getName(); vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL) << clrOutBOLD(clrCYAN,"[RIMPlugin] ") << "Adding the Remote Device: " << device_name << " to the RIM Pending List" << std::endl << vprDEBUG_FLUSH; if ( node == NULL ) { vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_STATUS_LVL) << clrOutBOLD(clrCYAN,"[RIMPlugin] ") << clrOutBOLD(clrRED, "WARNING:") << " Cluster node: " << device_host << " does not exist, there must be an error in the ClusterDepChecker." << std::endl << vprDEBUG_FLUSH; return false; } else if ( !node->isConnected() ) { vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL) << clrOutBOLD(clrCYAN,"[RIMPlugin] ") << clrOutBOLD(clrRED, "WARNING:") << " Cluster node: " << device_host << " is not connected, there must be an error in the ClusterDepChecker." << std::endl << vprDEBUG_FLUSH; return false; } DeviceRequest* device_req = new DeviceRequest(getHandlerGUID(), device_name); mRIM.addPendingDeviceRequest(device_req, node); setActive(true); return(true); } else { vprDEBUG(gadgetDBG_RIM,vprDBG_CRITICAL_LVL) << clrOutBOLD(clrCYAN,"[RIMPlugin] ") << clrOutBOLD(clrRED, "ERROR: ") << "recognizeRemoteDeviceConfig is broken." << std::endl << vprDEBUG_FLUSH; return(false); } }
/** * Removes the element from the current configuration. * @pre configCanHandle(element) == true */ bool SoundManagerSonix::configRemove(jccl::ConfigElementPtr element) { // remove any specified sounds... int size = element->getNum("sound"); for (int x = 0; x < size; ++x) { jccl::ConfigElementPtr sound_element = element->getProperty<jccl::ConfigElementPtr>("sound", x); std::string alias(sound_element->getName()); snx::sonix::instance()->remove(alias); } return true; }
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; }
bool DirectXJoystick::config(jccl::ConfigElementPtr e) { if(! (Input::config(e) && Digital::config(e) && Analog::config(e))) { return false; } mJsLabel = e->getName(); unsigned int num_axis_buttons = e->getNum("axis_buttons"); for ( unsigned int i = 0; i < num_axis_buttons; ++i ) { unsigned idx = e->getProperty<int>("axis_buttons", i); mAxisButtonIndices.push_back(idx); } // Override whatever the user configured with the minimum and maximum values // used by the standalone Direct Input device. User configuration input is // useless in this case. setMin((float) DirectXJoystickStandalone::getAxisMin()); setMax((float) DirectXJoystickStandalone::getAxisMax()); return true; }
/** * 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; }
bool SimDigital::config(jccl::ConfigElementPtr element) { //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimDigital::config()\n"<< vprDEBUG_FLUSH; if (! (Input::config(element) && Digital::config(element) && SimInput::config(element)) ) { return false; } std::vector<jccl::ConfigElementPtr> key_list; int key_count = element->getNum("key_pair"); for ( int i = 0; i < key_count; ++i ) { key_list.push_back(element->getProperty<jccl::ConfigElementPtr>("key_pair", i)); } mSimKeys = readKeyList(key_list); return true; }
bool AbstractNetworkManager::configRemove(jccl::ConfigElementPtr element) { if (recognizeClusterMachineConfig( element )) { vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL ) << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" ) << " Removing the Node: " << element->getName() << " from the Cluster Network\n" << vprDEBUG_FLUSH; return true; } else { vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL ) << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" ) << " ERROR, Something is seriously wrong, we should never get here\n" << vprDEBUG_FLUSH; return false; } }
bool IntersenseAPI::config(jccl::ConfigElementPtr e) { vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL) << "*** IntersenseAPI::config() ***" << std::endl << vprDEBUG_FLUSH; // Configure the subclasses if (!(Input::config(e) && Position::config(e) && Digital::config(e) && Analog::config(e))) { return false; } // Set various attributes of the Intersense driver mTracker.setPort( e->getProperty<std::string>("port") ); mTracker.setVerbose(e->getProperty<bool>("verbose")); // Get the location of the Intersense DSO mISenseDriverLocation = e->getProperty<std::string>("driver"); // Create a new array of StationConfigs mStations.resize(e->getNum("stations")); // Configure each station for( unsigned int i = 0; i < mStations.size(); ++i ) { jccl::ConfigElementPtr station_config = e->getProperty<jccl::ConfigElementPtr>("stations", i); mStations[i].enabled = station_config->getProperty<bool>("enabled"); mStations[i].stationIndex = station_config->getProperty<int>("station_index"); mStations[i].useDigital = station_config->getProperty<bool>("use_digital"); mStations[i].useAnalog = station_config->getProperty<bool>("use_analog"); mStations[i].dig_num = station_config->getProperty<int>("digital_count"); mStations[i].ana_num = station_config->getProperty<int>("analog_count"); } return true; }
/** * Check if the device factory or proxy factory can handle the element. */ bool InputManager::configureDevice(jccl::ConfigElementPtr element) { bool ret_val; std::string dev_name = element->getFullName(); vpr::DebugOutputGuard dbg_output(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL, std::string("InputManager::configureDevice: device[") + dev_name + std::string("]\n"), std::string("done configuring device\n")); Input* new_device; new_device = DeviceFactory::instance()->loadDevice(element); if ((new_device != NULL) && (new_device->startSampling())) { addDevice(new_device); ret_val = true; vprDEBUG(gadgetDBG_INPUT_MGR,vprDBG_STATE_LVL) << " Successfully added device: " << dev_name << std::endl << vprDEBUG_FLUSH; } else { vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL) << clrOutNORM(clrRED,"ERROR:") << "New device " << clrSetBOLD(clrCYAN) << dev_name << clrRESET << " failed to start. Deleting instance" << std::endl << vprDEBUG_FLUSH; if ( NULL != new_device ) { delete new_device; } ret_val = false; } return ret_val; }
bool AbstractNetworkManager::configAdd(jccl::ConfigElementPtr element) { if (recognizeClusterMachineConfig(element)) { // -If local machine element // -Add machine specific ConfigElements to the pending list. // -Start Listening thread // -Else // -Add Node to AbstractNetworkManager if (isLocalHost( element->getProperty<std::string>( "host_name" ) )) { // XXX: Hack to ensure that we don't start listening for connections until // we have fully configured all other nodes. ElementPred pred(getClusterNodeElementType()); jccl::ConfigManager* cfg_mgr = jccl::ConfigManager::instance(); unsigned int num_pending_nodes = std::count_if(cfg_mgr->getPendingBegin(), cfg_mgr->getPendingEnd(), pred); if (num_pending_nodes > 1) { vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL ) << clrSetBOLD(clrRED) << clrOutBOLD( clrMAGENTA,"[AbstractNetworkManager]" ) << " Some nodes not configured yet: " << num_pending_nodes << clrRESET << std::endl << vprDEBUG_FLUSH; return false; } // NOTE: Add all machine dependent ConfigElementPtr's here vprASSERT( element->getNum("display_system") == 1 && "A Cluster System element must have exactly 1 display_system element" ); std::vector<jccl::ConfigElementPtr> cluster_node_elements = element->getChildElements(); for (std::vector<jccl::ConfigElementPtr>::iterator i = cluster_node_elements.begin(); i != cluster_node_elements.end(); ++i) { jccl::ConfigManager::instance()->addConfigElement(*i, jccl::ConfigManager::PendingElement::ADD); vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL ) << clrSetBOLD(clrCYAN) << clrOutBOLD( clrMAGENTA,"[AbstractNetworkManager]" ) << " Adding Machine specific ConfigElement: " << (*i)->getName() << clrRESET << std::endl << vprDEBUG_FLUSH; } const int listen_port = element->getProperty<int>( "listen_port" ); startListening( listen_port, false ); } else { vprDEBUG( gadgetDBG_NET_MGR, vprDBG_CONFIG_LVL ) << clrOutBOLD( clrMAGENTA, "[AbstractNetworkManager]" ) << " Adding Node: " << element->getName() << " to the Cluster Network\n" << vprDEBUG_FLUSH; std::string name = element->getName(); std::string host_name = element->getProperty<std::string>( "host_name" ); vpr::Uint16 listen_port = element->getProperty<int>( "listen_port" ); addNode(name, host_name, listen_port); } return true; } return false; }
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; }