NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Executing a delay while looping

Due to unreliable communication I loop all communication steps in my seqeunce. It will stop looping after 1 pass or after a maximum of 3. What I'd like to do is slow it down and execute 200-500 ms delay between each retry. Can somebody suggest how this can be done? I tried calling a sequence with just a delay in it using Post Actions but I don't think this works as it technically does not fail until it fails 3 times.

Thanks

CM

Message 1 of 14
(4,693 Views)

Hi, I had this situation also.

We have the step looping with a delay inside the LV code. But of course you also could do this:

Capture.PNG

The precondition on the Break step, is that 'Communication Test' passed.

 

I'm pretty new to TS also, so others are welcome to comment on caveats on this or the first approach.

 

Best Regards

0 Kudos
Message 2 of 14
(4,687 Views)

Thanks mavini, but I am using looping that's built in TS and would like to know if a delay can be added there.

CT 

0 Kudos
Message 3 of 14
(4,681 Views)

Here's what it looks like to avoid any confusion.Looping.PNG 

0 Kudos
Message 4 of 14
(4,679 Views)

Hi cimteker

 

Yes, I did realize that you were looping on the step. However I dont know how to achieve the delay in the manner you request. I'm not sure its at all possible. Thats why I suggested two workarounds.

 

The workaround we used in our project was a delay inside the code of the LabVIEW code module. The delay occurs if the communication failed, and before it returns to teststand. You could also have retries occuring inside the codemodule instead of looping the step.

 

If you are'nt able to edit the code module, my other workaround was the for-loop.

 

Another workaround: if you cant edit the codemodule, wrap it in another codemodule or a subsequence with a conditional delay/wait. The condition of course being communication failing.

Then you could loop the step with the call to the wrapper-subsequense/-codemodule. And its ofcourse easy to add a parameter to control the delay.

 

 

 

But still, if it possible to add a delay in the looping on the step, I agree it would be practical and I would also like to know how to do it.

 

Best regards

 

 

0 Kudos
Message 5 of 14
(4,669 Views)

Thanks Mavimi,

 

But how do you prevent TS from failing the sequence if the first retry fails and second passes? 

CT 

0 Kudos
Message 6 of 14
(4,663 Views)

Hi

 

How about the approach in the attached sequence? It was a little experiment, but it seems to be working.

 

In a subsequence theres the (faked) actual communication test. If it fails, there's added a delay. The result from the actual test is copied to the parameters.

 

In the mainsequence I have a Pass/Fail step with looping, using the subsequence as a codemodule. Because I'm copying the result from the subsequence into the steps own result - I just use the steps own Pass/fail indicator as datasource.

 

In this case I pass Runstate.loopindex and a number to the codemodule for easy testing. When the runstate.loopindex equals the given number the faked communication test passes.

 

 

Best Regards

 

0 Kudos
Message 7 of 14
(4,658 Views)

Hi again

 

I was trying another approach, but I didn't finish it (it got too late I was up til 130am).

 

My idea was a customized steptype that executed a delay in the manner you requested. I tried to implement it as a poststep, and I was able to see from TS classes that the step is looping. However I got stuck in finding out if a iteration was passed or failed. I tried to poll RunState.LoopNumPassed. But I could see that it was not updated.

 

Maybe it's because the status expression is executed after poststeps?

 

Then I thought of making a custom substep and execute it in one of the expressions. But I ran out of time, and wont have time the next couple of days to finish the experiment.

 

I hope somebody else will reply on this idea?

0 Kudos
Message 8 of 14
(4,644 Views)

Why dont you just use the Post Actions with the Use Custom Condition enabled and set this True. In the On True Condition set to Call sequence and pick an internal sequence which when called will perform the necessary delay.

 

 

Regards
Ray Farmer
0 Kudos
Message 9 of 14
(4,642 Views)

The postaction is executed as one of the last things in a step, after the looping is finished. That means that the delay would occur only once after all iterations are done.

 

Whats needed is a delay on a fail once every iteration.

 

Now that i examined the execution order for at step, I think I would put the delay in a Pre-Step if I were to make a custom steptype with a delay.

 

First time its called - you can se that its the first iteration, and you dont have the delay. Subsequent calls to the Pre-Step are probably because the previous iteration failed, and you could safely execute the delay in the Pre-Step code module.

 

Best Regards

0 Kudos
Message 10 of 14
(4,640 Views)