LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queued state machine with Producer Consumer

Solved!
Go to solution

You should really consider using a state machine in your consumer. Your current logic is very convoluted and does not implement the basic requirements of the car wash example. Not to be harsh but based on this code I don't believe you are quite ready to take the CLD test yet. You need to get a better grasp on the basics of LabVIEW and how things work. For example, why are you dequeueing elements, adding them to an array then indexing that array and feeding that in all kinds of conditional tests and then feeding a case structure. The most basic example of a LabVIEW state machine would dequeue the element and use that as the input into the case statement. In addition, the code is not very neat or organized. Even if this code worked it would not pass a CLD exam. Give yourself a bit more time to learn LabVIEW and get practiced in good coding style before you attempt the exam.



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 11 of 19
(1,715 Views)

Hello Mark,

 

Sure I will take in all your inputs regarding the CLD.

 

Well I was wondering if you could please help me understanding how I could apply the queuing concept to the Car Wash Example.

Let me explain my problem,

 

When I dequeue and directly wire to the case structure in the consumer, it will immediately go to that sate.

However, the car wash application requires the user to select the states first, then disable the control

and index through the states one by one with some timing in between.

Therefore I need to collect the selected states somewhere before I run through them, right ?

How can I do this without building an array ?

 

Secondly, can you point me to some good resource for learning the style aspect that you mention about ?

 

Thanks so much,

Hope to get there soon.

0 Kudos
Message 12 of 19
(1,710 Views)

The whole point of queue is that it will store your states till you dequeue them. What I would do is when the state is first called, disable the front panel controls and then start the timer. I will enqueue a new state TO THE FRONT OF THE QUEUE http://zone.ni.com/reference/en-XX/help/371361H-01/glang/enqueue_opposite_end/ (CheckTimer or something similar) to the queue and basically it just loops in the consumer loop until the timer expire. However, you need to make sure that you are checking for the stop button too, you can use preview queue element to do this http://zone.ni.com/reference/en-XX/help/371361H-01/glang/preview_queue_element/.
Once the timer expire, enable the controls and the consumer loop will wait till a new element is added to the queue.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 13 of 19
(1,701 Views)

In the Car Wash, the user selects the front panel controls (or washes if you may) at one shot. After he presses the start button, then you are supposed disable the front panel controls and traverse the selected states one by one.

Based on whar you are suggesting if I understand correctly, the user will select a state, immediately it will get enqueued and dequeued and the timer will start, along with the fromt panel controls getting disabled. Once the timer elapses, the front panel controls will get enabled once again and the user will select another wash option.

But this is not the desired functionality as he will be selecting the wash options one by one and not in one shot.

Please correct me if I am wrong interpreting your reply.

0 Kudos
Message 14 of 19
(1,698 Views)

Well that's the gist of it. Basically, based on the program he selects, you know the states you need to traverse, so queue them all to the queue and the dequeue them and check timer in each of the respective states.


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 15 of 19
(1,694 Views)

So is it possible to queue them without building an array?

0 Kudos
Message 16 of 19
(1,689 Views)

Yes.

Look at the attached zip file. This was published by NI a long while ago, they also have evaluation sheets for each of the code. This may be of help.

 

Also look at the following links for guidelines:

http://search.ni.com/nisearch/app/main/p/bot/no/ap/global/lang/en/pg/1/q/LabVIEW%20Development%20Gui...

http://zone.ni.com/reference/en-XX/help/371361H-01/lvdevconcepts/style_guidelines/

http://zone.ni.com/reference/en-XX/help/371361H-01/lvdevconcepts/checklist/

 

CLD Exam Webcast

http://zone.ni.com/wv/app/doc/p/id/wv-179


CLA CTAChampionI'm attending the GLA Summit!
Subscribe to the Test Automation user group: UK Test Automation Group
0 Kudos
Message 17 of 19
(1,684 Views)

Thanks a ton.

Let me study these carefully and get back.

0 Kudos
Message 18 of 19
(1,675 Views)

Generally for this type of program you could build the array of elected wash states in the producer loop. Then when the user hits the Start button you would simply enqueue each array element that you have buffered. So, within the producer loop you would have the array of wash actions. Each time the user selects a given action you would add it to the array. When the Start is hit you would loop over the accumulated array and post each to the queue. The consumer would then get the individual actions to perform in th eorder they would need. There is a problem with this archtecture though. In a normal car wash there is a finite number of wash modes and they must be executed in the correct order. In addition, there can only be one of each mode selected for a single wash. Given the way you are chosing to implement this you would not be able to enforce those modes. Your mode selection should really be a static mode which is selected or not. When the start is hit you would enqueue each of the selected modes in the correct order.

 

As for style you can look at the NI LabVIEW style guide or get a copy of The LabVIEW Style Book by Peter Blume.



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 19 of 19
(1,666 Views)