MSEmitter Class Reference

#include <MSEmitter.h>

Inheritance diagram for MSEmitter:

MSTrigger Named GUIEmitter

Detailed Description

A vehicle emitting device.

Instances of this class are places at a lane where vehicles are inserted into the network. This mechanism can be used in parallel to the standard vehicle emission on roads. An emitter is meant to be used to simulate the entry of a flow into an area at places where induction loops are located at in reality.

Definition at line 59 of file MSEmitter.h.


Public Member Functions

bool childCheckEmit (MSEmitterChild *child)
size_t getActiveChildIndex () const
 Returns the index of the currently active child.
const std::string & getID () const throw ()
 Returns the id.
 MSEmitter (const std::string &id, MSNet &net, MSLane *destLane, SUMOReal pos, const std::string &file) throw ()
 Constructor.
void schedule (MSEmitterChild *child, MSVehicle *v, SUMOReal speed)
 Schedules a vehicle to emit.
void setActiveChild (MSEmitterChild *child)
 Sets the given child as the currently used one.
virtual ~MSEmitter () throw ()

Protected Attributes

MSEmitterChildmyActiveChild
 The currently active child.
MSLanemyDestLane
MSEmitterChildmyFileBasedEmitter
 The file-based child.
std::string myID
 The name of the object.
MSNetmyNet
 The network the emitter is located in.
SUMOReal myPos
 The position of the emitter at the lane.
std::map< MSEmitterChild
*, std::pair< MSVehicle
*, SUMOReal > > 
myToEmit
 A map children->vehicles to emit.

Private Member Functions

 MSEmitter (const MSEmitter &)
 Invalidated copy constructor.
MSEmitteroperator= (const MSEmitter &)
 Invalidated assignment operator.

Data Structures

class  MSEmitter_FileTriggeredChild
 An EmitterChild which uses information from a parsed file. More...
class  MSEmitterChild
 Holder of information about vehicle routes and types. More...

Constructor & Destructor Documentation

MSEmitter::MSEmitter ( const std::string &  id,
MSNet net,
MSLane destLane,
SUMOReal  pos,
const std::string &  file 
) throw ()

Constructor.

Parameters:
[in] id The id of the emitter
[in] net The net the emitter belongs to
[in] destLane The lane the emitter is placed on
[in] pos Position of the emitter on the given lane
[in] file Name of the file to read the emission definitions from

Definition at line 289 of file MSEmitter.cpp.

References MSEmitter::MSEmitter_FileTriggeredChild::MSEmitter_FileTriggeredChild(), myActiveChild, myFileBasedEmitter, and myPos.

00293         : MSTrigger(id), myNet(net),
00294         myDestLane(destLane), myPos((SUMOReal) pos) {
00295     assert(myPos>=0);
00296     myActiveChild =
00297         new MSEmitter_FileTriggeredChild(net, aXMLFilename, *this, net.getVehicleControl());
00298     myFileBasedEmitter = myActiveChild;
00299 }

MSEmitter::~MSEmitter (  )  throw () [virtual]

destructor

Definition at line 302 of file MSEmitter.cpp.

References myFileBasedEmitter, and myToEmit.

00302                               {
00303     delete myFileBasedEmitter;
00304     std::map<MSEmitterChild*, std::pair<MSVehicle*, SUMOReal> >::iterator i;
00305     for (i=myToEmit.begin(); i!=myToEmit.end(); ++i) {
00306         delete(*i).second.first;
00307     }
00308 }

MSEmitter::MSEmitter ( const MSEmitter  )  [private]

Invalidated copy constructor.


Member Function Documentation

bool MSEmitter::childCheckEmit ( MSEmitterChild child  ) 

Called by a MSEmitterChild (given as parameter) this method checks whether this child is the currently active one and whether a vehicle from this source can be emitted. Returns true if the child can continue with the next vehicle, false otherwise

Definition at line 312 of file MSEmitter.cpp.

