YarpManager::YarpManager(): m_acuity(0), m_brightness(0), m_fov(0), m_threshold(0) { std::cout<<"## YarpManager Initialisation ##"<<std::endl; std::cout<<"- Setting default parameters value"<<std::endl; setAcuity(3); setFov(100); setBrightness(50); setTreshold(150); std::cout<<"- Setting up YARP network"<<std::endl; yarp::os::Network::init(); std::cout<<"- Opening YARP port"<<std::endl; std::cout<<" * /target/module"<<std::endl; m_modulePort.open("/target/module"); m_modulePort.setStrict(); m_modulePort.useCallback(*this); std::cout<<" * /target/parameter"<<std::endl; m_parameterPort.open("/target/parameter"); m_parameterPort.setStrict(); m_parameterPort.useCallback(*this); }
void YarpManager::onRead(yarp::os::Bottle& b) { std::string name = b.get(0).asString().c_str(); int value = b.get(1).asInt(); if(name == "acuity") setAcuity(value); else if(name == "fov") setFov(value); else if(name == "brightness") setBrightness(value); else if(name == "threshold") setTreshold(value); else std::cout<<"Bottle message incorrect"<<std::endl; }
void initSensor(Sensor * sensor) { /* esempio di configurazione cablata nel codice: * ID 1 -> allarme * ID 2 -> allarme e confidenzialità * ID 3 -> niente */ if (sensor->ID < 3) { setAlarm(sensor, True); setTreshold(sensor, UPPER_TRESHOLD, LOWER_TRESHOLD); } else setAlarm(sensor, False); if (sensor->ID == 2) sensor->confidential=True; else sensor->confidential=False; }