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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
22 // Something on a lane to be noticed about vehicle movement
23 /****************************************************************************/
24 #pragma once
25 #include <config.h>
26 
27 #include <iostream>
28 #include <map>
29 #include <utils/common/SUMOTime.h>
30 #include <utils/common/StdDefs.h>
31 #ifdef HAVE_FOX
32 #include <fx.h>
33 #endif
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
39 class SUMOTrafficObject;
40 class MSLane;
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
65 public:
71  MSMoveReminder(const std::string& description, MSLane* const lane = 0, const bool doAdd = true);
72 
73 
76  virtual ~MSMoveReminder() {}
77 
78 
83  const MSLane* getLane() const {
84  return myLane;
85  }
86 
87 
89  enum Notification {
98  /* All notifications below must result in the vehicle not being on the net
99  * (onLeaveLane sets amOnNet=false if reason>=NOTIFICATION_TELEPORT) */
107  NOTIFICATION_ARRIVED, // arrived and everything after is treated as permanent deletion from the net
120  };
121 
122 
125 
136  virtual bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane) {
137  UNUSED_PARAMETER(reason);
138  UNUSED_PARAMETER(&veh);
139  UNUSED_PARAMETER(&enteredLane);
140  return true;
141  }
142 
143 
157  virtual bool notifyMove(SUMOTrafficObject& veh,
158  double oldPos,
159  double newPos,
160  double newSpeed) {
161  UNUSED_PARAMETER(oldPos);
162  UNUSED_PARAMETER(newPos);
163  UNUSED_PARAMETER(newSpeed);
164  UNUSED_PARAMETER(&veh);
165  return true;
166  }
167 
177  virtual bool notifyIdle(SUMOTrafficObject& veh) {
178  UNUSED_PARAMETER(&veh);
179  return true;
180  }
181 
195  virtual bool notifyLeave(SUMOTrafficObject& veh, double lastPos, Notification reason, const MSLane* enteredLane = 0) {
196  UNUSED_PARAMETER(&veh);
197  UNUSED_PARAMETER(lastPos);
198  UNUSED_PARAMETER(reason);
199  UNUSED_PARAMETER(enteredLane);
200  return true;
201  }
202 
203 
204  // TODO: Documentation
205  void updateDetector(SUMOTrafficObject& veh, double entryPos, double leavePos,
206  SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime,
207  bool cleanUp);
208 
210 
227  virtual void notifyMoveInternal(const SUMOTrafficObject& veh,
228  const double frontOnLane,
229  const double timeOnLane,
230  const double meanSpeedFrontOnLane,
231  const double meanSpeedVehicleOnLane,
232  const double travelledDistanceFrontOnLane,
233  const double travelledDistanceVehicleOnLane,
234  const double meanLengthOnLane) {
235  UNUSED_PARAMETER(meanLengthOnLane);
236  UNUSED_PARAMETER(travelledDistanceFrontOnLane);
237  UNUSED_PARAMETER(travelledDistanceVehicleOnLane);
238  UNUSED_PARAMETER(meanSpeedVehicleOnLane);
239  UNUSED_PARAMETER(meanSpeedFrontOnLane);
240  UNUSED_PARAMETER(frontOnLane);
241  UNUSED_PARAMETER(timeOnLane);
242  UNUSED_PARAMETER(&veh);
243  }
244 
245  void setDescription(const std::string& description) {
246  myDescription = description;
247  }
248 
249  const std::string& getDescription() const {
250  return myDescription;
251  }
252 
253 protected:
255 
256 protected:
257 
259  MSLane* const myLane;
261  std::string myDescription;
262 
263 #ifdef HAVE_FOX
265  mutable FXMutex myNotificationMutex;
266 #endif
267 
268 private:
269  std::map<SUMOTrafficObject*, std::pair<SUMOTime, double> > myLastVehicleUpdateValues;
270 
271 
272 private:
273  MSMoveReminder& operator=(const MSMoveReminder&); // just to avoid a compiler warning
274 
275 };
long long int SUMOTime
Definition: SUMOTime.h:31
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
Something on a lane to be noticed about vehicle movement.
virtual bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the reminder still has to be notified about the vehicle moves.
MSLane *const myLane
Lane on which the reminder works.
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.
virtual bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Called if the vehicle leaves the reminder's lane.
const MSLane * getLane() const
Returns the lane the reminder works on.
void setDescription(const std::string &description)
std::map< SUMOTrafficObject *, std::pair< SUMOTime, double > > myLastVehicleUpdateValues
virtual bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering the lane.
MSMoveReminder & operator=(const MSMoveReminder &)
Notification
Definition of a vehicle state.
@ NOTIFICATION_VAPORIZED_TRACI
The vehicle got removed via TraCI.
@ NOTIFICATION_ARRIVED
The vehicle arrived at its destination (is deleted)
@ NOTIFICATION_TELEPORT_ARRIVED
The vehicle was teleported out of the net.
@ NOTIFICATION_PARKING_REROUTE
The vehicle needs another parking area.
@ NOTIFICATION_VAPORIZED_CALIBRATOR
The vehicle got removed by a calibrator.
@ NOTIFICATION_VAPORIZED_GUI
The vehicle got removed via the GUI.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_VAPORIZED_VAPORIZER
The vehicle got vaporized with a vaporizer.
@ NOTIFICATION_JUNCTION
The vehicle arrived at a junction.
@ NOTIFICATION_PARKING
The vehicle starts or ends parking.
@ NOTIFICATION_VAPORIZED_COLLISION
The vehicle got removed by a collision.
@ NOTIFICATION_TELEPORT
The vehicle is being teleported.
virtual ~MSMoveReminder()
Destructor.
MSMoveReminder(const std::string &description, MSLane *const lane=0, const bool doAdd=true)
Constructor.
std::string myDescription
a description of this moveReminder
const std::string & getDescription() const
void removeFromVehicleUpdateValues(SUMOTrafficObject &veh)
virtual bool notifyIdle(SUMOTrafficObject &veh)
Computes idling emission values and adds them to the emission sums.
void updateDetector(SUMOTrafficObject &veh, double entryPos, double leavePos, SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime, bool cleanUp)
Representation of a vehicle, person, or container.