TestStand and Labview 版本Sample

本文详细描述了LabVIEWTestStandSample中的界面设计、程序面板步骤,特别是状态机结构,以及如何配置连接、执行入口点、用户交互功能如登录、关闭和运行。还涵盖了事件处理和错误处理的相关内容。
摘要由CSDN通过智能技术生成

TestStand and Labview 版本Sample-1

1.界面

可以看出来界面比较简洁

2.程序面板步骤

结构是状态机,7个状态

3.lnitialize

3.1:所有的控件都存储在移位寄存器中

3.2:获取TestStand驱动引用

通过这个调用方法获取TestStand Engine的reference

3.3:将应用程序管理器的引用分配到VI上

4.Configure Connections

4.1:Configures the Commands for the Application Manager

4.1.0:ConnectCommand

Syntax

ApplicationMgr.ConnectCommand ( uiObj, cmdKind, index = 0, opts = 0)

Return Value

CommandConnection

A reference to an object that represents the new connection. Discarding the reference does not affect the connection. When the object is already connected with this type of connection, the existing connection is returned.

Purpose

Connects a control to the Application Manager control to make the connected control function as a command.

Remarks

You can connect TestStand User Interface buttons and checkboxes using this method.

To disconnect an existing connection, you must first obtain the ApplicationMgrConnections object from the ApplicationMgr.Connections property. Then, access the ApplicationMgrConnections.Command property to obtain the CommandConnections collection.

4.1.1:CommandKind_LoginLogout

CommandKind_LoginLogout–(Value: 27) Launches the user login dialog box when no user is logged in. Otherwise, logs out the current user.

4.1.2:CommandKind_Exit

CommandKind_Exit–(Value: 30) Unloads all files and exits the application.

4.1.3:CommandKind_TerminateAll

CommandKind_TerminateAll–(Value: 77) Terminates all executions. This command applies only to the Application Manager control. This command has a default image.

4.1.4:ReloadSequenceFilesOnStart

Syntax

ApplicationMgr.ReloadSequenceFilesOnStart 

Data Type

ReloadFiles

Use the following constants with this data type:

  • ReloadFile_All–(Value: 2) Reloads all files.
  • ReloadFile_None–(Value: 0) Does not reload any files.
  • ReloadFile_Selected–(Value: 1) Reloads any file selected in a SequenceFileView Manager control.

Purpose

Specifies which files to reload when the application starts.

Remarks

A value of ReloadFile_None results in nothing being reloaded on start. A value of ReloadFile_Selected makes the ApplicationMgr.Start method reload all files selected in any SequenceFileView Manager controls the last time the ApplicationMgr.Shutdown method was called. A value of ReloadFile_All makes the ApplicationMgr.Start method reload all files that were open when the ApplicationMgr.Shutdown method was last called.

The files load after the first time a user logs in.

4.2:Configures the Connections and Commands for the SequenceFileView Manager.

4.2.1:StepGroupMode 

SequenceFileViewMgr.StepGroupMode 

Data Type

StepGroupModes

Use the following constants with this data type:

  • StepGroupMode_AllGroups–(Value: 2) Displays the Setup, Main, and Cleanup step groups.
  • StepGroupMode_OneGroup–(Value: 1) Displays only one step group.

Purpose

For connected controls that display steps, this property specifies whether to display all steps in the Cleanup, Main, and Setup groups or to display only the steps in the current step group.

Remarks

When you set this property to StepGroupMode_AllGroups, ensure that the application does not use the value of the SequenceFileViewMgr.StepGroup property.

4.2.2:CommandKind_ExecutionEntryPoints_Set

CommandKind_ExecutionEntryPoints_Set–(Value: 141) Specifies a set of commands that contains a CommandKind_RunEntryPoint command for each Execution entry point. When you specify commands to create menu items, use the CommandKind_ExecutionEntryPointInsertionMarker and CommandKind_ExecutionEntryPointDefaultInsertionMarker constants to honor any menu hints the entry points might specify.

4.2.3:CommandKind_ExecutionEntryPoints_Set-2

和上一个一样,区别在于index变了,相当于索引(我的理解)

4.2.4:ConnectSequenceFileList

Syntax

SequenceFileViewMgr.ConnectSequenceFileList ( uiObj, fullPath)

Return Value

SequenceFileListConnection

A reference to an object that represents the new connection. Discarding the reference does not affect the connection. When the object is already connected to this type of connection, the existing connection is returned.

Purpose

Connects a user interface control that displays the list of opened sequence files. The control can also select a sequence file to place into the SequenceFileView Manager control.

Remarks

