GUIEmitter::GUIEmitterChild_UserTriggeredChild Class Reference

#include <GUIEmitter.h>

Inheritance diagram for GUIEmitter::GUIEmitterChild_UserTriggeredChild:

MSEmitter::MSEmitterChild

Detailed Description

Definition at line 141 of file GUIEmitter.h.


Public Member Functions

SUMOReal computeOffset (SUMOReal flow) const
 Returns the time offset till the next vehicle emission for a given flow.
const std::vector< const
MSRoute * > & 
getAllRoutes () const
 Returns a list of all available routes.
const MSRoutegetRndRoute () const
 Returns a random route.
MSVehicleTypegetRndVType () const
 Returns a random type.
RandomDistributor< const
MSRoute * > & 
getRouteDist ()
 Returns the routes probability.
SUMOReal getUserFlow () const
 GUIEmitterChild_UserTriggeredChild (MSEmitter_FileTriggeredChild &s, MSEmitter &parent, MSVehicleControl &vc, SUMOReal flow) throw ()
bool hasRoutes () const
 Returns the information whether any route is stored.
bool hasVTypes () const
 Returns the information whether any vehicle type is stored.
SUMOTime wrappedExecute (SUMOTime currentTime) throw (ProcessError)
virtual ~GUIEmitterChild_UserTriggeredChild () throw ()

Protected Attributes

MSEmittermyParent
 The emitter this instance is child of.
RandomDistributor< const
MSRoute * > 
myRouteDist
 The used route probability distribution.
MSEmitter_FileTriggeredChild & mySource
SUMOReal myTimeOffset
 The time offset till next emission.
SUMOReal myUserFlow
MSVehiclemyVehicle
MSVehicleControlmyVehicleControl
 The vehicle control to use for vehicle building.
RandomDistributor
< MSVehicleType * > 
myVTypeDist
 The used vehicle type probability distribution.

Constructor & Destructor Documentation

GUIEmitter::GUIEmitterChild_UserTriggeredChild::GUIEmitterChild_UserTriggeredChild ( MSEmitter_FileTriggeredChild &  s,
MSEmitter parent,
MSVehicleControl vc,
SUMOReal  flow 
) throw ()

GUIEmitter::GUIEmitterChild_UserTriggeredChild::~GUIEmitterChild_UserTriggeredChild (  )  throw () [virtual]

Definition at line 117 of file GUIEmitter.cpp.

00117                                                                                           {
00118 }


Member Function Documentation

SUMOReal MSEmitter::MSEmitterChild::computeOffset ( SUMOReal  flow  )  const [inline, inherited]

Returns the time offset till the next vehicle emission for a given flow.

Definition at line 119 of file MSEmitter.h.

References MSEmitter::MSEmitterChild::myTimeOffset, and SUMOReal.

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

00119                                                     {
00120             SUMOReal freq = (SUMOReal)(1. / (flow / 3600.));
00121             SUMOReal ret = freq;
00122             myTimeOffset += (freq - (SUMOTime) ret);
00123             if (myTimeOffset>1) {
00124                 myTimeOffset -= 1;
00125                 ret += 1;
00126             }
00127             if (ret==0) { // !!! check what to do in this case (more than one vehicle/s)
00128                 ret = 1;
00129             }
00130             return ret;
00131         }

const std::vector<const MSRoute*>& MSEmitter::MSEmitterChild::getAllRoutes (  )  const [inline, inherited]

Returns a list of all available routes.

Definition at line 99 of file MSEmitter.h.

References RandomDistributor< T >::getVals(), and MSEmitter::MSEmitterChild::myRouteDist.

00099                                                               {
00100             return myRouteDist.getVals();
00101         }

const MSRoute* MSEmitter::MSEmitterChild::getRndRoute (  )  const [inline, inherited]

Returns a random route.

Definition at line 94 of file MSEmitter.h.

References RandomDistributor< T >::get(), and MSEmitter::MSEmitterChild::myRouteDist.

Referenced by wrappedExecute().

00094                                            {
00095             return myRouteDist.get();
00096         }

MSVehicleType* MSEmitter::MSEmitterChild::getRndVType (  )  const [inline, inherited]

Returns a random type.

Definition at line 104 of file MSEmitter.h.

References RandomDistributor< T >::get(), and MSEmitter::MSEmitterChild::myVTypeDist.

Referenced by wrappedExecute().

00104                                            {
00105             return myVTypeDist.get();
00106         }

RandomDistributor<const MSRoute*>& MSEmitter::MSEmitterChild::getRouteDist (  )  [inline, inherited]

Returns the routes probability.

Definition at line 134 of file MSEmitter.h.

References MSEmitter::MSEmitterChild::myRouteDist.

Referenced by GUIEmitter::getEdgeProbs().

00134                                                           {
00135             return myRouteDist;
00136         }

SUMOReal GUIEmitter::GUIEmitterChild_UserTriggeredChild::getUserFlow (  )  const

