1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
10 /// @file    Command_SaveTLCoupledDet.h
11 /// @author  Daniel Krajzewicz
12 /// @author  Michael Behrisch
13 /// @date    15 Feb 2004
14 /// @version $Id$
15 ///
16 // Writes e2 state on each tls switch
17 /****************************************************************************/
18 #ifndef Command_SaveTLCoupledDet_h
19 #define Command_SaveTLCoupledDet_h
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #include <config.h>
26 
27 #include <string>
28 #include <microsim/traffic_lights/MSTLLogicControl.h>
29 
30 
31 // ===========================================================================
32 // class declarations
33 // ===========================================================================
34 class MSNet;
35 class MSTrafficLightLogic;
36 class MSDetectorFileOutput;
37 class OutputDevice;
38 
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
43 /**
44  * @class Command_SaveTLCoupledDet
45  * @brief Writes e2 state on each tls switch
46  *
47  * @todo Problem: The detector may not save the last state (on simulation end)
48  */
49 class Command_SaveTLCoupledDet : public MSTLLogicControl::OnSwitchAction {
50 public:
51     /** @brief Constructor
52      *
53      * @param[in] tlls The logic to observe
54      * @param[in] dtf The detector used to generate the values
55      * @param[in] begin The begin simulation time
56      * @param[in] device The output device to write the detector values into
57      */
58     Command_SaveTLCoupledDet(MSTLLogicControl::TLSLogicVariants& tlls,
59                              MSDetectorFileOutput* dtf, SUMOTime begin, OutputDevice& device);
60 
61 
62     /// @brief Destructor
63     virtual ~Command_SaveTLCoupledDet();
64 
65 
66     /** @brief Executes the command
67      *
68      * Called when an active tls program switches, this method calls
69      *  "writeXMLOutput" of its detector (e2; the values are resetted there).
70      *
71      * @see MSDetectorFileOutput::writeXMLOutput
72      * @see MSE2Collector::writeXMLOutput
73      */
74     virtual void execute();
75 
76 
77 protected:
78     /// @brief The file to write the output to
79     OutputDevice& myDevice;
80 
81     /// @brief The logic to use
82     const MSTLLogicControl::TLSLogicVariants& myLogics;
83 
84     /// @brief The detector to use
85     MSDetectorFileOutput* myDetector;
86 
87     /// @brief The last time the values were written
88     SUMOTime myStartTime;
89 
90 
91 private:
92     /// @brief Invalidated copy constructor.
93     Command_SaveTLCoupledDet(const Command_SaveTLCoupledDet&);
94 
95     /// @brief Invalidated assignment operator.
96     Command_SaveTLCoupledDet& operator=(const Command_SaveTLCoupledDet&);
97 
98 };
99 
100 
101 #endif
102 
103 /****************************************************************************/
104 
105