Eclipse SUMO - Simulation of Urban MObility
MSMoveReminder.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2003-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Something on a lane to be noticed about vehicle movement
19 /****************************************************************************/
20 #ifndef MSMoveReminder_h
21 #define MSMoveReminder_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <iostream>
30 #include <map>
31 #include <utils/common/SUMOTime.h>
32 #include <utils/common/StdDefs.h>
33 #ifdef HAVE_FOX
34 #include <fx.h>
35 #endif
36 
37 
38 // ===========================================================================
39 // class declarations
40 // ===========================================================================
41 class SUMOTrafficObject;
42 class MSLane;
43 
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
67 public:
73  MSMoveReminder(const std::string& description, MSLane* const lane = 0, const bool doAdd = true);
74 
75 
78  virtual ~MSMoveReminder() {}
79 
80 
85  const MSLane* getLane() const {
86  return myLane;
87  }
88 
89 
91  enum Notification {
100  /* All notifications below must result in the vehicle not being on the net
101  * (onLeaveLane sets amOnNet=false if reason>=NOTIFICATION_TELEPORT) */
107  NOTIFICATION_ARRIVED, // arrived and everything after is treated as permanent deletion from the net
114  };
115 
116 
119 
130  virtual bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane) {
131  UNUSED_PARAMETER(reason);
132  UNUSED_PARAMETER(&veh);
133  UNUSED_PARAMETER(&enteredLane);
134  return true;
135  }
136 
137 
151  virtual bool notifyMove(SUMOTrafficObject& veh,
152  double oldPos,
153  double newPos,
154  double newSpeed) {
155  UNUSED_PARAMETER(oldPos);
156  UNUSED_PARAMETER(newPos);
157  UNUSED_PARAMETER(newSpeed);
158  UNUSED_PARAMETER(&veh);
159  return true;
160  }
161 
162 
176  virtual bool notifyLeave(SUMOTrafficObject& veh, double lastPos, Notification reason, const MSLane* enteredLane = 0) {
177  UNUSED_PARAMETER(&veh);
178  UNUSED_PARAMETER(lastPos);
179  UNUSED_PARAMETER(reason);
180  UNUSED_PARAMETER(enteredLane);
181  return true;
182  }
183 
184 
185  // TODO: Documentation
186  void updateDetector(SUMOTrafficObject& veh, double entryPos, double leavePos,
187  SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime,
188  bool cleanUp);
189 
191 
208  virtual void notifyMoveInternal(const SUMOTrafficObject& veh,
209  const double frontOnLane,
210  const double timeOnLane,
211  const double meanSpeedFrontOnLane,
212  const double meanSpeedVehicleOnLane,
213  const double travelledDistanceFrontOnLane,
214  const double travelledDistanceVehicleOnLane,
215  const double meanLengthOnLane) {
216  UNUSED_PARAMETER(meanLengthOnLane);
217  UNUSED_PARAMETER(travelledDistanceFrontOnLane);
218  UNUSED_PARAMETER(travelledDistanceVehicleOnLane);
219  UNUSED_PARAMETER(meanSpeedVehicleOnLane);
220  UNUSED_PARAMETER(meanSpeedFrontOnLane);
221  UNUSED_PARAMETER(frontOnLane);
222  UNUSED_PARAMETER(timeOnLane);
223  UNUSED_PARAMETER(&veh);
224  }
225 
226  void setDescription(const std::string& description) {
227  myDescription = description;
228  }
229 
230  const std::string& getDescription() const {
231  return myDescription;
232  }
233 
234 protected:
236 
237 protected:
238 
240  MSLane* const myLane;
242  std::string myDescription;
243 
244 #ifdef HAVE_FOX
245  FXMutex myNotificationMutex;
247 #endif
248 
249 private:
250  std::map<SUMOTrafficObject*, std::pair<SUMOTime, double> > myLastVehicleUpdateValues;
251 
252 
253 private:
254  MSMoveReminder& operator=(const MSMoveReminder&); // just to avoid a compiler warning
255 
256 };
257 
258 
259 #endif
260 
261 /****************************************************************************/
262 
MSMoveReminder::NOTIFICATION_LANE_CHANGE
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
Definition: MSMoveReminder.h:99
UNUSED_PARAMETER
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:31
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
MSMoveReminder::getDescription
const std::string & getDescription() const
Definition: MSMoveReminder.h:230
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSMoveReminder::notifyMove
virtual bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
Definition: MSMoveReminder.h:151
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSMoveReminder::NOTIFICATION_TELEPORT_ARRIVED
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
Definition: MSMoveReminder.h:111
MSMoveReminder
Something on a lane to be noticed about vehicle movement.
Definition: MSMoveReminder.h:66
MSMoveReminder::NOTIFICATION_VAPORIZED
@ NOTIFICATION_VAPORIZED
The vehicle got vaporized.
Definition: MSMoveReminder.h:109
MSMoveReminder::NOTIFICATION_PARKING_REROUTE
@ NOTIFICATION_PARKING_REROUTE
The vehicle needs another parking area.
Definition: MSMoveReminder.h:113
MSMoveReminder::notifyLeave
virtual bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Called if the vehicle leaves the reminder's lane.
Definition: MSMoveReminder.h:176
MSMoveReminder::updateDetector
void updateDetector(SUMOTrafficObject &veh, double entryPos, double leavePos, SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime, bool cleanUp)
Definition: MSMoveReminder.cpp:47
MSMoveReminder::operator=
MSMoveReminder & operator=(const MSMoveReminder &)
MSMoveReminder::removeFromVehicleUpdateValues
void removeFromVehicleUpdateValues(SUMOTrafficObject &veh)
Definition: MSMoveReminder.cpp:89
MSMoveReminder::MSMoveReminder
MSMoveReminder(const std::string &description, MSLane *const lane=0, const bool doAdd=true)
Constructor.
Definition: MSMoveReminder.cpp:32
MSMoveReminder::~MSMoveReminder
virtual ~MSMoveReminder()
Destructor.
Definition: MSMoveReminder.h:78
MSMoveReminder::myLastVehicleUpdateValues
std::map< SUMOTrafficObject *, std::pair< SUMOTime, double > > myLastVehicleUpdateValues
Definition: MSMoveReminder.h:250
MSMoveReminder::NOTIFICATION_DEPARTED
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSMoveReminder.h:93
MSMoveReminder::NOTIFICATION_SEGMENT
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
Definition: MSMoveReminder.h:97
MSMoveReminder::getLane
const MSLane * getLane() const
Returns the lane the reminder works on.
Definition: MSMoveReminder.h:85
MSMoveReminder::myDescription
std::string myDescription
a description of this moveReminder
Definition: MSMoveReminder.h:242
MSMoveReminder::NOTIFICATION_PARKING
@ NOTIFICATION_PARKING
The vehicle starts or ends parking.
Definition: MSMoveReminder.h:105
MSMoveReminder::NOTIFICATION_ARRIVED
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
Definition: MSMoveReminder.h:107
MSMoveReminder::setDescription
void setDescription(const std::string &description)
Definition: MSMoveReminder.h:226
MSMoveReminder::notifyEnter
virtual bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering the lane.
Definition: MSMoveReminder.h:130
config.h
StdDefs.h
MSMoveReminder::notifyMoveInternal
virtual void notifyMoveInternal(const SUMOTrafficObject &veh, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double meanLengthOnLane)
Internal notification about the vehicle moves.
Definition: MSMoveReminder.h:208
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
MSMoveReminder::NOTIFICATION_JUNCTION
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
Definition: MSMoveReminder.h:95
MSMoveReminder::NOTIFICATION_TELEPORT
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
Definition: MSMoveReminder.h:103
MSMoveReminder::myLane
MSLane *const myLane
Lane on which the reminder works.
Definition: MSMoveReminder.h:240