traci._lanearea

  1# -*- coding: utf-8 -*-
  2# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
  3# Copyright (C) 2011-2026 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    _lanearea.py
 15# @author  Mario Krumnow
 16# @author  Laura Bieker
 17# @date    2011-03-16
 18
 19from __future__ import absolute_import
 20from . import constants as tc
 21from .domain import Domain
 22
 23
 24class LaneAreaDomain(Domain):
 25
 26    def __init__(self, name="lanearea", deprecatedFor=None):
 27        Domain.__init__(self, name, tc.CMD_GET_LANEAREA_VARIABLE, tc.CMD_SET_LANEAREA_VARIABLE,
 28                        tc.CMD_SUBSCRIBE_LANEAREA_VARIABLE, tc.RESPONSE_SUBSCRIBE_LANEAREA_VARIABLE,
 29                        tc.CMD_SUBSCRIBE_LANEAREA_CONTEXT, tc.RESPONSE_SUBSCRIBE_LANEAREA_CONTEXT,
 30                        {}, deprecatedFor,
 31                        subscriptionDefault=(tc.LAST_STEP_VEHICLE_NUMBER,))
 32
 33    def getJamLengthVehicle(self, detID):
 34        """getJamLengthVehicle(string) -> integer
 35
 36        Returns the jam length in vehicles within the last simulation step.
 37        """
 38        return self._getUniversal(tc.JAM_LENGTH_VEHICLE, detID)
 39
 40    def getJamLengthMeters(self, detID):
 41        """getJamLengthMeters(string) -> double
 42
 43        Returns the jam length in meters within the last simulation step.
 44        """
 45        return self._getUniversal(tc.JAM_LENGTH_METERS, detID)
 46
 47    def getLastStepMeanSpeed(self, detID):
 48        """getLastStepMeanSpeed(string) -> double
 49
 50        Returns the current mean speed in m/s of vehicles that were on the named e2.
 51        """
 52        return self._getUniversal(tc.LAST_STEP_MEAN_SPEED, detID)
 53
 54    def getLastStepVehicleIDs(self, detID):
 55        """getLastStepVehicleIDs(string) -> tuple(string)
 56
 57        Returns the tuple of ids of vehicles that were on the named detector in the last simulation step.
 58        """
 59        return self._getUniversal(tc.LAST_STEP_VEHICLE_ID_LIST, detID)
 60
 61    def getLastStepOccupancy(self, detID):
 62        """getLastStepOccupancy(string) -> double
 63
 64        Returns the percentage of space the detector was occupied by a vehicle [%]
 65        """
 66        return self._getUniversal(tc.LAST_STEP_OCCUPANCY, detID)
 67
 68    def getPosition(self, detID):
 69        """getPosition(string) -> double
 70
 71        Returns the starting position of the detector measured from the beginning of the lane in meters.
 72        """
 73        return self._getUniversal(tc.VAR_POSITION, detID)
 74
 75    def getLaneID(self, detID):
 76        """getLaneID(string) -> string
 77
 78        Returns the id of the lane the detector is on.
 79        """
 80        return self._getUniversal(tc.VAR_LANE_ID, detID)
 81
 82    def getLength(self, detID):
 83        """getLength(string) -> double
 84
 85        Returns the length of the detector
 86        """
 87        return self._getUniversal(tc.VAR_LENGTH, detID)
 88
 89    def getLastStepVehicleNumber(self, detID):
 90        """getLastStepVehicleNumber(string) -> integer
 91
 92        Returns the number of vehicles that were on the named detector within the last simulation step.
 93        """
 94        return self._getUniversal(tc.LAST_STEP_VEHICLE_NUMBER, detID)
 95
 96    def getLastStepHaltingNumber(self, detID):
 97        """getLastStepHaltingNumber(string) -> integer
 98
 99        Returns the number of vehicles which were halting during the last time step.
100        """
101        return self._getUniversal(tc.LAST_STEP_VEHICLE_HALTING_NUMBER, detID)
102
103    def getIntervalOccupancy(self, detID):
104        """getIntervalOccupancy(string) -> double
105
106        Returns the mean occupancy during the current interval
107        """
108        return self._getUniversal(tc.VAR_INTERVAL_OCCUPANCY, detID)
109
110    def getIntervalMeanSpeed(self, detID):
111        """getIntervalMeanSpeed(string) -> double
112
113        Returns the mean speed during the current interval
114        """
115        return self._getUniversal(tc.VAR_INTERVAL_SPEED, detID)
116
117    def getIntervalMeanTimeLoss(self, detID):
118        """getIntervalMeanTimeLoss(string) -> double
119
120        Returns the mean timeLoss per vehicle during the current interval
121        """
122        return self._getUniversal(tc.VAR_INTERVAL_TIMELOSS, detID)
123
124    def getIntervalMaxJamLengthInMeters(self, detID):
125        """getIntervalMaxJamLengthInMeters(string) -> double
126
127        Returns the max jam length during the current interval
128        """
129        return self._getUniversal(tc.VAR_INTERVAL_MAX_JAM_LENGTH_METERS, detID)
130
131    def getIntervalVehicleNumber(self, detID):
132        """getIntervalVehicleNumber(string) -> int
133
134        Returns the number of seen vehicles during the current interval
135        """
136        return self._getUniversal(tc.VAR_INTERVAL_NUMBER, detID)
137
138    def getLastIntervalOccupancy(self, detID):
139        """getLastIntervalOccupancy(string) -> double
140
141        Returns the mean occupancy during the previous interval
142        """
143        return self._getUniversal(tc.VAR_LAST_INTERVAL_OCCUPANCY, detID)
144
145    def getLastIntervalMeanSpeed(self, detID):
146        """getLastIntervalMeanSpeed(string) -> double
147
148        Returns the mean speed during the previous interval
149        """
150        return self._getUniversal(tc.VAR_LAST_INTERVAL_SPEED, detID)
151
152    def getLastIntervalMeanTimeLoss(self, detID):
153        """getLastIntervalMeanTimeLoss(string) -> double
154
155        Returns the mean timeLoss per vehicle during the previous interval
156        """
157        return self._getUniversal(tc.VAR_LAST_INTERVAL_TIMELOSS, detID)
158
159    def getLastIntervalMaxJamLengthInMeters(self, detID):
160        """getLastIntervalMaxJamLengthInMeters(string) -> double
161
162        Returns the max jam length during the previous interval
163        """
164        return self._getUniversal(tc.VAR_LAST_INTERVAL_MAX_JAM_LENGTH_METERS, detID)
165
166    def getLastIntervalVehicleNumber(self, detID):
167        """getLastIntervalVehicleNumber(string) -> int
168
169        Returns the number of seen vehicles during the previous interval
170        """
171        return self._getUniversal(tc.VAR_LAST_INTERVAL_NUMBER, detID)
172
173    def overrideVehicleNumber(self, detID, vehNum):
174        """overrideVehicleNumber(string, integer) -> None
175        Persistently overrides the number of vehicles on the detector.
176        Setting a negative value resets the override.
177        """
178        return self._setCmd(tc.VAR_VIRTUAL_DETECTION, detID, "i", vehNum)
class LaneAreaDomain(traci.domain.Domain):
 25class LaneAreaDomain(Domain):
 26
 27    def __init__(self, name="lanearea", deprecatedFor=None):
 28        Domain.__init__(self, name, tc.CMD_GET_LANEAREA_VARIABLE, tc.CMD_SET_LANEAREA_VARIABLE,
 29                        tc.CMD_SUBSCRIBE_LANEAREA_VARIABLE, tc.RESPONSE_SUBSCRIBE_LANEAREA_VARIABLE,
 30                        tc.CMD_SUBSCRIBE_LANEAREA_CONTEXT, tc.RESPONSE_SUBSCRIBE_LANEAREA_CONTEXT,
 31                        {}, deprecatedFor,
 32                        subscriptionDefault=(tc.LAST_STEP_VEHICLE_NUMBER,))
 33
 34    def getJamLengthVehicle(self, detID):
 35        """getJamLengthVehicle(string) -> integer
 36
 37        Returns the jam length in vehicles within the last simulation step.
 38        """
 39        return self._getUniversal(tc.JAM_LENGTH_VEHICLE, detID)
 40
 41    def getJamLengthMeters(self, detID):
 42        """getJamLengthMeters(string) -> double
 43
 44        Returns the jam length in meters within the last simulation step.
 45        """
 46        return self._getUniversal(tc.JAM_LENGTH_METERS, detID)
 47
 48    def getLastStepMeanSpeed(self, detID):
 49        """getLastStepMeanSpeed(string) -> double
 50
 51        Returns the current mean speed in m/s of vehicles that were on the named e2.
 52        """
 53        return self._getUniversal(tc.LAST_STEP_MEAN_SPEED, detID)
 54
 55    def getLastStepVehicleIDs(self, detID):
 56        """getLastStepVehicleIDs(string) -> tuple(string)
 57
 58        Returns the tuple of ids of vehicles that were on the named detector in the last simulation step.
 59        """
 60        return self._getUniversal(tc.LAST_STEP_VEHICLE_ID_LIST, detID)
 61
 62    def getLastStepOccupancy(self, detID):
 63        """getLastStepOccupancy(string) -> double
 64
 65        Returns the percentage of space the detector was occupied by a vehicle [%]
 66        """
 67        return self._getUniversal(tc.LAST_STEP_OCCUPANCY, detID)
 68
 69    def getPosition(self, detID):
 70        """getPosition(string) -> double
 71
 72        Returns the starting position of the detector measured from the beginning of the lane in meters.
 73        """
 74        return self._getUniversal(tc.VAR_POSITION, detID)
 75
 76    def getLaneID(self, detID):
 77        """getLaneID(string) -> string
 78
 79        Returns the id of the lane the detector is on.
 80        """
 81        return self._getUniversal(tc.VAR_LANE_ID, detID)
 82
 83    def getLength(self, detID):
 84        """getLength(string) -> double
 85
 86        Returns the length of the detector
 87        """
 88        return self._getUniversal(tc.VAR_LENGTH, detID)
 89
 90    def getLastStepVehicleNumber(self, detID):
 91        """getLastStepVehicleNumber(string) -> integer
 92
 93        Returns the number of vehicles that were on the named detector within the last simulation step.
 94        """
 95        return self._getUniversal(tc.LAST_STEP_VEHICLE_NUMBER, detID)
 96
 97    def getLastStepHaltingNumber(self, detID):
 98        """getLastStepHaltingNumber(string) -> integer
 99
100        Returns the number of vehicles which were halting during the last time step.
101        """
102        return self._getUniversal(tc.LAST_STEP_VEHICLE_HALTING_NUMBER, detID)
103
104    def getIntervalOccupancy(self, detID):
105        """getIntervalOccupancy(string) -> double
106
107        Returns the mean occupancy during the current interval
108        """
109        return self._getUniversal(tc.VAR_INTERVAL_OCCUPANCY, detID)
110
111    def getIntervalMeanSpeed(self, detID):
112        """getIntervalMeanSpeed(string) -> double
113
114        Returns the mean speed during the current interval
115        """
116        return self._getUniversal(tc.VAR_INTERVAL_SPEED, detID)
117
118    def getIntervalMeanTimeLoss(self, detID):
119        """getIntervalMeanTimeLoss(string) -> double
120
121        Returns the mean timeLoss per vehicle during the current interval
122        """
123        return self._getUniversal(tc.VAR_INTERVAL_TIMELOSS, detID)
124
125    def getIntervalMaxJamLengthInMeters(self, detID):
126        """getIntervalMaxJamLengthInMeters(string) -> double
127
128        Returns the max jam length during the current interval
129        """
130        return self._getUniversal(tc.VAR_INTERVAL_MAX_JAM_LENGTH_METERS, detID)
131
132    def getIntervalVehicleNumber(self, detID):
133        """getIntervalVehicleNumber(string) -> int
134
135        Returns the number of seen vehicles during the current interval
136        """
137        return self._getUniversal(tc.VAR_INTERVAL_NUMBER, detID)
138
139    def getLastIntervalOccupancy(self, detID):
140        """getLastIntervalOccupancy(string) -> double
141
142        Returns the mean occupancy during the previous interval
143        """
144        return self._getUniversal(tc.VAR_LAST_INTERVAL_OCCUPANCY, detID)
145
146    def getLastIntervalMeanSpeed(self, detID):
147        """getLastIntervalMeanSpeed(string) -> double
148
149        Returns the mean speed during the previous interval
150        """
151        return self._getUniversal(tc.VAR_LAST_INTERVAL_SPEED, detID)
152
153    def getLastIntervalMeanTimeLoss(self, detID):
154        """getLastIntervalMeanTimeLoss(string) -> double
155
156        Returns the mean timeLoss per vehicle during the previous interval
157        """
158        return self._getUniversal(tc.VAR_LAST_INTERVAL_TIMELOSS, detID)
159
160    def getLastIntervalMaxJamLengthInMeters(self, detID):
161        """getLastIntervalMaxJamLengthInMeters(string) -> double
162
163        Returns the max jam length during the previous interval
164        """
165        return self._getUniversal(tc.VAR_LAST_INTERVAL_MAX_JAM_LENGTH_METERS, detID)
166
167    def getLastIntervalVehicleNumber(self, detID):
168        """getLastIntervalVehicleNumber(string) -> int
169
170        Returns the number of seen vehicles during the previous interval
171        """
172        return self._getUniversal(tc.VAR_LAST_INTERVAL_NUMBER, detID)
173
174    def overrideVehicleNumber(self, detID, vehNum):
175        """overrideVehicleNumber(string, integer) -> None
176        Persistently overrides the number of vehicles on the detector.
177        Setting a negative value resets the override.
178        """
179        return self._setCmd(tc.VAR_VIRTUAL_DETECTION, detID, "i", vehNum)
LaneAreaDomain(name='lanearea', deprecatedFor=None)
27    def __init__(self, name="lanearea", deprecatedFor=None):
28        Domain.__init__(self, name, tc.CMD_GET_LANEAREA_VARIABLE, tc.CMD_SET_LANEAREA_VARIABLE,
29                        tc.CMD_SUBSCRIBE_LANEAREA_VARIABLE, tc.RESPONSE_SUBSCRIBE_LANEAREA_VARIABLE,
30                        tc.CMD_SUBSCRIBE_LANEAREA_CONTEXT, tc.RESPONSE_SUBSCRIBE_LANEAREA_CONTEXT,
31                        {}, deprecatedFor,
32                        subscriptionDefault=(tc.LAST_STEP_VEHICLE_NUMBER,))
def getJamLengthVehicle(self, detID):
34    def getJamLengthVehicle(self, detID):
35        """getJamLengthVehicle(string) -> integer
36
37        Returns the jam length in vehicles within the last simulation step.
38        """
39        return self._getUniversal(tc.JAM_LENGTH_VEHICLE, detID)

