NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to specify environment when using custom OI

Solved!
Go to solution

How do I specify which TestStand 2016 environment to use when running from a custom operator interface? I want to create multiple environments but I don't know how I can have my software ensure I am using the right environment.

0 Kudos
Message 1 of 16
(4,529 Views)

You can specify an environment through the command line when you launch the operator interface (TS Help: Choosing an Environment). I like to make a shortcut that already has the /env specified, similar to how the full featured OIs specify the /editor or /operatorInterface flags.

 

From your OI code, you can call Engine.GetEnvironmentPath to check the current environment and react appropriately.

 

https://www.linkedin.com/in/trentweaver
0 Kudos
Message 2 of 16
(4,511 Views)

The question is, once I know the environment I'm in, can I programmatically change it or does it require the user to open the Sequence Editor?

0 Kudos
Message 3 of 16
(4,499 Views)
Solution
Accepted by Skeptical

Changing environments requires exiting the existing application instance and launching a new one. You could programmatically re-launch your application with the correct environment, but there's no way around restarting it if you need to change environments.

 

The engine reads some config files on initialization, so it needs to be started with the environment you want to use.

https://www.linkedin.com/in/trentweaver
Message 4 of 16
(4,489 Views)

It would be nice if I could programmatically set the environment in the AxApplicationManager when it gets initialized or something like that. Perhaps a future version will allow that. Thanks for your response.

0 Kudos
Message 5 of 16
(4,453 Views)

I would like to pass an environment to the Engine as well, especially when I am debugging my TSUI. Right now I have to add information to the Global environment in order to debug the OI. That is slow goin' and hard to explain. I see this as very similar to a Python virtualenv, where the shell can be activated to use said env. To follow that logic, I tried setting the "TestStand" environment variables of a cmd.exe instance to my AppData and PubDocs folders. When I ran seqedit.exe from that cmd.exe I was hoping the engine would use those environment variables and launch in a fake Global environment that I had overridden.

That didn't work Smiley Sad I guess seqedit has hardcoded Global environment settings?

I don't see why the Application Manager's GetEngine() method couldn't include an override for providing an environment file.

Another option would be to allow the setting of the Application Managers' CommandLineArgs. I tried to use the .Add() method on that but it errors and says you cannot set these strings.

I agree that we need to be able to, somehow, pass environments in programmatically.

0 Kudos
Message 6 of 16
(3,714 Views)

Since the Environment is needed to initialize the engine, it needs to be set before creating one. This is possible with a customOI similar to what is described here:

https://forums.ni.com/t5/NI-TestStand/How-to-specify-environment-when-using-custom-interface/td-p/36...

 

For the sequence editor, you're limited to command line args.

https://www.linkedin.com/in/trentweaver
0 Kudos
Message 7 of 16
(3,707 Views)

Good to know. I use a custom OI to execute the sequences but typically edit them in the sequence editor.

0 Kudos
Message 8 of 16
(3,705 Views)

If this to say that the ApplicationManager that I use to call GetEngine() has already loaded the engine and, therefore, config files?

I understand the complexity if that is the case.

0 Kudos
Message 9 of 16
(3,693 Views)

That's right

https://www.linkedin.com/in/trentweaver
0 Kudos
Message 10 of 16
(3,689 Views)