Beispiel #1
0
ScopeGadgetWidget::ScopeGadgetWidget(QWidget *parent) : QwtPlot(parent)
{
	setMouseTracking(true);
//	canvas()->setMouseTracking(true);

    //Setup the timer that replots data
    replotTimer = new QTimer(this);
    connect(replotTimer, SIGNAL(timeout()), this, SLOT(replotNewData()));

    // Listen to telemetry connection/disconnection events, no point in
    // running the scopes if we are not connected and not replaying logs.
    // Also listen to disconnect actions from the user
    Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
    connect(cm, SIGNAL(deviceAboutToDisconnect()), this, SLOT(stopPlotting()));
    connect(cm, SIGNAL(deviceConnected(QIODevice*)), this, SLOT(startPlotting()));

    m_csvLoggingStarted=0;
    m_csvLoggingEnabled=0;
    m_csvLoggingHeaderSaved=0;
    m_csvLoggingDataSaved=0;
    m_csvLoggingDataUpdated=0;
    m_csvLoggingNameSet=0;
    m_csvLoggingConnected=0;
    m_csvLoggingNewFileOnConnect=0;
    m_csvLoggingPath = QString("./csvlogging/");
    m_csvLoggingStartTime = QDateTime::currentDateTime();

    //Listen to autopilot connection events
    connect(cm, SIGNAL(deviceAboutToDisconnect()), this, SLOT(csvLoggingDisconnect()));
    connect(cm, SIGNAL(deviceConnected(QIODevice*)), this, SLOT(csvLoggingConnect()));
}
/**
*   Method called by plugins who want to force a disconnection.
*   Used by Uploader gadget for instance.
*/
bool ConnectionManager::disconnectDevice()
{
    if (!m_ioDev) {
        // apparently we are already disconnected: this can
        // happen if a plugin tries to force a disconnect whereas
        // we are not connected. Just return.
        return false;
    }

    // We are connected - disconnect from the device

    // signal interested plugins that user is disconnecting his device
    emit deviceAboutToDisconnect();

    try {
        if (m_connectionDevice.connection)
            m_connectionDevice.connection->closeDevice(m_connectionDevice.devName);
    } catch (...) {	// handle exception
        qDebug() << "Exception: m_connectionDevice.connection->closeDevice(" << m_connectionDevice.devName << ")";
    }

    m_connectionDevice.connection = NULL;
    m_ioDev = NULL;

    m_connectBtn->setText("Connect");
    m_availableDevList->setEnabled(true);

    return true;
}
Beispiel #3
0
/**
 * Called at startup, before any plugin which depends on us is initialized
 */
bool UAVTalkPlugin::initialize(const QStringList & arguments, QString *errorString)
{
    // Done
    Q_UNUSED(arguments);
    Q_UNUSED(errorString);

    // Create TelemetryManager
    telMngr = new TelemetryManager();
    addAutoReleasedObject(telMngr);

    // Connect to connection manager so we get notified when the user connect to his device
    Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
    QObject::connect(cm, SIGNAL(deviceConnected(QIODevice *)),
                     this, SLOT(onDeviceConnect(QIODevice *)));
    QObject::connect(cm, SIGNAL(deviceAboutToDisconnect()),
                     this, SLOT(onDeviceDisconnect()));
    return true;
}
Beispiel #4
0
/**
*   Method called by plugins who want to force a disconnection.
*   Used by Uploader gadget for instance.
*/
bool ConnectionManager::disconnectDevice()
{
    // tell the monitor widget we're disconnected
    m_monitorWidget->disconnect();

    if (!m_ioDev) {
        // apparently we are already disconnected: this can
        // happen if a plugin tries to force a disconnect whereas
        // we are not connected. Just return.
        return false;
    }

    // We are connected - disconnect from the device

    // stop our timers
    if(reconnect->isActive())
        reconnect->stop();
    if(reconnectCheck->isActive())
        reconnectCheck->stop();

    // signal interested plugins that user is disconnecting his device
    emit deviceAboutToDisconnect();

    try {
        if (m_connectionDevice.connection) {
            m_connectionDevice.connection->closeDevice(m_connectionDevice.getConName());
        }
    } catch (...) {	// handle exception
        qDebug() << "Exception: m_connectionDevice.connection->closeDevice(" << m_connectionDevice.getConName() << ")";
    }

    m_connectionDevice.connection = NULL;
    m_ioDev = NULL;

    emit deviceDisconnected();
    m_connectBtn->setText("Connect");
    m_availableDevList->setEnabled(true);

    return true;
}