LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

# of elements in queue

Solved!
Go to solution

Brandyn,

 

Isn't a state machine still considered polling? I guess I don't see the difference between the way I have it written now and the State Machine idea.

 

I've used your ideas in the updated code.

0 Kudos
Message 21 of 36
(1,104 Views)

State Machines inherently arnt polling, its the action of continuously having your while loop iterate that makes something polling.  Notice on your dequeue function you do not have a timeout wired.  The default is -1 which means it will sit and wait until it has something to dequeue. Implementing a state machine in the consumer loop will provide a lot more flexibility and scalability.  

 

Im curious.  In the updated code, whats the purpose of the while loop with the queue status function? 

Certified LabVIEW Architect
Certified Professional Instructor
0 Kudos
Message 22 of 36
(1,102 Views)

That one was a suggestion from crossrulz on Message #11. Basically, instead of looking at the elements in the queue each time the consumer loop made a pass, his idea (how I interperted it) was to just move it down to the other while loop to see how many items were left. When it's zero, it jumps out of the While Loop, releases the queue (and errors out the dequeue element) and closes out.

 

I'll take a stab at the state machine idea. Thanks for all of your suggestions.

 

Eric

0 Kudos
Message 23 of 36
(1,098 Views)

Ahhhhhh....yes, sorry normally Im used to having the producer on top and consumer on the bottom.  Please excuse the brain fart.  But when I have time later tonite, I will show you what I mean about having a state machine in the consumer loop.

Certified LabVIEW Architect
Certified Professional Instructor
0 Kudos
Message 24 of 36
(1,096 Views)

@Eric1977 wrote:

That one was a suggestion from crossrulz on Message #11. Basically, instead of looking at the elements in the queue each time the consumer loop made a pass, his idea (how I interperted it) was to just move it down to the other while loop to see how many items were left. When it's zero, it jumps out of the While Loop, releases the queue (and errors out the dequeue element) and closes out.

 

I'll take a stab at the state machine idea. Thanks for all of your suggestions.

 

Eric


While this works it is a sketchy architecture at best and once again turns the system into a polling system. I hate to harp on it and crossrulz will probably call me out on it but explicit control of the system is a more robust architecture. Granted, most of the stuff I work on are fairly large system and require the extra complexity just to get a maintainable system but I have learned over the years that even small projects can end up growing and take on a life of their own. Adopting good practices in any code you develop makes expansion and maintenance much easier. Also, if you think things through a bit and consider reuse from day one you end up developing some nice libraries over time as well as common approaches to things. Each system you develop becomes easier to implement because you are building upon proven techniques and code.

 



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
Message 25 of 36
(1,088 Views)

I havne't looked at the code, but to ensure that the queue is finished before exiting; Stop button should enqueue a Stop command and exit it's producer loop. Thus the consumer will consume all commands until it encounters Stop and exits and destroys the queue.

 

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 26 of 36
(1,081 Views)

@Mark_Yedinak wrote:
I hate to harp on it and crossrulz will probably call me out on it...

Actually, I'm in full agreement with you Mark.  I just made that suggestion just as an option.



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 27 of 36
(1,063 Views)

@Brandyn wrote:

Ahhhhhh....yes, sorry normally Im used to having the producer on top and consumer on the bottom.  Please excuse the brain fart.  But when I have time later tonite, I will show you what I mean about having a state machine in the consumer loop.


I look forward to it. Smiley Happy

0 Kudos
Message 28 of 36
(1,057 Views)

Eric,

 I apologize I was not able to get to it last night. I will try my best to get it up between tonite or tomorrow. 

Certified LabVIEW Architect
Certified Professional Instructor
0 Kudos
Message 29 of 36
(1,044 Views)

That is quite alright. I was off for the weekend.

0 Kudos
Message 30 of 36
(1,022 Views)