vissim4.3 是德国PTV公司的一款微观交通模拟软件.
其可以模拟道路车辆,红绿灯运行,可以模拟3D的景象.我这里直说2D
在2D的一段道路上,有车在运动,如何获取车子的坐标信息呢??
根据Vissim文档,可以通过Vissim的COM编程接口进行编程,COM接口可以使用VB(s)/VC/Python/等所有支持COM的语言编程.
其步骤是:1 安装vissim软件,4.3很特殊,有个破解的license,但是要修改时间为2008年,具体可以到 智能交通 论坛下载.
2.安装VB,如果使用VBS可直接开始编程.我使用了VB6进行编程.(没办法,虽然老,但是无法替代啊.)
3.新建立VB工程,默认的exe就可以.
然后在工程->引用 ->浏览 添加 C:\PTV_Vision\VISSIM430\Exe\vissim.exe 这个vissim的可执行文件(其也是COM Server的组件)
然后 整一个按钮,双击开始添加代码
Dim vis As vissim Dim SIM As Simulation Dim vehins As VehicleInputs Dim vehin As VehicleInput Dim vehicles As vehicles Dim vehicle As vehicle Set vis = CreateObject("VISSIM.Vissim") 'NEW Vissim vis.LoadNet "C:\PTV_Vision\VB COM for VISSIM\Demo_VISSIM_CrossTraffic_INP\crossTraffic.inp" Set vehins = vis.Net.VehicleInputs Set vehicles = vis.Net.vehicles Set SIM = vis.Simulation For i = 1 To vehins.Count If True Then Set vehin = vehins(i) 'or vehins.Item(i) msgbox "VeHins.Count=(" & vehins.Count & ");i =" & i msgbox "VeHin.name=" & vehin.Name & vbCrLf _ & "VeHin.ID=" & vehin.ID & vbCrLf _ & "VeHin.AttValue(TIMEFROM)=" & vehin.AttValue("TIMEFROM") & vbCrLf _ & "VeHin.AttValue(TIMEUNTIL)=" & vehin.AttValue("TIMEUNTIL") & vbCrLf _ & "VeHin.AttValue(VOLUME)=" & vehin.AttValue("VOLUME") & vbCrLf & "==============================" & vbCrLf End If Next 'i For i = 0 To 1000 SIM.RunSingleStep If vehicles.Count > 0 Then Call ShowAllVehicles End If vis.DoEvents Next SIM.Stop MsgBox "End() Success" Sub showAllvehicles Dim j For j = 1 To vehicles.Count Set vehicle = vehicles(j) 'or vehicles.Item(i) msgbox "Vehicles.count=(" & vehicles.Count & ");j=" & j msgbox "vehicle.name=" & vehicle.Name msgbox "vehicle.ID=" & vehicle.ID msgbox "vehicle.AttValue(POINT).X=" & vehicle.AttValue("POINT").X msgbox "vehicle.AttValue(POINT).Y=" & vehicle.AttValue("POINT").Y msgbox "vehicle.AttValue(POINT).Z=" & vehicle.AttValue("POINT").Z Set vehicle = Nothing Next End Sub
大约就是这个样子.循环是相当的多的....
仅限于做少量的测试.