traci._calibrator

  1# -*- coding: utf-8 -*-
  2# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
  3# Copyright (C) 2008-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    _calibrator.py
 15# @author  Jakob Erdmann
 16# @date    2020-03-16
 17
 18from __future__ import absolute_import
 19from . import constants as tc
 20from .domain import Domain
 21
 22
 23class CalibratorDomain(Domain):
 24
 25    def __init__(self):
 26        Domain.__init__(self, "calibrator", tc.CMD_GET_CALIBRATOR_VARIABLE, tc.CMD_SET_CALIBRATOR_VARIABLE,
 27                        tc.CMD_SUBSCRIBE_CALIBRATOR_VARIABLE, tc.RESPONSE_SUBSCRIBE_CALIBRATOR_VARIABLE,
 28                        tc.CMD_SUBSCRIBE_CALIBRATOR_CONTEXT, tc.RESPONSE_SUBSCRIBE_CALIBRATOR_CONTEXT)
 29
 30    def getEdgeID(self, calibratorID):
 31        """getEdgeID(string) -> string
 32        Returns the edge of this calibrator
 33        """
 34        return self._getUniversal(tc.VAR_ROAD_ID, calibratorID)
 35
 36    def getLaneID(self, calibratorID):
 37        """getLaneID(string) -> string
 38        Returns the lane of this calibrator (if it applies to a single lane)
 39        """
 40        return self._getUniversal(tc.VAR_LANE_ID, calibratorID)
 41
 42    def getVehsPerHour(self, calibratorID):
 43        """getVehsPerHour(string) -> double
 44        Returns the number of vehicles per hour in the current calibration interval
 45        """
 46        return self._getUniversal(tc.VAR_VEHSPERHOUR, calibratorID)
 47
 48    def getSpeed(self, calibratorID):
 49        """getSpeed(string) -> double
 50        Returns the target speed of the current calibration interval
 51        """
 52        return self._getUniversal(tc.VAR_SPEED, calibratorID)
 53
 54    def getTypeID(self, calibratorID):
 55        """getTypeID(string) -> string
 56        Returns the type id for the current calibration interval
 57        """
 58        return self._getUniversal(tc.VAR_TYPE, calibratorID)
 59
 60    def getBegin(self, calibratorID):
 61        """getBegin(string) -> double
 62        Returns the begin time of the current calibration interval
 63        """
 64        return self._getUniversal(tc.VAR_BEGIN, calibratorID)
 65
 66    def getEnd(self, calibratorID):
 67        """getEnd(string) -> double
 68        Returns the end time of the current calibration interval
 69        """
 70        return self._getUniversal(tc.VAR_END, calibratorID)
 71
 72    def getRouteID(self, calibratorID):
 73        """getRouteID(string) -> string
 74        Returns the route id for the current calibration interval
 75        """
 76        return self._getUniversal(tc.VAR_ROUTE_ID, calibratorID)
 77
 78    def getRouteProbeID(self, calibratorID):
 79        """getRouteProbeID(string) -> string
 80        Returns the routeProbe id for this calibrator
 81        """
 82        return self._getUniversal(tc.VAR_ROUTE_PROBE, calibratorID)
 83
 84    def getVTypes(self, calibratorID):
 85        """getVTypes(string) -> tuple(string)
 86
 87        Returns a tuple of all types to which the calibrator applies (in a type filter is active)
 88        """
 89        return self._getUniversal(tc.VAR_VTYPES, calibratorID)
 90
 91    def getPassed(self, calibratorID):
 92        """getPassed(string) -> double
 93        Returns the number of passed vehicles in the current calibration interval
 94        """
 95        return self._getUniversal(tc.VAR_PASSED, calibratorID)
 96
 97    def getInserted(self, calibratorID):
 98        """getInserted(string) -> double
 99        Returns the number of inserted vehicles in the current calibration interval
100        """
101        return self._getUniversal(tc.VAR_INSERTED, calibratorID)
102
103    def getRemoved(self, calibratorID):
104        """getRemoved(string) -> double
105        Returns the number of removed vehicles in the current calibration interval
106        """
107        return self._getUniversal(tc.VAR_REMOVED, calibratorID)
108
109    def setFlow(self, calibratorID, begin, end, vehsPerHour, speed, typeID,
110                routeID, departLane="first", departSpeed="max"):
111        """setFlow(string, double, double, double, double, string, string, string, string) -> None
112        Update or add a calibrator interval
113        """
114        self._setCmd(tc.CMD_SET_FLOW, calibratorID, "tddddssss", 8, begin, end,
115                     vehsPerHour, speed, typeID, routeID, departLane, departSpeed)
class CalibratorDomain(traci.domain.Domain):
 24class CalibratorDomain(Domain):
 25
 26    def __init__(self):
 27        Domain.__init__(self, "calibrator", tc.CMD_GET_CALIBRATOR_VARIABLE, tc.CMD_SET_CALIBRATOR_VARIABLE,
 28                        tc.CMD_SUBSCRIBE_CALIBRATOR_VARIABLE, tc.RESPONSE_SUBSCRIBE_CALIBRATOR_VARIABLE,
 29                        tc.CMD_SUBSCRIBE_CALIBRATOR_CONTEXT, tc.RESPONSE_SUBSCRIBE_CALIBRATOR_CONTEXT)
 30
 31    def getEdgeID(self, calibratorID):
 32        """getEdgeID(string) -> string
 33        Returns the edge of this calibrator
 34        """
 35        return self._getUniversal(tc.VAR_ROAD_ID, calibratorID)
 36
 37    def getLaneID(self, calibratorID):
 38        """getLaneID(string) -> string
 39        Returns the lane of this calibrator (if it applies to a single lane)
 40        """
 41        return self._getUniversal(tc.VAR_LANE_ID, calibratorID)
 42
 43    def getVehsPerHour(self, calibratorID):
 44        """getVehsPerHour(string) -> double
 45        Returns the number of vehicles per hour in the current calibration interval
 46        """
 47        return self._getUniversal(tc.VAR_VEHSPERHOUR, calibratorID)
 48
 49    def getSpeed(self, calibratorID):
 50        """getSpeed(string) -> double
 51        Returns the target speed of the current calibration interval
 52        """
 53        return self._getUniversal(tc.VAR_SPEED, calibratorID)
 54
 55    def getTypeID(self, calibratorID):
 56        """getTypeID(string) -> string
 57        Returns the type id for the current calibration interval
 58        """
 59        return self._getUniversal(tc.VAR_TYPE, calibratorID)
 60
 61    def getBegin(self, calibratorID):
 62        """getBegin(string) -> double
 63        Returns the begin time of the current calibration interval
 64        """
 65        return self._getUniversal(tc.VAR_BEGIN, calibratorID)
 66
 67    def getEnd(self, calibratorID):
 68        """getEnd(string) -> double
 69        Returns the end time of the current calibration interval
 70        """
 71        return self._getUniversal(tc.VAR_END, calibratorID)
 72
 73    def getRouteID(self, calibratorID):
 74        """getRouteID(string) -> string
 75        Returns the route id for the current calibration interval
 76        """
 77        return self._getUniversal(tc.VAR_ROUTE_ID, calibratorID)
 78
 79    def getRouteProbeID(self, calibratorID):
 80        """getRouteProbeID(string) -> string
 81        Returns the routeProbe id for this calibrator
 82        """
 83        return self._getUniversal(tc.VAR_ROUTE_PROBE, calibratorID)
 84
 85    def getVTypes(self, calibratorID):
 86        """getVTypes(string) -> tuple(string)
 87
 88        Returns a tuple of all types to which the calibrator applies (in a type filter is active)
 89        """
 90        return self._getUniversal(tc.VAR_VTYPES, calibratorID)
 91
 92    def getPassed(self, calibratorID):
 93        """getPassed(string) -> double
 94        Returns the number of passed vehicles in the current calibration interval
 95        """
 96        return self._getUniversal(tc.VAR_PASSED, calibratorID)
 97
 98    def getInserted(self, calibratorID):
 99        """getInserted(string) -> double
100        Returns the number of inserted vehicles in the current calibration interval
101        """
102        return self._getUniversal(tc.VAR_INSERTED, calibratorID)
103
104    def getRemoved(self, calibratorID):
105        """getRemoved(string) -> double
106        Returns the number of removed vehicles in the current calibration interval
107        """
108        return self._getUniversal(tc.VAR_REMOVED, calibratorID)
109
110    def setFlow(self, calibratorID, begin, end, vehsPerHour, speed, typeID,
111                routeID, departLane="first", departSpeed="max"):
112        """setFlow(string, double, double, double, double, string, string, string, string) -> None
113        Update or add a calibrator interval
114        """
115        self._setCmd(tc.CMD_SET_FLOW, calibratorID, "tddddssss", 8, begin, end,
116                     vehsPerHour, speed, typeID, routeID, departLane, departSpeed)
def getEdgeID(self, calibratorID):
31    def getEdgeID(self, calibratorID):
32        """getEdgeID(string) -> string
33        Returns the edge of this calibrator
34        """
35        return self._getUniversal(tc.VAR_ROAD_ID, calibratorID)

