#include <MSDevice_HBEFA.h>

Each device collects the vehicular emissions / fuel consumption by being called each time step, computing the current values using HelpersHBEFA, and aggregating them into internal storages over the whol journey.
Definition at line 61 of file MSDevice_HBEFA.h.
Public Member Functions | |
| MSVehicle & | getHolder () const throw () |
| Returns the vehicle that holds this device. | |
| const std::string & | getID () throw () |
| Returns the id of this device. | |
| void | tripInfoOutput (OutputDevice &os) const throw (IOError) |
| Called on writing tripinfo output. | |
| SUMOTime | wrappedComputeCommandExecute (SUMOTime currentTime) throw (ProcessError) |
| Performs rerouting after a period. | |
Methods called on vehicle movement / state change, overwriting MSDevice | |
| void | enterLaneAtEmit (MSLane *enteredLane, const MSVehicle::State &state) |
| Computes a new route on vehicle emission. | |
Methods called on vehicle movement / state change | |
| virtual void | enterLaneAtLaneChange (MSLane *enteredLane) |
| Update of members if vehicle enters a new lane in the laneChange step. | |
| virtual void | enterLaneAtMove (MSLane *enteredLane, SUMOReal driven) |
| Update if vehicle enters a new lane in the move step. | |
| virtual void | leaveLane () |
| Update of members if vehicle leaves a new lane in the lane change step. | |
| virtual void | leaveLaneAtMove (SUMOReal driven) |
| Update of members if vehicle leaves a new lane in the move step. | |
| virtual void | onRemovalFromNet () |
| Called when the vehicle leaves the lane. | |
| virtual void | onTryEmit () |
| Called when the vehicle tries to get into the net. | |
Static Public Member Functions | |
| static void | buildVehicleDevices (MSVehicle &v, std::vector< MSDevice * > &into) throw () |
| Build devices for the given vehicle, if needed. | |
| static void | insertOptions () throw () |
| Inserts MSDevice_HBEFA-options. | |
Protected Attributes | |
| MSVehicle & | myHolder |
| The vehicle that stores the device. | |
Private Member Functions | |
| MSDevice_HBEFA (const MSDevice_HBEFA &) | |
| Invalidated copy constructor. | |
| MSDevice_HBEFA (MSVehicle &holder, const std::string &id) throw () | |
| Constructor. | |
| MSDevice_HBEFA & | operator= (const MSDevice_HBEFA &) |
| Invalidated assignment operator. | |
| ~MSDevice_HBEFA () throw () | |
| Destructor. | |
Private Attributes | |
| WrappingCommand< MSDevice_HBEFA > * | myComputeAndCollectCommand |
| The (optional) command responsible for rerouting. | |
Internal storages for pollutant/fuel sum | |
| SUMOReal | myCO |
| SUMOReal | myCO2 |
| SUMOReal | myFuel |
| SUMOReal | myHC |
| SUMOReal | myNOx |
| SUMOReal | myPMx |
Static Private Attributes | |
| static int | myVehicleIndex = 0 |
| A static vehicle index for computing deterministic vehicle fractions. | |
| MSDevice_HBEFA::MSDevice_HBEFA | ( | MSVehicle & | holder, | |
| const std::string & | id | |||
| ) | throw () [private] |
Constructor.
| [in] | holder | The vehicle that holds this device |
| [in] | id | The ID of the device |
Definition at line 100 of file MSDevice_HBEFA.cpp.
Referenced by buildVehicleDevices().
00101 : MSDevice(holder, id), myComputeAndCollectCommand(0), 00102 myCO2(0), myCO(0), myHC(0), myPMx(0), myNOx(0), myFuel(0) { 00103 }
| MSDevice_HBEFA::~MSDevice_HBEFA | ( | ) | throw () [private] |
Destructor.
Definition at line 106 of file MSDevice_HBEFA.cpp.
References WrappingCommand< T >::deschedule(), and myComputeAndCollectCommand.
00106 { 00107 // make the rerouting command invalid 00108 if (myComputeAndCollectCommand!=0) { 00109 myComputeAndCollectCommand->deschedule(); 00110 } 00111 }
| MSDevice_HBEFA::MSDevice_HBEFA | ( | const MSDevice_HBEFA & | ) | [private] |
Invalidated copy constructor.
| void MSDevice_HBEFA::buildVehicleDevices | ( | MSVehicle & | v, | |
| std::vector< MSDevice * > & | into | |||
| ) | throw () [static] |
Build devices for the given vehicle, if needed.
The options are read and evaluated whether hbefa-devices shall be built for the given vehicle.
When the first device is built, the static container of edge weights used for routing is initialised with the mean speed the edges allow. In addition, an event is generated which updates these weights is built and added to the list of events to execute at a simulation end.
For each seen vehicle, the global vehicle index is increased.
The built device is stored in the given vector.
| [in] | v | The vehicle for which a device may be built |
| in,filled] | into The vector to store the built device in |
Definition at line 74 of file MSDevice_HBEFA.cpp.
References OptionsCont::getBool(), OptionsCont::getFloat(), OptionsCont::getOptions(), OptionsCont::isInStringVector(), OptionsCont::isSet(), MSDevice_HBEFA(), myVehicleIndex, and RandHelper::rand().
Referenced by MSVehicle::MSVehicle().
00074 { 00075 OptionsCont &oc = OptionsCont::getOptions(); 00076 if (oc.getFloat("device.hbefa.probability")==0&&!oc.isSet("device.hbefa.knownveh")) { 00077 // no route computation is modelled 00078 return; 00079 } 00080 // route computation is enabled 00081 bool haveByNumber = false; 00082 if (oc.getBool("device.hbefa.deterministic")) { 00083 haveByNumber = ((myVehicleIndex%1000) < (int)(oc.getFloat("device.hbefa.probability")*1000.)); 00084 } else { 00085 haveByNumber = RandHelper::rand()<=oc.getFloat("device.hbefa.probability"); 00086 } 00087 bool haveByName = oc.isSet("device.hbefa.knownveh") && OptionsCont::getOptions().isInStringVector("device.hbefa.knownveh", v.getID()); 00088 if (haveByNumber||haveByName) { 00089 // build the device 00090 MSDevice_HBEFA* device = new MSDevice_HBEFA(v, "hbefa_" + v.getID()); 00091 into.push_back(device); 00092 } 00093 myVehicleIndex++; 00094 }
| void MSDevice_HBEFA::enterLaneAtEmit | ( | MSLane * | enteredLane, | |
| const MSVehicle::State & | state | |||
| ) | [virtual] |
Computes a new route on vehicle emission.
An event is created and added to the list of simulation step end events which executes "wrappedComputeCommandExecute".
| [in] | enteredLane | The lane the vehicle enters |
| [in] | state | The vehicle's state during the emission |
MSEventHandler
Reimplemented from MSDevice.
Definition at line 115 of file MSDevice_HBEFA.cpp.
References MSEventControl::ADAPT_AFTER_EXECUTION, MSEventControl::addEvent(), MSNet::getEndOfTimestepEvents(), MSNet::getInstance(), myComputeAndCollectCommand, and wrappedComputeCommandExecute().
00115 { 00116 if (myComputeAndCollectCommand!=0) { 00117 return; 00118 } 00119 myComputeAndCollectCommand = new WrappingCommand< MSDevice_HBEFA >(this, &MSDevice_HBEFA::wrappedComputeCommandExecute); 00120 MSNet::getInstance()->getEndOfTimestepEvents().addEvent( 00121 myComputeAndCollectCommand, MSNet::getInstance()->getCurrentTimeStep(), 00122 MSEventControl::ADAPT_AFTER_EXECUTION); 00123 }
| virtual void MSDevice::enterLaneAtLaneChange | ( | MSLane * | enteredLane | ) | [inline, virtual, inherited] |
Update of members if vehicle enters a new lane in the laneChange step.
| [in] | enteredLane | The lane the vehicle enters |
Definition at line 121 of file MSDevice.h.
| virtual void MSDevice::enterLaneAtMove | ( | MSLane * | enteredLane, | |
| SUMOReal | driven | |||
| ) | [inline, virtual, inherited] |
Update if vehicle enters a new lane in the move step.
| [in] | enteredLane | The lane the vehicle enters |
| [in] | driven | The distance driven by the vehicle within this time step |
Definition at line 106 of file MSDevice.h.
| MSVehicle& MSDevice::getHolder | ( | ) | const throw () [inline, inherited] |
Returns the vehicle that holds this device.
Definition at line 81 of file MSDevice.h.
References MSDevice::myHolder.
Referenced by wrappedComputeCommandExecute().
00081 { 00082 return myHolder; 00083 }
| const std::string& MSDevice::getID | ( | ) | throw () [inline, inherited] |
Returns the id of this device.
Definition at line 89 of file MSDevice.h.
References MSDevice::myID.
00089 { 00090 return myID; 00091 }
| void MSDevice_HBEFA::insertOptions | ( | ) | throw () [static] |
Inserts MSDevice_HBEFA-options.
!! describe
!! describe
!! describe
Definition at line 56 of file MSDevice_HBEFA.cpp.
References OptionsCont::addDescription(), OptionsCont::addOptionSubTopic(), OptionsCont::doRegister(), OptionsCont::getOptions(), and myVehicleIndex.
Referenced by MSFrame::fillOptions().
00056 { 00057 OptionsCont &oc = OptionsCont::getOptions(); 00058 oc.addOptionSubTopic("Emissions"); 00059 00060 oc.doRegister("device.hbefa.probability", new Option_Float(0.)); 00061 oc.addDescription("device.hbefa.probability", "Emissions", "The probability for a vehicle to have an emission logging device"); 00062 00063 oc.doRegister("device.hbefa.knownveh", new Option_String()); 00064 oc.addDescription("device.hbefa.knownveh", "Emissions", "Assign a device to named vehicles"); 00065 00066 oc.doRegister("device.hbefa.deterministic", new Option_Bool(false)); 00067 oc.addDescription("device.hbefa.deterministic", "Emissions", "The devices are set deterministic using a fraction of 1000"); 00068 00069 myVehicleIndex = 0; 00070 }
| virtual void MSDevice::leaveLane | ( | ) | [inline, virtual, inherited] |
Update of members if vehicle leaves a new lane in the lane change step.
Definition at line 132 of file MSDevice.h.
| virtual void MSDevice::leaveLaneAtMove | ( | SUMOReal | driven | ) | [inline, virtual, inherited] |
Update of members if vehicle leaves a new lane in the move step.
| [in] | driven | The distance driven by the vehicle within this time step |
Definition at line 128 of file MSDevice.h.
| virtual void MSDevice::onRemovalFromNet | ( | ) | [inline, virtual, inherited] |
| virtual void MSDevice::onTryEmit | ( | ) | [inline, virtual, inherited] |
Called when the vehicle tries to get into the net.
Reimplemented in MSDevice_Routing.
Definition at line 98 of file MSDevice.h.
| MSDevice_HBEFA& MSDevice_HBEFA::operator= | ( | const MSDevice_HBEFA & | ) | [private] |
Invalidated assignment operator.
| void MSDevice_HBEFA::tripInfoOutput | ( | OutputDevice & | os | ) | const throw (IOError) [virtual] |
Called on writing tripinfo output.
| [in] | os | The stream to write the information into |
| IOError | not yet implemented |
Reimplemented from MSDevice.
Definition at line 145 of file MSDevice_HBEFA.cpp.
References myCO, myCO2, myFuel, myHC, myNOx, and myPMx.
00145 { 00146 os << resetiosflags(std::ios::floatfield); 00147 (os.openTag("emissions") << 00148 " CO_abs=\"" << myCO << 00149 "\" CO2_abs=\"" << myCO2 << 00150 "\" HC_abs=\"" << myHC << 00151 "\" PMx_abs=\""<< myPMx << 00152 "\" NOx_abs=\""<< myNOx << 00153 "\" fuel_abs=\""<< myFuel << 00154 "\"").closeTag(true); 00155 os<<setiosflags(std::ios::fixed); 00156 }
| SUMOTime MSDevice_HBEFA::wrappedComputeCommandExecute | ( | SUMOTime | currentTime | ) | throw (ProcessError) |
Performs rerouting after a period.
The current amounts of emitted pollutants / consumed fuel is computed using the according methods from "HelpersHBEFA" and are added to the internal sums.
This method is called from the event handler at the end of a simulation step.
| [in] | currentTime | The current simulation time |
MSEventHandler
Definition at line 127 of file MSDevice_HBEFA.cpp.
References HelpersHBEFA::computeCO(), HelpersHBEFA::computeCO2(), HelpersHBEFA::computeFuel(), HelpersHBEFA::computeHC(), HelpersHBEFA::computeNOx(), HelpersHBEFA::computePMx(), DELTA_T, MSVehicleType::getEmissionClass(), MSDevice::getHolder(), MSVehicle::getPreDawdleAcceleration(), MSVehicle::getSpeed(), MSVehicle::getVehicleType(), myCO, myCO2, myFuel, myHC, myNOx, myPMx, and SUMOReal.
Referenced by enterLaneAtEmit().
00127 { 00128 if (!getHolder().isOnRoad()) { 00129 return 1; 00130 } 00131 SUMOEmissionClass c = getHolder().getVehicleType().getEmissionClass(); 00132 SUMOReal v = getHolder().getSpeed(); 00133 SUMOReal a = getHolder().getPreDawdleAcceleration(); 00134 myCO2 += HelpersHBEFA::computeCO2(c, v, a); 00135 myCO += HelpersHBEFA::computeCO(c, v, a); 00136 myHC += HelpersHBEFA::computeHC(c, v, a); 00137 myPMx += HelpersHBEFA::computePMx(c, v, a); 00138 myNOx += HelpersHBEFA::computeNOx(c, v, a); 00139 myFuel += HelpersHBEFA::computeFuel(c, v, a); 00140 return DELTA_T; 00141 }
SUMOReal MSDevice_HBEFA::myCO [private] |
Definition at line 158 of file MSDevice_HBEFA.h.
Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().
SUMOReal MSDevice_HBEFA::myCO2 [private] |
Definition at line 158 of file MSDevice_HBEFA.h.
Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().
The (optional) command responsible for rerouting.
Definition at line 153 of file MSDevice_HBEFA.h.
Referenced by enterLaneAtEmit(), and ~MSDevice_HBEFA().
SUMOReal MSDevice_HBEFA::myFuel [private] |
Definition at line 158 of file MSDevice_HBEFA.h.
Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().
SUMOReal MSDevice_HBEFA::myHC [private] |
Definition at line 158 of file MSDevice_HBEFA.h.
Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().
MSVehicle& MSDevice::myHolder [protected, inherited] |
The vehicle that stores the device.
Definition at line 158 of file MSDevice.h.
Referenced by MSDevice_Routing::enterLaneAtEmit(), MSDevice::getHolder(), MSDevice_Routing::onTryEmit(), and MSDevice_Routing::wrappedRerouteCommandExecute().
SUMOReal MSDevice_HBEFA::myNOx [private] |
Definition at line 158 of file MSDevice_HBEFA.h.
Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().
SUMOReal MSDevice_HBEFA::myPMx [private] |
Definition at line 158 of file MSDevice_HBEFA.h.
Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().
int MSDevice_HBEFA::myVehicleIndex = 0 [static, private] |
A static vehicle index for computing deterministic vehicle fractions.
Definition at line 150 of file MSDevice_HBEFA.h.
Referenced by buildVehicleDevices(), and insertOptions().
1.5.6