You can connect a ComboBox, ListBarPage, and ListBox to SequenceFileLists.

To disconnect an existing connection, you must first obtain the SequenceFileViewMgrConnections object from the SequenceFileViewMgr.Connections property. Then, access the SequenceFileViewMgrConnections.SequenceFileList property to obtain the SequenceFileListConnections collection.

文件打开框

4.2.5:ConnectSequenceList

Syntax

SequenceFileViewMgr.ConnectSequenceList ( uiObj)

Return Value

SequenceListConnection

A reference to an object that represents the new connection. Discarding the reference does not affect the connection. When the object is already connected to this type of connection, the existing connection is returned.

Purpose

Connects a user interface control that displays the list of sequences in the current sequence file. The control can also select a sequence to place into the SequenceFileView Manager control.

Remarks

You can connect the ComboBox, ListBarPage, and ListBox to SequenceFileLists.

To disconnect an existing connection, you must first obtain the SequenceFileViewMgrConnections object from SequenceFileViewMgr.Connections property. Then, access the SequenceFileViewMgrConnections.SequenceList property to obtain the SequenceListConnections collection.

4.2.6:OpenSequenceFiles

  • CommandKind_OpenSequenceFile–(Value: 20) Launches the Open File dialog box. When the user selects a sequence file, the command loads and displays the file. This command has a default image.
  • CommandKind_OpenSequenceFiles–(Value: 147) Launches the Open Multiple File dialog box, in which the user can select any number of files to open. The command loads all selected sequence files and displays one of the selected sequence files. This command has a default image.

这里选用的是Files去作为按键功能

4.2.7:CommandKind_Close

  • CommandKind_Close–(Value: 21) Closes the currently selected sequence file or execution. This command applies to the ExecutionView Manager and SequenceFileView Manager controls.

4.2.8:CommandKind_RunCurrentSequence

  • CommandKind_RunCurrentSequence–(Value: 44) Runs the selected sequence without using a process model. This command applies only to the SequenceFileView Manager control. This command has a default image.

以上所有的功能都会添加到sequencesFileView Manger

4.3:Connections and Commands for the ExecutionView Manager.

4.3.1:StepGroupMode

StepGroupMode Property

Syntax

ExecutionViewMgr.StepGroupMode

Data Type

StepGroupModes

Use the following constants with this data type:

  • StepGroupMode_AllGroups–(Value: 2) Displays the Setup, Main, and Cleanup step groups.
  • StepGroupMode_OneGroup–(Value: 1) Displays only one step group.

Purpose

Specifies whether the SequenceView controls that connect to the ExecutionView Manager control display steps in all the step groups or only steps in the current step group.

4.3.2:ConnectExecutionList

ConnectExecutionList Method

Syntax

ExecutionViewMgr.ConnectExecutionList ( uiObj)

Return Value

ExecutionListConnection

A reference to an object that represents the new connection. Discarding the reference does not affect the connection. When the object is already connected to this type of connection, the existing connection is returned.

Purpose

Connects a ComboBox, ListBarPage, or ListBox control to the list of running executions. The connected item displays the executions and allows the user to select an execution in the ExecutionView Manager control.

Remarks

To disconnect an existing connection, you must first obtain the ExecutionViewMgrConnections object from the ExecutionViewMgr.Connections property. Then, access the ExecutionViewMgrConnections.ExecutionList property to obtain the ExecutionListConnections collection.

4.3.3:DisplayExpression

DisplayExpression Property

Syntax

ExecutionListConnection.DisplayExpression

Data Type

String

Purpose

Specifies how to display executions in the execution list using a format expression. By default, the value of this property is "%CurrentExecution%". Refer to the CaptionSource_MacroExpression enumeration value for more information about types of caption sources.

4.3.4:ConnectExecutionView

ConnectExecutionView Method

Syntax

ExecutionViewMgr.ConnectExecutionView ( uiObj, opts = 0)

Return Value

ExecutionViewConnection

A reference to an object that represents the new connection. Discarding the reference does not affect the connection. When the object is already connected to this type of connection, the existing connection is returned.

Purpose

Connects a SequenceView control to display the steps of the running sequence in the execution.

Remarks

To disconnect an existing connection, you must first obtain the ExecutionViewMgrConnections object from the ExecutionViewMgr.Connections property. Then, access the ExecutionViewMgrConnections.ExecutionView property to obtain the ExecutionViewConnections collection.

4.3.5:ConnectReportView

ConnectReportView Method

Syntax

ExecutionViewMgr.ConnectReportView ( uiObj)

Return Value

ReportViewConnection

