示例#1
0
// Adds AdItem to request queue and calls handleRequests
void RequestQueue::addToQueue(QObject *object)
{
    // no need to add same object multipletimes
    if (!m_adItemQueue.contains(object)) {
        m_adItemQueue.enqueue(object);
        QTimer::singleShot(0, this, SLOT(handleRequests()));
    }
}
示例#2
0
void GUIPlugin::process(const ed::WorldModel& world, ed::UpdateRequest& req)
{
    world_model_ = &world;

    handleRequests();

    publishMapImage();
}
示例#3
0
void FtpClient::request(QString request)
{
    qDebug() << "FtpClient:: " << port << " request " << request;
    //mRequests.append(request);

    // If we are trandferring. we must add this to outbuffer
    // but if we are not trnsferring, then we must not send older bytes
    if (mTransferring)
        mOutBuffer.append(request);
    else
        mOutBuffer= QByteArray(request.toLatin1());
    handleRequests();
}
示例#4
0
void RequestQueue::adRequestFinished(QNetworkReply *req)
{
    if (!req)
        return;
    QObject *adItem = req->property("AdItem").value<QObject*>();
    if (!adItem) {
        req->deleteLater();
        return;
    }

    QByteArray data = req->readAll();

    m_requestRunning = false;
    if (req->attribute(QNetworkRequest::HttpStatusCodeAttribute) != 200) {
        QMetaObject::invokeMethod(adItem, "adError",
                                  Q_ARG(QString,req->errorString()));
        // When no connectivity -> UnknownNetworkError
        if (req->error() == QNetworkReply::UnknownNetworkError) {
            AdInterface *adI = qobject_cast<AdInterface*>(parent());
            emit adI->networkNotAccessible();
        }
        req->deleteLater();
        QTimer::singleShot(0, this, SLOT(handleRequests()));
        return;
    }
    req->deleteLater();

    // Update client ID
    int idStart = data.indexOf("Client Id=\"")+11;
    int idSize = data.indexOf("\"/>",data.indexOf("Id=\""))-idStart;
    QMetaObject::invokeMethod(adItem, "__idUpdated", Qt::DirectConnection,
                              Q_ARG(QVariant, data.mid(idStart,idSize)));

    adItem->setProperty("__xml", QString::fromUtf8(data));
    QTimer::singleShot(0, this, SLOT(handleRequests()));
}
示例#5
0
    bool Application::run() {
        while(!_myTerminate) {

            if(!handleRequests())
                goto fail;

            if(!process())
                goto fail;

            usleep(_myInterval);
        }

        return true;

    fail:
        return false;
    }
示例#6
0
void FtpClient::handleBytesWritten( qint64 bytes )
{
    qDebug() << "FtpClient:: " << port << " handleBytesWritten bytes " << bytes << "mOutBuffer.size() " << mOutBuffer.size();
    if (bytes <= mOutBuffer.size())
        mOutBuffer.remove(0,bytes);
    else
        mOutBuffer.clear();

    if (mOutBuffer.size() == 0) {
        mTransferring = false;
        qDebug() << "FtpClient:: " << port << " handleBytesWritten mTransferring " << mTransferring;
        emit deviceStateChanged(DeviceManager::WrittenState);
    } else
    {
        handleRequests();
    }
}
示例#7
0
void FtpClient::handleStateChanged ( QAbstractSocket::SocketState socketState )
{
    qDebug() << "FtpClient:: " << port << " handleStateChanged";
    switch (socketState) {
    case QAbstractSocket::UnconnectedState:
        qDebug() << tr("UnconnectedState: The socket is not connected.");
        emit deviceStateChanged(DeviceManager::UnconnectedState);
        qDebug() << tr("UnconnectedState: handleRequests()");
        mConnected = false;
        mTransferring = false;
        qDebug() << "FtpClient:: " << port << " handleStateChanged mTransferring " << mTransferring;
        handleRequests();   // reconnect if we have something to send
        break;
    case QAbstractSocket::HostLookupState:
        qDebug() << tr("HostLookupState: The socket is performing a host name lookup.");
        emit deviceStateChanged(DeviceManager::UnconnectedState);
        break;
    case QAbstractSocket::ConnectingState:
        qDebug() << tr("ConnectingState: The socket has started establishing a connection.");
        emit deviceStateChanged(DeviceManager::ConnectingState);
        break;
    case QAbstractSocket::ConnectedState:
        qDebug() << tr("ConnectedState: A connection is established.");
        emit deviceStateChanged(DeviceManager::ConnectedState);
        break;
    case QAbstractSocket::BoundState:
        qDebug() << tr("BoundState: The socket is bound to an address and port (for servers).");
        break;
    case QAbstractSocket::ClosingState:
        qDebug() << tr("ClosingState: The socket is about to close (data may still be waiting to be written).");
        emit deviceStateChanged(DeviceManager::ClosingState);
        break;
    case QAbstractSocket::ListeningState:
        qDebug() << tr("ListeningState (For internal use only.)");
        break;
    default:
        qDebug() << tr("Unknown socket state");
        break;

    }
}
示例#8
0
void FtpClient::handleConnected()
{
    emit deviceStateChanged(DeviceManager::ConnectedState);

    mConnected = true;
    mConnecting = false;
    mTransferring = false;
    qDebug() << "FtpClient:: " << port << " handleConnected mTransferring " << mTransferring;
    //request(QString(REQUEST_WHO).arg(QString::number(mOutCommandNumber++)));
    // ask picture if camera is on, and output buffer is empty

    // test
    //sendCommand(Command("", -1, Command::Stop));

    if (mCameraOn && (mOutBuffer.size() == 0))
    {
        sendCommand(Command("", -1, Command::Picture));
    } else  // else handle requests we have
    {
        handleRequests();
    }
}
int main(int argc, char *argv[])
{
     ros::init(argc, argv, "coordination_server_info_fusion");
     ros::NodeHandle n1, n2, n3, n4, n5;
     vel_pub = n1.advertise<geometry_msgs::Twist>("/cmd_vel", 1);
     pos_sub = n2.subscribe("/position", 1, positionCallback);
     pospub = n3.advertise<position_tracker::Position>("/position", 1); //SET QUEUE SIZE = 1!!! (keep only last msg)
     bump_sub = n4.subscribe("/sensorPacket", 1, bumperCallback);
     wifi_sub = n5.subscribe("/wifiNNs", 1, wifiCallback);       

	 //loadMap();

	//JUST FOR testing:
	position_tracker::Position *tmp_pos = new position_tracker::Position();
	tmp_pos->x = 9;
	tmp_pos->y = 13;
	tmp_pos->theta = 0;
	cur_pos = *tmp_pos;

     ros::spinOnce(); 
     //ros::spin();     
 
     handleRequests();
}