Definition at line 163 of file GUIEmitter.cpp.

References myUserFlow.

00163                                                                 {
00164     return myUserFlow;
00165 }

bool MSEmitter::MSEmitterChild::hasRoutes (  )  const [inline, inherited]

Returns the information whether any route is stored.

Definition at line 109 of file MSEmitter.h.

References RandomDistributor< T >::getOverallProb(), and MSEmitter::MSEmitterChild::myRouteDist.

Referenced by wrappedExecute().

00109                                {
00110             return myRouteDist.getOverallProb()!=0;
00111         }

bool MSEmitter::MSEmitterChild::hasVTypes (  )  const [inline, inherited]

Returns the information whether any vehicle type is stored.

Definition at line 114 of file MSEmitter.h.

References RandomDistributor< T >::getOverallProb(), and MSEmitter::MSEmitterChild::myVTypeDist.

Referenced by wrappedExecute().

00114                                {
00115             return myVTypeDist.getOverallProb()!=0;
00116         }

SUMOTime GUIEmitter::GUIEmitterChild_UserTriggeredChild::wrappedExecute ( SUMOTime  currentTime  )  throw (ProcessError)

Definition at line 122 of file GUIEmitter.cpp.

References MSVehicleControl::buildVehicle(), MSEmitter::childCheckEmit(), MSEmitter::MSEmitterChild::computeOffset(), SUMOVehicleParameter::depart, RandomDistributor< T >::get(), MsgHandler::getErrorInstance(), Named::getID(), MSNet::getInstance(), RandomDistributor< T >::getOverallProb(), MSEmitter::MSEmitterChild::getRndRoute(), MSEmitter::MSEmitterChild::getRndVType(), MSNet::getVehicleControl(), MSVehicleControl::getVType(), MSEmitter::MSEmitterChild::hasRoutes(), MSEmitter::MSEmitterChild::hasVTypes(), SUMOVehicleParameter::id, MsgHandler::inform(), MSTriggeredReader::init(), MSTriggeredReader::isInitialised(), MSEmitter::MSEmitterChild::myParent, MSEmitter::MSEmitterChild::myRouteDist, mySource, myUserFlow, myVehicle, MSEmitter::MSEmitterChild::myVTypeDist, MSEmitter::schedule(), and toString().

00122                                                                                                      {
00123     if (myUserFlow<=0) {
00124         return 0;
00125     }
00126     if (!mySource.isInitialised()) {
00127         mySource.init();
00128     }
00129     if (myVehicle==0) {
00130         SUMOVehicleParameter* p = new SUMOVehicleParameter();
00131         p->id = myParent.getID() + "_user_" +  toString(currentTime);
00132         const MSRoute *aRoute = myRouteDist.getOverallProb()!=0
00133                                 ? myRouteDist.get()
00134                                 : mySource.hasRoutes()
00135                                 ? mySource.getRndRoute()
00136                                 : 0;
00137         if (aRoute==0) {
00138             MsgHandler::getErrorInstance()->inform("Emitter '" + myParent.getID() + "' has no valid route.");
00139             return 0;
00140         }
00141         MSVehicleType *aType = myVTypeDist.getOverallProb()!=0
00142                                ? myVTypeDist.get()
00143                                : mySource.hasVTypes()
00144                                ? mySource.getRndVType()
00145                                : MSNet::getInstance()->getVehicleControl().getVType();
00146         if (aType==0) {
00147             MsgHandler::getErrorInstance()->inform("Emitter '" + myParent.getID() + "' has no valid vehicle type.");
00148             return 0;
00149         }
00150         p->depart = currentTime;
00151         myVehicle = MSNet::getInstance()->getVehicleControl().buildVehicle(p, aRoute, aType);
00152         myParent.schedule(this, myVehicle, -1);
00153     }
00154     if (myParent.childCheckEmit(this)) {
00155         myVehicle = 0;
00156         return (SUMOTime) computeOffset(myUserFlow);
00157     }
00158     return 1;
00159 }


Field Documentation

MSEmitter_FileTriggeredChild& GUIEmitter::GUIEmitterChild_UserTriggeredChild::mySource [protected]

Definition at line 153 of file GUIEmitter.h.

Referenced by wrappedExecute().

SUMOReal MSEmitter::MSEmitterChild::myTimeOffset [mutable, protected, inherited]

The time offset till next emission.

Definition at line 152 of file MSEmitter.h.

Referenced by MSEmitter::MSEmitterChild::computeOffset().

Definition at line 151 of file GUIEmitter.h.

Referenced by getUserFlow(), and wrappedExecute().

Definition at line 152 of file GUIEmitter.h.

Referenced by wrappedExecute().

The vehicle control to use for vehicle building.

Definition at line 143 of file MSEmitter.h.

Referenced by MSEmitter::MSEmitter_FileTriggeredChild::myStartElement().


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

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