NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically browse workspace

From my LabVIEW UI I have to always do a File>Browse Workspace...
I do this because I normaly use a workspace file with the TS UI so all my paths (code modules and sequences) are relative to this workspace.

Is there a way to programmatically browse to or load a workspace file?


Michael Aivaliotis
VI Shots LLC
0 Kudos
Message 1 of 7
(3,956 Views)
Hi Michael,

I would use an expression step with 'RunState.Engine.DisplayWorkspaceBrowserDialog("",0)' as the value for the expression field.

This will accomplish the same function and clicking File»Browse Workspace... in your OI.

-EvanP



Evan Prothro
RF Systems Engineer | NI

0 Kudos
Message 2 of 7
(3,916 Views)
Thank you. However is it possible to specify a file path to the workspace so that you don't require the user to perform a browse?


Michael Aivaliotis
VI Shots LLC
0 Kudos
Message 3 of 7
(3,913 Views)
Absolutely; try RunState.Engine.OpenWorkspaceFile("<your project folder path>\\<your workspace>.tsw",0,1). The 0 and 1 correspond to the default options for this function.
This should obsolete the need for the previous function that I mentioned, since opening the dialog is not necessary when we open the workspace directly.

Ensure that you execute this expression before you open your sequence file, so that the paths are relative to the correct locations.

Thanks!




Evan Prothro
RF Systems Engineer | NI

0 Kudos
Message 4 of 7
(3,895 Views)
Hmm, I'm trying this but for some reason it does not have  the effect i want. See image.






Even after I execute this code, the workspace is show as not loaded.
 



Message Edited by Michael Aivaliotis on 12-05-2007 12:02 PM


Michael Aivaliotis
VI Shots LLC
Download All
0 Kudos
Message 5 of 7
(3,886 Views)
Engine.OpenWorkspaceFile() reuturns a reference to the WorkspaceFile object. Setting Engine.CurrentWorkspaceFile to reference this WorkspaceFile will accomplish what you are wanting.

So, continuing with our expression example from earlier, our expression value wold be:

RunState.Engine.CurrentWorkspaceFile =  RunState.Engine.OpenWorkspaceFile("<your project folder absolute path>\\<your workspace>.tsw",0,1)

In your LabVIEW example, adding a property node for the CurrentWorkspaceFile is necessary as wellas ensuring that you close the OpenWorkspaceFile reference after you feed it to  this property node. (This would not be necessary if compiled in TestStand, since TestStand would automatically clean-up this object reference)



Evan Prothro
RF Systems Engineer | NI

0 Kudos
Message 6 of 7
(3,876 Views)

@evanp wrote:
Engine.OpenWorkspaceFile() reuturns a reference to the WorkspaceFile object. Setting Engine.CurrentWorkspaceFile to reference this WorkspaceFile will accomplish what you are wanting.

Ok, perfect. I made this change and now it's working properly. Thank You.


Michael Aivaliotis
VI Shots LLC
0 Kudos
Message 7 of 7
(3,872 Views)