Skip to main content

read_export

Function read_export 

Source
pub fn read_export(text: &str) -> Result<FlightLog, LogError>
Expand description

Reads one of the exports PerfectFlite’s software writes from a flight: comma-separated, with a header row such as Time,Altitude,Velocity,Temperature (F),Voltage, or tab-separated, with a header row such as Time, Altitude, Temp., Voltage and temperatures written with their unit, such as 58.7F.

A tab-separated export may have no header row: its rows are then the four cells the text export writes under Time, Altitude, Temp., Voltage, and a row is recognized by its temperature’s unit letter, as no other layout HPR Sim knows writes one. The record notes that the columns were taken so. Four of the project’s sample logs are written this way; cargo xtask logs checks their altitudes’ unit as it checks the other exports’.

The units are a .pf2’s: seconds, feet, feet per second, and the temperature’s stated unit. The header doesn’t state the altitude’s. cargo xtask logs bears out feet on the project’s sample exports: most peak at exactly the height of the .pf2 saved beside them, and the rest climb, read in feet, as long as those do against a fall in vacuum from the peak (its report, validation/reports/log-import.md, gives the counts and ratios). An export doesn’t name the logger’s model, so the logger reads PerfectFlite. A column the reader doesn’t know, such as Acceleration (calculated), is kept as written.

§Errors

LogError::NotThisFormat if the first line isn’t an export’s header row; LogError::Syntax for a cell that isn’t a number, a temperature in a unit other than its column’s or too large to convert to kelvin, a row with more cells than the header, or a time that doesn’t increase; LogError::NoData if there are no rows.