NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to unlock in case of runtime error

Solved!
Go to solution

Hi,

 

I have a block of steps locked using two Lock synchronization steps in Lock and Early Unlock modes. If a step within the section errors out, and the operator selects go to cleanup, the the lock remains locked becasue the unlock step is skipped. What's a good way to handle this? If I put an unlock in Cleanup it will generate an error when the section has executed with no error and lock is already unlocked. There seems to be no way to check the lock/unlocked state of a lock.

 

The only thing I can think of is to only put unlock steps in Cleanup. 

 

cc

0 Kudos
Message 1 of 7
(5,057 Views)

If you set the lifetime the same as the sequence wouldn't it unlock when the sequence completes after cleanup?

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 2 of 7
(5,030 Views)

A couple of ideas:

 

1) Use lock operation lifetime specified by object reference, store the reference in a local variable. To release the lock, instead of calling Early Unlock, set the object reference variable to Nothing in an expression step (Nothing is a keyword for a null reference). Setting the reference to Nothing in cleanup if it is already set to Nothing is harmless.

 

Or

 

2) Use sequence lifetime and move your steps into a subsequence.

 

Hope this helps,

-Doug

0 Kudos
Message 3 of 7
(5,025 Views)

Hi,

 

This sounds like what I need, to be able to unlock (without an error) even if the Lock is not locked.

 

"...To release the lock, instead of calling Early Unlock, set the object reference variable to Nothing..."

 

It doesn't work for me. I tried setting both the Create Lock obj reference, and the Lock step obj reference = Nothing.

 

Some context, I have a thread with a While step monitoring a power supply to see if the over current has tripped during a test. When there's an error in MainSequence in the middle of a locked section (and goto Cleanup), MainSeq does not unlock and the thread remains blocked while MainSeq appears to be done, but not done. I try to set the object reference variable to Nothing at the end of MainSeq, but the thread remains stuck at its Lock step waiting for the Lock.

 

I might just move all my power supply calls in the MainSequence into subsequences with the Unlocks in Cleanups, your #2.

 

It seems like you should be able to kill the Lock lifetime as you described to release all the objects. I've done this many times in LabVIEW to kill sleeping Notifiers and Ques.

 

Thanks both of you guys for the posts.

cc

0 Kudos
Message 4 of 7
(5,015 Views)
Solution
Accepted by topic author DowNow_

DowNow,

 

It works for me.

 

Consider this example:

 

 

Hope this helps,

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 Kudos
Message 5 of 7
(5,011 Views)

@DowNow_ wrote:

Hi,

 

This sounds like what I need, to be able to unlock (without an error) even if the Lock is not locked.

 

"...To release the lock, instead of calling Early Unlock, set the object reference variable to Nothing..."

 

It doesn't work for me. I tried setting both the Create Lock obj reference, and the Lock step obj reference = Nothing.

 

Some context, I have a thread with a While step monitoring a power supply to see if the over current has tripped during a test. When there's an error in MainSequence in the middle of a locked section (and goto Cleanup), MainSeq does not unlock and the thread remains blocked while MainSeq appears to be done, but not done. I try to set the object reference variable to Nothing at the end of MainSeq, but the thread remains stuck at its Lock step waiting for the Lock.

 

I might just move all my power supply calls in the MainSequence into subsequences with the Unlocks in Cleanups, your #2.

 

It seems like you should be able to kill the Lock lifetime as you described to release all the objects. I've done this many times in LabVIEW to kill sleeping Notifiers and Ques.

 

Thanks both of you guys for the posts.

cc


You're probably using the wrong lifetime reference, I meant the one for the lock operation, not the lock itself. There are two places you can specify lifetime, one when creating the lock, and one when locking the lock. I meant the later, you probably thought I meant the former.

 

-Doug

0 Kudos
Message 6 of 7
(4,985 Views)

Hi,

 

I was using the wrong reference. There were three possible and I tried the wrong two. Thanks for the example .seq.

 

I've attached the example with steps for what I'm trying to achieve added. The sequence execution now completes no matter what is chosen in the Skip Unlock dialog. Before I was hanging on the Lock step within the MonitorCurrent seq.

 

Thanks again.

0 Kudos
Message 7 of 7
(4,976 Views)