• Vissim4.3之API/SDK编程;Vissim编程;


    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

    大约就是这个样子.循环是相当的多的....

    仅限于做少量的测试.

  • 相关阅读:
    十分钟内学会:控制浏览器是否缓存网页状态
    编写 iPhone Friendly 的 Web 应用程序 (Part 7 多点触击)
    写个 JavaScript 异步调用框架 (Part 4 链式调用)
    拆分自然数:纯while实现 (Part 2 实现)
    诚聘 项目经理 & C++开发高手
    李天平:日常管理随笔一
    诚聘:.Net 软件工程师
    对 Enterprise Library 2.0 进一步封装: DbHelperSQL2
    李天平:无为而治&灯下黑
    累并快乐着!
  • 原文地址:https://www.cnblogs.com/ayanmw/p/2446251.html
Copyright © 2020-2023  润新知