ICAROUS
All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Modules Pages
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
larcfm::StateWriter Class Reference

#include <StateWriter.h>

Inheritance diagram for larcfm::StateWriter:
larcfm::ErrorReporter

Public Member Functions

 StateWriter ()
 
void open (const std::string &filename)
 
void open (std::ostream *writer)
 
void close ()
 
bool isVelocity () const
 
void setVelocity (bool velocity)
 
bool isTrkGsVs () const
 
void setTrkGsVs (bool trkgsvs)
 
int getPrecision () const
 
void setPrecision (int precision)
 
bool isOutputTime () const
 
void setOutputTime (bool display_time)
 
bool isOutputUnits () const
 
void setOutputUnits (bool display_units)
 
void setColumnDelimiterTab ()
 
void setColumnDelimiterComma ()
 
void setColumnDelimiterSpace ()
 
void addComment (std::string comment)
 
void setParameters (ParameterData pr)
 
void writeState (const std::string &name, double time, const Position &p, const Velocity &v)
 
void writeState (const std::string &name, double time, const Position &p)
 
void writeState (const std::string &name, double time, const std::pair< Position, Velocity > &pv)
 
void writeState (const std::string &name, const Position &p, const Velocity &v)
 
void writeState (const std::string &name, const Position &p)
 
int size () const
 
bool isLatLon () const
 
std::string toString () const
 
bool hasError () const
 
bool hasMessage () const
 
std::string getMessage ()
 
std::string getMessageNoClear () const
 

Private Attributes

ErrorLog error
 
SeparatedOutput output
 
bool velocity
 
bool latlon
 
bool trkgsvs
 
bool display_time
 
bool first_line
 
bool display_units
 
int precision
 
int lines
 
std::string fname
 
std::ostream * fw
 

Static Private Attributes

static const double default_time = 0.0
 

Detailed Description

This object writes a set of aircraft states, possibly over time, (and parameters) from a file The Aircraft states are stored in an ArrayList<AircraftState>.

State files consist of comma or space-separated values, with one point per line. Required columns include aircraft name, 3 position columns (either x[nmi]/y[nmi]/z[ft] or latitude[deg]/longitude[deg]/altitude[ft]) and 3 velocity columns (either vx[knot]/vy[knot]/vz[fpm] or track[deg]/gs[knot]/vs[fpm]).

An optional column is time [s]. If it is included, a "history" will be build if an aircraft has more than one entry. If it is not included, only the last entry for an aircraft will be stored.

It is necessary to include a header line that defines the column ordering. The column definitions are not case sensitive. There is also an optional header line, immediately following the column definition, that defines the unit type for each column (the defaults are listed above).

If points are consecutive for the same aircraft, subsequent name fields may be replaced with a double quotation mark (&quot). The aircraft name is case sensitive, so US54A != Us54a != us54a.

Any empty line or any line starting with a hash sign (#) is ignored.

Files may also include parameter definitions prior to other data. Parameter definitions are of the form <key> = <value>, one per line, where <key> is a case-insensitive alphanumeric word and <value> is either a numeral or string. The <value> may include a unit, such as "dist = 50 [m]". Note that parameters require a space on either side of the equals sign. Note that it is possible to also update the stored parameter values (or store additional ones) through API calls.

Parameters can be interpreted as double values, strings, or Boolean values, and the user is required to know which parameter is interpreted as which type.

If the optional parameter "filetype" is specified, its value must be "state" or "history" (no quotes) for this reader to accept the file without error.

Constructor & Destructor Documentation

◆ StateWriter()

larcfm::StateWriter::StateWriter ( )

A new StateWriter.

Member Function Documentation

◆ addComment()

void larcfm::StateWriter::addComment ( std::string  comment)

Adds a comment line to the file.

◆ getMessage()

std::string larcfm::StateWriter::getMessage ( )
virtual

Return a string representation of any errors or warnings. Calling this method will clear any messages and reset both the error and warning status to none.

Returns
error and warning messages. If there are no messages, an empty string is returned.

Implements larcfm::ErrorReporter.

◆ getMessageNoClear()

std::string larcfm::StateWriter::getMessageNoClear ( ) const
virtual

Return a string representation of any errors or warnings. Calling this method will not clear the error or warning status (i.e., hasError() will return the same value before and after this call.)

Returns
error and warning messages. If there are no messages, an empty string is returned.

Implements larcfm::ErrorReporter.

◆ hasError()

bool larcfm::StateWriter::hasError ( ) const
virtual

Does this object have an error?

Returns
true if there is an error.

Implements larcfm::ErrorReporter.

◆ hasMessage()

bool larcfm::StateWriter::hasMessage ( ) const
virtual

Does this object have an error or a warning?

Returns
true if there is an error or warning.

Implements larcfm::ErrorReporter.

◆ isOutputTime()

bool larcfm::StateWriter::isOutputTime ( ) const

Will the time be added to the file

◆ isOutputUnits()

bool larcfm::StateWriter::isOutputUnits ( ) const

Will the units be displayed?

◆ open()

void larcfm::StateWriter::open ( const std::string &  filename)

A new StateReader based on the given file.

◆ setColumnDelimiterComma()

void larcfm::StateWriter::setColumnDelimiterComma ( )

Sets the column delimiter to a comma. This method can only be used before the first "writeState" method.

◆ setColumnDelimiterSpace()

void larcfm::StateWriter::setColumnDelimiterSpace ( )

Sets the column delimiter to a space. This method can only be used before the first "writeState" method.

◆ setColumnDelimiterTab()

void larcfm::StateWriter::setColumnDelimiterTab ( )

Sets the column delimiter to a tab. This method can only be used before the first "writeState" method.

◆ setOutputTime()

void larcfm::StateWriter::setOutputTime ( bool  display_time)

Should the time be added to the file

◆ setOutputUnits()

void larcfm::StateWriter::setOutputUnits ( bool  displayunits)

Should the units be displayed?

◆ setParameters()

void larcfm::StateWriter::setParameters ( ParameterData  pr)

Set parameters. Use all the parameters in the reader.

◆ size()

int larcfm::StateWriter::size ( ) const

Return the number of states added to the file


The documentation for this class was generated from the following files: