zoukankan      html  css  js  c++  java
  • 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

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

    仅限于做少量的测试.

  • 相关阅读:
    谷歌推开发者培训指南 欲提升Android软件质量
    装饰者模式【java版】
    Java GetBytes 编码方式
    为什么程序员都是夜猫子
    Android的Handler总结
    常见的自然法则及管理启示
    java常用设计模式
    Android optionsmenu例程
    关于程序员成长的一点思考
    Java 字节流读写文件
  • 原文地址:https://www.cnblogs.com/ayanmw/p/2446251.html
Copyright © 2011-2022 走看看