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

#include <SequenceReader.h>

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

Public Member Functions

 SequenceReader ()
 
 SequenceReader (const std::string &filename)
 
virtual void open (const std::string &filename)
 
virtual void open (std::istream *in)
 
int sequenceSize () const
 
void setWindowSize (int s)
 
int getWindowSize () const
 
void setActive (double tm)
 
void setFirstActive ()
 
void setLastActive ()
 
bool hasEntry (const std::string &name, double time)
 
Position getSequencePosition (const std::string &name, double time)
 
Velocity getSequenceVelocity (const std::string &name, double time)
 
void setEntry (double time, const std::string &name, const Position &p, const Velocity &v)
 
void clearSingletons ()
 
void removeAircraft (const std::vector< std::string > &alist)
 
std::vector< double > sequenceKeys ()
 
std::vector< double > sequenceKeysUpTo (int n, double tm)
 
bool hasExtraColumnData (double time, const std::string &acName, const std::string &colname) const
 
double getExtraColumnValue (double time, const std::string &acName, const std::string &colname) const
 
bool getExtraColumnBool (double time, const std::string &acName, const std::string &colname) const
 
std::string getExtraColumnString (double time, const std::string &acName, 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
 
- Public Member Functions inherited from larcfm::StateReader
 StateReader ()
 
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
 

Private Types

typedef std::pair< Position, VelocityDataPoint
 
typedef std::map< std::string, DataPoint > SequenceEntry
 
typedef std::map< double, SequenceEntry > SequenceEntryMap
 
typedef std::map< Triple< double, std::string, int >, Triple< double, bool, std::string > > allExtraTblType
 

Private Member Functions

void loadfile ()
 
void buildActive (double tm)
 

Private Attributes

int windowSize
 
SequenceEntryMap sequenceTable
 
std::vector< std::string > nameIndex
 
std::set< std::string > names
 
allExtraTblType allExtracolumnValues
 

Additional Inherited Members

- Protected Types inherited from larcfm::StateReader
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 inherited from larcfm::StateReader
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 inherited from larcfm::StateReader
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 inherited from larcfm::StateReader
static const int definedColumns = TM_CLK + 1
 

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

This can read state/history files as well as sequence files (slight variations on history files).

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[kn]/vy[kn]/vz[fpm] or track[deg]/gs[kn]/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 ("). 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", "history", or "sequence" 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. The 2-parameter versions (index, column) inherited from StateReader will only return the last active values for a given aircraft (which may be blank). To retrieve values at arbitrary times, use the 3-parameter versions (time, name, column). New columns are assumed unitless unless units are specified.

Constructor & Destructor Documentation

◆ SequenceReader()

larcfm::SequenceReader::SequenceReader ( )

A new, empty StateReader. This may be used to store parameters, but nothing else.

Member Function Documentation

◆ clearSingletons()

void larcfm::SequenceReader::clearSingletons ( )

remove any time-point entries for which there is only one aircraft (and so no chance of conflict)

◆ getExtraColumnBool() [1/2]

bool larcfm::SequenceReader::getExtraColumnBool ( double  time,
const std::string &  acName,
const std::string &  colname 
) const

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

Parameters
time
acName
colname
Returns
information

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

◆ getExtraColumnBool() [2/2]

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

◆ getExtraColumnString() [1/2]

std::string larcfm::SequenceReader::getExtraColumnString ( double  time,
const std::string &  acName,
const std::string &  colname 
) const

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

Parameters
time
acName
colname
Returns
information

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

◆ getExtraColumnString() [2/2]

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

◆ getExtraColumnValue() [1/2]

double larcfm::SequenceReader::getExtraColumnValue ( double  time,
const std::string &  acName,
const std::string &  colname 
) const

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

Parameters
time
acName
colname
Returns
information

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

◆ getExtraColumnValue() [2/2]

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

◆ getSequencePosition()

Position larcfm::SequenceReader::getSequencePosition ( const std::string &  name,
double  time 
)

Returns the Position entry for a given name and time. If no entry for this name and time, returns a zero position and sets a warning.

Parameters
name
time
Returns
position

Returns the Position entry for a given name and time. If no entry for this name and time, returns a zero position and sets a warning.

◆ getSequenceVelocity()

Velocity larcfm::SequenceReader::getSequenceVelocity ( const std::string &  name,
double  time 
)

Returns the Velocity entry for a given name and time. If no entry for this name and time, returns a zero velocity and sets a warning.

Parameters
name
time
Returns
velocity

Returns the Velocity entry for a given name and time. If no entry for this name and time, returns a zero velocity and sets a warning.

◆ getWindowSize()

int larcfm::SequenceReader::getWindowSize ( ) const

Returns the current window size

Returns
size

Returns the current window size

◆ hasEntry()

bool larcfm::SequenceReader::hasEntry ( const std::string &  name,
double  time 
)

Returns true if an entry exists for the given name and time

Parameters
name
time
Returns
true, if aircraft exists

Returns true if an entry exists for the given name and time

◆ hasExtraColumnData() [1/2]

bool larcfm::SequenceReader::hasExtraColumnData ( double  time,
const std::string &  acName,
const std::string &  colname 
) const

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

Parameters
time
acName
colname
Returns
true, if extra data is available

Updates a ParameterData with new parameters based on user columns for a given aircraft at a given time.

◆ hasExtraColumnData() [2/2]

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

◆ open() [1/2]

virtual void larcfm::SequenceReader::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.

Reimplemented from larcfm::StateReader.

◆ open() [2/2]

void larcfm::SequenceReader::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 from larcfm::StateReader.

◆ removeAircraft()

void larcfm::SequenceReader::removeAircraft ( const std::vector< std::string > &  alist)

This purges all references of a given set of aircraft from this reader. This then resets the active time to the last time in the list

Parameters
alistList of aircraft identifiers

◆ sequenceKeys()

vector< double > larcfm::SequenceReader::sequenceKeys ( )

Returns a sorted list of all sequence keys

◆ sequenceKeysUpTo()

vector< double > larcfm::SequenceReader::sequenceKeysUpTo ( int  n,
double  tm 
)

a list of n > 0 sequence keys, stopping at the given time (inclusive)

◆ sequenceSize()

int larcfm::SequenceReader::sequenceSize ( ) const

Return the number of sequence entries in the file

Returns
size

Return the number of sequence entries in the file

◆ setActive()

void larcfm::SequenceReader::setActive ( double  tm)

Given a sequence key, set the active set of states. If no such key exists, the active set is left empty.

Parameters
tmSequence key (time)

◆ setEntry()

void larcfm::SequenceReader::setEntry ( double  time,
const std::string &  name,
const Position p,
const Velocity v 
)

sets a particular entry without reading in from a file

Parameters
time
name
p
v

◆ setFirstActive()

void larcfm::SequenceReader::setFirstActive ( )

Set the first entry to be the active one.

◆ setLastActive()

void larcfm::SequenceReader::setLastActive ( )

Set the last entry to be the active one.

◆ setWindowSize()

void larcfm::SequenceReader::setWindowSize ( int  s)

Sets the window size for the active sequence set

Parameters
snew window size

Sets the window size for the active sequence set

Parameters
s> 0

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