LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with consumer/producer loop.

I've decided to use a Producer-Consumer architecture for a project, but it is my first experience with one and I'm having a problem. To operate the program as I have so far: 1. Select an active device button (1 of 10) 2. Select "Start Burn In" 3. (May repeat process for any or all of the active device buttons - all 10 can be active at once) 4. To stop burn in for any device select "Stop Burn In" for the selected active device button. The way I have it shown in 1.VI it does what I expect. But when I try to add code in the "TimeCheck" case of the Producer loop things do not work. This can be shown by removing the disabled loop in "TimeCheck". The intent of data in the "TimeCheck" case is to run continuously for all loaded devices as individual devices are started and stopped, or stop automatically after 48 hours. As an alternate approach, I also tried putting the code I have in the "TimeCheck" case directly into the "TimeOut" event, but I couldnt get that to work either. Notice in 2.VI I tried just putting a while loop into the "TimeOut" event and it doesn't execute. Any help is greatly appreciated.
Download All
0 Kudos
Message 1 of 25
(3,373 Views)

Your code is incompletely posted, referring to VIs scattered all over that are not included:  E:\Take Home Work, HP34970a.llb, other VIs in the same folder, etc.  Hard to make sense of it that way.

 

You say that "all 10 devices can be active at once", yet you have a single shift register that stores -THE- active device. 

 

 

 But when I try to add code in the "TimeCheck" case of the Producer loop things do not work. 

 

--- I don't understand.  The way I see it, the Producer is the upper loop, since it produces some sort of task-control cluster for the other loop to use.

The bottom loop looks for these clusters and executes them, therefore it is the consumer.

 

I see no code in the TIMECHECK case of the consumer.

 

--- You have a TYPEDEF for the control cluster definition - why in the world don't you use the names it provides?  the BUNDLE BY NAME function would be clearer than just a BUNDLE.

 

 

I recommend a state-machine approach for each device.  

Make a single CORE VI that handles ONE device, and stores all info needed about that one device in shift regs.

Make it re-entrant.

 

Make a "Master" that has the same inputs and outputs, but ALSO has a device-select input.

The master holds 10 copies of the CORE VI, and chooses which one to call based on the device-select input.

 

It's a WHOLE LOT less pain for you.

 

My blog has an entry for that : State of the Machine

 

Message Edited by CoastalMaineBird on 04-17-2010 03:47 PM
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 25
(3,359 Views)

WOW!

 

uhmmmm.... OK you need to add a lot of comments to your code- and look at the style guide.  And YES- there is a lot of WEC in there (WEC- Wire equivalent code)

 

 

That being said the " TimCheck" state is the default state that you enter whenever the dequeue element function returns- Like when the queue is destroyed or a "Default" is enqueued.    turn on highlighting and see what's really happening.... and what you expect

 

You are getting bit by the "use default if unwired" tunnel in the producer loop. 

 

I would suggest enqueueing INSIDE the event structure.  Smiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 25
(3,354 Views)

I've posted the remaining VIs. The reason I don't use a state machine for each device is because I'm uning only one CAN device.

0 Kudos
Message 4 of 25
(3,315 Views)

Jeff,

 

I believe I made the changes that you suggested in 3.vi. I don't understand why the "For Loop" in "Time Check" (which is where I want to put all my VIs in the form of a state machine for periodic checking) doesn't work.

 

Thank you.

0 Kudos
Message 5 of 25
(3,305 Views)

OK I still cannot load your code completely, because it refers to things that don't exist on my system.

 

 Something called "Test 1.vi" in LabVIEW 8.6/Examples.  It's not a good plan to have code scattered all over your file system.

 

I assume you're judging that the FOR loop doesn't run, by the fact that the NUMERIC 2 does not increment.

 

If that loop is not running, it has to be because the CASE containing it is not executing.

 

That would be indicated by the NEXT STATE indicator NOT showing "TIME CHECK" - does it do that or not?

 

If it does NOT, then it's not coming out of the queue.  I wonder why not?

 

You carry the ERROR line around, but you don't ever check it, that I see.  Maybe there's an error occurring - probe it and find out.

 

If it's not coming OUT of the queue, then maybe it's not going INTO the queue.  

 

Chase the problem from the end backward, and from the start forward.  These are basic debugging skills that you will need.  

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 6 of 25
(3,297 Views)

Steve,

 

I think your right on it here!  Either a type def is out of sync- causing the dequeue element to fail or an error is occeuing in the consumer loop and being passed back to the dequeue element function.  and the consumer loop is halted.

 

Try replacing the error Shift Register with a tunnel.


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 25
(3,289 Views)

There's some basic misunderstanding here - there's a WHILE loop with a TRUE constant tied to the STOP terminal.  That means it will never loop.  Since there are no SRs in that loop, the loop does nothing except obfuscate the intent.  Another loop has a TRUE constant tied to the STOP terminal.  It has shift registers, but they are never changed within the loop, and since they are initialized outside the loop, the loop is completely pointless.

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 8 of 25
(3,279 Views)
That didn't seem to make a difference.
0 Kudos
Message 9 of 25
(3,270 Views)

That didn't seem to make a difference.

 

 

Just so you know, I can't tell to whom you are replying, nor what the "that" refers to.

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 10 of 25
(3,264 Views)