getJamLengthVehicle(string) -> integer

Returns the jam length in vehicles within the last simulation step.

def getJamLengthMeters(self, detID):
41    def getJamLengthMeters(self, detID):
42        """getJamLengthMeters(string) -> double
43
44        Returns the jam length in meters within the last simulation step.
45        """
46        return self._getUniversal(tc.JAM_LENGTH_METERS, detID)

getJamLengthMeters(string) -> double

Returns the jam length in meters within the last simulation step.

def getLastStepMeanSpeed(self, detID):
48    def getLastStepMeanSpeed(self, detID):
49        """getLastStepMeanSpeed(string) -> double
50
51        Returns the current mean speed in m/s of vehicles that were on the named e2.
52        """
53        return self._getUniversal(tc.LAST_STEP_MEAN_SPEED, detID)

getLastStepMeanSpeed(string) -> double

Returns the current mean speed in m/s of vehicles that were on the named e2.

def getLastStepVehicleIDs(self, detID):
55    def getLastStepVehicleIDs(self, detID):
56        """getLastStepVehicleIDs(string) -> tuple(string)
57
58        Returns the tuple of ids of vehicles that were on the named detector in the last simulation step.
59        """
60        return self._getUniversal(tc.LAST_STEP_VEHICLE_ID_LIST, detID)

