NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Change "Execution Options" mode dynamically

Solved!
Go to solution

Hi,

 

Here you are.

Extract .zip to your maschine.

A Demo.seq and StepType Dll is implemented.

Please add in SearchDirectories of TestStand the Path to Demo.seq and enable sub directories.

 

Source code is also included. Just to see how this stuff works with c++.

 

Regards

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 11 of 17
(2,839 Views)

Hi,

 

If you dont want to use the DLL, then you may try changing the TS properties from TestStand. For example to use newthread or not you can play with the below variable as per the swtich condition,

 

RunState.Step.TS.SData.ThreadOpt=1  //makes the sequence to rrun in new thread

RunState.Step.TS.SData.ThreadOpt=0  //Makes the sequence call to run within the same thread

 

 

Similar way , you can mange to create new execution or Run in remote computer as well by changing TS.Sdata parameters. 

 

But you have to be cautious as these paremeters are internal variables and entering wrong values may create diffrent results. 

 

 

0 Kudos
Message 12 of 17
(2,827 Views)

Hi

 

you are right. BUT: As you have mentioned you accessing the variables in a undocumented way.

So i am just wondering why NI is spending a huge effort in API documentation.

I am always prefering API calls to TS properties, because they are safe.

The expression field supports TS API, so there is no reason why not using the API.

 

Regards

 

Juergen

 

 

  

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
Message 13 of 17
(2,823 Views)

Thank you very much! j_dodek, your code seems very useful, my problem is I still do not know how to translate that code to CVI LabWindows. But I am still trying to achieve it.

 

 

Ranjith_Naduvil, that way does work, the only problem is, that code is not going to run until the sequence starts.

That should not be a problem, except because in my editing sequence necessarily I need to place Wait to thread steps. And in the configuration of these steps I would need to know which steps were going to Run In A New Thread for select them (not happening now because is until the sequence starts that we know the way to run of the steps).

 

Image1.png

 

###################

 

 

Image2.png

Message 14 of 17
(2,808 Views)
Solution
Accepted by AlejandroMartinezMeza

Hi,

 

To find the TS-function it is very important that you add tsadpcvi.fp to your project and #include "tsadpcvi.h"

 

HRESULT CVIFUNC TS_SequenceCallModuleGetMultithreadingAndRemoteExecOption (CAObjHandle objectHandle,
                                                                           ERRORINFO *errorInfo,
                                                                           enum TSEnum_SeqCallMultithreadOptions *propertyValue);

 

HRESULT CVIFUNC TS_SequenceCallModuleSetMultithreadingAndRemoteExecOption (CAObjHandle objectHandle,
                                                                           ERRORINFO *errorInfo,
                                                                           enum TSEnum_SeqCallMultithreadOptions propertyValue);

 

 

If this stuff is working i think you should pimp your StepType!

When reading your last message i read that you have to add a wait-step when thread-button is hit.

You have a CustomStepType - So let it do for you!

 

Regards

 

Juergen

  

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
Message 15 of 17
(2,799 Views)

It works now!

 

Image 1.png

 

j_dodek, thanks a lot for your help. Indeed, I was using the function TS_SequenceCallModuleSetMultithreadingAndRemoteExecOption but it was not working and I do not know why.

 

My problem was not sending the correct parameter. Instead of sending "Step.Module", I was always sending "ThisContext" or "ThisContext.Step" thinking that would work.

 

Image 2.png

 

My function at the end was something like:

 

void ModifyPropertyRunInNewThread(CAObjHandle context)
{
	//Variable to read the state of the switch
	int StateOfTheSwitch;
	
	//Value for errors
	ERRORINFO errorInfo;
	
	//Value from QuitUserInferface
	int ReturnValue;
	
	//Load panel in memory	
	if ((panelHandle = LoadPanelEx (0,"CVI_Example.uir", PANEL, __CVIUserHInst)) < 0 )
	{	
		//If there is a error,  terminate the function
		return;	
	}
	//Show panel in screen
	DisplayPanel (panelHandle);
	
	//Read status of the RunInNewThread property from TestStand
	TS_SequenceCallModuleGetMultithreadingAndRemoteExecOption( context, &errorInfo, &StateOfTheSwitch );
	
	if(StateOfTheSwitch == 0) SetCtrlVal(panelHandle, PANEL_switchTHREAD, 0);
	if(StateOfTheSwitch == 1) SetCtrlVal(panelHandle, PANEL_switchTHREAD, 1);
	
	//Variable to catch the data return from the RunInterface()
	ReturnValue = RunUserInterface();
	
	//Data return from the QuitUserInterface
	if(ReturnValue == 1)
	{
		//Read which value are we going to send to the TestStand interface
		GetCtrlVal(panelHandle, PANEL_switchTHREAD, &StateOfTheSwitch); 
		
		//Constants for the function
		//TSConst_SeqCallMultithread_None         = 0
		//TSConst_SeqCallMultithread_NewThread    = 1

		//Set the MultithreadingAndRemoteExecOption according to the state of the switch
		if(StateOfTheSwitch == 0) TS_SequenceCallModuleSetMultithreadingAndRemoteExecOption( context, &errorInfo, 0 );
		if(StateOfTheSwitch == 1) TS_SequenceCallModuleSetMultithreadingAndRemoteExecOption( context, &errorInfo, 1 );	
	}
	
	//Close the panel
	DiscardPanel(panelHandle);
}

 

Attached to this message I include the example I used to probe the function.

Message 16 of 17
(2,765 Views)

Hi,

 

Here is a solution with SequenceContext

 

Regards

 

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 17 of 17
(2,718 Views)