/** * Invoked periodically to give the connection handlers * time to cleanup and handle state updates */ static void handle_periodic_timeout(ev_loop *lp, ev_timer *t, int ready_events) { // Get the user data worker_ev_userdata *data = ev_userdata(lp); // Prepare to invoke the handler bloom_conn_handler handle; handle.config = data->netconf->config; handle.mgr = data->netconf->mgr; handle.conn = NULL; // Invoke the connection handler layer periodic_update(&handle); }
void periodic_update() { v_ = calc(); if (slot_) { std::cerr << "periodic\n"; std::thread([this]() { std::cerr << "next\n"; ::usleep(update_interval_usec_); auto slot = slot_; if (slot_) slot->on_changed(slot_, parent_); periodic_update(); }).detach(); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // serialport m_serial = new QSerialPort(this); connect(ui->eStop, SIGNAL(clicked()), this, SLOT(eStop_clicked()));// connect(ui->eStepPwr, SIGNAL(clicked()), this, SLOT(eStepPwr_clicked()));// // connect(ui->spinBoxExtTarget, SIGNAL(valueChanged (int)), this, SLOT(extSpinbox_changed())); connect(ui->ExtUpX10, SIGNAL(clicked()), this, SLOT(extTarget_Up_10()));// connect(ui->ExtUpX1, SIGNAL(clicked()), this, SLOT(extTarget_Up_1()));// connect(ui->ExtDnX1, SIGNAL(clicked()), this, SLOT(extTarget_Dn_1()));// connect(ui->ExtDnX10, SIGNAL(clicked()), this, SLOT(extTarget_Dn_10()));// connect(ui->extEnable, SIGNAL(clicked()), this, SLOT(extEnable_clicked())); // connect(ui->spinBoxBedTarget, SIGNAL(valueChanged (int)), this, SLOT(bedSpinbox_changed())); connect(ui->BedUpX10, SIGNAL(clicked()), this, SLOT(bedTarget_Up_10()));// connect(ui->BedUpX1, SIGNAL(clicked()), this, SLOT(bedTarget_Up_1()));// connect(ui->BedDnX1, SIGNAL(clicked()), this, SLOT(bedTarget_Dn_1()));// connect(ui->BedDnX10, SIGNAL(clicked()), this, SLOT(bedTarget_Dn_10()));// connect(ui->bedEnable, SIGNAL(clicked()), this, SLOT(bedEnable_clicked())); connect(ui->getCode, SIGNAL(clicked()), this, SLOT(getCode_clicked())); connect(ui->exitButton, SIGNAL(clicked()), this, SLOT(exitButton_clicked())); connect(ui->searchButton, SIGNAL(clicked()), this, SLOT(searchButton_clicked())); connect(ui->comboBoxDevices, SIGNAL(activated(int)), this, SLOT(comboBoxDevices_clicked())); connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectButton_clicked()));// connect(ui->comboBoxFiles, SIGNAL(activated(int)), this, SLOT(comboBoxFiles_clicked())); connect(ui->waittempsButton, SIGNAL(clicked()), this, SLOT(waittempsButton_clicked())); m_chartScene.setSceneRect(0, 0, 600, 280); m_chartScene.setBackgroundBrush(Qt::white); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(periodic_update())); ui->comboBoxDevices->addItem("Select a Device to connect to",""); ui->comboBoxFiles->addItem("No \"g\" code file selected",""); ui->eStop->setStyleSheet("background-color: #00C000; border-radius: 5px; color : #ffffff;"); timer->start(1000); }
bool connect(::statefs_slot *slot) { slot_ = slot; std::cerr << "connect to seconds\n"; periodic_update(); return true; }