getEdgeID(string) -> string Returns the edge of this calibrator

def getLaneID(self, calibratorID):
37    def getLaneID(self, calibratorID):
38        """getLaneID(string) -> string
39        Returns the lane of this calibrator (if it applies to a single lane)
40        """
41        return self._getUniversal(tc.VAR_LANE_ID, calibratorID)

getLaneID(string) -> string Returns the lane of this calibrator (if it applies to a single lane)

def getVehsPerHour(self, calibratorID):
43    def getVehsPerHour(self, calibratorID):
44        """getVehsPerHour(string) -> double
45        Returns the number of vehicles per hour in the current calibration interval
46        """
47        return self._getUniversal(tc.VAR_VEHSPERHOUR, calibratorID)

getVehsPerHour(string) -> double Returns the number of vehicles per hour in the current calibration interval

def getSpeed(self, calibratorID):
49    def getSpeed(self, calibratorID):
50        """getSpeed(string) -> double
51        Returns the target speed of the current calibration interval
52        """
53        return self._getUniversal(tc.VAR_SPEED, calibratorID)

getSpeed(string) -> double Returns the target speed of the current calibration interval

def getTypeID(self, calibratorID):
55    def getTypeID(self, calibratorID):
56        """getTypeID(string) -> string
57        Returns the type id for the current calibration interval
58        """
59        return self._getUniversal(tc.VAR_TYPE, calibratorID)