A reference to an object that represents the new connection. Discarding the reference does not affect the connection. When the object is already connected to this type of connection, the existing connection is returned.

Purpose

Connects a ReportView control to display the report of the selected execution in the ExecutionView Manager control.

Remarks

To disconnect an existing connection, you must first obtain the ExecutionViewMgrConnections object from the ExecutionViewMgr.Connections property. Then, access the ExecutionViewMgrConnections.ReportView property to obtain the ReportViewConnections collection.

4.3.6:CommandKind_Close

CommandKind_Close–(Value: 21) Closes the currently selected sequence file or execution. This command applies to the ExecutionView Manager and SequenceFileView Manager controls.

4.3.7:CommandKind_BreakResume

  • CommandKind_BreakResume–(Value: 72) Suspends the selected execution if it is executing. Resumes the selected execution if it is suspended. This command applies only to the ExecutionView Manager control.

4.3.8:CommandKind_TerminateRestart

CommandKind_TerminateRestart–(Value: 74) Terminates the selected execution if it is executing or suspended and restarts the selected execution if it has completed. This command applies only to the ExecutionView Manager control. This command has a default image.

5:Register Event Callbacks

Teststand采用了许多回调事件去响应,意思就是当你运行到一个节点的时候,会通过这个Vi去运行从而响应操作,以下是Application Manger所有的回调事件

5.1:DisplaySequenceFile Event

Syntax

ControlName_DisplaySequenceFile ( file, reason)

Applies To

ApplicationMgr

Purpose

Occurs when a sequence file is opened directly or in response to a UIMsg_OpenWindows event TestStand sends.

Remarks

Use this event to display the sequence file in a Sequence File window by setting the SequenceFileViewMgr.SequenceFile property on the SequenceFileView Manager control for the window.

Parameters

file As SequenceFile

[In] Specifies the sequence file to display.

reason As SequenceFileDisplayReasons

[In] Specifies the reason why the event was generated. Refer to the SequenceFileDisplayReasons enumeration for more information about reasons for sequence file actions.

5.2:ExitApplication Event

Syntax

ControlName_ExitApplication

Applies To

ApplicationMgr

Purpose

Occurs when the application has completed the shutdown process.

Remarks

The application responds to this event by exiting. Refer to the ApplicationMgr.Shutdown method for more information about exiting.

5.3:DisplayExecution Event

Syntax

ControlName_DisplayExecution ( exec, reason)

Applies To

ApplicationMgr

Purpose

Occurs when a visible execution starts, when an execution breaks, or in response to a UIMsg_OpenWindow or a UIMsg_GotoLocation user interface message. Use the reason parameter to find out why this event was called.

Remarks

Use this event to display the execution in a window by setting the ExecutionViewMgr.Execution property on the ExecutionView Manager control for the window.

Parameters

exec As Execution

[In] Specifies the execution to display.

reason As ExecutionDisplayReasons

[In] Specifies the reason why the event was generated. Refer to the ExecutionDisplayReasons enumeration for more information about reasons for execution actions.

Execution Property

Syntax

ExecutionViewMgr.Execution 

Data Type

Execution

Purpose

Specifies the execution selected in the ExecutionView Manager control.

Remarks

An execution cannot be selected in more than one ExecutionView Manager control at a time. The ExecutionView Manager control generates an ExecutionViewMgr.ExecutionChanged event when this property changes.

5.4:Wait

Syntax

ControlName_Wait ( showWait)

Applies To

ApplicationMgr

Purpose

Occurs when the application is performing lengthy tasks.

Remarks

Use this event to display or remove a wait cursor or other indicator to show when the application is busy.

Parameters

showWait As Boolean

[In] When this parameter is True, the application has started a long operation. When this parameter is False, the application has finished the long operation.

5.5:ReportError Event

Syntax

ControlName_ReportError ( errorCode, errorMessage)

Applies To

ApplicationMgr

Purpose

Occurs when an error is reported. This event notifies the application of errors that occur while the user operates connected controls. This event is also called when the ApplicationMgr.RaiseError method is called.

Remarks

Use this event to display an error message to the user of the user interface.

Parameters

errorCode As Long

[In] Specifies the error code for the error that caused the event.

errorMessage As String

[In] Specifies the descriptive error string

6:Start Application

Syntax

ApplicationMgr.Start

Purpose

Initializes the user interface, acquires the necessary license, and runs the LoginLogout Front-End callback sequence, if the ApplicationMgr.LoginOnStart property is True.

Remarks

Call this method after you create the user interface window. If the application edits sequence files, set the ApplicationMgr.IsEditor property before calling this method. This method calls the Engine.AcquireLicense method to request the proper license for the application to start.

