Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2013-2024 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 : /****************************************************************************/
14 : /// @file MSDevice_Bluelight.h
15 : /// @author Laura Bieker-Walz
16 : /// @date 01.06.2017
17 : ///
18 : // A device which stands as an implementation example and which outputs movereminder calls
19 : /****************************************************************************/
20 : #pragma once
21 : #include <config.h>
22 :
23 : #include "MSVehicleDevice.h"
24 : #include <utils/common/SUMOTime.h>
25 :
26 :
27 : // ===========================================================================
28 : // class declarations
29 : // ===========================================================================
30 : class SUMOVehicle;
31 : class SUMOTrafficObject;
32 :
33 :
34 : // ===========================================================================
35 : // class definitions
36 : // ===========================================================================
37 : /**
38 : * @class MSDevice_Bluelight
39 : * @brief A device which collects info on the vehicle trip (mainly on departure and arrival)
40 : *
41 : * Each device collects departure time, lane and speed and the same for arrival.
42 : *
43 : * @see MSDevice
44 : */
45 : class MSDevice_Bluelight : public MSVehicleDevice {
46 : public:
47 : /** @brief Inserts MSDevice_Bluelight-options
48 : * @param[filled] oc The options container to add the options to
49 : */
50 : static void insertOptions(OptionsCont& oc);
51 :
52 :
53 : /** @brief Build devices for the given vehicle, if needed
54 : *
55 : * The options are read and evaluated whether a example-device shall be built
56 : * for the given vehicle.
57 : *
58 : * The built device is stored in the given vector.
59 : *
60 : * @param[in] v The vehicle for which a device may be built
61 : * @param[filled] into The vector to store the built device in
62 : */
63 : static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
64 :
65 :
66 :
67 : public:
68 : /// @brief Destructor.
69 : ~MSDevice_Bluelight();
70 :
71 :
72 :
73 : /// @name Methods called on vehicle movement / state change, overwriting MSDevice
74 : /// @{
75 :
76 : /** @brief Checks for waiting steps when the vehicle moves
77 : *
78 : * @param[in] veh Vehicle that asks this reminder.
79 : * @param[in] oldPos Position before move.
80 : * @param[in] newPos Position after move with newSpeed.
81 : * @param[in] newSpeed Moving speed.
82 : *
83 : * @return True (always).
84 : */
85 : bool notifyMove(SUMOTrafficObject& veh, double oldPos,
86 : double newPos, double newSpeed);
87 :
88 :
89 : /** @brief Saves departure info on insertion
90 : *
91 : * @param[in] veh The entering vehicle.
92 : * @param[in] reason how the vehicle enters the lane
93 : * @return Always true
94 : * @see MSMoveReminder::notifyEnter
95 : * @see MSMoveReminder::Notification
96 : */
97 : bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
98 :
99 :
100 : /** @brief Saves arrival info
101 : *
102 : * @param[in] veh The leaving vehicle.
103 : * @param[in] lastPos Position on the lane when leaving.
104 : * @param[in] isArrival whether the vehicle arrived at its destination
105 : * @param[in] isLaneChange whether the vehicle changed from the lane
106 : * @return True if it did not leave the net.
107 : */
108 : bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
109 : MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
110 : /// @}
111 :
112 :
113 : /// @brief return the name for this type of device
114 0 : const std::string deviceName() const {
115 0 : return "bluelight";
116 : }
117 :
118 : /// @brief try to retrieve the given parameter from this device. Throw exception for unsupported key
119 : std::string getParameter(const std::string& key) const;
120 :
121 : /// @brief try to set the given parameter for this device. Throw exception for unsupported key
122 : void setParameter(const std::string& key, const std::string& value);
123 :
124 : /** @brief Called on writing tripinfo output
125 : *
126 : * @param[in] os The stream to write the information into
127 : * @exception IOError not yet implemented
128 : * @see MSDevice::generateOutput
129 : */
130 : void generateOutput(OutputDevice* tripinfoOut) const;
131 :
132 :
133 :
134 : private:
135 : /** @brief Constructor
136 : *
137 : * @param[in] holder The vehicle that holds this device
138 : * @param[in] id The ID of the device
139 : */
140 : MSDevice_Bluelight(SUMOVehicle& holder, const std::string& id, const double reactionDist, const double minGapFactor);
141 :
142 : /// @brief restore type of influenced vehicle
143 : void resetVehicle(MSVehicle* veh2, const std::string& targetTypeID);
144 :
145 :
146 : private:
147 : // @brief collects all vehicleIDs which had to react to the emergency vehicle
148 : std::set<std::string> myInfluencedVehicles;
149 :
150 : // @brief collects all VehicleTypes of the vehicles which had to react to the emergency vehicle
151 : Parameterised::Map myInfluencedTypes;
152 :
153 : /// @brief reaction distance of other vehicle (i.e. due to different noise levels of the siren)
154 : double myReactionDist;
155 :
156 : /// @brief min gap reduction of other vehicles
157 : double myMinGapFactor;
158 :
159 : private:
160 : /// @brief Invalidated copy constructor.
161 : MSDevice_Bluelight(const MSDevice_Bluelight&);
162 :
163 : /// @brief Invalidated assignment operator.
164 : MSDevice_Bluelight& operator=(const MSDevice_Bluelight&);
165 :
166 :
167 : };
|