Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 : // Copyright (C) 2012-2017 German Aerospace Center (DLR) and others.
4 : /****************************************************************************/
5 : //
6 : // This program and the accompanying materials
7 : // are made available under the terms of the Eclipse Public License v2.0
8 : // which accompanies this distribution, and is available at
9 : // http://www.eclipse.org/legal/epl-v20.html
10 : //
11 : /****************************************************************************/
12 : /// @file TraCI_MultiEntryExit.cpp
13 : /// @author Daniel Krajzewicz
14 : /// @author Mario Krumnow
15 : /// @author Jakob Erdmann
16 : /// @author Michael Behrisch
17 : /// @date 30.05.2012
18 : /// @version $Id$
19 : ///
20 : // C++ TraCI client API implementation
21 : /****************************************************************************/
22 :
23 :
24 : // ===========================================================================
25 : // included modules
26 : // ===========================================================================
27 : #ifdef _MSC_VER
28 : #include <windows_config.h>
29 : #else
30 : #include <config.h>
31 : #endif
32 :
33 : #include <microsim/output/MSDetectorControl.h>
34 : #include <microsim/output/MSE2Collector.h>
35 : #include <microsim/MSNet.h>
36 : #include <traci-server/TraCIDefs.h>
37 : #include "TraCI_MultiEntryExit.h"
38 :
39 :
40 : // ===========================================================================
41 : // member definitions
42 : // ===========================================================================
43 : std::vector<std::string>
44 6 : TraCI_MultiEntryExit::getIDList() {
45 6 : std::vector<std::string> ids;
46 6 : MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_ENTRY_EXIT_DETECTOR).insertIDs(ids);
47 6 : return ids;
48 : }
49 :
50 :
51 : int
52 6 : TraCI_MultiEntryExit::getIDCount() {
53 6 : std::vector<std::string> ids;
54 6 : return (int)MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_ENTRY_EXIT_DETECTOR).size();
55 : }
56 :
57 :
58 : int
59 58 : TraCI_MultiEntryExit::getLastStepVehicleNumber(const std::string& detID) {
60 58 : return getDetector(detID)->getVehiclesWithin();
61 : }
62 :
63 :
64 : double
65 45 : TraCI_MultiEntryExit::getLastStepMeanSpeed(const std::string& detID) {
66 45 : return getDetector(detID)->getCurrentMeanSpeed();
67 : }
68 :
69 :
70 : std::vector<std::string>
71 45 : TraCI_MultiEntryExit::getLastStepVehicleIDs(const std::string& detID) {
72 45 : return getDetector(detID)->getCurrentVehicleIDs();
73 : }
74 :
75 :
76 : int
77 3 : TraCI_MultiEntryExit::getLastStepHaltingNumber(const std::string& detID) {
78 3 : return getDetector(detID)->getCurrentHaltingNumber();
79 : }
80 :
81 :
82 : MSE3Collector*
83 151 : TraCI_MultiEntryExit::getDetector(const std::string& id) {
84 151 : MSE3Collector* e3 = dynamic_cast<MSE3Collector*>(MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_ENTRY_EXIT_DETECTOR).get(id));
85 151 : if (e3 == 0) {
86 1 : throw TraCIException("Multi entry exit detector '" + id + "' is not known");
87 : }
88 150 : return e3;
89 43554 : }
90 :
91 :
92 : /****************************************************************************/
|