MSLane.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MSLane_h
00020 #define MSLane_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include "MSEdge.h"
00033 #include "MSVehicle.h"
00034 #include "MSEdgeControl.h"
00035 #include <bitset>
00036 #include <deque>
00037 #include <vector>
00038 #include <utility>
00039 #include <map>
00040 #include <string>
00041 #include <iostream>
00042 #include "MSNet.h"
00043 #include <utils/geom/Position2DVector.h>
00044 #include <utils/common/SUMOTime.h>
00045 #include <utils/common/SUMOVehicleClass.h>
00046
00047
00048
00049
00050
00051 class MSLaneChanger;
00052 class MSLink;
00053 class MSMoveReminder;
00054 class GUILaneWrapper;
00055 class GUIGlObjectStorage;
00056 class MSVehicleTransfer;
00057 class OutputDevice;
00058
00059
00060
00061
00062
00070 class MSLane {
00071 public:
00073 friend class MSLaneChanger;
00074
00075 friend class GUILaneWrapper;
00076
00077 friend class MSXMLRawOut;
00078
00081 struct VehPosition : public std::binary_function< const MSVehicle*,
00082 SUMOReal, bool > {
00084 bool operator()(const MSVehicle* cmp, SUMOReal pos) const {
00085 return cmp->getPositionOnLane() >= pos;
00086 }
00087 };
00088
00089
00090 public:
00102 MSLane(const std::string &id, SUMOReal maxSpeed, SUMOReal length, MSEdge * const edge,
00103 unsigned int numericalID, const Position2DVector &shape,
00104 const std::vector<SUMOVehicleClass> &allowed,
00105 const std::vector<SUMOVehicleClass> &disallowed) throw();
00106
00107
00109 virtual ~MSLane() throw();
00110
00111
00112
00115
00124 void initialize(MSLinkCont* succs);
00126
00127
00128
00131
00133 typedef std::vector< MSMoveReminder* > MoveReminderCont;
00134
00135
00142 virtual void addMoveReminder(MSMoveReminder* rem) throw();
00143
00144
00148 inline const MoveReminderCont &getMoveReminders() const throw() {
00149 return myMoveReminders;
00150 }
00152
00153
00154
00157
00175 bool emit(MSVehicle& v) throw(ProcessError);
00176
00177
00196 virtual bool isEmissionSuccess(MSVehicle* vehicle, SUMOReal speed, SUMOReal pos,
00197 bool recheckNextLanes) throw(ProcessError);
00198
00199
00206 bool freeEmit(MSVehicle& veh, SUMOReal speed) throw();
00208
00209
00210
00213
00225 SUMOReal setPartialOccupation(MSVehicle *v, SUMOReal leftVehicleLength) throw();
00226
00227
00231 void resetPartialOccupation(MSVehicle *v) throw();
00232
00233
00237 MSVehicle *getPartialOccupator() const throw() {
00238 return myInlappingVehicle;
00239 }
00240
00241
00245 SUMOReal getPartialOccupatorEnd() const throw() {
00246 return myInlappingVehicleEnd;
00247 }
00248
00249
00258 std::pair<MSVehicle*, SUMOReal> getLastVehicleInformation() const throw();
00260
00261
00262
00265
00269 unsigned int getVehicleNumber() const throw() {
00270 return (unsigned int) myVehicles.size();
00271 }
00272
00273
00280 virtual const std::deque< MSVehicle* > &getVehiclesSecure() const throw() {
00281 return myVehicles;
00282 }
00283
00284
00287 virtual void releaseVehicles() const throw() { }
00289
00290
00291
00294
00298 const std::string &getID() const throw() {
00299 return myID;
00300 }
00301
00302
00306 size_t getNumericalID() const throw() {
00307 return myNumericalID;
00308 }
00309
00310
00314 const Position2DVector &getShape() const throw() {
00315 return myShape;
00316 }
00317
00318
00322 SUMOReal getMaxSpeed() const throw() {
00323 return myMaxSpeed;
00324 }
00325
00326
00330 SUMOReal getLength() const throw() {
00331 return myLength;
00332 }
00333
00334
00338 const std::vector<SUMOVehicleClass> &getAllowedClasses() const throw() {
00339 return myAllowedClasses;
00340 }
00341
00342
00346 const std::vector<SUMOVehicleClass> &getNotAllowedClasses() const throw() {
00347 return myNotAllowedClasses;
00348 }
00350
00351
00352
00355
00356 virtual bool moveCritical(SUMOTime t);
00357
00360 virtual bool setCritical(SUMOTime t, std::vector<MSLane*> &into);
00361
00363 virtual bool integrateNewVehicle(SUMOTime t);
00365
00366
00367
00369 virtual void detectCollisions(SUMOTime timestep);
00370
00371
00374 virtual bool appropriate(const MSVehicle *veh);
00375
00376
00378 const MSLinkCont &getLinkCont() const;
00379
00380
00382 bool empty() const {
00383 assert(myVehBuffer.size()==0);
00384 return myVehicles.empty();
00385 }
00386
00387 void setMaxSpeed(SUMOReal val) throw() {
00388 myMaxSpeed = val;
00389 }
00390
00391 void setLength(SUMOReal val) throw() {
00392 myLength = val;
00393 }
00394
00395
00399 MSEdge &getEdge() const throw() {
00400 return *myEdge;
00401 }
00402
00406 static bool dictionary(std::string id, MSLane* lane);
00407
00410 static MSLane* dictionary(std::string id);
00411
00413 static void clear();
00414
00415 static size_t dictSize() {
00416 return myDict.size();
00417 }
00418
00419 static void insertIDs(std::vector<std::string> &into) throw();
00420
00422 typedef std::deque< MSVehicle* > VehCont;
00423
00428 virtual MSLinkCont::const_iterator succLinkSec(const SUMOVehicle& veh,
00429 unsigned int nRouteSuccs,
00430 const MSLane& succLinkSource,
00431 const std::vector<MSLane*> &conts) const;
00432
00433
00436 bool isLinkEnd(MSLinkCont::const_iterator &i) const;
00437
00440 bool isLinkEnd(MSLinkCont::iterator &i);
00441
00443 virtual MSVehicle * const getLastVehicle() const;
00444 virtual const MSVehicle * const getFirstVehicle() const;
00445
00446 void init(MSEdgeControl &, std::vector<MSLane*>::const_iterator firstNeigh, std::vector<MSLane*>::const_iterator lastNeigh);
00447
00448
00449
00450
00451 virtual GUILaneWrapper *buildLaneWrapper(GUIGlObjectStorage &idStorage);
00452
00453 virtual MSVehicle *removeFirstVehicle();
00454 virtual MSVehicle *removeVehicle(MSVehicle *remVehicle);
00455
00457 Position2DVector myShape;
00458
00459
00460
00461 void leftByLaneChange(MSVehicle *v);
00462 void enteredByLaneChange(MSVehicle *v);
00463
00464
00465 MSLane * const getLeftLane() const;
00466 MSLane * const getRightLane() const;
00467
00468 void setAllowedClasses(const std::vector<SUMOVehicleClass> &classes) throw() {
00469 myAllowedClasses = classes;
00470 }
00471
00472
00473 void setNotAllowedClasses(const std::vector<SUMOVehicleClass> &classes) throw() {
00474 myNotAllowedClasses = classes;
00475 }
00476
00477
00478 bool allowsVehicleClass(SUMOVehicleClass vclass) const;
00479
00480 void addIncomingLane(MSLane *lane, MSLink *viaLink);
00481
00482 struct IncomingLaneInfo {
00483 MSLane *lane;
00484 SUMOReal length;
00485 MSLink *viaLink;
00486 };
00487
00488 const std::vector<IncomingLaneInfo> &getIncomingLanes() const {
00489 return myIncomingLanes;
00490 }
00491
00492 std::pair<MSVehicle * const, SUMOReal> getFollowerOnConsecutive(SUMOReal dist, SUMOReal seen,
00493 SUMOReal leaderSpeed, SUMOReal backOffset) const;
00494
00495 std::pair<MSVehicle * const, SUMOReal> getLeaderOnConsecutive(SUMOReal dist, SUMOReal seen,
00496 SUMOReal leaderSpeed, const MSVehicle &veh, const std::vector<MSLane*> &bestLaneConts) const;
00497
00498
00500
00501
00505 SUMOReal getMeanSpeed() const throw();
00506
00507
00511 SUMOReal getOccupancy() const throw();
00512
00513
00517 SUMOReal getVehLenSum() const throw();
00518
00519
00523 SUMOReal getHBEFA_CO2Emissions() const throw();
00524
00525
00529 SUMOReal getHBEFA_COEmissions() const throw();
00530
00531
00535 SUMOReal getHBEFA_PMxEmissions() const throw();
00536
00537
00541 SUMOReal getHBEFA_NOxEmissions() const throw();
00542
00543
00547 SUMOReal getHBEFA_HCEmissions() const throw();
00548
00549
00553 SUMOReal getHBEFA_FuelConsumption() const throw();
00554
00555
00559 SUMOReal getHarmonoise_NoiseEmissions() const throw();
00561
00562
00563 protected:
00567 virtual bool push(MSVehicle* veh);
00568
00570 virtual MSVehicle* pop(SUMOTime t);
00571
00573 virtual void swapAfterLaneChange(SUMOTime t);
00574
00575
00576
00577 protected:
00579 std::string myID;
00580
00582 size_t myNumericalID;
00583
00591 VehCont myVehicles;
00592
00594 SUMOReal myLength;
00595
00597 MSEdge* myEdge;
00598
00600 SUMOReal myMaxSpeed;
00601
00604 VehCont myTmpVehicles;
00605
00606
00607 SUMOReal myBackDistance;
00608
00613 std::vector<MSVehicle*> myVehBuffer;
00614
00616 std::vector<SUMOVehicleClass> myAllowedClasses;
00617
00619 std::vector<SUMOVehicleClass> myNotAllowedClasses;
00620
00621 std::vector<IncomingLaneInfo> myIncomingLanes;
00622
00624 SUMOReal myVehicleLengthSum;
00625
00627 SUMOReal myInlappingVehicleEnd;
00628
00630 MSVehicle *myInlappingVehicle;
00631
00632
00634 std::vector<MSLane*>::const_iterator myFirstNeigh;
00635
00637 std::vector<MSLane*>::const_iterator myLastNeigh;
00638
00640 SUMOReal myLeftVehLength;
00641
00644 MSLinkCont myLinks;
00645
00647 typedef std::map< std::string, MSLane* > DictType;
00648
00650 static DictType myDict;
00651
00652 private:
00654 MoveReminderCont myMoveReminders;
00655
00656
00661 class vehicle_position_sorter {
00662 public:
00664 explicit vehicle_position_sorter() { }
00665
00666
00672 int operator()(MSVehicle *v1, MSVehicle *v2) const {
00673 return v1->getPositionOnLane()>v2->getPositionOnLane();
00674 }
00675
00676 };
00677
00678
00679 private:
00681 MSLane(const MSLane&);
00682
00684 MSLane& operator=(const MSLane&);
00685
00686
00687 };
00688
00689
00690 #endif
00691
00692
00693