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
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
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.