t.p.n.NMEAAdapter(object) : class documentation

Part of twisted.positioning.nmea View Source View In Hierarchy

An adapter from NMEAProtocol receivers to positioning receivers.
Instance Variable yearThreshold 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. (type: int)
Method __init__ Initializes a new NMEA adapter.
Method clear Resets this adapter.
Method sentenceReceived Called when a sentence is received.
Class Variable _STATEFUL_UPDATE Information on how to update partial information in the sentence data or internal adapter state. For more information, see _statefulUpdate's docstring. (type: See _statefulUpdate's docstring)
Class Variable _ACCEPTABLE_UNITS A set of NMEA notations of units that are already acceptable (metric), and therefore don't need to be converted. (type: frozenset of bytestrings)
Class Variable _UNIT_CONVERTERS 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. (type: dict of bytestrings to unary callables)
Class Variable _SPECIFIC_SENTENCE_FIXES A mapping of sentece types to specific fixes that are required to extract useful information from data from those sentences. (type: dict of sentence types to callables that take self and modify it in-place)
Class Variable _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. (type: dict of native strings to unary callables)
Instance Variable _state The current internal state of the receiver. (type: dict)
Instance Variable _sentenceData The data present in the sentence currently being processed. Starts empty, is filled as the sentence is parsed. (type: dict)
Instance Variable _receiver The positioning receiver that will receive parsed data. (type: ipositioning.IPositioningReceiver)
Method _fixTimestamp Turns the NMEAProtocol timestamp notation into a datetime.time object. The time in this object is expressed as Zulu time.
Method _fixDatestamp Turns an NMEA datestamp format into a datetime.date object.
Method _fixCoordinateFloat Turns the NMEAProtocol coordinate format into Python float.
Method _fixHemisphereSign Fixes the sign for a hemisphere.
Method _getHemisphereSign Returns the hemisphere sign for a given coordinate type.
Method _convert A simple conversion fix.
Method _statefulUpdate Does a stateful update of a particular positioning attribute. Specifically, this will mutate an object in the current sentence data.
Method _fixUnits Fixes the units of a certain value. If the units are already acceptable (metric), does nothing.
Method _fixGSV Parses partial visible satellite information from a GSV sentence.
Method _fixGSA Extracts the information regarding which satellites were used in obtaining the GPS fix from a GSA sentence.
Method _sentenceSpecificFix Executes a fix for a specific type of sentence.
Method _validateCurrentSentence Tests if a sentence contains a valid fix.
Method _cleanCurrentSentence Cleans the current sentence.
Method _updateState Updates the current state with the new information from the sentence.
Method _updateBeaconInformation Updates existing beacon information state with new data.
Method _updateUsedBeacons Searches the adapter state and sentence data for information about which beacons where used, then adds it to the provided beacon information object.
Method _mergeBeaconInformation Merges beacon information in the adapter state (if it exists) into the provided beacon information. Specifically, this merges used and seen beacons.
Method _combineDateAndTime No summary
Method _fireSentenceCallbacks Fires sentence callbacks for the current sentence.
_STATEFUL_UPDATE =
Information on how to update partial information in the sentence data or internal adapter state. For more information, see _statefulUpdate's docstring. (type: See _statefulUpdate's docstring)
_ACCEPTABLE_UNITS =
A set of NMEA notations of units that are already acceptable (metric), and therefore don't need to be converted. (type: frozenset of bytestrings)
_UNIT_CONVERTERS =
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. (type: dict of bytestrings to unary callables)
_SPECIFIC_SENTENCE_FIXES =
A mapping of sentece types to specific fixes that are required to extract useful information from data from those sentences. (type: dict of sentence types to callables that take self and modify it in-place)
_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. (type: dict of native strings to unary callables)
yearThreshold =
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. (type: int)
_state =
The current internal state of the receiver. (type: dict)
_sentenceData =
The data present in the sentence currently being processed. Starts empty, is filled as the sentence is parsed. (type: dict)
_receiver =
The positioning receiver that will receive parsed data. (type: ipositioning.IPositioningReceiver)
def __init__(self, receiver): (source)
Initializes a new NMEA adapter.
ParametersreceiverThe receiver for positioning sentences. (type: ipositioning.IPositioningReceiver)
def _fixTimestamp(self): (source)
Turns the NMEAProtocol timestamp notation into a datetime.time object. The time in this object is expressed as Zulu time.
def _fixDatestamp(self): (source)
Turns an NMEA datestamp format into a datetime.date object.
RaisesValueErrorWhen the day or month value was invalid, e.g. 32nd day, or 13th month, or 0th day or month.
def _fixCoordinateFloat(self, coordinateType): (source)
Turns the NMEAProtocol coordinate format into Python float.
ParameterscoordinateTypeThe coordinate type. (type: One of Angles.LATITUDE or Angles.LONGITUDE.)
def _fixHemisphereSign(self, coordinateType, sentenceDataKey=None): (source)

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']
ParameterscoordinateTypeCoordinate type. One of Angles.LATITUDE, Angles.LONGITUDE or Angles.VARIATION.
sentenceDataKeyThe key name of the hemisphere sign being fixed in the sentence data. If unspecified, coordinateType is used. (type: str (unless None))
def _getHemisphereSign(self, coordinateType): (source)
Returns the hemisphere sign for a given coordinate type.
ParameterscoordinateTypeThe coordinate type to find the hemisphere for. (type: Angles.LATITUDE, Angles.LONGITUDE or Angles.VARIATION.)
ReturnsThe sign of that hemisphere (-1 or 1). (type: int)
def _convert(self, key, converter): (source)
A simple conversion fix.
ParameterskeyThe attribute name of the value to fix. (type: native string (Python identifier))
converterThe function that converts the value. (type: unary callable)
def _statefulUpdate(self, sentenceKey): (source)
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.

