11-01-2012 01:45 AM
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.
11-01-2012 03:04 AM
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.
11-01-2012 05:05 AM
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.
11-01-2012 05:15 AM
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.
11-01-2012 05:31 AM
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.
11-01-2012 06:34 AM
So is it possible to queue them without building an array?
11-01-2012 07:12 AM
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://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
11-01-2012 08:34 AM
Thanks a ton.
Let me study these carefully and get back.
11-01-2012 09:38 AM
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.