06-30-2014 05:51 AM
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..
Solved! Go to Solution.
06-30-2014 05:54 AM
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…
06-30-2014 06:06 AM
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..
06-30-2014 06:19 AM
@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
06-30-2014 06:21 AM
OK..thanks.
06-30-2014 09:07 AM
Gerw, I guess I thought I knew what was going on..Is this thread still open?
06-30-2014 09:19 AM
@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?
06-30-2014 09:57 AM
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??
06-30-2014 10:29 AM - edited 06-30-2014 10:29 AM
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.
06-30-2014 11:04 AM
Thanks in advance. Each one of you helped contribute to a solution..