NmeaSource QML Type

Provides access to an NMEA sentence read from or written to an external device. More...

Import Statement: import ArcGIS.AppFramework.Devices 1.0
Inherits:

DataSource

Properties

Signals

Methods

Detailed Description

This code sample shows an example usage of the NmeaSource component, receiving information from a device found by DeviceDiscoveryAgent and displaying it in a list view.

Item {
        property DeviceListModel deviceListModel: discoveryAgent.devices
        property Device currentDevice

        ColumnLayout {
                anchors.fill: parent
                anchors.margins: 10

                ComboBox {
                        id: comboBox
                        Layout.fillWidth: true
                        model: deviceListModel
                        textRole: "name"
                        onCurrentTextChanged: selectDevice(deviceListModel.get(currentIndex))
                }

                ListView {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        model: messagesListModel
                        delegate: Text { text: msg }
                }
        }

        DeviceDiscoveryAgent {
                id: discoveryAgent
        }

        NmeaSource {
                id: nmeaSource

                onReceivedNmeaData: log(nmeaSource.receivedSentence.trim())
        }

        PositionSource {
                id: positionSource
                active: false
                nmeaSource: nmeaSource
        }

        ListModel {
                id: messagesListModel
        }

        Connections {
                target: deviceListModel
                onCountChanged: if (comboBox.currentIndex == -1 && deviceListModel.count > 0) { comboBox.currentIndex = 0; }
        }

        function selectDevice(device) {
                positionSource.active = false;
                currentDevice = device;
                nmeaSource.source = currentDevice;
                messagesListModel.clear();
                JSON.stringify(currentDevice, undefined, 2).split("\n").forEach(log);
                positionSource.active = true;
        }

        function log(txt) {
                console.log(txt);
                messagesListModel.append( { msg: txt } );
                if (messagesListModel.count > 20) { messagesListModel.remove(0); }
        }

        Component.onCompleted: discoveryAgent.start()
}

The NmeaSource component inherits the DataSource component, and can use all of its functions. When using the source property within NmeaSource, you can also provide the path to a log file containing NMEA position-specification data. Setting this property will load and parse the file. Refer to the setPropertyValue method to configure how the log file will be parsed. The following code sample demonstrates how to use NmeaSource to read from an NMEA log file.

NmeaSource {
        id: nmeaSource

        source: "NMEALog.txt"

        properties: {
                "interval": 1000,
                "repeat": true,
                "type": NmeaSource.NmeaSourceTypeGNSS
        }

        onReceivedNmeaData: log(nmeaSource.receivedSentence.trim())
}

To read or write from an external NMEA device, set the source as in the following code sample.

NmeaSource {
    id: nmeaSource

    source: externalReceiver

    onReceivedNmeaData: console.log("NMEA Message", receivedSentence.trim())
}

Device {
   id: externalReceiver
}

NMEA messages from the internal GNSS receiver on Android devices can also be displayed. In this case the source property must be undefined and the PositionSource or the SatelliteInfoSource must be active.

Enumerations

NmeaSourceType enumeration

NameValue
NmeaSource.NmeaSourceTypeGeneric0
NmeaSource.NmeaSourceTypeGNSS1

NmeaError enumeration

NameValue
NmeaSource.NmeaErrorNone0
NmeaSource.NmeaErrorAccess1

Property Documentation

[read-only] error : NmeaError


logSentences : bool

If true, logs all NMEA sentences. Default is false.


properties : object


[read-only] receivedFields : object

Lists fields that are parsed from an NMEA sentence received from the source device.


[read-only] receivedSentence : string

Returns an NMEA sentence received from the source device. If parsing fails, this property is empty.


sendFields : object

Lists fields that should be written to the source device.


Signal Documentation

receivedNmeaData()

Signal emitted when NMEA data has been received.

Note: The corresponding handler is onReceivedNmeaData.


Method Documentation

object propertyValue(string key)

The key parameter

See also setPropertyValue().


setPropertyValue(string key, object value)

The property values configure how NMEA log files are parsed. They have no effect if the source property is a device. The following values are supported, using the provided defaults if they are not set.

KeyDescriptionDefault Value
interval(integer) Time between position updates if parsing a GNSS file, or time between reading lines if parsing a generic NMEA data log. Time measured in milliseconds.1000
repeat(boolean) Restart parsing after reaching the end of the file.false
type(enum) Type of data contained in the log file, either GNSS or generic NMEA data.NmeaSource.NmeaSourceTypeGNSS

The key parameter

The keys being set separate from their defaults.

The value parameter

The new values being set for each key.

See also propertyValue().


Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.