10-15-2010 05:24 AM - edited 10-15-2010 05:27 AM
Hi, this is my first NI post so if i get something wrong please don't flame me
In teststand i have my mainsequence running along side another thread (the other thread is being used to look for keyboard entry)
If I push escape on my keyboard i want to use the goto command to take me to the cleanup section in the mainsequence therefore ending the test and running cleanup.
The closest i have managed to get is teststand bringing up an error telling me that the step i am trying to move to is not in the current sequence.
Here is the code:
While Locals.TestRunning
Get Input (labview get keyboard input)
If Locals.keyPressed == 62
Goto <- i want this to say goto mainsequence thread to whatever point i want (cleanup in this case)
End
End
Any solution or other way of doing this will be much appreciated
Solved! Go to Solution.
10-15-2010 06:16 AM
@NIcurious wrote:
[...]please don't flame me [...]
I hope that you see from reading other threads that "flaming" is something rare in this forum. So if you are professional in your questions/statements, you will usually receive professional answers.
Reading your question let me think of two different solutions for your request:
a) Every step of your first checks if Escape is pressed. Since this is a very "random moment in time" you will have to create a module storing this information which is "asked". The module has to run separatly (hence another thread, yes).
b) If you are using a custom written user interface, your UI could handle this. Either you keep the info there for the modules (which are called in the TS sequence) or you terminate the sequence' execution by using "Terminate Execution" from the TS API. This approach needs some knowledge in TS API usage which is for example part of the TestStand II course provided by NI.
hope this helps,
Norbert
10-18-2010 01:26 AM - edited 10-18-2010 01:28 AM
With solution A, yes it is already in another thread running, my problem with it being in another thread is I can't use the GoTo function to move back to the mainsequence to a specific point (e.g. cleanup).
Solution B, no it is not part of a UI
10-18-2010 02:36 AM
Well, what i was up about in case a) is that this "watchdog" (or whatever you want to call it) will store the info in a threadsave element which is read by each module in the main sequence. So each module can decide wether it should proceed or call a "go to functionality".....
Norbert
10-18-2010 03:02 AM - edited 10-18-2010 03:03 AM
I think i know what you are saying but this would mean putting lots more if statements and goto commands all through my mainsequence?
I was trying to avoid this because it will make the code 2-3x longer and it is already pretty long
10-18-2010 03:18 AM
Nah, it does not really make the code more complex. You can simply leave the code module in this case passing a boolean to TestStand. In your step, you evaluate this value in a custom condition as a Post Action. If this condition fails (or meets it, however you define it) you will either choose to "GoTo" a certain step/sequence or simply terminate the execution.
hope this helps,
Norbert
10-18-2010 04:18 AM - edited 10-18-2010 04:20 AM
Ok yes I see what you are saying, this the only way you know to do it? I have 50+ sequences that I want to implement the button thread for, and to have to go through every action of every sequence to do this is very long winded, I can do this if its the only way but I was looking to just drop the thread into each of them and be able to achieve this
10-18-2010 04:30 AM - edited 10-18-2010 04:34 AM
Any chance i can pass in a parameter like in C or something which will return a boolean which when returned can do a check, if true then call a Goto with the mainsequence not losing its place in the thread unless true?
Or even terminate the mainsequence from the button thread?
10-18-2010 04:41 AM
You can pass the sequence context to this "watchdog" when starting the execution and then call Terminate Execution. This is not really the nicest solution, but maybe the best one without the need for rework those sequences and code modules....
Norbert
10-18-2010 05:54 AM
Yeh this is what I have done thanks for your help, I just put a forced fail statement in the button thread with the post action of terminating the sequence if the button is pushed.
It works fine, i just move my data collection to the start of the cleanup since as this is still called when the sequence it terminated.
Thanks a lot for your help