double CameraWorker::_getProp(int prop) { if (!props.contains(prop)) { subscribe(); props[prop] = cam.get(prop); emit propProbingFinished(prop, props[prop]); unsubscribe(); } return props.value(prop); }
int main(int argc, char *argv[]) { auto values = rxcpp::observable<>::from(1, 2, 2, 3, 3, 3, 4, 5, 5, 6) .distinct() //.distinct_until_changed(); .filter([](int v) { return v % 2; }) .max(); values.subscribe([](int v) { printf("%d ", v); }, []{}); return 0; }
ConnectionInfo::ConnectionInfo() : m_connected(false), m_interfaceName("Unknown"), m_interfaceType( ConnectionInfo::Unknown) { subscribe(netstatus_get_domain()); bps_initialize(); // Request all network status events. netstatus_request_events(0); info = NULL; }
void QApplicationStatus::start() { #ifdef QT_DEBUG DEBUG_TAG(1, "status", "start") #endif updateState(Connecting); if (connectSockets()) { subscribe(); } }
MainWindow::MainWindow() : QWidget() , _positionUpdatedTimer(this) , _body(this) , _icon(CreateIcon()) , _titleText(qsl("Telegram")) { subscribe(Theme::Background(), [this](const Theme::BackgroundUpdate &data) { if (data.paletteChanged()) { if (_title) { _title->update(); } updatePalette(); } }); subscribe(Global::RefUnreadCounterUpdate(), [this] { updateUnreadCounter(); }); subscribe(Global::RefWorkMode(), [this](DBIWorkMode mode) { workmodeUpdated(mode); }); subscribe(Messenger::Instance().authSessionChanged(), [this] { checkAuthSession(); }); checkAuthSession(); _isActiveTimer.setCallback([this] { updateIsActive(0); }); _inactivePressTimer.setCallback([this] { setInactivePress(false); }); }
void OctreeVisualizer::setOctreeTopic(const std::string& topic) { unsubscribe(); octree_topic_ = topic; subscribe(); if ( property_grid_ ) { property_grid_->SetPropertyValue( property_grid_->GetProperty( property_prefix_ + TOPIC_PROPERTY ), wxString::FromAscii( octree_topic_.c_str() ) ); } }
bool ListRenders::caseMessage( af::Msg* msg) { //AFINFO("ListRenders::caseMessage:\n"); switch( msg->type()) { case af::Msg::TRendersList: af::MCAfNodes nodes( msg); setList( nodes); subscribe(); return true; } return false; }
/*! All ROS interfaces are shutdown and then restarted after the topic name has been changed. By shutting down all interfaces, it simplifies the process */ void ImageMapDisplay::setMobotPoseCount(const std::string& topic){ unsubscribe(); clear(); try { mobotPoseCount = boost::lexical_cast<int>(topic); } catch( boost::bad_lexical_cast const& ) { mobotPoseCount = 0; ROS_ERROR("Error: mobot pose count was not valid %s", topic.c_str()); } subscribe(); propertyChanged(mobotPoseCountProperty); causeRender(); }
// constructor OdomEstimationNode::OdomEstimationNode() : ros::node("odom_estimation"), robot_state_(*this, true), odom_broadcaster_(*this), vo_notifier_(&robot_state_, this, boost::bind(&OdomEstimationNode::voCallback, this, _1), "vo", "base_link", 10), vel_desi_(2), vel_active_(false), odom_active_(false), imu_active_(false), vo_active_(false), odom_initializing_(false), imu_initializing_(false), vo_initializing_(false) { // advertise our estimation advertise<robot_msgs::PoseWithCovariance>("odom_estimation",10); // subscribe to messages subscribe("cmd_vel", vel_, &OdomEstimationNode::velCallback, 10); subscribe("odom", odom_, &OdomEstimationNode::odomCallback, 10); subscribe("imu_data", imu_, &OdomEstimationNode::imuCallback, 10); // paramters param("odom_estimation/freq", freq_, 30.0); param("odom_estimation/sensor_timeout", timeout_, 1.0); // fiexed transform between camera frame and vo frame vo_camera_ = Transform(Quaternion(M_PI/2.0, -M_PI/2,0), Vector3(0,0,0)); #ifdef __EKF_DEBUG_FILE__ // open files for debugging odom_file_.open("odom_file.txt"); imu_file_.open("imu_file.txt"); vo_file_.open("vo_file.txt"); corr_file_.open("corr_file.txt"); time_file_.open("time_file.txt"); extra_file_.open("extra_file.txt"); #endif };
void PointcloudFloorFilter::connectCb() { boost::lock_guard<boost::mutex> lock(connect_mutex_); if (!pointcloud_pub_.getNumSubscribers()) { unsubscribe(); } else { subscribe(); } }
void LaserScanVisualizer::setScanTopic( const std::string& topic ) { unsubscribe(); scan_topic_ = topic; subscribe(); if ( property_grid_ ) { property_grid_->SetPropertyValue( property_grid_->GetProperty( property_prefix_ + SCAN_TOPIC_PROPERTY ), wxString::FromAscii( scan_topic_.c_str() ) ); } }
GStatsProfiler::GStatsProfiler(const char *format, ...) { char *str; va_list ap; va_start(ap, format); str = getText(format, ap); va_end(ap); name = str; subscribe(); }
BackgroundWidget::BackgroundWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_background)) { createControls(); subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) { notifyFileQueryUpdated(update); }); subscribe(Window::chatBackground(), [this](const Window::ChatBackgroundUpdate &update) { using Update = Window::ChatBackgroundUpdate; if (update.type == Update::Type::New) { _background->updateImage(); } else if (update.type == Update::Type::Start) { needBackgroundUpdate(update.tiled); } }); subscribe(Adaptive::Changed(), [this]() { if (Global::AdaptiveLayout() == Adaptive::WideLayout) { _adaptive->slideDown(); } else { _adaptive->slideUp(); } }); }
void RobotModelDisplay::setMechanismTopic( const std::string& topic ) { unsubscribe(); mechanism_topic_ = topic; subscribe(); if ( mechanism_topic_property_ ) { mechanism_topic_property_->changed(); } }
void PointGroupFactoryImpl::subscribePointGroup( const std::string &hmSymbol, const std::string &generatorString, const std::string &description) { if (isSubscribed(hmSymbol)) { throw std::invalid_argument( "Point group with this symbol is already registered."); } PointGroupGenerator_sptr generator = boost::make_shared<PointGroupGenerator>( hmSymbol, generatorString, description); subscribe(generator); }
NotificationsWidget::NotificationsWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_notify)) { createControls(); subscribe(AuthSession::Current().notifications().settingsChanged(), [this](ChangeType type) { if (type == ChangeType::DesktopEnabled) { desktopEnabledUpdated(); } else if (type == ChangeType::ViewParams) { viewParamUpdated(); } else if (type == ChangeType::SoundEnabled) { _playSound->setChecked(Global::SoundNotify()); } }); }
void RosoutPanel::setTopic(const std::string& topic) { if (topic == topic_) { return; } unsubscribe(); topic_ = topic; subscribe(); }
void AmbientSoundDisplay::setTopic( const std::string& topic )/*{{{*/ { unsubscribe(); clear(); topic_ = topic; subscribe(); // Broadcast the fact that the variable has changed. propertyChanged( topic_property_ ); // Make sure rviz renders the next time it gets a chance. causeRender(); }/*}}}*/
PointCloudSnapshotter() : ros::node("point_cloud_snapshotter") { prev_signal_.header.stamp.fromNSec(0) ; advertise<PointCloud> ("full_cloud", 1) ; subscribe("laser_scanner_signal", cur_signal_, &PointCloudSnapshotter::scannerSignalCallback, 40) ; std::string default_fixed_frame = "torso" ; param("~fixed_frame", fixed_frame_, std::string("torso")) ; first_time_ = true ; }
void SubscribeToolButton::subscribePrivate() { if (menu()) { #ifdef USE_MENUBUTTONPOPUP showMenu(); #endif return; } emit subscribe(true); setSubscribed(true); }
Status ProcessEventSubscriber::init() { auto sc = createSubscriptionContext(); // Monitor for execve syscalls. sc->rules.push_back({AUDIT_SYSCALL_EXECVE, ""}); // Request call backs for all parts of the process execution state. // Drop events if they are encountered outside of the expected state. sc->types = {AUDIT_SYSCALL, AUDIT_EXECVE, AUDIT_CWD, AUDIT_PATH}; subscribe(&ProcessEventSubscriber::Callback, sc); return Status(0, "OK"); }
void ChatSearchFromController::prepare() { setSearchNoResultsText(lang(lng_blocked_list_not_found)); delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled); delegate()->peerListSetTitle(langFactory(lng_search_messages_from)); rebuildRows(); subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::MembersChanged, [this](const Notify::PeerUpdate &update) { if (update.peer == _chat) { rebuildRows(); } })); }
TEST_F(FSEventsTests, test_fsevents_event_action) { // Assume event type is registered. StartEventLoop(); // Simulate registering an event subscriber. auto sub = std::make_shared<TestFSEventsEventSubscriber>(); auto status = sub->init(); auto sc = sub->GetSubscription(real_test_path, 0); EventFactory::registerEventSubscriber(sub); sub->subscribe(&TestFSEventsEventSubscriber::Callback, sc); event_pub_->configure(); CreateEvents(); sub->WaitForEvents(kMaxEventLatency, 1); // Make sure the fsevents action was expected. ASSERT_TRUE(sub->actions_.size() > 0); bool has_created = false; bool has_unknown = false; { WriteLock lock(sub->mutex_); for (const auto& action : sub->actions_) { // Expect either a created event or attributes modified event. if (action == "CREATED" || action == "ATTRIBUTES_MODIFIED") { has_created = true; } else if (action == "UNKNOWN" || action == "") { // Allow an undetermined but existing FSevent on our target to pass. has_unknown = true; } } } EXPECT_TRUE(has_created || has_unknown); CreateEvents(); sub->WaitForEvents(kMaxEventLatency, 2); bool has_updated = false; { WriteLock lock(sub->mutex_); // We may have triggered several updated events. for (const auto& action : sub->actions_) { if (action == "UPDATED") { has_updated = true; } } } EXPECT_TRUE(has_updated); EndEventLoop(); }
//CONSTRUCTOR THAT ESTABLISHES THIS AS A ROS NODE, INIT PUBLIC VARIABLES HERE AxisControl() : ros::node("axis_control_demo"), cv_bridge_(&image_, CvBridge<std_msgs::Image>::CORRECT_BGR), cv_image_(NULL), quit(false) { //This pops up an OpenCV highgui window and puts in mouse call back and 3 sliders cvNamedWindow("cv_view", CV_WINDOW_AUTOSIZE); cvSetMouseCallback("cv_view", left_mouse, 0); cvCreateTrackbar("Pan", "cv_view", &g_pan, 350, pan_callback); cvCreateTrackbar("Tilt", "cv_view", &g_tilt, 135, tilt_callback); cvCreateTrackbar("Zoom", "cv_view", &g_zoom, 10000, zoom_callback); //Ros stuff, subscribe to image and ptz state nodes subscribe("image", image_, &AxisControl::image_cb, 1); subscribe("ptz_state", ptz_state_, &AxisControl::ptz_cb, 1); //Advertise that you'll be talking commands to the ptz advertise<axis_cam::PTZActuatorCmd>("ptz_cmd", 1); //I PRE SET THE COMMANDS HERE g_pan = 175; ptz_cmd_.pan.cmd = g_pan - 175; ptz_cmd_.pan.rel = 0; ptz_cmd_.pan.mode = 0; ptz_cmd_.pan.valid = 1; g_pan_go = true; //Start at 0 g_tilt = 45; ptz_cmd_.tilt.cmd = g_tilt - 45; ptz_cmd_.tilt.rel = 0; ptz_cmd_.tilt.mode = 0; ptz_cmd_.tilt.valid=1; g_tilt_go = true; g_zoom = 0; ptz_cmd_.zoom.cmd = g_zoom; ptz_cmd_.zoom.rel = 0; ptz_cmd_.zoom.mode = 0; ptz_cmd_.zoom.valid = 1; g_zoom_go = true; }
GStatsChangeHist::GStatsChangeHist(const char *format,...) { char *str; va_list ap; va_start(ap, format); str = getText(format, ap); va_end(ap); name = str; subscribe(); lastUpdate = 0; }
void reconfigureCallback(jsk_perception::HoughLinesConfig &new_config, uint32_t level) { config_ = new_config; _rho = config_.rho; _theta = config_.theta; _threshold = config_.threshold; _minLineLength = config_.minLineLength; _maxLineGap = config_.maxLineGap; if (subscriber_count_) { // @todo Could do this without an interruption at some point. unsubscribe(); subscribe(); } }
void EffortDisplay::setRobotDescription( const std::string& description_param ) { description_param_ = description_param; propertyChanged(robot_description_property_); if ( isEnabled() ) { load(); unsubscribe(); subscribe(); causeRender(); } }
InteractiveMarkerClient::InteractiveMarkerClient( tf::Transformer& tf, const std::string& target_frame, const std::string &topic_ns ) : state_("InteractiveMarkerClient",IDLE) , tf_(tf) { target_frame_ = target_frame; if ( !topic_ns.empty() ) { subscribe( topic_ns ); } callbacks_.setStatusCb( boost::bind( &InteractiveMarkerClient::statusCb, this, _1, _2, _3 ) ); }
LocalStorageBox::LocalStorageBox() : AbstractBox() , _clear(this, lang(lng_local_storage_clear), st::defaultBoxLinkButton) , _close(this, lang(lng_box_ok), st::defaultBoxButton) { connect(_clear, SIGNAL(clicked()), this, SLOT(onClear())); connect(_close, SIGNAL(clicked()), this, SLOT(onClose())); connect(App::wnd(), SIGNAL(tempDirCleared(int)), this, SLOT(onTempDirCleared(int))); connect(App::wnd(), SIGNAL(tempDirClearFailed(int)), this, SLOT(onTempDirClearFailed(int))); subscribe(FileDownload::ImageLoaded(), [this] { update(); }); checkLocalStoredCounts(); prepare(); }
void LuaSystem::subscribeEntity(Entity &entity, const std::string &eventName) { // Subscribe the LuaSystem to the specified event, and tell that the // entity that's related to this script is interested in such events. LuaComponent *comp = entity.getComponent<LuaComponent>(); if(comp->subscribedEvents.find(eventName) == comp->subscribedEvents.end()) { subscribe(eventName); comp->subscribedEvents.insert(eventName); m_subscribedScripts[eventName].push_back(&entity); } }