References MSVehicleControl::addVehicle(), MSEdge::emit(), MSNet::getCurrentTimeStep(), MSVehicle::getDesiredDepart(), MSLane::getEdge(), MSVehicle::getID(), MSNet::getInstance(), MSVehicle::getMaxSpeed(), MSLane::getMaxSpeed(), MSNet::getVehicleControl(), MSLane::isEmissionSuccess(), MSEdge::isVaporizing(), MIN2(), MIN3(), myActiveChild, myDestLane, myNet, myPos, myToEmit, MSVehicle::onDepart(), and SUMOReal.

Referenced by MSEmitter::MSEmitter_FileTriggeredChild::execute(), MSEmitter::MSEmitter_FileTriggeredChild::processNextEntryReaderTriggered(), and GUIEmitter::GUIEmitterChild_UserTriggeredChild::wrappedExecute().

00312                                                {
00313     if (myToEmit.find(child)==myToEmit.end()) {
00314         // should not happen - a child is calling and should have a vehicle added
00315         throw 1;
00316     }
00317     if (child!=myActiveChild||myDestLane->getEdge().isVaporizing()) {
00318         // check whether this is due to vaporization
00319         if (myDestLane->getEdge().isVaporizing()) {
00320             myToEmit[child].first->setWasVaporized(true);
00321         }
00322         // remove the vehicle previously inserted by the child
00323         delete myToEmit[child].first;
00324         // erase the child information
00325         myToEmit.erase(myToEmit.find(child));
00326         // inform child to process the next one (the current was not used)
00327         return true;
00328     }
00329     // get the vehicle and the speed the child has read/generated
00330     MSVehicle *veh = myToEmit[child].first;
00331     if (veh->getDesiredDepart()>MSNet::getInstance()->getCurrentTimeStep()) {
00332         return false;
00333     }
00334     SUMOReal speed = myToEmit[child].second;
00335     // !!! add warning if speed to high or negative
00336     // check whether the speed shall be patched
00337     SUMOReal pos = myPos;
00338     if (speed<0) {
00339         speed = MIN2(myDestLane->getMaxSpeed(), veh->getMaxSpeed());
00340     } else {
00341         speed = MIN3(myDestLane->getMaxSpeed(), veh->getMaxSpeed(), speed);
00342     }
00343     // try to emit
00344 #ifdef HAVE_MESOSIM
00345     if (MSGlobals::gUseMesoSim) {
00346         if (myDestLane->getEdge().emit(*veh,  myNet.getCurrentTimeStep())) {
00347             veh->onDepart();
00348             // insert vehicle into the dictionary
00349             if (!myNet.getVehicleControl().addVehicle(veh->getID(), veh)) {
00350                 // !!!
00351                 throw 1;
00352             }
00353             // erase the child information
00354             myToEmit.erase(myToEmit.find(child));
00355             return true;
00356         }
00357     } else {
00358 #endif
00359         if (myDestLane->isEmissionSuccess(veh, speed, pos, true)) {
00360             veh->onDepart();
00361             // insert vehicle into the dictionary
00362             if (!myNet.getVehicleControl().addVehicle(veh->getID(), veh)) {
00363                 // !!!
00364                 throw 1;
00365             }
00366             // erase the child information
00367             myToEmit.erase(myToEmit.find(child));
00368             return true;
00369         }
00370 #ifdef HAVE_MESOSIM
00371     }
00372 #endif
00373     return false;
00374 }

size_t MSEmitter::getActiveChildIndex (  )  const

Returns the index of the currently active child.

Definition at line 386 of file MSEmitter.cpp.

References myActiveChild, and myFileBasedEmitter.

Referenced by GUIEmitter::GUIManip_TriggeredEmitter::GUIManip_TriggeredEmitter().

00386                                      {
00387     return
00388         myFileBasedEmitter==myActiveChild ? 0 : 1;
00389 }

const std::string& Named::getID (  )  const throw () [inline, inherited]

Returns the id.

Returns:
The stored id

Definition at line 59 of file Named.h.

References Named::myID.

