NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass parameters to the SequenceFilePostStep callback

Solved!
Go to solution

I need to call a subsequence with several parameters in case of RunTimeError of any of my main sequence steps. I would like to override the SequenceFilePostStepRuntimeError callback to do this.

The callback starts ok but no parameters passed to it. I don't see a way to explicitly set those parameters for the callback call (the way we have it for subsequence call) so I just created parameters with the same name in the MainSequence and the SequenceFilePostStepRuntimeError sequence.

I have seen this post but it does not describe how to pass parameters to a callback.

Please see the attached sequence. The SequenceFilePostStep callback is used for demonstration purposes.

0 Kudos
Message 1 of 11
(5,534 Views)
Solution
Accepted by topic author Sergey_Kolbunov

Hi,

 

One way you could try.

 

Instead of having  Parameters.Message use a Local variable. Change your Parameters.Message to Locals.Message in both your sequences (MainSequence and SequenceFilePostStep).

 

In the SequenceFilePostStep set the Locals.Message to 'Allow Propagation from Caller' ( Select the Locals.Message variable and right mouse click, you should see the two options)

In the MainSequence set the Locals.Message to 'Propagate to Subsequence'

 

Make sure you change the MessagePopup to use Locals>message and set Locals.Message with your message in your expression step.

 

Now when you run your MainSequence you should see your message in the DialogBox.

 

Hope this helps.

Regards

Ray Farmer 

 

Regards
Ray Farmer
Message 2 of 11
(5,527 Views)
Thank you Ray! I've completely missed that way to pass data.
0 Kudos
Message 3 of 11
(5,494 Views)

Hi,

 

That's ok.

 

I would use this method sparingly.  Generally Locals should be used only within the scope of the sequence its been declared in. If this method needs to be used then make sure it's well documented.

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 4 of 11
(5,491 Views)
One more question then. I use parameters to pass configuration data from the top level sequence where the data read to subsequences. Subsequences may belong to the same file or be a separate files.  I may be several layers of calls. So technically I may just create the same named locals in all of my sequences with propagation settings on and call these sequences without parameters. Will it give me any benefits compare to parameters passing (may be less memory usage or what)? Then, parameter can be modified in subsequence and returned back to the caller, do I understand right what this is not happened in case of locals propagation?
0 Kudos
Message 5 of 11
(5,488 Views)

Ok, I just tried to modify local in subsequence and calling sequence got this modified value.

So, what the difference than between calling sequence with parameters and locals propagating? Is the only difference what for calling with parameters we may link differently named variables but for locals propagating it must be the same named locals and using of second method is a kind of hidden (that's why it should be well documented) ? 

0 Kudos
Message 6 of 11
(5,485 Views)

Hi,

 

As you have found out there's no real difference between using Parameters and usings the Locals with propagation. There maybe some memory usage difference but probably not enough to make any difference.

 

You do have to make sure you have declared the variables lower down and matched the names. I dont thing a error is generated if a sequence calls a sub sequence with an local set to propagate and the local isn't available. (I maybe wrong on this).

 

The main thing is when someone else picks up your sequences, there will be no obvious link between sequences and how data is getting from one to the other. The normal convention is to expect data to be passed via parameters or some form of global.  Therefore doucumenting this approach is very important.

 

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 7 of 11
(5,446 Views)

Hi Ray,

I found out that local propagation works fine without declaring the same name local in subsequence. Actually, that is what I found in TestStand help:

 

PropFlags_Propagate–(Value: 0x100) This flag only applies to local variables. If you set the Propagate flag for a sequence local, the variable also appears at run-time as a local variable in subsequences that the sequence calls. The variable continues to propagate as the call chain extends.

 

So, at run-time everything works fine and even allows to extend the call chain. If the local is passed by reference you can modify it in subsequences and use modified value in futher calls. The only difference there is what the subsequence without locals declared can not be run by itself but only called from some master sequence.

This is exactly the architecture I use in my application, I have a master sequence which reads configuration data and then from this master sequence I call subsecuences which use these data and have the all same structure.

 

Thank you for your help,

Sergey

0 Kudos
Message 8 of 11
(5,427 Views)

Hi Sergey,

 

Thanks for that bit of info.

 

To add to that, if you have declared the same local in the subsequence and you dont have Allow Propagation to Caller set then that local in the subsequence does not get updated from the caller.

 

In you subsequence, maybe you should add a step in the setup to check the exists of the Locals and if its not present then display some message and then terminate the execution.

 

Regards

Ray

Regards
Ray Farmer
0 Kudos
Message 9 of 11
(5,423 Views)

I'm having issues with this one. I know its an old thread but I believe it should be here.

 

According to the Best Practices, you should put your instruments in ProcessSetup and ProcessCleanup (full text at end).

 

So I transfered my VISA open of 2 serial communications from Setup to ProcessSetup and from Cleanup to ProcessCleanup.

I copied the Local.Serial#_Session to the Locals of each process and set them to "Allow Propagation from Caller".

Set the same Locals from MainSequence to Propagate to SubSequence

 

I keep getting an issue from the Locals in the MainSequence. I attached my code (saved as 2010). You might need to remap the VIs.

 

Also tried changing the Write and Read of serials to Load dynamically to see if that could be an issue.

 

 

 

From Best Practices:

Instrument initialization routines and calibration routines should be part of the ProcessSetup callback, while instrument communication closure should be part of the ProcessCleanup callback. By placing the initialization and cleanup into these callbacks, the instrument communications code executes once for all UUTs rather than once for each UUT.

 

Thanks

0 Kudos
Message 10 of 11
(4,269 Views)