getLastStepVehicleIDs(string) -> tuple(string)

Returns the tuple of ids of vehicles that were on the named detector in the last simulation step.

def getLastStepOccupancy(self, detID):
62    def getLastStepOccupancy(self, detID):
63        """getLastStepOccupancy(string) -> double
64
65        Returns the percentage of space the detector was occupied by a vehicle [%]
66        """
67        return self._getUniversal(tc.LAST_STEP_OCCUPANCY, detID)

getLastStepOccupancy(string) -> double

Returns the percentage of space the detector was occupied by a vehicle [%]

def getPosition(self, detID):
69    def getPosition(self, detID):
70        """getPosition(string) -> double
71
72        Returns the starting position of the detector measured from the beginning of the lane in meters.
73        """
74        return self._getUniversal(tc.VAR_POSITION, detID)

getPosition(string) -> double

Returns the starting position of the detector measured from the beginning of the lane in meters.

def getLaneID(self, detID):
76    def getLaneID(self, detID):
77        """getLaneID(string) -> string
78
79        Returns the id of the lane the detector is on.
80        """
81        return self._getUniversal(tc.VAR_LANE_ID, detID)

getLaneID(string) -> string

Returns the id of the lane the detector is on.

def getLength(self, detID):
83    def getLength(self, detID):
84        """getLength(string) -> double
85
86        Returns the length of the detector
87        """
88        return self._getUniversal(tc.VAR_LENGTH, detID)

