使用ActiveX调用来评估TestStand表达式
主要软件:
主要软件版本: 3.5
主要软件修正版本: N/A
次要软件: N/A
问题: 我想以编程方式使用TestStand ActiveX调用评估表达式。这可能吗?
解答: TestStand包含一个可从TestStand Engine访问的Expression对象。Expression对象保存表达式字符串,并允许您检查表达式字符串的有效性或计算表达式字符串以获取表达式的结果。
按照以下步骤使用TestStand API通过ActiveX / COM操作步骤创建和评估一个Expression对象。
- 创建三个新的本地变量,用于以后的ActiveX调用。
- NewExpr: 类型 对象引用
- Result: 类型 对象引用
- MyString: 类型 字符串
- 此步骤将创建并返回Expression对象。
- Object Reference: RunState.Engine
- Automation Server: NI TestStand API 3.5 (Ver 1.0)
- Object Class: Engine (IEngine)
- Action: Call Method
- Method: New Expression
- Param (Return Value): Locals.NewExpr
- 此步骤指定Expression对象求值的表达式的文本。
- Object Reference: Locals.NewExpr
- Automation Server: NI TestStand API 3.5 (Ver 1.0)
- Object Class: Expression
- Action: Set Property
- Property: New Expression
- Param (newValue): "Locals.MyString = \"Hello World!\""
(注意:如果我们的表达式需要引用,例如引用一个字符串,那么我们必须使用反斜杠(\“)来表示引号。)
- 此步骤计算表达式,并以PropertyObject的形式返回表达式的结果。
- Object Reference: Locals.NewExpr
- Automation Server: NI TestStand API 3.5 (Ver 1.0)
- Object Class: Expression
- Action: Call Method
- Method: Evaluate
- Param (Return Value): Locals.Result
- Param (evaluationContext): ThisContext
- Param (EvaluationOptions): 0
evaluationContext 参数必须提供数据环境,其中可以访问表达式引用的变量。 例如,如果我们想访问Locals.MyString,那么我们将提供找到Locals的Context,即"ThisContext"。
有关上述seq的示例,请参阅附带的“Expression Object.seq”序列文件
相关链接: KnowledgeBase 304GARY6: How to Retrieve Values of Evaluated Expressions in Code Modules
附件:
- Expression Object.seq
报告日期: 08/30/2005
最近更新: 12/24/2016
文档编号: 3OTJAIA8
Other Support Options
Ask the NI Community
Collaborate with other users in our discussion forums
Request Support from an Engineer
A valid service agreement may be required, and support options vary by country.