7:Handle Events

7.1:前面板关闭

Syntax

ApplicationMgr.Shutdown

Return Value

Boolean

Purpose

Closes opened sequence files and executions. This method also releases the TestStand Engine.

Remarks

Call this method before the parent window of the Application Manager control is destroyed. When this method returns True, it is safe to destroy the parent window. When this method returns False, do not destroy the window until the Application Manager control generates an ApplicationMgrExitApplication event. When you cancel the TestStand Engine shutdown procedure, the Application Manager control generates the ApplicationMgrShutDownCancelled event.

7.2:用户事件

由于之前使用了用户事件,所以基本上不会触发这一步骤

8:Shutdown

分为四步:

1:注册事件注销

2:事件回调注册注销

3:用户事件注销

4:TestStand Engine注销

9:Handle Errors

9.1:Get ErrorString

Syntax

Engine.GetErrorString ( errorCode, errorString)

Return Value

Boolean

Returns False when the errorCode is not a TSError.

Purpose

Returns an error description string that corresponds to a specific TSError code.

Parameters

errorCode As TSError

[In] Specifies the error code to describe.

errorString As String

[Out] Returns a description of the errorCode. If the error code is not a TSError, the parameter returns the string "User defined error code."

9.2:IsStarted

Syntax

ApplicationMgr.IsStarted 

Data Type

Boolean

Purpose

Returns True when the ApplicationMgr.Start method has been called. Returns False when the Application Manager control has been shutdown.