getLength(string) -> double

Returns the length of the detector

def getLastStepVehicleNumber(self, detID):
90    def getLastStepVehicleNumber(self, detID):
91        """getLastStepVehicleNumber(string) -> integer
92
93        Returns the number of vehicles that were on the named detector within the last simulation step.
94        """
95        return self._getUniversal(tc.LAST_STEP_VEHICLE_NUMBER, detID)

getLastStepVehicleNumber(string) -> integer

Returns the number of vehicles that were on the named detector within the last simulation step.

def getLastStepHaltingNumber(self, detID):
 97    def getLastStepHaltingNumber(self, detID):
 98        """getLastStepHaltingNumber(string) -> integer
 99
100        Returns the number of vehicles which were halting during the last time step.
101        """
102        return self._getUniversal(tc.LAST_STEP_VEHICLE_HALTING_NUMBER, detID)

getLastStepHaltingNumber(string) -> integer

Returns the number of vehicles which were halting during the last time step.

def getIntervalOccupancy(self, detID):
104    def getIntervalOccupancy(self, detID):
105        """getIntervalOccupancy(string) -> double
106
107        Returns the mean occupancy during the current interval
108        """
109        return self._getUniversal(tc.VAR_INTERVAL_OCCUPANCY, detID)

getIntervalOccupancy(string) -> double

