LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop containing event loop and a regular loop result in system unresponsiveness

Hello All,

My name is gil and I have a problem.

I have customer specifications that force me to use event case and a while loop uner the same parent while loop

The codes must work in such a way: the while loop is connected after the event case so after the event case has reached the "Timeout" event, the next loop will statr working until it is stopped and then again to the event structure.

- as can be seen in file1.

The reason behind this is that the coustomre has already built events that both update the GUI and communicate with the hardware.

 

I have tested this configuration seperatly and It works rather well.

When implementing this code in the version. all of the controls become unresponsive and I cannot do anything.

I have placed a probe on the index of while that runs after the the event case, And I can see the number of itteration is growing, i.e. the program is running.

 

I cannot attached the original code due to proprietary issues. but I have attached a code the mimics the logic.

Can anyone please tell me why the system become unresponsive? 

 

Thanks!

Gil,

 

0 Kudos
Message 1 of 21
(1,803 Views)

Apply LabVIEW dataflow basics here: "A node executes only when data is available at all of its input terminals and supplies data to the output terminals only when the node finishes execution."

 

A structure is a node.  If the while loop that comes after the event structure has not finished, how is the event structure supposed to service any events?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 21
(1,798 Views)

Make sense! Think dataflow!

 

The outer loop cannot go to the next iteration until everything in it has completed, so if you press stop2, stop will still be false, thus reentering the inner loop. You need to press stop, then stop 2 to complete the code.

 

I assume that you have other events, such as value change for some of the booleans. Most likely these events are set to "lock the panel until the event completes", but the event can never complete while the code is inside the inner loop and pressing "stop 2" will not be seen if that happens.

 


@gilmaor1 wrote:

 

I have customer specifications that force me to use event case and a while loop uner the same parent while loop


Your customer is clueless. If he thinks he is so smart, why does he ask you to do the coding? I see serious architectural problems in the current design. I would just refuse to work for that customer unless he agrees on a better architecture.

Message 3 of 21
(1,797 Views)

Are you really *sure* that your customer insists on that kind of code structure?  It's a bad one, for exactly the reasons you're experiencing.  The inner While loop prevents normal responsive GUI event processing.

 

A much more typical approach would make that loop run in parallel to the event handling loop.  And it would then add some kind of messaging scheme where the event loop  "commands" the parallel loop to do things at the appropriate time.  You can still have the timeout case *initiate* action in the parallel loop, but this way you don't get stuck waiting for the action to complete.  (Of course, you still need to consider and manage the possibility of queuing up a whole series of actions for the parallel loop while it's still busy working on the first one...)

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 21
(1,783 Views)

@altenbach wrote:

Make sense! Think dataflow!

 

The outer loop cannot go to the next iteration until everything in it has completed, so if you press stop2, stop will still be false, thus reentering the inner loop. You need to press stop, then stop 2 to complete the code.

 

I assume that you have other events, such as value change for some of the booleans. Most likely these events are set to "lock the panel until the event completes", but the event can never complete while the code is inside the inner loop and pressing "stop 2" will not be seen if that happens.

 


@gilmaor1 wrote:

 

I have customer specifications that force me to use event case and a while loop uner the same parent while loop


Your customer is clueless. If he thinks he is so smart, why does he ask you to do the coding? I see serious architectural problems in the current design. I would just refuse to work for that customer unless he agrees on a better architecture.


Not to sound too harsh but the OP needs some serious training before they should be contracting their LabVIEW services out.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 21
(1,779 Views)

@Mark_Yedinak wrote:
Not to sound too harsh but the OP needs some serious training before they should be contracting their LabVIEW services out.

Agreed!

 

(I did not want to focus too strongly on terminology ("customer" etc.). Could be a K-12 student that got some poor code from the teacher, an undergraduate forced to extend code from a previous undergraduate, etc. 😄 )

0 Kudos
Message 6 of 21
(1,749 Views)

Why not create an action engine? A while loop that contains a case structure with a queue of values wired in. Create a nothing value in the case via your queue and in that case place an event structure that handles the necessary Booleans. Not knowing the root of your programming needs, I think this would benefit you in cleaning up your diagram and controlling rampant cpu usage. Below is a snippet of an action engine from an old project of mine. Hopefully this can help.sweat.PNG

Creig Mills
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 7 of 21
(1,744 Views)

Thanks for the advices.

For the time being I have circumvent the problem by removing the by uncheking the lock panel option. now I have to find the problematic event.

Gil,

0 Kudos
Message 8 of 21
(1,706 Views)

@gilmaor1 wrote:

For the time being I have circumvent the problem by removing the by uncheking the lock panel option. now I have to find the problematic event.

Gil,


You don't have a problematic event, but a problematic architecture!

 

 

0 Kudos
Message 9 of 21
(1,703 Views)

I Know.

What did, Is to remove all inner loop. and create case structure, where I control the their indexes.. and thus I creating "Loops" and loops within loops.

Thanks! 

0 Kudos
Message 10 of 21
(1,693 Views)
Products may include a surcharge. Surcharge is calculated during checkout for U.S. customers. Learn more