class NMEAAdapter: (source)
Constructor: NMEAAdapter(receiver)
Implements interfaces: twisted.positioning.ipositioning.INMEAReceiver
An adapter from NMEAProtocol receivers to positioning receivers.
Method | __init__ |
Initializes a new NMEA adapter. |
Method | clear |
Resets this adapter. |
Method | sentence |
Called when a sentence is received. |
Instance Variable | current |
Undocumented |
Instance Variable | year |
The earliest possible year that data will be interpreted as. For example, if this value is 1990, an NMEA 0183 two-digit year of "96" will be interpreted as 1996, and a two-digit year of "13" will be interpreted as 2013. |
Method | _clean |
Cleans the current sentence. |
Method | _combine |
Combines a datetime.date object and a datetime.time object, collected from one or more NMEA sentences, into a single datetime.datetime object suitable for sending to the IPositioningReceiver . |
Method | _convert |
A simple conversion fix. |
Method | _fire |
Fires sentence callbacks for the current sentence. |
Method | _fix |
Turns the NMEAProtocol coordinate format into Python float. |
Method | _fix |
Turns an NMEA datestamp format into a datetime.date object. |
Method | _fix |
Extracts the information regarding which satellites were used in obtaining the GPS fix from a GSA sentence. |
Method | _fix |
Parses partial visible satellite information from a GSV sentence. |
Method | _fix |
Fixes the sign for a hemisphere. |
Method | _fix |
Turns the NMEAProtocol timestamp notation into a datetime.time object. The time in this object is expressed as Zulu time. |
Method | _fix |
Fixes the units of a certain value. If the units are already acceptable (metric), does nothing. |
Method | _get |
Returns the hemisphere sign for a given coordinate type. |
Method | _merge |
Merges beacon information in the adapter state (if it exists) into the provided beacon information. Specifically, this merges used and seen beacons. |
Method | _sentence |
Executes a fix for a specific type of sentence. |
Method | _stateful |
Does a stateful update of a particular positioning attribute. Specifically, this will mutate an object in the current sentence data. |
Method | _update |
Updates existing beacon information state with new data. |
Method | _update |
Updates the current state with the new information from the sentence. |
Method | _update |
Searches the adapter state and sentence data for information about which beacons where used, then adds it to the provided beacon information object. |
Method | _validate |
Tests if a sentence contains a valid fix. |
Constant | _ACCEPTABLE |
A set of NMEA notations of units that are already acceptable (metric), and therefore don't need to be converted. |
Constant | _FIXERS |
Set of unary callables that take an NMEAAdapter instance and extract useful data from the sentence data, usually modifying the adapter's sentence data in-place. |
Constant | _SPECIFIC |
A mapping of sentece types to specific fixes that are required to extract useful information from data from those sentences. |
Constant | _STATEFUL |
Information on how to update partial information in the sentence data or internal adapter state. For more information, see _statefulUpdate's docstring. |
Constant | _UNIT |
Mapping of NMEA notations of units that are not acceptable (not metric) to converters that take a quantity in that unit and produce a metric quantity. |
Instance Variable | _receiver |
The positioning receiver that will receive parsed data. |
Instance Variable | _sentence |
The data present in the sentence currently being processed. Starts empty, is filled as the sentence is parsed. |
Instance Variable | _state |
The current internal state of the receiver. |
Initializes a new NMEA adapter.
Parameters | |
receiver:ipositioning.IPositioningReceiver | The receiver for positioning sentences. |
Called when a sentence is received.
Will clean the received NMEAProtocol sentence up, and then update the adapter's state, followed by firing the callbacks.
If the received sentence was invalid, the state will be cleared.
Parameters | |
sentence:NMEASentence | The sentence that is received. |
The earliest possible year that data will be interpreted as. For example, if this value is 1990, an NMEA 0183 two-digit year of "96" will be interpreted as 1996, and a two-digit year of "13" will be interpreted as 2013.
Combines a datetime.date object and a datetime.time object, collected from one or more NMEA sentences, into a single datetime.datetime object suitable for sending to the IPositioningReceiver
.
A simple conversion fix.
Parameters | |
key:native string (Python identifier) | The attribute name of the value to fix. |
converter:unary callable | The function that converts the value. |
Fires sentence callbacks for the current sentence.
A callback will only fire if all of the keys it requires are present in the current state and at least one such field was altered in the current sentence.
The callbacks will only be fired with data from _state
.
Turns the NMEAProtocol coordinate format into Python float.
Parameters | |
coordinateAngles.LATITUDE or Angles.LONGITUDE . | The coordinate type. |
Turns an NMEA datestamp format into a datetime.date object.
Raises | |
ValueError | When the day or month value was invalid, e.g. 32nd day, or 13th month, or 0th day or month. |
Extracts the information regarding which satellites were used in obtaining the GPS fix from a GSA sentence.
Precondition: A GSA sentence was fired. Postcondition: The current sentence data (self._sentenceData will contain a set of the currently used PRNs (under the key _usedPRNs.
Fixes the sign for a hemisphere.
This method must be called after the magnitude for the thing it determines the sign of has been set. This is done by the following functions:
- self.FIXERS['magneticVariation']
- self.FIXERS['latitudeFloat']
- self.FIXERS['longitudeFloat']
Parameters | |
coordinate | Coordinate type. One of Angles.LATITUDE , Angles.LONGITUDE or Angles.VARIATION . |
sentenceNone ) | The key name of the hemisphere sign being fixed in the sentence data. If unspecified, coordinateType is used. |
Turns the NMEAProtocol timestamp notation into a datetime.time object. The time in this object is expressed as Zulu time.
Fixes the units of a certain value. If the units are already acceptable (metric), does nothing.
None of the keys are allowed to be the empty string.
Parameters | |
unit | The name of the key/attribute under which the unit can be found in the current sentence. If the unit parameter is set, this parameter is not used. |
value | The key name in which the data will be stored in the _sentenceData instance attribute. If unset, attempts to remove "Units" from the end of the unitKey parameter. If that fails, raises ValueError. |
source | The name of the key/attribute that contains the current value to be converted (expressed in units as defined according to the unit parameter). If unset, will use the same key as the value key. |
unit:str | The unit that is being converted from. If unspecified or None , asks the current sentence for the unitKey. If that also fails, raises AttributeError. |
Returns the hemisphere sign for a given coordinate type.
Parameters | |
coordinateAngles.LATITUDE , Angles.LONGITUDE or Angles.VARIATION . | The coordinate type to find the hemisphere for. |
Returns | |
int | The sign of that hemisphere (-1 or 1). |
Merges beacon information in the adapter state (if it exists) into the provided beacon information. Specifically, this merges used and seen beacons.
If the adapter state has no beacon information, does nothing.
Parameters | |
newtwisted.positioning.base.BeaconInformation | The beacon information object that beacon information will be merged into (if necessary). |
Does a stateful update of a particular positioning attribute. Specifically, this will mutate an object in the current sentence data.
Using the sentenceKey, this will get a tuple containing, in order, the key name in the current state and sentence data, a factory for new values, the attribute to update, and a converter from sentence data (in NMEA notation) to something useful.
If the sentence data doesn't have this data yet, it is grabbed from the state. If that doesn't have anything useful yet either, the factory is called to produce a new, empty object. Either way, the object ends up in the sentence data.
Parameters | |
sentence | The name of the key in the sentence attributes, NMEAAdapter._STATEFUL_UPDATE dictionary and the adapter state. |
Searches the adapter state and sentence data for information about which beacons where used, then adds it to the provided beacon information object.
If no new beacon usage information is available, does nothing.
Parameters | |
beacontwisted.positioning.base.BeaconInformation | The beacon information object that beacon usage information will be added to (if necessary). |
A set of NMEA notations of units that are already acceptable (metric), and therefore don't need to be converted.
Value |
|
Set of unary callables that take an NMEAAdapter instance and extract useful data from the sentence data, usually modifying the adapter's sentence data in-place.
Value |
|
Information on how to update partial information in the sentence data or internal adapter state. For more information, see _statefulUpdate's docstring.
Value |
|
Mapping of NMEA notations of units that are not acceptable (not metric) to converters that take a quantity in that unit and produce a metric quantity.
Value |
|