Parses data received from the data relay into a usable format for the ground station's event emitters
- Copyright:
-
- Waterloo Aerial Robotics Group 2016
- Source:
- See:
Requires
- module:util/Logger
- module:util/Validator
- module:models/PacketTypes
- module:underscore
Methods
-
<inner> checkForMissingHeaders(headers_array)
-
Compares the received headers to that of the headers in the PacketTypes module. Warns the user if there are extra or missing headers
Parameters:
Name Type Description headers_arrayArray - Source:
-
<inner> parseData(data, headers_array)
-
Converts a string of data into a packet type object, to be emitted by the TelemetryData module. Uses the PacketTypes module in order to sort the headers into the appropriate packet types as well as to perform the correct validations on each one
Parameters:
Name Type Description datastring A stringified version of the data (split by commas)
headers_arrayArray An array of the headers in the same order as the headers
- Source:
Throws:
Error if the specified validation function doesn't exist
Returns:
A hash indexed by the packet type name, with the values being another hash in a format of header_name => data_value
- Type
- Object
Example
Given
'34, 89.654, ...'as data and['heading', 'lon', ...]as headers, will return:{ aircraft_position: { heading: 34, lon: 89.654 ... }, aircraft_orientation: {...}, aircraft_gains: {...} ... }