最全的Teststand 教程(英文版) Introduction Introduction.................................................................................................................xi Technical Support Options.........................................................................................xii Course Objectives.......................................................................................................xiii Course Description .....................................................................................................xiii Course Map.................................................................................................................xiv Items You Need for this Course Module:...................................................................xv Note on Hands-On Exercises......................................................................................xvi Lesson 1 Introduction to TestStand Introduction.................................................................................................................1-1 The Role of a Test Executive......................................................................................1-2 The TestStand Goal ....................................................................................................1-3 What is TestStand?.....................................................................................................1-4 The TestStand Architecture........................................................................................1-5 The Sequence Editor...................................................................................................1-6 The Operator Interface................................................................................................1-7 The TestStand Engine.................................................................................................1-8 Module Adapters ........................................................................................................1-9 The TestStand Architecture........................................................................................1-10 Summary.....................................................................................................................1-13 Exercises Exercise 1-1 Running a Sequence File..................................................................1-15 Exercise 1-2A Running a Sequence File from the LabVIEW Operator Interface ............................................................................1-20 Exercise 1-2B Running a Sequence File from the LabWindows/CVI Operator Interface..............................................1-25 Contents TestStand Development Course Manual iv www.ni.com Lesson 2 The TestStand Environment Introduction.................................................................................................................2-1 What is a Sequence?...................................................................................................2-2 Step Groups.................................................................................................................2-3 TestStand Sequence Files ...........................................................................................2-4 Debugging Tools.........................................................................................................2-5 The TestStand Process Model.....................................................................................2-8 The Default Process Model: Test UUTs Mode ..........................................................2-9 TestStandModel.seq....................................................................................................2-10 The Role of the Process Model within the TestStand Architecture............................2-11 Exercises Exercise 2-1 Understanding the Sequence File.....................................................2-15 Exercise 2-2 Running a Sequence File with Breakpoints and Single Stepping.................................................................................2-21 Exercise 2-3 Understanding the Process Model....................................................2-28 Lesson 3 Creating Sequences Introduction.................................................................................................................3-1 How to Create Test Sequences ...................................................................................3-2 Action 1 : Specify the Adapter ...................................................................................3-3 Action 2: Select the Step Type ...................................................................................3-4 Step Types...................................................................................................................3-5 Action 3: Specify the Test Module.............................................................................3-6 Specifying the Module................................................................................................3-7 Specifying the Module: Search Directories................................................................3-8 Action 4: Configure Step Properties...........................................................................3-9 Step Properties: General Tab......................................................................................3-10 Step Properties: Preconditions....................................................................................3-11 Step Properties: Run Options......................................................................................3-12 Step Properties: Post Actions......................................................................................3-14 Step Properties: Loop..................................................................................................3-15 Step Properties: Expressions.......................................................................................3-17 Exercises Exercise 3-1 Creating Steps in the Sequence Editor .............................................3-23 Exercise 3-2 Configuring Loop Options ...............................................................3-34 Exercise 3-3 Creating a Sequence.........................................................................3-38 Exercise 3-4 Running Sequences in Parallel (Optional) .......................................3-58 Contents © National Instruments Corporation v TestStand Development Course Manual Lesson 4 TestStand Parameters, Variables, and Expressions Introduction.................................................................................................................4-1 Parameters...................................................................................................................4-2 Parameters: Passing data from top-level sequences to subsequences.........................4-3 TestStand Variables....................................................................................................4-4 Local Variables...........................................................................................................4-5 Creating Locals Variables...........................................................................................4-6 Sequence File Global Variables..................................................................................4-8 Creating Sequence File Global Variables...................................................................4-9 Station Globals............................................................................................................4-10 The Expression Browser.............................................................................................4-11 Exercises Exercise 4-1 Using Local Variables......................................................................4-19 Exercise 4-2 Examine the Uses and Differences between Locals, File Globals, and Station Globals.....................................................4-22 Exercise 4-3 Using Expressions to Change Step Properties..................................4-30 Exercise 4-4 Passing Parameters...........................................................................4-39 Exercise 4-5 Dynamically Selecting Which Sequence to Run..............................4-49 Exercise 4-6 Using the UUT Serial Number to Determine Which Sequence to Run...............................................................................4-50 Lesson 5 Creating Test Modules in External Environments Introduction.................................................................................................................5-1 Creating Tests in External Application Development Environments (ADEs)...........5-2 Methods of Data Transfer for TestStand ....................................................................5-3 Method 1—Passing Parameters Directly Using Structures........................................5-3 Using Clusters to Pass Data from LabVIEW..............................................................5-4 Using Structures to Pass Data from LabWindows/CVI..............................................5-6 Method 2—Passing Arbitrary Number of Parameters Directly..................................5-8 Method 3—Using the ActiveX Automation API to Access Properties and Methods .............................................................................................................5-12 What is ActiveX Automation?....................................................................................5-13 Summary of ActiveX Automation..............................................................................5-14 TestStand and ActiveX Automation...........................................................................5-15 Using TestStand ActiveX Automation Functions in LabVIEW.................................5-16 An Example of Using ActiveX Automation in LabVIEW.........................................5-17 Using ActiveX Automation in LabWindows/CVI......................................................5-18 An Example Of Using The TestStand API Instrument Driver In LabWindows/CVI.....................................................................................................5-19 Using TestStand to Generate Code Templates...........................................................5-24 Code Templates ..........................................................................................................5-25 Contents TestStand Development Course Manual vi www.ni.com Exercises Exercise 5-1A Creating Pass/Fail Tests in LabVIEW..............................................5-27 Exercise 5-1B Creating Pass/Fail Tests with LabWindows/CVI.............................5-33 Exercise 5-1C Creating Pass/Fail Tests for the DLL Flexible Prototype Adapter.............................................................................5-44 Exercise 5-2A Creating Numeric Limit Tests with LabVIEW................................5-54 Exercise 5-2B Creating Numeric Limit Tests with LabWindows/CVI.............................................................................5-59 Exercise 5-2C Creating Numeric Limit Tests for the DLL Flexible Prototype Adapter...............................................................5-67 Exercise 5-3A Debugging Tests Using LabVIEW...................................................5-80 Exercise 5-3B Debugging Tests Using LabWindows/CVI......................................5-84 Exercise 5-3C Debugging Tests that use the DLL Flexible Prototype Adapter.............................................................................5-88 Exercise 5-4A Using the ActiveX API in Code Modules with LabVIEW .................................................................................5-91 Exercise 5-4B Using the ActiveX API in Code Modules with LabWindows/CVI ....................................................................5-100 Exercise 5-4C Using the ActiveX API in Flexible DLL Code Modules............................................................................................5-110 Exercise 5-5A Creating a Simple Test Using the LabVIEW Standard Prototype Adapter .............................................................5-122 Exercise 5-5B Creating A Simple Test Using The C/CVI Standard Prototype Adapter .............................................................5-124 Exercise 5-6A Passing Parameters from TestStand to LabVIEW using The TestStand API..................................................................5-125 Exercise 5-6B Passing Parameters from TestStand to LabWindows/CVI using The TestStand API...................................5-127 Exercise 5-7 Passing Data Between TestStand and a Test Module Using the DLL Flexible Prototype Adapter........................5-129 Lesson 6 User Management Introduction.................................................................................................................6-1 The TestStand User Manager .....................................................................................6-2 Default User Profiles in TestStand .............................................................................6-3 Linking Windows System Users.................................................................................6-5 Exercise Exercise 6-1 Setting User Login Access and Privileges........................................6-7 ...............
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值