错误-307665:使用VeriStand Python API时,通道没有写入权限

更新 Nov 10, 2025

适用于

软件

  • VeriStand

程式语言

  • Python

问题详述

我正在使用VeriStand Python API,在我部署的VeriStand项目中设置通道值。我能够为项目中的大多数通道创建ChannelReference,并写入对象的value属性以设置通道值,如API 参考示例所示。但是,当我使用此方法写入模型参数的值时,出现以下错误:

The call into the C# API failed with error code -307665. Message: NI VeriStand: Channel does not have write access.

解决方案

模型参数与VeriStand项目中的其他通道不同,无法使用ChannelReference.value方法写入。相反,您必须打开 ModelManager2会话并使用ModelManager2 API中的方法来设置参数值。请参阅ModelManager2 methods in the NIVeriStand Legacy Python API Refence

例如,这里有一个Python脚本,可用于设置VeriStand附带的Engine Demo模型的Idle_Speed_RPM参数。在运行此代码之前,请在VeriStand中打开Engine Demo示例项目并进行部署。

from niveristand.legacy import NIVeriStand

def set_parameter_value():
    
    # Open a ModelManager2 reference using "localhost" as the gateway address.
    modelRef = NIVeriStand.ModelManager2("localhost")
	
    #Here we use the the SetSingleParameterValue(target, name, value) method from the ModelManager2 API. Target is the name of the controller where the model 
is running. Name is the name or expression of the model parameter you wish to set. 
    modelRef.SetSingleParameterValue("Controller","Idle_Speed_RPM", 1500)

if __name__ == '__main__':
    set_parameter_value()

ModelManager2包含许多用于读取和写入单个或多个参数的不同方法。

相关信息

模型管理器是一个异步过程,允许您批量读取和写入模型参数,这样就不会影响运行模型的循环的性能。

有关与参数交互的方式的更多详细信息,请参阅设置模型参数