Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vissim-python脚本中的模型更改_Python_Python 3.x_Python 2.7 - Fatal编程技术网

Vissim-python脚本中的模型更改

Vissim-python脚本中的模型更改,python,python-3.x,python-2.7,Python,Python 3.x,Python 2.7,我想用python脚本替换Vissim 5.4中的模型。根据驾驶时间和交通灯上显示的颜色,我想更改VMS板的型号。 我在Vissim和Python方面没有太多经验,但我做过类似的事情: import win32com.client #constants RED = 3 #signal group type #permanent red# SWDELAY = 15 #switch delay 15s #===============================================

我想用python脚本替换Vissim 5.4中的模型。根据驾驶时间和交通灯上显示的颜色,我想更改VMS板的型号。 我在Vissim和Python方面没有太多经验,但我做过类似的事情:

import win32com.client
#constants
RED = 3 #signal group type #permanent red#
SWDELAY = 15 #switch delay 15s

#=======================================================
#initialize global variables
#=======================================================
SgCtrls = VISSIM.Net.SignalControllers
SgGrps = SgCtrls.GetSignalControllerByNumber(1).SignalGroups.GetSignalGroupByNumber(1)
SgGrps.SetAttValue("TYPE", RED)

Dets = SgCtrls.GetSignalControllerByNumber(1).Detectors
DetsIn = Dets.GetDetectorByNumber(5)

StObjs = VISSIM.Net.StaticObjects
VmsObjectI = StObjs.GetStaticObjectByName('VMS_2_1.3ds')
VmsObjectO = StObjs.GetStaticObjectByName('VMS_2_2.3ds') 

def ControlTravel():
#here you should check if SgGrps == RED and TravelTimes > 100 and SWDELAY pass then
#if "TRUE" then model should be replaced by the VmsObjectO 
#if "FALSE" then model should be replaced by the VmsObjectI

#=======================================================
#update occupied places counters
#=======================================================
def CountOccupiedSpaces() :
...
...
#=======================================================
#update digit counters
#=======================================================
def UpdateCounters() :
...
...
#=======================================================
#start simulating
for SimStep in range(1, Sim.Period * Sim.Resolution) :
 Sim.RunSingleStep()
 ControlTravel()
 CountOccupiedSpaces()
 #update counters every second
 if (SimStep % Sim.Resolution) == 0:
 UpdateCounters()
 VISSIM.DoEvents() #allow VISSIM to handle its events
#======================================================= 
关于初始化全局变量的第一部分正确吗

ControlTravel()函数应该是什么样子的,以便在满足条件时可以交换模型

如果脚本必须更改两个VM的模型,该怎么办?在这种情况下,全局变量的所有初始化都必须是数组

有没有人有一个脚本,我可以在上面创建类似的东西或一些有用的提示