11-23-2011 01:24 PM
Hello
I am currently working on some software that will be using test stand for running our tests. All of our calls will be made through the .NET Adapter.
Primarily, we have a few main types of calls to make things easy for test maintainence.
for example we have...
bool GetNextStationSetup()
bool HasOven()
void DoSetTemperature(double degressCelcius);
in C# this code put into practice would look something like this.
while(GetNextStationSetup())
{
if( HasOven() )
{
DoSetTemperature(100);
}
}
My problem is in test stand, there is no way to directly make the call to GetNextStationSetup inside the while condition.
The solution that I think should work is to create a custom step that combines NI_Flow_While step with an Action step. I am also adding a boolean variable 'IsRunning' to the new Step.
When the step is hit, under the Module tab, I am setting the Value field to Step.IsRunning. (default is true)
My problem is that when it hits the end condition, it never returns back to the top of the while loop. It just continues the execution as if the while loop wasn't even there.
I have verified that GetNextStationSetup is not getting called a second time, because I have a message box that pops up right before the method returns. Also, if it was not executing the method a second time, but returning to the top of the loop, it would continue to loop indefinitely.
Any help would be greatly appreciated.
Thank you
-Joel
Solved! Go to Solution.
11-28-2011 11:10 AM
Why not just simplify things by writing the equivalent to:
bool getNextStationSetupResult = GetNextStationSetup(); // .NET Action step storing the return value in a local variable
while (getNextStationSetupResult) // while loop checking local variable instead of directly making the call.
{
// ... rest of your code.
getNextStationSetupResult = GetNextStationSetup(); // .NET Action step storing the return value in a local variable
}
Hope this helps,
-Doug
11-28-2011 01:18 PM
dug, you are right, that would work, but I'm not the one who will be writing the tests. I won't be on the project for a whole lot longer, but I want to make it as simple as possible for the next person to use. If I can get the customized while loop working, that will be much easier to document and read through when changes need to be made to the test.
11-29-2011 10:24 AM
Maintaining a custom step type is probably a bigger maintenance burden than using a builtin feature in a slightly non-optimal way. That said, if you want to create a custom while loop step type you need to make sure the beginning of the name is the same as the original step type's name. For example, you could name your step type something like:
NI_Flow_While_With_Action
Hope this helps,
-Doug
12-01-2011 09:44 AM
Doug, thank you, that worked. I also had to do the following. (In case anybody else needs to do something similar)
* Create an NI_Flow_End_With_Action to pair with NI_Flow_With_Action. (Make NI_Flow_End_With_Action a block end type for NI_Flow_With_Action, and make NI_Flow_With_Action a block start type for NI_Flow_End_With_Action.)
* Create a variable in the step called IsRunning as a boolean, with the PropFlags_PermitPropegation variable.
* Set the while condition to IsRunning == true (You can do this in the type editor so it's the default for all steps of this type)
*Designate the .NET adapter and specify the default DLL and class name, leaving the method to be determined by the designer.
Thank you all for the help, you've made things easier for me and my team.