OwncloudDolphinPluginHelper::OwncloudDolphinPluginHelper() { connect(&_socket, &QLocalSocket::connected, this, &OwncloudDolphinPluginHelper::slotConnected); connect(&_socket, &QLocalSocket::readyRead, this, &OwncloudDolphinPluginHelper::slotReadyRead); _connectTimer.start(45 * 1000, Qt::VeryCoarseTimer, this); tryConnect(); }
void MainWindow::initConnectParams() { QEventLoop eventLoop, eventLoop2; for(int i = 0; i < availablePorts.size(); i++) { for(int j = 0; j < baudList.size(); j++) { currPair.port = availablePorts.at(i); currPair.baud = baudList.at(j); pserial = new AbstractSerial(this); if(tryConnect(pserial, currPair.port, currPair.baud)) { answerFlag = true; connect(this, SIGNAL(signPackReceive(QByteArray)), this, SLOT(parceAnswerPack(QByteArray))); connect(this, SIGNAL(signPackReceive(QByteArray)), &eventLoop2, SLOT(quit())); connect(pserial, SIGNAL(readyRead()), this, SLOT(onProcSerialReceive())); connect(pserial, SIGNAL(readyRead()), &eventLoop, SLOT(quit())); Command comm(-1, -1, 0x6c); sendPack(comm); QTimer::singleShot(100, &eventLoop, SLOT(quit())); eventLoop.exec(); QTimer::singleShot(100, &eventLoop2, SLOT(quit())); eventLoop2.exec(); } answerFlag = true; pserial->close(); } } }
/* Function: mdlOutputs ======================================================= * */ static void mdlOutputs(SimStruct *S, int_T tid) { uint8_T *y0 = (uint8_T *)ssGetOutputPortRealSignal(S,0); const int_T y_width = ssGetOutputPortWidth(S,0); int i; char* buffer[1]; int connected=ssGetIWorkValue(S, 0); int curCon = ssGetIWorkValue(S, 2); char* last = (void*) ssGetPWorkValue(S, 1); if(connected==1) { fcntl(curCon, F_SETFL, O_NONBLOCK); if(recv(curCon,buffer, 1, MSG_PEEK)>0) { read(curCon,last,y_width); /*printf("%.*s\n",y_width,last);*/ } } else { connected=tryConnect(S); if (connected) printf("Connected To Client\n"); } /*fflush(stdout);*/ for(i=0;i<y_width;i++) y0[i]=last[i]; ssSetIWorkValue(S, 0, connected); /*ssSetPWorkValue(S, 0, (void*) newsockfd);*/ }
void CAsyncSerialPort::reconnectTimerHandler(const boost::system::error_code& error) { if (error != 0) throw exception::CException("Error code should be 0 here"); tryConnect(); }
void TcpSocketImpl::endConnect() { log_trace("ending connect"); if(_pfd && ! _socket.wbuf()) { _pfd->events &= ~POLLOUT; } checkPendingError(); if( _isConnected ) return; try { while (true) { pollfd pfd; pfd.fd = this->fd(); pfd.revents = 0; pfd.events = POLLOUT; log_debug("wait " << timeout() << " ms"); bool avail = this->wait(this->timeout(), pfd); if (avail) { // something has happened int sockerr = checkConnect(); if (_isConnected) return; if (++_addrInfoPtr == _addrInfo.impl()->end()) { // no more addrInfo - propagate error throw IOError(connectFailedMessage(_addrInfo, sockerr)); } } else if (++_addrInfoPtr == _addrInfo.impl()->end()) { log_debug("timeout"); throw IOTimeout(); } close(); _connectResult = tryConnect(); if (_isConnected) return; checkPendingError(); } } catch(...) { close(); throw; } }
bool MainWindow::sendTryConn(QString _port, QString _baud) { currPair.port = _port; currPair.baud = _baud; pserial->close(); pserial = new AbstractSerial(this); return tryConnect(pserial, _port, _baud); }
// - - - - - - - - // karmaModule methods // - - - - - - - - bool serialControllerV1::enable(){ //singletonModule<serialControllerV1>::enable(); bool ret = karmaModule::enable(); tryConnect(hardwareID); return ret; }
void OwncloudDolphinPluginHelper::timerEvent(QTimerEvent *e) { if (e->timerId() == _connectTimer.timerId()) { tryConnect(); return; } QObject::timerEvent(e); }
void MainWindow::boot_connect() { //delete pserial; pserial->close(); pserial = new AbstractSerial(this); pserial->enableEmitStatus(true); tryConnect(pserial, currPair.port, currPair.baud); connect(pserial, SIGNAL(readyRead()), this, SLOT(onProcSerialReceive())); }
void CAsyncSerialPort::start() { if (!!m_asyncThread) return; // Already started // Try to connect tryConnect(); m_asyncThread.reset(new boost::thread(boost::bind(&boost::asio::io_service::run, &m_ioService))); }
/** Funkcja próbująca uzyskać dostęp do głównego okna czatu: * * Sprawdzane są przesyłane dane i w przypadku ich prawidłowości próbowane jest * nawiązanie połączenia z serwerem. W przypadku niepowodzenia obsługa błędów. * */ void SignIn::enterChat() { bool noError = true; ui->connectionLabel->setVisible(false); // Sprawdzenie prawidłości podanego adresu IP if (!checkIPFormat(ui->ipAddressEdit->text())) { ui->ipAddressEdit->setStyleSheet("background-color: rgb(255, 255, 255);border: 1px solid #FF0000"); noError = false; } else { ui->ipAddressEdit->setStyleSheet("background-color: rgb(255, 255, 255);border: 1px solid #AAAAAA"); } // Sprawdzenie prawidłości podanego numeru portu if (!checkPortFormat(ui->portEdit->text())) { ui->portEdit->setStyleSheet("background-color: rgb(255, 255, 255);border: 1px solid #FF0000"); noError = false; } else { ui->portEdit->setStyleSheet("background-color: rgb(255, 255, 255);border: 1px solid #AAAAAA"); } // Sprawdzenie prawidłości podanej nazwy użytkownika if (!checkUsernameFormat(ui->usernameEdit->text())) { ui->usernameEdit->setStyleSheet("background-color: rgb(255, 255, 255);border: 1px solid #FF0000"); noError = false; } else { ui->usernameEdit->setStyleSheet("background-color: rgb(255, 255, 255);border: 1px solid #AAAAAA"); } if (!checkPasswordFormat(ui->passwordEdit->text())) { ui->passwordEdit->setStyleSheet("background-color: rgb(255, 255, 255);border: 1px solid #FF0000"); noError = false; } else { ui->passwordEdit->setStyleSheet("background-color: rgb(255, 255, 255);border: 1px solid #AAAAAA"); } // Jeżeli nie było żadnych błędów próba nawiązania połączenia if (noError) { // Zablokowanie możliwości ponownego połączenia dopóki nie otrzymamy informacji o niepowodzeniu ui->ipAddressEdit->setEnabled(false); ui->portEdit->setEnabled(false); ui->usernameEdit->setEnabled(false); ui->startChatButton->setEnabled(false); // Czy udało się połączyć if (!tryConnect()) { // Odblokowanie możliwości ponownego łączenia z serwerem ui->ipAddressEdit->setEnabled(true); ui->portEdit->setEnabled(true); ui->usernameEdit->setEnabled(true); ui->startChatButton->setEnabled(true); ui->connectionLabel->setVisible(true); } } }
void ServerConnection::errHandler(const boost::system::error_code& e, Connection*, std::string dummy) { LOGERROR() << "serverconnection error" <<"ip"<<m_ip.c_str() <<"port"<<m_port <<"dummy"<<dummy <<LOGEND(); tryConnect(); }
void SignalSlotConnection::setConnectionType(ConnectionType value) { Q_D(SignalSlotConnection); d->_connectionType = value; if(d->_internalConnection) { tryDisconnect(); tryConnect(); } }
// load module settings from xml // xml's cursor is pushed to the root of the <module> tag to load bool serialControllerV1::loadFromXML(ofxXmlSettings& xml){ reset(); bool ret=karmaModule::loadFromXML(xml); //OSCListeningPort = xml.getValue("OSCListeningPort", KM_OSC_PORT_IN ); tryConnect(xml.getValue("hwID", hardwareID) ); return ret; }
void ServerConnection::init(std::string ip, int port) { m_ip = ip; m_port = port; this->setErrHandler(boost::bind(&ServerConnection::errHandler, this, boost::asio::placeholders::error, _2, _3)); tryConnect(); /* m_tickTimer.expires_from_now(boost::posix_time::seconds(CONNECT_INTERVAL)); m_tickTimer.async_wait(boost::bind(&ServerConnection::tick, this, boost::asio::placeholders::error));*/ }
bool TcpSocketImpl::beginConnect(const AddrInfo& addrInfo) { log_trace("begin connect"); assert(!_isConnected); _addrInfo = addrInfo; _addrInfoPtr = _addrInfo.impl()->begin(); _connectResult = tryConnect(); checkPendingError(); return _isConnected; }
void SignalSlotConnection::onLiveChanging(bool value) { Q_D(SignalSlotConnection); if(value && !d->_internalConnection) { tryConnect(); } if(!value && d->_internalConnection) { tryDisconnect(); } }
void RhrController::addClient(const Port *client) { if (!m_clients.empty()) { CERR << "not servicing client port " << *client << std::endl; } m_clients.insert(client); if (!m_rhr) { initializeServer(); } sendConfigObject(); tryConnect(); }
int EvTransport::sendMessage(void* msg, size_t msglen) { assert(sock != NULL); int r; if (!connected) { r = tryConnect(); if (r != 0) return -1; } pendingMessages.push_back(make_pair(msg, msglen)); sendPendingMessages(); return 0; }
void MainWindow::mainCycle() { while(chckBxInterView->isChecked()) { bool flag69 = false; if(!commLst.isEmpty()) { if((commLst.last().time == 0) || (commLst.last().command == 0x03)) sendPack(commLst.last()); qDebug() << "commLst.last().command =" << QString::number(commLst.last().command, 16); for(int i = commLst.size() - 1; i >= 0 ; i--) { if((commLst.at(i).numCh > 0) && (commLst.at(i).counter > 0) && (commLst.at(i).command != 0x03)) { Command comm(commLst.takeAt(i)); int sni, bni; sni = mdl->mdlDt(mdl->rowMdl(comm.numCh, comm.numClass), 29).toInt(); bni = mdl->mdlDt(mdl->rowMdl(comm.numCh, comm.numClass), 28).toInt(); qDebug() << "comm.time =" << comm.time << "sni * bni =" << sni * bni; //if(comm.time < (sni * bni)) { if(((bni / 2) < 1) || (comm.time < (bni / 2))) { comm.time = 0; commLst.push_back(comm); sendPack(commLst.last()); } else { comm.time--; commLst.push_front(comm); mdl->setMdlDt(mdl->rowMdl(comm.numCh, comm.numClass), 19, QString::number(comm.time / 2)); } flag69 = true; } } } if(flag69 || commLst.isEmpty()) { Command comm(-1, -1, 0x69); commLst.push_front(comm); sendPack(comm); } if(!answerFlag) { qDebug() << "!answerFlag" << tryConnect(pserial, currPair.port, currPair.baud); pb->wait(1000); answerFlag = true; sendPack(commLst.last()); } qApp->processEvents(); } if(customCommFlag) sendCustomComm(); if(refreshFlag) refresh(); }
NETWORK_BEGIN NetClient::NetClient(boost::asio::io_service& ioservice, const std::string& host, uint16 port) : m_strHost(host) , m_nPort(port) , m_nHeadCount(0) , m_bClosed(true) , m_io_service(ioservice) ,m_socket(ioservice) { static boost::detail::atomic_count m_last_id(0l); m_nId = ++m_last_id; tryConnect(); }
clientController::clientController(QObject *parent) : QObject(parent) { m_w = new clientConnectWindow(); m_userWindow = new userListWindow(); connect(m_w, SIGNAL(tryConnect(QString,QString,QString)), this, SLOT(on_tryConnect(QString,QString,QString))); connect(this, SIGNAL(userListChanged(QStringList)), m_userWindow, SLOT(updateUserList(QStringList))); connect(m_userWindow, SIGNAL(tryChatConnect(QString)), this, SLOT(on_tryStartChat(QString))); connect(this, SIGNAL(newMessage(QString,QString)), this, SLOT(on_newMessage(QString,QString))); connect(this, SIGNAL(rcvDisconnect(QString, QString)), this, SLOT(on_rcvDisconnect(QString,QString))); m_w->show(); }
void MainWindow::printDevices(QStringList l) { m_sde->setDeviceName(currPair.port); if(!m_sde->isExists()) { lblStatus->setText("Disconnected"); lblArrow->setPixmap(*out_y); //pserial->close(); } else { qDebug() << "printDevices"; tryConnect(pserial, currPair.port, currPair.baud); if(lblStatus->text() == "Disconnected") { lblStatus->setText("Connected"); answerFlag = true; pb->wait(3000); } } }
void ServerConnection::connectHandler(const boost::system::error_code& e) { if(!e) { LOGNORMAL() << "connect " << m_ip.c_str() << " " << m_port << " OK" << LOGEND(); //m_status = CONN_STATUS_CONNECTED; start(); // send handshake message // trigger read //tryRead(); } else { m_status = CONN_STATUS_DISCONNECT; LOGERROR() << "connect error " << m_ip.c_str() << " " << m_port << LOGEND(); tryConnect(); } }
bool InsteonNetwork::tryConnect(vector<InsteonConnection*> connections) { if (connections.size() > 0) { for (auto it=connections.begin(); it!=connections.end(); ++it) { stringstream ss; ss << "Trying connection " + to_string((it - connections.begin()) + 1) + " of " + to_string(connections.size()) + " on " + (*it)->getValue(); if ((*it)->getName() != (*it)->getValue()) ss << " '" + (*it)->getName() + "'"; if (!(*it)->getAddress()->isEmpty()) ss << " (" + (*it)->getAddress()->toString() + ")"; onConnectProgress(50 * (it - connections.begin()) / connections.size() + 50, ss.str()); // 50% to 100% progress if (tryConnect(*it)) return true; } } return false; }
bool InsteonNetwork::tryConnect() { vector<InsteonConnection*> connections = getAvailableConnections(); if (connections.size() <= 0) return false; for (auto it=connections.begin(); it!=connections.end(); ++it) Log::writeLine(Severity_level::info, "Available connection '" + (*it)->toString() + "'"); bool result = tryConnect(connections); if(result) { for (auto it=connections.begin(); it!=connections.end(); ++it) { if(connection != (*it)) delete (*it); } } return result; }
void Connector::tryNextAddress() { if (addressQueryResults.empty()) { SWIFT_LOG(debug) << "Done trying addresses. Moving on." << std::endl; // Done trying all addresses. Move on to the next host. if (!serviceQueryResults.empty()) { serviceQueryResults.pop_front(); } tryNextServiceOrFallback(); } else { SWIFT_LOG(debug) << "Trying next address" << std::endl; HostAddress address = addressQueryResults.front(); addressQueryResults.pop_front(); int connectPort = (port == -1 ? 5222 : port); if (!serviceQueryResults.empty()) { connectPort = serviceQueryResults.front().port; } tryConnect(HostAddressPort(address, connectPort)); } }
NoInterface::NoInterface(QWidget *parent, SerialPort *serialPort) : ModuleWidget(parent, serialPort, true), m_tryCount(0) { QHBoxLayout *layout = new QHBoxLayout(this); m_label = new QLabel(this); m_label->setWordWrap(true); if (m_serialPort->FoundButClosed()) { m_label->setText(QString(tr("Try to connect to a device on a port %1...").arg(m_serialPort->GetPortName()))); m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), this, SLOT(tryConnect())); m_timer->start(1000); } else { m_label->setText(tr("No interface is connected.")); } layout->addWidget(m_label); }
void Client::run() { while(true) { if (mIsConnected) { handleInput(); handleOutput(); //usleep(3); usleep(1500000); } else { mIsConnected = tryConnect(); usleep(1500000); } } uninit(); }
void RRPlugin::postSwapBuffers(int windowNumber) { if (windowNumber != 0) return; if (!coVRMSController::instance()->isMaster()) return; if (!m_rrdpy) { if (m_clientList.empty()) waitForConnection(); else tryConnect(true); } if (!m_rrdpy) return; try { sendvgl(m_rrdpy, GL_FRONT, false, fconfig.compress, fconfig.qual, fconfig.subsamp, true /*block*/); while (rrxevent *rev = m_rrdpy->getevent()) { m_eventQueue.push_back(*rev); delete rev; } } catch (...) { delete m_rrdpy; m_rrdpy = NULL; fprintf(stderr, "sendvgl failed\n"); } }