ParameterssentenceKeyThe name of the key in the sentence attributes, NMEAAdapter._STATEFUL_UPDATE dictionary and the adapter state. (type: str)
def _fixUnits(self, unitKey=None, valueKey=None, sourceKey=None, unit=None): (source)
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.

ParametersunitThe unit that is being converted from. If unspecified or None, asks the current sentence for the unitKey. If that also fails, raises AttributeError. (type: str)
unitKeyThe 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. (type: str)
sourceKeyThe 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. (type: str)
valueKeyThe 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. (type: str)
def _fixGSV(self): (source)
Parses partial visible satellite information from a GSV sentence.
def _fixGSA(self): (source)
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.

def _sentenceSpecificFix(self): (source)
Executes a fix for a specific type of sentence.
def clear(self): (source)
Resets this adapter.

This will empty the adapter state and the current sentence data.

def sentenceReceived(self, sentence): (source)
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.

ParameterssentenceThe sentence that is received. (type: NMEASentence)
def _validateCurrentSentence(self): (source)
Tests if a sentence contains a valid fix.
def _cleanCurrentSentence(self): (source)
Cleans the current sentence.
def _updateState(self): (source)
Updates the current state with the new information from the sentence.
def _updateBeaconInformation(self): (source)
Updates existing beacon information state with new data.
def _updateUsedBeacons(self, beaconInformation): (source)
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.

ParametersbeaconInformationThe beacon information object that beacon usage information will be added to (if necessary). (type: twisted.positioning.base.BeaconInformation)
def _mergeBeaconInformation(self, newBeaconInformation): (source)
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.

ParametersbeaconInformationThe beacon information object that beacon information will be merged into (if necessary). (type: twisted.positioning.base.BeaconInformation)
def _combineDateAndTime(self): (source)
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.
def _fireSentenceCallbacks(self): (source)
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 self._state.

API Documentation for Twisted, generated by pydoctor at 2015-01-30 14:14:53.