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

#include <StateReader.h>

Inheritance diagram for larcfm::StateReader:
larcfm::ErrorReporter larcfm::ParameterReader larcfm::ParameterProvider larcfm::SequenceReader

Public Member Functions

 StateReader ()
 
virtual void open (const std::string &filename)
 
virtual void open (std::istream *ins)
 
ParameterDatagetParametersRef ()
 
ParameterData getParameters () const
 
void updateParameterData (ParameterData &p) const
 
int size () const
 
AircraftState getAircraftState (int i) const
 
std::vector< AircraftStategetAircraftStateList () const
 
Position getPosition (int ac) const
 
Velocity getVelocity (int ac) const
 
std::string getName (int ac) const
 
double getTime (int ac) const
 
bool isLatLon () const
 
std::vector< std::string > getExtraColumnList () const
 
std::string getExtraColumnUnits (const std::string &colname) const
 
bool hasExtraColumnData (int ac, const std::string &colname) const
 
double getExtraColumnValue (int ac, const std::string &colname) const
 
bool getExtraColumnBool (int ac, const std::string &colname) const
 
std::string getExtraColumnString (int ac, const std::string &colname) const
 
bool hasError () const
 
bool hasMessage () const
 
std::string getMessage ()
 
std::string getMessageNoClear () const
 

Protected Types

enum  {
  NAME , LAT_SX , LON_SY , ALT_SZ ,
  TRK_VX , GS_VY , VS_VZ , TM_CLK
}
 
typedef std::map< std::pair< int, int >, Triple< double, bool, std::string > > extraTblType
 

Protected Member Functions

int altHeadings (const std::string &s1, const std::string &s2, const std::string &s3, const std::string &s4) const
 
int altHeadings (const std::string &s1, const std::string &s2, const std::string &s3) const
 
int altHeadings (const std::string &s1, const std::string &s2) const
 
double parseClockTime (const std::string &s) const
 
int getIndex (const std::string &s) const
 

Protected Attributes

extraTblType extracolumnValues
 
ErrorLog error
 
SeparatedInput input
 
std::vector< AircraftStatestates
 
bool hasRead
 
bool latlon
 
bool trkgsvs
 
bool clock
 
std::vector< int > head
 
bool interpretUnits
 

Static Protected Attributes

static const int definedColumns = TM_CLK + 1
 

Private Member Functions

void loadfile ()
 

Detailed Description