Referenced by RORouteDef_Alternatives::addAlternative(), MSRouteProbe::addRoute(), MSEmitter::MSEmitter_FileTriggeredChild::buildAndScheduleFlowVehicle(), MSCalibrator::MSCalibrator_FileTriggeredChild::buildAndScheduleFlowVehicle(), RORouteDef_Complete::buildCurrentRoute(), ODDistrictHandler::closeDistrict(), NBTrafficLightDefinition::collectLinks(), NBTrafficLightDefinition::compute(), GUIPointOfInterest::drawGL(), MSInductLoop::enterDetectorByMove(), MSVTypeProbe::execute(), MSNet::getBusStopID(), GUITriggeredRerouter::getMicrosimID(), GUIPointOfInterest::getMicrosimID(), GUILaneSpeedTrigger::getMicrosimID(), GUIInductLoop::MyWrapper::getMicrosimID(), GUIEmitter::getMicrosimID(), GUIBusStop::getMicrosimID(), GUI_E2_ZS_Collector::MyWrapper::getMicrosimID(), traci::TraCIServer::handlePoiDomain(), RORDLoader_SUMOBase::myCharacters(), NBOwnTLDef::myCompute(), NBLoadedTLDef::myCompute(), MSTriggeredRerouter::myStartElement(), MSLaneSpeedTrigger::myStartElement(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), MSCalibrator::MSCalibrator_FileTriggeredChild::myStartElement(), NBLoadedTLDef::SignalGroup::patchTYellow(), TraCIServerAPI_Vehicle::processGet(), MSVehicle::replaceRoute(), MSVehicle::saveState(), NBOwnTLDef::setTLControllingInformation(), NBLoadedTLDef::setTLControllingInformation(), RORDLoader_SUMOBase::startRoute(), GUIEmitter::GUIEmitterChild_UserTriggeredChild::wrappedExecute(), NBTrafficLightLogic::writeXML(), MSRouteProbe::writeXMLOutput(), MSInductLoop::writeXMLOutput(), MSE2Collector::writeXMLOutput(), and MSVehicle::~MSVehicle().

00059                                            {
00060         return myID;
00061     }

MSEmitter& MSEmitter::operator= ( const MSEmitter  )  [private]

Invalidated assignment operator.

void MSEmitter::schedule ( MSEmitterChild child,
MSVehicle v,
SUMOReal  speed 
)

Schedules a vehicle to emit.

Definition at line 378 of file MSEmitter.cpp.

References myToEmit, and MSVehicle::onTryEmit().

Referenced by MSEmitter::MSEmitter_FileTriggeredChild::buildAndScheduleFlowVehicle(), MSEmitter::MSEmitter_FileTriggeredChild::myStartElement(), and GUIEmitter::GUIEmitterChild_UserTriggeredChild::wrappedExecute().

00379                                                   {
00380     v->onTryEmit();
00381     myToEmit[child] = std::make_pair(v, speed);
00382 }

void MSEmitter::setActiveChild ( MSEmitterChild child  ) 

Sets the given child as the currently used one.

Definition at line 393 of file MSEmitter.cpp.

References myActiveChild.

00393                                            {
00394     myActiveChild = c;
00395 }


Field Documentation

The currently active child.

Definition at line 287 of file MSEmitter.h.

Referenced by childCheckEmit(), getActiveChildIndex(), MSEmitter(), setActiveChild(), and GUIEmitter::setActiveChild().

the lane the emitter is placed on

Definition at line 275 of file MSEmitter.h.

Referenced by childCheckEmit().

std::string Named::myID [protected, inherited]

MSNet& MSEmitter::myNet [protected]

The network the emitter is located in.

Definition at line 272 of file MSEmitter.h.

Referenced by childCheckEmit(), and GUIEmitter::setUserFlow().

SUMOReal MSEmitter::myPos [protected]

The position of the emitter at the lane.

Definition at line 278 of file MSEmitter.h.

Referenced by childCheckEmit(), and MSEmitter().

std::map<MSEmitterChild*, std::pair<MSVehicle*, SUMOReal> > MSEmitter::myToEmit [protected]

A map children->vehicles to emit.

Definition at line 284 of file MSEmitter.h.

Referenced by childCheckEmit(), schedule(), and ~MSEmitter().


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

Generated on Wed May 5 00:06:47 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6