LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pause the reading of a script file without stalling main while loop

Solved!
Go to solution

@jedi.engineer wrote:
The only issue I have with this setup is the dequeue on the main loop. It throws an error and I'm not entirely sure why.

Your middle loop is finishing and releasing both queues, then your bottom loop is still going and trying to dequeue elements from a now-released queue.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 31 of 39
(1,112 Views)

@FireFist-Redhawk wrote:

@jedi.engineer wrote:
The only issue I have with this setup is the dequeue on the main loop. It throws an error and I'm not entirely sure why.

Your middle loop is finishing and releasing both queues, then your bottom loop is still going and trying to dequeue elements from a now-released queue.


I just found that, and thank you for all your help! One last question if I may, and an updated file is attached... my main loop doesn't respond (button triggers blinking light) until I load the file and run it. in the interim, it hangs. Is it pending on that queue? how can I mitigate this situation?

0 Kudos
Message 32 of 39
(1,108 Views)

@FireFist-Redhawk wrote:

@jedi.engineer wrote:
The only issue I have with this setup is the dequeue on the main loop. It throws an error and I'm not entirely sure why.

Your middle loop is finishing and releasing both queues, then your bottom loop is still going and trying to dequeue elements from a now-released queue.


Yes, you should close the queue on your bottom loop, not the middle loop.

Message 33 of 39
(1,140 Views)
Solution
Accepted by topic author jedi.engineer

@jedi.engineer wrote:

@FireFist-Redhawk wrote:

@jedi.engineer wrote:
The only issue I have with this setup is the dequeue on the main loop. It throws an error and I'm not entirely sure why.

Your middle loop is finishing and releasing both queues, then your bottom loop is still going and trying to dequeue elements from a now-released queue.


I just found that, and thank you for all your help! One last question if I may, and an updated file is attached... my main loop doesn't respond (button triggers blinking light) until I load the file and run it. in the interim, it hangs. Is it pending on that queue? how can I mitigate this situation?


Put a timeout on the Dequeue and put anything that you don't want to run if no data is received on the queue inside the FALSE statement with the Timeout wired to it from the queue. You can leave the True case empty. Remember, LabVIEW is a dataflow language. A node (loop) can only continue when everything it depends on has completed.

Message 34 of 39
(1,127 Views)

@StevenD wrote:

@jedi.engineer wrote:

I think we might have gotten off track a little from the original topic, when we went down the road of the producer-consumer structure, which can be a help, I think. What I'm trying to do is this:

  • open a text file that contains scripted commands, as in the example I gave.
  • process commands in my "main" or "consumer" loop.
  • When a "WAIT" command comes through, commands to the "main" or "Consumer" loop are paused until that "WAIT" command finishes, without pausing my main loop.

How would you pause a loop..... without pausing a loop?

 

I'm guessing you meant without pausing your producer loop?

 

As others have said it's hard to give suggestions without seeing how the whole program is put together. It seems your question really can only be answered by looking at the architecture of the rest of the program. I edited your uploaded example VI with some notes on what I think you want, or at least an example of what might work. Mainly I got rid of the second loop and put the event structure in a while loop (this is pretty standard structure for handling UI events). The producer loop (the top UI loop) can respond to other events and keep running in parallel while the consumer loop can do longer processes.

 

One note I made is that if possible I would just pass the file path to the consumer loop and have it perform the read and parsing functionality you currently have in the event structure.

 

 

 

 

 


@StevenD - thanks for the input. As I said in several of my replies, I'M RESTRICTED for some pretty damn good reasons, from disclosing my whole program, which is why I made the sample program. I get it, you need to see it. And as I've told the others who asked, there's nothing I can do about it. 

 

On that note, what you sent back is the current structure of my main program. The problem I ran into, as my title explains, is that my main loop pauses when I execute a WAIT command. I only need it to delay the execution of the subsequent commands, and I need my main loop to execute continuously while the WAIT command is executing. 

 

None the less, I thank you for your input. 

0 Kudos
Message 35 of 39
(1,122 Views)

What I'm attaching is an old CLD sample exam that I did for my CLD prep. It also involves reading steps from a text file, and going to the next step when the time of the previous step has elapsed. Maybe looking at this will be a complete waste of time for you, maybe not. 

 

The two states in this that are most pertinent to what you are trying to do, are "Run" and "StepChange". I'll show a pic of the "Run" state for the class. It's from a while back and kind of ugly, so don't judge me anyone.

 

FireFist-Redhawk_0-1598473010924.png

 

So here, the Run state is self-enqueueing. I check a timer FGV to see if a certain amount of time has elapsed. If it hasn't, I just enqueue Run again. If it has, that's when I do what I need to do to get the next step going.

 

Now, my specific implementation was to keep a shift register of remaining steps to do. When time elapsed on a step, I delete it from the array and that's how I keep track of what I have and haven't done. The takeaway is that what I didn't do, was read my entire list of steps and enqueue everything at once from the get-go. Which is what you are doing.

 

Whew, what a throwback. Again I don't know if this will help you or confuse you even more but there ya go. Hopefully the former...

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 36 of 39
(1,114 Views)

@FireFist-Redhawk wrote:

Now, my specific implementation was to keep a shift register of remaining steps to do. When time elapsed on a step, I delete it from the array and that's how I keep track of what I have and haven't done. The takeaway is that what I didn't do, was read my entire list of steps and enqueue everything at once from the get-go. Which is what you are doing....


So ... you've implemented a queue. 😉

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 37 of 39
(1,088 Views)

@FireFist-Redhawk wrote:

What I'm attaching is an old CLD sample exam that I did for my CLD prep. It also involves reading steps from a text file, and going to the next step when the time of the previous step has elapsed. Maybe looking at this will be a complete waste of time for you, maybe not. 

 

The two states in this that are most pertinent to what you are trying to do, are "Run" and "StepChange". I'll show a pic of the "Run" state for the class. It's from a while back and kind of ugly, so don't judge me anyone.

 

FireFist-Redhawk_0-1598473010924.png

 

So here, the Run state is self-enqueueing. I check a timer FGV to see if a certain amount of time has elapsed. If it hasn't, I just enqueue Run again. If it has, that's when I do what I need to do to get the next step going.

 

Now, my specific implementation was to keep a shift register of remaining steps to do. When time elapsed on a step, I delete it from the array and that's how I keep track of what I have and haven't done. The takeaway is that what I didn't do, was read my entire list of steps and enqueue everything at once from the get-go. Which is what you are doing.

 

Whew, what a throwback. Again I don't know if this will help you or confuse you even more but there ya go. Hopefully the former...


A little confusing, but I get most of it - maybe the shift register approach should have been taken from the beginning, but for me to go back and change it now would take a while, especially since I'd need a self-sizing array, because some of these scripts may be set to run for more than 24 hours... and I'm about out of time to reprogram anyway. But thanks for the input!

0 Kudos
Message 38 of 39
(1,065 Views)

@johntrich1971 wrote:


Put a timeout on the Dequeue and put anything that you don't want to run if no data is received on the queue inside the FALSE statement with the Timeout wired to it from the queue. You can leave the True case empty. Remember, LabVIEW is a dataflow language. A node (loop) can only continue when everything it depends on has completed.



Thank you, this has worked.

0 Kudos
Message 39 of 39
(1,017 Views)