Eclipse SUMO - Simulation of Urban MObility
VehicleEngineHandler Class Reference

#include <VehicleEngineHandler.h>

Inheritance diagram for VehicleEngineHandler:
[legend]
Collaboration diagram for VehicleEngineHandler:
[legend]

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 84 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 28 of file VehicleEngineHandler.cpp.

References vehicleToLoad.

◆ ~VehicleEngineHandler()

VehicleEngineHandler::~VehicleEngineHandler ( )
virtual

Destructor.

Definition at line 34 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 313 of file VehicleEngineHandler.cpp.

References transcode().

Referenced by loadEngineData(), and parseStringAttribute().

Here is the caller graph for this function:

◆ getEngineParameters()

const EngineParameters & VehicleEngineHandler::getEngineParameters ( )

Definition at line 212 of file VehicleEngineHandler.cpp.

References engineParameters.

Referenced by RealisticEngineModel::loadParameters().

Here is the caller graph for this function:

◆ loadBrakesData()

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

Load data about brakes

Definition at line 309 of file VehicleEngineHandler.cpp.

References EngineParameters::brakesTau_s, ENGINE_TAG_BRAKES, ENGINE_TAG_BRAKES_TAU, engineParameters, and parseDoubleAttribute().

Referenced by startElement().

Here is the caller graph for this function:

◆ loadDifferentialData()

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

Load final drive ratio

Definition at line 279 of file VehicleEngineHandler.cpp.

References EngineParameters::differentialRatio, ENGINE_TAG_GEAR_DIFFERENTIAL, ENGINE_TAG_GEAR_RATIO, engineParameters, and parseDoubleAttribute().

Referenced by startElement().

Here is the caller graph for this function:

◆ 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 226 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().

Here is the caller graph for this function:

◆ loadEngineData()

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

◆ 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 285 of file VehicleEngineHandler.cpp.

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

Referenced by startElement().

Here is the caller graph for this function:

◆ loadGearData()

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

Load gear ratios

Definition at line 263 of file VehicleEngineHandler.cpp.

References currentGear, ENGINE_TAG_GEAR, ENGINE_TAG_GEAR_N, ENGINE_TAG_GEAR_RATIO, gearRatios, parseDoubleAttribute(), and parseIntAttribute().

Referenced by startElement().

Here is the caller graph for this function:

◆ 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 219 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().

Here is the caller graph for this function:

◆ loadShiftingData()

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

Load the gear shifting rules

Definition at line 302 of file VehicleEngineHandler.cpp.

References EngineParameters::GearShiftingRules::deltaRpm, ENGINE_TAG_SHIFTING, ENGINE_TAG_SHIFTING_DELTARPM, ENGINE_TAG_SHIFTING_RPM, engineParameters, parseDoubleAttribute(), EngineParameters::GearShiftingRules::rpm, and EngineParameters::shiftingRule.

Referenced by startElement().

Here is the caller graph for this function:

◆ loadWheelsData()

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

Load data about vehicle's wheels, such as diameter and friction coefficient

Definition at line 233 of file VehicleEngineHandler.cpp.

References EngineParameters::cr1, EngineParameters::cr2, ENGINE_TAG_WHEELS, ENGINE_TAG_WHEELS_CR1, ENGINE_TAG_WHEELS_CR2, ENGINE_TAG_WHEELS_DIAMETER, ENGINE_TAG_WHEELS_FRICTION, engineParameters, parseDoubleAttribute(), EngineParameters::tiresFrictionCoefficient, and EngineParameters::wheelDiameter_m.

Referenced by startElement().

Here is the caller graph for this function:

◆ 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 329 of file VehicleEngineHandler.cpp.

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

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

Here is the caller graph for this function:

◆ 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 326 of file VehicleEngineHandler.cpp.

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

Referenced by loadEngineData(), and loadGearData().

Here is the caller graph for this function:

◆ 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 332 of file VehicleEngineHandler.cpp.

References ENGINE_TAG_ENGINE_POWER, and parseDoubleAttribute().

Referenced by loadEngineModelData().

Here is the caller graph for this function:

◆ 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 316 of file VehicleEngineHandler.cpp.

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

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

Here is the caller graph for this function:

◆ 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 340 of file VehicleEngineHandler.cpp.

Referenced by parseStringAttribute().

Here is the caller graph for this function:

◆ raiseUnknownTagError()

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

Writes an unknown tag error to stderr and terminates the simulation

Definition at line 348 of file VehicleEngineHandler.cpp.

Referenced by startElement().

Here is the caller graph for this function:

◆ startElement()

Field Documentation

◆ currentGear

int VehicleEngineHandler::currentGear
private

Definition at line 201 of file VehicleEngineHandler.h.

Referenced by endElement(), and loadGearData().

◆ currentTag

int VehicleEngineHandler::currentTag
private

Definition at line 195 of file VehicleEngineHandler.h.

Referenced by endElement(), and startElement().

◆ engineParameters

◆ gearRatios

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

Definition at line 205 of file VehicleEngineHandler.h.

Referenced by endElement(), and loadGearData().

◆ skip

bool VehicleEngineHandler::skip
private

Definition at line 199 of file VehicleEngineHandler.h.

Referenced by endElement(), and startElement().

◆ vehicleToLoad

std::string VehicleEngineHandler::vehicleToLoad
private

Definition at line 197 of file VehicleEngineHandler.h.

Referenced by startElement(), and VehicleEngineHandler().


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