androidGps::androidGps(QObject *parent) : QObject(parent) { QGeoPositionInfoSource *source1 = QGeoPositionInfoSource::createDefaultSource(0); connect(source1, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); connect(source1, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(error(QGeoPositionInfoSource::Error))); if (source1) { source1->setUpdateInterval(1000); source1->startUpdates(); qDebug() << "Gps1 status: " << source1->sourceName(); } QGeoSatelliteInfoSource *source = QGeoSatelliteInfoSource::createDefaultSource(0); if (source) { source->setUpdateInterval(1000); source->startUpdates(); } connect(source, SIGNAL(satellitesInUseUpdated(QList<QGeoSatelliteInfo>)), this, SLOT(satellitesInViewUpdated(QList<QGeoSatelliteInfo>))); qDebug() << source->sourceName() << "Source name"; }
void GpsPosition::startGps() { if (_location){ connect(_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); _location->startUpdates(); } }
void GPSWidget::startGPS() { // Obtain the location data source if it is not obtained already if (!locationDataSource) { locationDataSource = QGeoPositionInfoSource::createDefaultSource(this);//this if (locationDataSource) { // Whenever the location data source signals that the current // position is updated, the positionUpdated function is called. QObject::connect(locationDataSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); // Start listening for position updates locationDataSource->startUpdates(); } else { // Not able to obtain the location data source // TODO: Error handling } } else { // Start listening for position updates locationDataSource->startUpdates(); } qWarning("startujemy z GPS updates"); }
TrackRecorder::TrackRecorder(QObject *parent) : QObject(parent) { qDebug()<<"TrackRecorder constructor"; m_distance = 0.0; m_accuracy = -1; m_tracking = false; m_isEmpty = true; m_applicationActive = true; m_autoSavePosition = 0; // Load autosaved track if left from previous session loadAutoSave(); // Setup periodic autosave m_autoSaveTimer.setInterval(60000); connect(&m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave())); m_autoSaveTimer.start(); m_posSrc = QGeoPositionInfoSource::createDefaultSource(0); if (m_posSrc) { m_posSrc->setUpdateInterval(1000); connect(m_posSrc, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); connect(m_posSrc, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(positioningError(QGeoPositionInfoSource::Error))); // Position updates are started/stopped in setIsTracking(...) } else { qDebug()<<"Failed initializing PositionInfoSource!"; } }
void QgsQtLocationConnection::startGPS() { QgsDebugMsg( "Starting GPS QtLocation connection" ); // Obtain the location data source if it is not obtained already if ( !locationDataSource ) { locationDataSource = QGeoPositionInfoSource::createDefaultSource( this ); if ( locationDataSource ) { locationDataSource->setPreferredPositioningMethods( QGeoPositionInfoSource::SatellitePositioningMethods ); //QGeoPositionInfoSource::AllPositioningMethods locationDataSource->setUpdateInterval(1000); // Whenever the location data source signals that the current // position is updated, the positionUpdated function is called. QObject::connect( locationDataSource, SIGNAL( positionUpdated( QGeoPositionInfo ) ), this, SLOT( positionUpdated( QGeoPositionInfo ) ) ); // Start listening for position updates locationDataSource->startUpdates(); } else { // Not able to obtain the location data source QgsDebugMsg( "No QtLocation Position Source" ); } } else { // Start listening for position updates locationDataSource->startUpdates(); } }
void LocationWatcher::disable() { if (source) { source->stopUpdates(); disconnect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); } }
void LocationWatcher::enable() { if (getSetting("active")=="1"){ if (source) { connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)),this, SLOT(positionUpdated(QGeoPositionInfo))); source->startUpdates(); } } }
ClientApplication::ClientApplication(QWidget *parent) : QMainWindow(parent) { textEdit = new QTextEdit; setCentralWidget(textEdit); LogFilePositionSource *source = new LogFilePositionSource(this); connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); source->startUpdates(); }
void GeolocationClientQt::startUpdating() { if (!m_location && (m_location = QGeoPositionInfoSource::createDefaultSource(this))) connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); if (!m_location) { WebCore::Page* page = QWebPagePrivate::core(m_page); RefPtr<WebCore::GeolocationError> error = GeolocationError::create(GeolocationError::PositionUnavailable, failedToStartServiceErrorMessage); page->geolocationController()->errorOccurred(error.get()); return; } m_location->startUpdates(); }
QTM_BEGIN_NAMESPACE #define UPDATE_INTERVAL_5S 5000 QGeoAreaMonitorPolling::QGeoAreaMonitorPolling(QObject *parent) : QGeoAreaMonitor(parent) { insideArea = false; location = QGeoPositionInfoSource::createDefaultSource(this); if (location) { location->setUpdateInterval(UPDATE_INTERVAL_5S); connect(location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); } }
void tst_QNmeaPositionInfoSource::requestUpdate_after_start() { QNmeaPositionInfoSource source(m_mode); QNmeaPositionInfoSourceProxyFactory factory; QNmeaPositionInfoSourceProxy *proxy = static_cast<QNmeaPositionInfoSourceProxy*>(factory.createProxy(&source)); QSignalSpy spyUpdate(proxy->source(), SIGNAL(positionUpdated(QGeoPositionInfo))); QSignalSpy spyTimeout(proxy->source(), SIGNAL(updateTimeout())); // Start updates with 500ms interval and requestUpdate() with 100ms // timeout. Feed an update, and it should be emitted immediately due to // the requestUpdate(). The update should not be emitted again after that // (i.e. the startUpdates() interval should not cause it to be re-emitted). QDateTime dt = QDateTime::currentDateTime().toUTC(); proxy->source()->setUpdateInterval(500); proxy->source()->startUpdates(); proxy->source()->requestUpdate(100); proxy->feedUpdate(dt); QTRY_COMPARE(spyUpdate.count(), 1); QCOMPARE(spyUpdate[0][0].value<QGeoPositionInfo>().timestamp(), dt); QCOMPARE(spyTimeout.count(), 0); spyUpdate.clear(); // Update has been emitted for requestUpdate(), shouldn't be emitted for startUpdates() QTRY_COMPARE_WITH_TIMEOUT(spyUpdate.count(), 0, 1000); }
void QGeoPositionInfoSourceAndroid::updateTimeoutElapsed() { QGeoPositionInfo position; position=m_lastUpdate; if (position.isValid()) { if (m_positionInfoState & QGeoPositionInfoSourceAndroid::RequestActive) { m_requestTimer->stop(); m_positionInfoState &= ~QGeoPositionInfoSourceAndroid::RequestActive; if (m_positionInfoState & QGeoPositionInfoSourceAndroid::Stopped ||!(m_positionInfoState & QGeoPositionInfoSourceAndroid::StartUpdateActive)) { QtLocationJni::disableUpdates(this); } } emit positionUpdated(position); } else { emit updateTimeout(); } activateTimer(); }
//! [2] void AppModel::networkSessionOpened() { d->src = QGeoPositionInfoSource::createDefaultSource(this); if (d->src) { d->useGps = true; connect(d->src, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); d->src->startUpdates(); } else { d->useGps = false; d->city = "Brisbane"; emit cityChanged(); this->refreshWeather(); } }
/* This is _only_ called when QGeoPositionInfoValidator::valid() returns true for the position. This means that it is implied that: - (data.dwValidFields & GPS_VALID_LATITUDE) != 0 - (data.dwValidFields & GPS_VALID_LONGITUDE) != 0 - (data.dwValidFields & GPS_VALID_UTC_TIME) != 0 This guarantees that the newly created position will be valid. If the code is changed such that this is no longer guaranteed then this method will need to be updated to test for those conditions. */ void QGeoPositionInfoSourceWinCE::dataUpdated(GPS_POSITION data) { QGeoCoordinate coordinate(data.dblLatitude, data.dblLongitude); // The altitude is optional in QGeoCoordinate, so we do not strictly require that the // GPS_POSITION structure has valid altitude data in order to trigger an update. if ((data.dwValidFields & GPS_VALID_ALTITUDE_WRT_SEA_LEVEL) != 0) coordinate.setAltitude(data.flAltitudeWRTSeaLevel); QDate date(data.stUTCTime.wYear, data.stUTCTime.wMonth, data.stUTCTime.wDay); QTime time(data.stUTCTime.wHour, data.stUTCTime.wMinute, data.stUTCTime.wSecond, data.stUTCTime.wMilliseconds); QDateTime dateTime(date, time, Qt::UTC); QGeoPositionInfo pos(coordinate, dateTime); // The following properties are optional, and so are set if the data is present and valid in // the GPS_POSITION structure. if ((data.dwValidFields & GPS_VALID_SPEED) != 0) pos.setAttribute(QGeoPositionInfo::GroundSpeed, data.flSpeed); if ((data.dwValidFields & GPS_VALID_HEADING) != 0) pos.setAttribute(QGeoPositionInfo::Direction, data.flHeading); if ((data.dwValidFields & GPS_VALID_MAGNETIC_VARIATION) != 0) pos.setAttribute(QGeoPositionInfo::MagneticVariation, data.dblMagneticVariation); lastPosition = pos; emit positionUpdated(pos); }
void QGeoPositionInfoSourceAndroid::processPositionUpdate(const QGeoPositionInfo &pInfo) { //single update request and served as part of regular update if (m_requestTimer.isActive()) m_requestTimer.stop(); emit positionUpdated(pInfo); }
GPSTracker::GPSTracker(QObject *parent) : QObject(parent) { geoPositionInfoSource = QGeoPositionInfoSource::createDefaultSource(this); // emit funktioniert erst nach dem Konstruktor if(geoPositionInfoSource) { connect(geoPositionInfoSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); connect(geoPositionInfoSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); changeGPSStatus(INACTIVE); } else { changeGPSStatus(ERROR); } trackingInterval = 500; tracking = false; }
void InputManager::UpdatePosition() { /* Update position */ int64_t i_length = var_GetInteger( p_input , "length" ); int64_t i_time = var_GetInteger( p_input , "time"); float f_pos = var_GetFloat( p_input , "position" ); emit positionUpdated( f_pos, i_time, i_length / CLOCK_FREQ ); }
void QGeoPositionInfoSourceSimulator::updatePosition() { if (qtPositionInfo()->enabled) { lastPosition = Simulator::toPositionInfo(*qtPositionInfo()); emit positionUpdated(lastPosition); } else { emit updateTimeout(); } }
void GPSTracker::positionUpdated(QGeoPositionInfo position) { if(tracking){ addPosition(position); } emit positionUpdated(Point(position)); horizontalAccuracy = position.attribute(QGeoPositionInfo::HorizontalAccuracy); verticalAccuracy = position.attribute(QGeoPositionInfo::VerticalAccuracy); changeGPSStatus(RECEIVE); }
/* delete Input if it ever existed. Delete the callbacls on input p_input is released once here */ void InputManager::delInput() { if( !p_input ) return; msg_Dbg( p_intf, "IM: Deleting the input" ); /* Save time / position */ float f_pos = var_GetFloat( p_input , "position" ); int64_t i_time = var_GetTime( p_input, "time"); int i_length = var_GetTime( p_input , "length" ) / CLOCK_FREQ; if( f_pos < 0.05 || f_pos > 0.95 || i_length < 60) { i_time = -1; } RecentsMRL::getInstance( p_intf )->setTime( p_item->psz_uri, i_time ); delCallbacks(); i_old_playing_status = END_S; p_item = NULL; oldName = ""; artUrl = ""; b_video = false; timeA = 0; timeB = 0; f_rate = 0. ; if( p_input_vbi ) { vlc_object_release( p_input_vbi ); p_input_vbi = NULL; } vlc_object_release( p_input ); p_input = NULL; emit positionUpdated( -1.0, 0 ,0 ); emit rateChanged( var_InheritFloat( p_intf, "rate" ) ); emit nameChanged( "" ); emit chapterChanged( 0 ); emit titleChanged( 0 ); emit playingStatusChanged( END_S ); emit teletextPossible( false ); emit AtoBchanged( false, false ); emit voutChanged( false ); emit voutListChanged( NULL, 0 ); /* Reset all InfoPanels but stats */ emit artChanged( NULL ); emit artChanged( "" ); emit infoChanged( NULL ); emit currentMetaChanged( (input_item_t *)NULL ); emit encryptionChanged( false ); emit recordingStateChanged( false ); emit cachingChanged( 1 ); }
void LocationData::start() { source = QGeoPositionInfoSource::createDefaultSource(this); if (source) { source->setPreferredPositioningMethods(QGeoPositionInfoSource::SatellitePositioningMethods); source->setUpdateInterval(1000); connect(source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(onPositionChanged(QGeoPositionInfo))); source->startUpdates(); } }
void InputManager::UpdatePosition() { /* Update position */ int i_length; int64_t i_time; float f_pos; i_length = var_GetTime( p_input , "length" ) / 1000000; i_time = var_GetTime( p_input , "time"); f_pos = var_GetFloat( p_input , "position" ); emit positionUpdated( f_pos, i_time, i_length ); }
void CLbsPositionLogger::readNextPosition() { QByteArray line = m_logFile.readLine().trimmed(); if (line.isEmpty()) { LOG_MODEL_ERROR("CLbsPositionLogger", "no readlien"); return; } QList<QByteArray> data = line.split(','); QGeoCoordinate coordinate; QGeoPositionInfo info; bool hasTimestamp = false; QDateTime timestamp = QDateTime::fromTime_t(data.value(0).toLong(&hasTimestamp), Qt::UTC); if(hasTimestamp && timestamp.isValid()) info.setTimestamp(timestamp); double latitude; bool hasLatitude = false; latitude = data.value(1).toDouble(&hasLatitude); if(hasLatitude) coordinate.setLatitude(latitude); double longitude; bool hasLongitude = false; longitude = data.value(2).toDouble(&hasLongitude); if(hasLongitude) coordinate.setLongitude(longitude); double altitude; bool hasAltitude = false; altitude = data.value(3).toDouble(&hasAltitude); if(hasAltitude) coordinate.setAltitude(altitude); info.setCoordinate(coordinate); double HorizontalAccuracy; bool hasHorizontalAccuracy = false; HorizontalAccuracy = data.value(4).toDouble(&hasHorizontalAccuracy); if(hasHorizontalAccuracy) info.setAttribute(QGeoPositionInfo::HorizontalAccuracy, HorizontalAccuracy); double Direction; bool hasDirection = false; Direction = data.value(5).toDouble(&hasDirection); if(hasDirection) info.setAttribute(QGeoPositionInfo::Direction, Direction); double GroundSpeed; bool hasGroundSpeed = false; GroundSpeed = data.value(6).toDouble(&hasGroundSpeed); if(hasGroundSpeed) info.setAttribute(QGeoPositionInfo::GroundSpeed, GroundSpeed); if (info.isValid()) { m_lastPosition = info; emit positionUpdated(info); } }
void Daemon::createGPS() { if (!m_location) { m_location = QGeoPositionInfoSource::createDefaultSource(this); m_location->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods); m_location->setUpdateInterval(10*1000); // System has some positioning source found if (m_location) { QObject::connect(m_location, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); QObject::connect(m_location, SIGNAL(updateTimeout()), this, SLOT(updateTimeout())); } else { // System has not any positioning source log("Device has not any positioning source. WhoWhereDaemon is exiting"); // Exit application QCoreApplication::exit(); } } }
void TutorialUnit::setScene(GraphicsView *scene) { mScene = scene; connect(this, SIGNAL(moveRel(QPointF,int)), scene, SLOT(moveRobotRel(QPointF,int))); connect(this, SIGNAL(moveAbs(QPointF,int)), scene, SLOT(moveRobotAbs(QPointF,int))); connect(this, SIGNAL(rotateAbs(double,int)), scene, SLOT(rotateRobotAbs(double,int))); connect(this, SIGNAL(rotateRel(double,int)), scene, SLOT(rotateRobotRel(double,int))); connect(this, SIGNAL(setGripperState(bool)), scene, SLOT(setGripperState(bool))); connect(this, SIGNAL(resetScene(bool)), scene, SLOT(reset(bool))); connect(scene, SIGNAL(movementFinished()), SLOT(onMovementFinished())); connect(scene, SIGNAL(positionUpdate(QPointF,qreal)), this, SIGNAL(positionUpdated(QPointF,qreal))); }
GpsLocation::GpsLocation(QObject *parent) : QObject(parent), Location("0", "0", "GPS", "GPS"), m_gps(QGeoPositionInfoSource::createDefaultSource(this)), m_active(false), latitude(0), longitude(0) { m_valid = false; m_gps->setUpdateInterval(20000); connect(m_gps, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(updateLocation(QGeoPositionInfo))); connect(m_gps, SIGNAL(updateTimeout()), this, SLOT(timeout())); }
PushN8PhoneGPS::PushN8PhoneGPS(QObject *) { computeUTCOffset(); gpsSource = QGeoPositionInfoSource::createDefaultSource(0); // lastCoord = gpsSource->lastKnownPosition(true); connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); gpsSource->requestUpdate(60000); gpsSource->setUpdateInterval(500); gpsSource->startUpdates(); gpsOnline = false; timerId = -1;//disable any periodic events streaming = false; }
void QDeclarativePositionSource::setName(const QString &newName) { if (m_positionSource && m_positionSource->sourceName() == newName) return; const QString previousName = name(); int previousUpdateInterval = updateInterval(); PositioningMethods previousPositioningMethods = supportedPositioningMethods(); PositioningMethods previousPreferredPositioningMethods = preferredPositioningMethods(); delete m_positionSource; if (newName.isEmpty()) m_positionSource = QGeoPositionInfoSource::createDefaultSource(this); else m_positionSource = QGeoPositionInfoSource::createSource(newName, this); if (m_positionSource) { connect(m_positionSource, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdateReceived(QGeoPositionInfo))); connect(m_positionSource, SIGNAL(error(QGeoPositionInfoSource::Error)), this, SLOT(sourceErrorReceived(QGeoPositionInfoSource::Error))); connect(m_positionSource, SIGNAL(updateTimeout()), this, SLOT(updateTimeoutReceived())); m_positionSource->setUpdateInterval(m_updateInterval); m_positionSource->setPreferredPositioningMethods( static_cast<QGeoPositionInfoSource::PositioningMethods>(int(m_preferredPositioningMethods))); setPosition(m_positionSource->lastKnownPosition()); } if (previousUpdateInterval != updateInterval()) emit updateIntervalChanged(); if (previousPreferredPositioningMethods != preferredPositioningMethods()) emit preferredPositioningMethodsChanged(); if (previousPositioningMethods != supportedPositioningMethods()) emit supportedPositioningMethodsChanged(); emit validityChanged(); if (m_active) { m_active = false; emit activeChanged(); } if (previousName != name()) emit nameChanged(); }
void Target::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[Target::mouseReleaseEvent()]"; #else T_FUNCINFO; #endif #endif emit positionUpdated(event->scenePos()); QGraphicsItem::mouseReleaseEvent(event); }
PointInPolygonWidget::PointInPolygonWidget(QWidget *parent) : QWidget(parent), ui(new Ui::PointInPolygon) { ui->setupUi(this); ui->PolygonTable->setContextMenuPolicy(Qt::ActionsContextMenu); QAction* menu_action_remove_row; menu_action_remove_row = new QAction("Remover", this); ui->PolygonTable->addAction(menu_action_remove_row); QObject::connect(menu_action_remove_row, SIGNAL(triggered()), this, SLOT(remove_row())); //Initialize GPS position_info_ = QGeoPositionInfoSource::createDefaultSource(this); dist_acc_= 0; is_first_distance_ = true; if (position_info_) { position_info_->startUpdates(); connect(position_info_, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo))); } }