Returns the mean occupancy during the current interval

def getIntervalMeanSpeed(self, detID):
111    def getIntervalMeanSpeed(self, detID):
112        """getIntervalMeanSpeed(string) -> double
113
114        Returns the mean speed during the current interval
115        """
116        return self._getUniversal(tc.VAR_INTERVAL_SPEED, detID)

getIntervalMeanSpeed(string) -> double

Returns the mean speed during the current interval

def getIntervalMeanTimeLoss(self, detID):
118    def getIntervalMeanTimeLoss(self, detID):
119        """getIntervalMeanTimeLoss(string) -> double
120
121        Returns the mean timeLoss per vehicle during the current interval
122        """
123        return self._getUniversal(tc.VAR_INTERVAL_TIMELOSS, detID)

getIntervalMeanTimeLoss(string) -> double

Returns the mean timeLoss per vehicle during the current interval

def getIntervalMaxJamLengthInMeters(self, detID):
125    def getIntervalMaxJamLengthInMeters(self, detID):
126        """getIntervalMaxJamLengthInMeters(string) -> double
127
128        Returns the max jam length during the current interval
129        """
130        return self._getUniversal(tc.VAR_INTERVAL_MAX_JAM_LENGTH_METERS, detID)

getIntervalMaxJamLengthInMeters(string) -> double

