Provides access to an NMEA sentence read from or written to an external device. More...
Import Statement: | import ArcGIS.AppFramework.Devices 1.0 |
Inherits: |
Properties
- error : NmeaError
- logSentences : bool
- properties : object
- receivedFields : object
- receivedSentence : string
- sendFields : object
Signals
Methods
- object propertyValue(string key)
- setPropertyValue(string key, object value)
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
Name | Value |
---|---|
NmeaSource.NmeaSourceTypeGeneric | 0 |
NmeaSource.NmeaSourceTypeGNSS | 1 |
NmeaError enumeration
Name | Value |
---|---|
NmeaSource.NmeaErrorNone | 0 |
NmeaSource.NmeaErrorAccess | 1 |
Property Documentation
Lists fields that are parsed from an NMEA sentence received from the source device.
Returns an NMEA sentence received from the source device. If parsing fails, this property is empty.
Signal Documentation
Signal emitted when NMEA data has been received.
Note: The corresponding handler is onReceivedNmeaData
.
Method Documentation
The key parameter
See also setPropertyValue().
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.
Key | Description | Default 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().