LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structure and while loop

Solved!
Go to solution

From what I've been reading so far its not a good idea to place a loop inside an event structure. Before I found that out  I used one of the discussion grp examples for picture ring in which a png is played over and over ( the do while loop) .  It shows a printer w the paper in various postions during print.  My event ( simplified) is PRINT or STOP.  I want it so that when the user hits print it prints the file ( I have a vi that does this already) and runs the code that shows the paper being printed ( I also have that code working).  Would I be better off using a statemachine w consumer/user or can I keep my event/loop code?  BTW I can't get the event/loop code to work together so some help here if thats the way to go.

Thanks..

 

0 Kudos
Message 1 of 15
(3,706 Views)
Solution
Accepted by topic author Clint_Eastwood1000

Hi Clint,

 

when you want help on your code you should attach it here…

 

You could:

- put your ring change code into the TimeOut case of your event structure (but not within a loop). Each TimeOut will update the ring in case you print some sheets of paper…

- use a consumer/producer structure with parallel loops…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 15
(3,702 Views)

Thanks.. The code is on a test set and for co policy I can't post it..  I guess I'll try the consumer/producer.  Just wanted some confirmation..

0 Kudos
Message 3 of 15
(3,696 Views)

@Clint_Eastwood1000 wrote:

From what I've been reading so far its not a good idea to place a loop inside an event structure. Before I found that out  I used one of the discussion grp examples for picture ring in which a png is played over and over ( the do while loop) .  It shows a printer w the paper in various postions during print.  My event ( simplified) is PRINT or STOP.  I want it so that when the user hits print it prints the file ( I have a vi that does this already) and runs the code that shows the paper being printed ( I also have that code working).  Would I be better off using a statemachine w consumer/user or can I keep my event/loop code?  BTW I can't get the event/loop code to work together so some help here if thats the way to go.

Thanks..

 



Misquoted, you shouldn't have long running code in an event case since it'll lock the events. E.g. if you want to click Cancel while printing it wont work.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 15
(3,680 Views)

OK..thanks.

0 Kudos
Message 5 of 15
(3,677 Views)

Gerw, I guess I thought I knew what was going on..Is this thread still open?

0 Kudos
Message 6 of 15
(3,652 Views)

@Clint_Eastwood1000 wrote:

Gerw, I guess I thought I knew what was going on..Is this thread still open?


Technically, yes.  If Gerd's post didn't solve your issue, then you should unselect it as the solution so more people will check out your thread.

 

So what do you not understand about what your code is doing?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 15
(3,646 Views)

I looked up "queue" in examples. "Outside" the event structure I obtain the que.  I have 2 buttons for the event..STOP and PRINT.  When I hit print it calls easy text.vi which does somethings and prints out the file I wanted.  Simutaneously I want the vi to show, using pict ring, a sequence of pngs which show "paper" being printed out.  I have the pict ring and easy test vi working.  If I'm using queues what do I que up ( in the producer) and what do I de-que in the consumer??  The pict ring vi uses a do while loop because it has to keep going thru a list of the enums in the pict ring to display various stages of "print".  I want the pict ring vi to stop once the file is printed out.  So do I que up the boolean to stop the pict ring vi?  I have event w the PRINT ( using the easy print.vi) and pict ring .vi in it.  The STOP button just passes "T"  boolean to the stop in the outer do while loop??

0 Kudos
Message 8 of 15
(3,637 Views)

Here, give this VI a try.

 

Watch the data flow.  What you need is to use the error wires to sequence when things happen.  You want the While loop and the Print to happen in parallel.  So you have to make sure they have no data dependencies.  When the print is complete, then you enqueue the TRUE.  Also, you will need to supply a timeout for the Dequeue in order for the ring to update.  Otherwise the Dequeue will wait forever and your loop won't iterate.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 9 of 15
(3,631 Views)

Thanks in advance.  Each one of you helped contribute to a solution..

0 Kudos
Message 10 of 15
(3,620 Views)