Returns the max jam length during the current interval

def getIntervalVehicleNumber(self, detID):
132    def getIntervalVehicleNumber(self, detID):
133        """getIntervalVehicleNumber(string) -> int
134
135        Returns the number of seen vehicles during the current interval
136        """
137        return self._getUniversal(tc.VAR_INTERVAL_NUMBER, detID)

getIntervalVehicleNumber(string) -> int

Returns the number of seen vehicles during the current interval

def getLastIntervalOccupancy(self, detID):
139    def getLastIntervalOccupancy(self, detID):
140        """getLastIntervalOccupancy(string) -> double
141
142        Returns the mean occupancy during the previous interval
143        """
144        return self._getUniversal(tc.VAR_LAST_INTERVAL_OCCUPANCY, detID)

getLastIntervalOccupancy(string) -> double

Returns the mean occupancy during the previous interval

def getLastIntervalMeanSpeed(self, detID):
146    def getLastIntervalMeanSpeed(self, detID):
147        """getLastIntervalMeanSpeed(string) -> double
148
149        Returns the mean speed during the previous interval
150        """
151        return self._getUniversal(tc.VAR_LAST_INTERVAL_SPEED, detID)

getLastIntervalMeanSpeed(string) -> double

Returns the mean speed during the previous interval

def getLastIntervalMeanTimeLoss(self, detID):
153    def getLastIntervalMeanTimeLoss(self, detID):
154        """getLastIntervalMeanTimeLoss(string) -> double
155
156        Returns the mean timeLoss per vehicle during the previous interval
157        """
158        return self._getUniversal(tc.VAR_LAST_INTERVAL_TIMELOSS, detID)

getLastIntervalMeanTimeLoss(string) -> double

Returns the mean timeLoss per vehicle during the previous interval

def getLastIntervalMaxJamLengthInMeters(self, detID):
160    def getLastIntervalMaxJamLengthInMeters(self, detID):
161        """getLastIntervalMaxJamLengthInMeters(string) -> double
162
163        Returns the max jam length during the previous interval
164        """
165        return self._getUniversal(tc.VAR_LAST_INTERVAL_MAX_JAM_LENGTH_METERS, detID)

getLastIntervalMaxJamLengthInMeters(string) -> double

Returns the max jam length during the previous interval

def getLastIntervalVehicleNumber(self, detID):
167    def getLastIntervalVehicleNumber(self, detID):
168        """getLastIntervalVehicleNumber(string) -> int
169
170        Returns the number of seen vehicles during the previous interval
171        """
172        return self._getUniversal(tc.VAR_LAST_INTERVAL_NUMBER, detID)

getLastIntervalVehicleNumber(string) -> int

Returns the number of seen vehicles during the previous interval

def overrideVehicleNumber(self, detID, vehNum):
174    def overrideVehicleNumber(self, detID, vehNum):
175        """overrideVehicleNumber(string, integer) -> None
176        Persistently overrides the number of vehicles on the detector.
177        Setting a negative value resets the override.
178        """
179        return self._setCmd(tc.VAR_VIRTUAL_DETECTION, detID, "i", vehNum)

overrideVehicleNumber(string, integer) -> None Persistently overrides the number of vehicles on the detector. Setting a negative value resets the override.