Eclipse SUMO - Simulation of Urban MObility
VehicleEngineHandler Class Reference

#include <VehicleEngineHandler.h>

Inheritance diagram for VehicleEngineHandler:
Collaboration diagram for VehicleEngineHandler:

Public Member Functions

void endDocument ()
 
void endElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
 
const EngineParametersgetEngineParameters ()
 
void startElement (const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
 VehicleEngineHandler (const std::string &toLoad)
 
virtual ~VehicleEngineHandler ()
 Destructor. More...
 

Protected Member Functions

int existsAttribute (std::string tag, const char *attribute, const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void loadBrakesData (const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void loadDifferentialData (const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void loadDragData (const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void loadEngineData (const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void loadEngineModelData (const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void loadGearData (const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void loadMassData (const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void loadShiftingData (const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void loadWheelsData (const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
double parseDoubleAttribute (std::string tag, const char *attribute, const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
int parseIntAttribute (std::string tag, const char *attribute, const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
double parsePolynomialCoefficient (int index, const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
std::string parseStringAttribute (std::string tag, const char *attribute, const XERCES_CPP_NAMESPACE::Attributes &attrs)
 
void raiseMissingAttributeError (std::string tag, std::string attribute)
 
void raiseUnknownTagError (std::string tag)
 

Private Member Functions

const VehicleEngineHandleroperator= (const VehicleEngineHandler &s)
 invalidated assignment operator More...
 
 VehicleEngineHandler (const VehicleEngineHandler &s)
 invalidated copy constructor More...
 

Private Attributes

int currentGear
 
int currentTag
 
EngineParameters engineParameters
 
std::vector< double > gearRatios
 
bool skip
 
std::string vehicleToLoad
 

Detailed Description

SAX handler used to parse engine parameters

Definition at line 81 of file VehicleEngineHandler.h.

Constructor & Destructor Documentation

◆ VehicleEngineHandler() [1/2]

VehicleEngineHandler::VehicleEngineHandler ( const std::string &  toLoad)

Constructor

Parameters
[in]toLoadid of the vehicle to be loaded

Definition at line 29 of file VehicleEngineHandler.cpp.

References vehicleToLoad.

◆ ~VehicleEngineHandler()

VehicleEngineHandler::~VehicleEngineHandler ( )
virtual

Destructor.

Definition at line 35 of file VehicleEngineHandler.cpp.

◆ VehicleEngineHandler() [2/2]

VehicleEngineHandler::VehicleEngineHandler ( const VehicleEngineHandler s)
private

invalidated copy constructor

Member Function Documentation

◆ endDocument()

void VehicleEngineHandler::endDocument ( )

◆ endElement()

void VehicleEngineHandler::endElement ( const XMLCh *const  uri,
const XMLCh *const  localname,
const XMLCh *const  qname 
)

◆ existsAttribute()

int VehicleEngineHandler::existsAttribute ( std::string  tag,
const char *  attribute,
const XERCES_CPP_NAMESPACE::Attributes &  attrs 
)
protected

Checks whether an attribute exists

Returns
the index, if the attribute exists, -1 otherwise

Definition at line 314 of file VehicleEngineHandler.cpp.

References transcode().

Referenced by loadEngineData(), and parseStringAttribute().

◆ getEngineParameters()

const EngineParameters & VehicleEngineHandler::getEngineParameters ( )

Definition at line 213 of file VehicleEngineHandler.cpp.

References engineParameters.

Referenced by RealisticEngineModel::loadParameters().

◆ loadBrakesData()

void VehicleEngineHandler::loadBrakesData ( const XERCES_CPP_NAMESPACE::Attributes &  attrs)
protected

◆ loadDifferentialData()

void VehicleEngineHandler::loadDifferentialData ( const XERCES_CPP_NAMESPACE::Attributes &  attrs)
protected

◆ loadDragData()

void VehicleEngineHandler::loadDragData ( const XERCES_CPP_NAMESPACE::Attributes &  attrs)
protected

Load air drag related data such as drag coefficient and maximum vehicle section

Definition at line 227 of file VehicleEngineHandler.cpp.

References EngineParameters::a_m2, EngineParameters::cAir, ENGINE_TAG_DRAG, ENGINE_TAG_DRAG_CAIR, ENGINE_TAG_DRAG_SECTION, engineParameters, and parseDoubleAttribute().

Referenced by startElement().

◆ loadEngineData()

◆ loadEngineModelData()

void VehicleEngineHandler::loadEngineModelData ( const XERCES_CPP_NAMESPACE::Attributes &  attrs)
protected

Load the mapping between engine rpm and output power in terms of linear function, i.e., slope and intercept

Definition at line 286 of file VehicleEngineHandler.cpp.

References EngineParameters::PolynomialEngineModelRpmToHp::degree, EngineParameters::engineMapping, engineParameters, MAX_POLY_DEGREE, parsePolynomialCoefficient(), and EngineParameters::PolynomialEngineModelRpmToHp::x.

Referenced by startElement().

◆ loadGearData()

void VehicleEngineHandler::loadGearData ( const XERCES_CPP_NAMESPACE::Attributes &  attrs)
protected

◆ loadMassData()

void VehicleEngineHandler::loadMassData ( const XERCES_CPP_NAMESPACE::Attributes &  attrs)
protected

Loads mass information, i.e., mass in kg and mass factor which takes into account rotational parts of the engine

Definition at line 220 of file VehicleEngineHandler.cpp.

References ENGINE_TAG_MASS, ENGINE_TAG_MASS_FACTOR, ENGINE_TAG_MASS_MASS, engineParameters, EngineParameters::mass_kg, EngineParameters::massFactor, and parseDoubleAttribute().

Referenced by startElement().

◆ loadShiftingData()

void VehicleEngineHandler::loadShiftingData ( const XERCES_CPP_NAMESPACE::Attributes &  attrs)
protected

◆ loadWheelsData()

void VehicleEngineHandler::loadWheelsData ( const XERCES_CPP_NAMESPACE::Attributes &  attrs)
protected

◆ operator=()

const VehicleEngineHandler& VehicleEngineHandler::operator= ( const VehicleEngineHandler s)
private

invalidated assignment operator

◆ parseDoubleAttribute()

double VehicleEngineHandler::parseDoubleAttribute ( std::string  tag,
const char *  attribute,
const XERCES_CPP_NAMESPACE::Attributes &  attrs 
)
protected

Search and returns a double attribute if existing. If not, an error is printed to stderr and the simulation is stopped. The simulation is stopped if the double cannot be parsed as well

Definition at line 330 of file VehicleEngineHandler.cpp.

References parseStringAttribute(), and StringUtils::toDouble().

Referenced by loadBrakesData(), loadDifferentialData(), loadDragData(), loadEngineData(), loadGearData(), loadMassData(), loadShiftingData(), loadWheelsData(), and parsePolynomialCoefficient().

◆ parseIntAttribute()

int VehicleEngineHandler::parseIntAttribute ( std::string  tag,
const char *  attribute,
const XERCES_CPP_NAMESPACE::Attributes &  attrs 
)
protected

Search and returns an integer attribute if existing. If not, an error is printed to stderr and the simulation is stopped. The simulation is stopped if the integer cannot be parsed as well

Definition at line 327 of file VehicleEngineHandler.cpp.

References parseStringAttribute(), and StringUtils::toInt().

Referenced by loadEngineData(), and loadGearData().

◆ parsePolynomialCoefficient()

double VehicleEngineHandler::parsePolynomialCoefficient ( int  index,
const XERCES_CPP_NAMESPACE::Attributes &  attrs 
)
protected

Search for the x_i coefficient in the list of attributes. If not found, an error is printed to stderr and the simulation is stopped. The simulation is stopped if the value cannot be parsed as well

Definition at line 333 of file VehicleEngineHandler.cpp.

References ENGINE_TAG_ENGINE_POWER, and parseDoubleAttribute().

Referenced by loadEngineModelData().

◆ parseStringAttribute()

std::string VehicleEngineHandler::parseStringAttribute ( std::string  tag,
const char *  attribute,
const XERCES_CPP_NAMESPACE::Attributes &  attrs 
)
protected

Search and returns a string attribute if existing. If not, an error is printed to stderr and the simulation is stopped

Definition at line 317 of file VehicleEngineHandler.cpp.

References existsAttribute(), raiseMissingAttributeError(), and transcode().

Referenced by loadEngineData(), parseDoubleAttribute(), and parseIntAttribute().

◆ raiseMissingAttributeError()

void VehicleEngineHandler::raiseMissingAttributeError ( std::string  tag,
std::string  attribute 
)
protected

Writes a missing attribute error to stderr and terminates the simulation

Definition at line 341 of file VehicleEngineHandler.cpp.

Referenced by parseStringAttribute().

◆ raiseUnknownTagError()

void VehicleEngineHandler::raiseUnknownTagError ( std::string  tag)
protected

Writes an unknown tag error to stderr and terminates the simulation

Definition at line 349 of file VehicleEngineHandler.cpp.

Referenced by startElement().

◆ startElement()

Field Documentation

◆ currentGear

int VehicleEngineHandler::currentGear
private

Definition at line 198 of file VehicleEngineHandler.h.

Referenced by endElement(), and loadGearData().

◆ currentTag

int VehicleEngineHandler::currentTag
private

Definition at line 192 of file VehicleEngineHandler.h.

Referenced by endElement(), and startElement().

◆ engineParameters

◆ gearRatios

std::vector<double> VehicleEngineHandler::gearRatios
private

Definition at line 202 of file VehicleEngineHandler.h.

Referenced by endElement(), and loadGearData().

◆ skip

bool VehicleEngineHandler::skip
private

Definition at line 196 of file VehicleEngineHandler.h.

Referenced by endElement(), and startElement().

◆ vehicleToLoad

std::string VehicleEngineHandler::vehicleToLoad
private

Definition at line 194 of file VehicleEngineHandler.h.

Referenced by startElement(), and VehicleEngineHandler().


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