我使用Python通过其COM接口与VISSIM流量模拟软件进行通信。
我正在尝试在运行模拟时访问VehicleNetworkPerformanceMeasurement总延迟属性
#run vissim
env = win32com.client.Dispatch('Vissim.Vissim.800')
#load layout,network
env.LoadNet( r'X:\Users\rHalabi\singleIntersection\Ryan.inpx')
env.LoadLayout( r'X:\Users\rHalabi\singleIntersection\Ryan.layx' )
#tell vissim to collect vehicle performance data
env.Net.Evaluation.SetAttValue( 'VehNetPerfCollectData', 1)
#run a few steps
for i in range(10):
env.Simulation.RunSingleStep()
#collect results
env.Net.VehicleNetworkPerformanceMeasurement.AttValue( 'DelayTot' )
最后一行返回错误
com_error: (-2147352567, 'Exception occurred.', (0, 'VISSIM.Vissim.800', 'Sub-attribute not specified', None, 0, -2147352567), None)
除了' DelayTot'我还尝试了其他属性。但没有工作。我已经按照文档进行了查询,并且能够查询其他对象没问题。
如何访问此数据?
答案 0 :(得分:0)
证明了具有子属性的属性,您需要在查询中提供子属性。以下是VISSIM文档中有关如何查询TravelTimeMeasurements的一些示例代码
Veh_TT_measurement = Vissim.Net.VehicleTravelTimeMeasurements.ItemByKey(Veh_TT_measurement_number)
# Syntax to get the travel times:
# Veh_TT_measurement.AttValue('TravTm(sub_attribut_1, sub_attribut_2, sub_attribut_3)')
#
# sub_attribut_1: SimulationRun
# 1, 2, 3, ... Current: the value of one specific simulation (number according to the tribute "No" of Simulation Runs (see List of Simulation Runs))
# Avg, StdDev, Min, Max: aggregated value of all simulations runs: Avg, StdDev, Min, Max
# sub_attribut_2: TimeInterval
# 1, 2, 3, ... Last: the value of one specific time interval (number of time interval always starts at 1 (first time interval), 2 (2nd TI), 3 (3rd TI), ...)
# Avg, StdDev, Min, Max: aggregated value of all time interval of one simulation: Avg, StdDev, Min, Max
# Total: sum of all time interval of one simulation
# sub_attribut_3: VehicleClass
# 10, 20 or All values only from vehicles of the defined vehicle class number (according to the attribute "No" of Vehicle Classes)
# Note: You can only access the results of specific vehicle classes if you set it in Evaluation > Configuration > Result Attributes
#
# The value of on time interval is the arithmetic mean of all single travel times of the vehicles.
答案 1 :(得分:0)
哈拉比说得很对。 更具体地说,您可以查询子属性,例如
VNPM = env.Net.VehicleNetworkPerformanceMeasurement.AttValue( 'DelayTot(Current, Tot, All)' )
要检查您要使用的属性是否存在任何子属性,Vissim 工具栏上的“帮助”>“COM 帮助”将为您提供帮助。