This reads in and stores a set of aircraft states, possibly over time, (and parameters) from a file The aircraft states are stored in an ArrayList<AircraftState>. A state file consists of comma or space-separated values, with one position and velocity per line. Required columns include aircraft name, 3 position columns (either x[NM]/y[NM]/z[ft] or latitude[deg]/longitude[deg]/altitude[ft]) and 3 velocity columns (either vx[kn]/vy[kn]/vz[fpm] or track[deg]/gs[kn]/vs[fpm]). All empty lines or comment lines (starting with a hash sign (#)) are ignored.

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. If multiple aircraft and time are included (a fairly conventional case) then all the table must be organized with all the data for one aircraft listed consecutively. Thus, all the data for the first aircraft must be grouped together, then all the data for the second aircraft, etc. If consecutive position and velocity lines are for the same aircraft, subsequent name fields may be replaced with a double quotation mark ("). The aircraft name is case sensitive, so US54A != Us54a != us54a.

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).

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. However, something reasonable will come out, for instance a double value read as a string will come out as the string representation of the value.

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.

This allows for arbitrary additional user-defined columns.
New columns' information may be accessed by the get getNewColumnValue(), getNewColumnBoolean(), or getNewColumnString() methods. If there are multiple time-points in the file, only the values for the last time for an aircraft will be stored. New columns are assumed unitless unless units are specified.

Constructor & Destructor Documentation

◆ StateReader()

larcfm::StateReader::StateReader ( )

A new, empty StateReader. After you have a StateReader object then use the open() method.

Member Function Documentation

◆ getAircraftState()

AircraftState larcfm::StateReader::getAircraftState ( int  i) const

Returns the i-th AircraftState in the file

◆ getAircraftStateList()

vector< AircraftState > larcfm::StateReader::getAircraftStateList ( ) const

Returns the list of all AircraftStates in the file

◆ getExtraColumnBool()

bool larcfm::StateReader::getExtraColumnBool ( int  ac,
const std::string &  colname 
) const

Returns the column value associated with a given aircraft, interpreted as a boolean, or false if there is no info

◆ getExtraColumnList()

std::vector< std::string > larcfm::StateReader::getExtraColumnList ( ) const

Return a list of all user-defined columns in this reader.

◆ getExtraColumnString()

std::string larcfm::StateReader::getExtraColumnString ( int  ac,
const std::string &  colname 
) const

Returns the column value associated with a given aircraft, interpreted as a string, or the empty string if there is no info

◆ getExtraColumnUnits()

std::string larcfm::StateReader::getExtraColumnUnits ( const std::string &  colname) const

Return the units for a given column. If no units were specified, then return "unspecified". If the column name was not found, return the empty string.

Parameters
colnamename of the column in question.

◆ getExtraColumnValue()

double larcfm::StateReader::getExtraColumnValue ( int  ac,
const std::string &  colname 
) const

Returns the column value associated with a given aircraft, interpreted as a double, or NaN if there is no info

◆ getMessage()

std::string larcfm::StateReader::getMessage ( )
inlinevirtual

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::StateReader::getMessageNoClear ( ) const
inlinevirtual

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.

◆ getName()

string larcfm::StateReader::getName ( int  ac) const

returns the string name of aircraft i

Parameters
acaircraft index
Returns
name

◆ getParameters()

ParameterData larcfm::StateReader::getParameters ( ) const
virtual

◆ getParametersRef()

ParameterData & larcfm::StateReader::getParametersRef ( )
virtual

◆ getPosition()

Position larcfm::StateReader::getPosition ( int  ac) const

Returns the (most recent) position of the i-th aircraft state in the file. This is the raw position, and has not been through any projection.

Parameters
acaircraft index
Returns
position

◆ getVelocity()

Velocity larcfm::StateReader::getVelocity ( int  ac) const

Returns the (most recent) velocity of the i-th aircraft state in the file. This is the raw velocity, and has not been through any projection.

Parameters
acaircraft index
Returns
velocity

◆ hasError()

bool larcfm::StateReader::hasError ( ) const
inlinevirtual

Does this object have an error?

Returns
true if there is an error.

Implements larcfm::ErrorReporter.

◆ hasExtraColumnData()

bool larcfm::StateReader::hasExtraColumnData ( int  ac,
const std::string &  colname 
) const

Return true if the given aircraft has data for the indicated column.

Parameters
ac
colname
Returns

◆ hasMessage()

bool larcfm::StateReader::hasMessage ( ) const
inlinevirtual

Does this object have an error or a warning?

Returns
true if there is an error or warning.

Implements larcfm::ErrorReporter.

◆ open() [1/2]

virtual void larcfm::StateReader::open ( const std::string &  filename)
virtual

Read a new file into an existing StateReader. Parameters are preserved if they are not specified in the file.

Parameters
filenamefile name

Reimplemented in larcfm::SequenceReader.

◆ open() [2/2]

void larcfm::StateReader::open ( std::istream *  ins)
virtual

Read a new stream into an existing StateReader. Parameters are preserved if they are not specified in the file.

Reimplemented in larcfm::SequenceReader.

◆ parseClockTime()

double larcfm::StateReader::parseClockTime ( const std::string &  s) const
protected

Return the string as a single value in seconds. If the column is labeled "clock," then it is expected in a "HH:MM:SS" format. If the column is labeled "time" then just read it as a value. If the string cannot be parsed, return 0.0;

Parameters
sthe string to be parsed
Returns

◆ size()

int larcfm::StateReader::size ( ) const

Return the number of AircraftStates in the file

Returns
size

◆ updateParameterData()

void larcfm::StateReader::updateParameterData ( ParameterData p) const
virtual

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