getTypeID(string) -> string Returns the type id for the current calibration interval

def getBegin(self, calibratorID):
61    def getBegin(self, calibratorID):
62        """getBegin(string) -> double
63        Returns the begin time of the current calibration interval
64        """
65        return self._getUniversal(tc.VAR_BEGIN, calibratorID)

getBegin(string) -> double Returns the begin time of the current calibration interval

def getEnd(self, calibratorID):
67    def getEnd(self, calibratorID):
68        """getEnd(string) -> double
69        Returns the end time of the current calibration interval
70        """
71        return self._getUniversal(tc.VAR_END, calibratorID)

getEnd(string) -> double Returns the end time of the current calibration interval

def getRouteID(self, calibratorID):
73    def getRouteID(self, calibratorID):
74        """getRouteID(string) -> string
75        Returns the route id for the current calibration interval
76        """
77        return self._getUniversal(tc.VAR_ROUTE_ID, calibratorID)

getRouteID(string) -> string Returns the route id for the current calibration interval

def getRouteProbeID(self, calibratorID):
79    def getRouteProbeID(self, calibratorID):
80        """getRouteProbeID(string) -> string
81        Returns the routeProbe id for this calibrator
82        """
83        return self._getUniversal(tc.VAR_ROUTE_PROBE, calibratorID)

getRouteProbeID(string) -> string Returns the routeProbe id for this calibrator

def getVTypes(self, calibratorID):
85    def getVTypes(self, calibratorID):
86        """getVTypes(string) -> tuple(string)
87
88        Returns a tuple of all types to which the calibrator applies (in a type filter is active)
89        """
90        return self._getUniversal(tc.VAR_VTYPES, calibratorID)

getVTypes(string) -> tuple(string)

Returns a tuple of all types to which the calibrator applies (in a type filter is active)

def getPassed(self, calibratorID):
92    def getPassed(self, calibratorID):
93        """getPassed(string) -> double
94        Returns the number of passed vehicles in the current calibration interval
95        """
96        return self._getUniversal(tc.VAR_PASSED, calibratorID)

getPassed(string) -> double Returns the number of passed vehicles in the current calibration interval

def getInserted(self, calibratorID):
 98    def getInserted(self, calibratorID):
 99        """getInserted(string) -> double
100        Returns the number of inserted vehicles in the current calibration interval
101        """
102        return self._getUniversal(tc.VAR_INSERTED, calibratorID)

getInserted(string) -> double Returns the number of inserted vehicles in the current calibration interval

def getRemoved(self, calibratorID):
104    def getRemoved(self, calibratorID):
105        """getRemoved(string) -> double
106        Returns the number of removed vehicles in the current calibration interval
107        """
108        return self._getUniversal(tc.VAR_REMOVED, calibratorID)

getRemoved(string) -> double Returns the number of removed vehicles in the current calibration interval

def setFlow( self, calibratorID, begin, end, vehsPerHour, speed, typeID, routeID, departLane='first', departSpeed='max'):
110    def setFlow(self, calibratorID, begin, end, vehsPerHour, speed, typeID,
111                routeID, departLane="first", departSpeed="max"):
112        """setFlow(string, double, double, double, double, string, string, string, string) -> None
113        Update or add a calibrator interval
114        """
115        self._setCmd(tc.CMD_SET_FLOW, calibratorID, "tddddssss", 8, begin, end,
116                     vehsPerHour, speed, typeID, routeID, departLane, departSpeed)

setFlow(string, double, double, double, double, string, string, string, string) -> None Update or add a calibrator interval