LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OOP learning

Solved!
Go to solution

So I was trying to learn OOP and Inheritance. So I made this program that is basically a cash register for a coffee shop.  I believe the OOP part of the program is fine. I am sure there are a lot of improvements can be made but for a beginner to OOP I think this is fine, but maybe I am wrong. The sad part is the main VI where all the classes are connected, that's where the problem is. And the problem is with event structure which is basics and I feel embarrassed on getting this wrong. For one thing, the stop button is not working. I click stop. There is an event called stop value change. It goes into that event, stop is true, but the true value does not come out of the event structure to stop the while loop. I don't know what the issue is. There are some other issues as well, which is again a problem with the event structure. Here is a brief description of the program :

There is a parent class called hot drink and its child classes are the four drinks for the cash register, i.e. espresso, cappuccino, hot chocolate and tea. Each has two or three data in its cluster, i.e. price, size and milk used. There are method VI's to enter price, get price, select size and select type of milk used. The enter price VI is not used. It's simply there. Price is entered in the select size, according to the size selected the price will be entered into the class wire. There is a 5th class called total price which takes in a hot drink class in its cluster and every time you select a hot drink this class will add to the total prize. Now in the main program, there are four buttons for the four drinks Espresso, Cappuccino, Hot Chocolate and Tea, three buttons for its size large medium and small, 5 buttons for the different milk type and add to cart button and print bill button and finally stop button. Now all sizes are not available for all drinks and all milk options are also not available for all drinks. For e.g. : espresso has no large size and none of the milk option. So if you click espresso, large and all milk buttons will be disabled. So you select a drink by clicking the button, then click the size and if you need special milk click on that and click add to cart, current total price is shown. And you select the next and son on. When done, click print bill, and everything is reset. 

 

This is the program. So the stop button is the problem. I also saw the same problem where I click the print bill. It should go to the case structure below in a case called reset price. But the case is not entering. These are the two problems. Maybe there are more. I have attached the project.  Kindly give a check on my program and help me correct the mistake. Thank you

 

0 Kudos
Message 1 of 5
(1,211 Views)
Solution
Accepted by topic author govindsankar

The even is caught by the event structure.

 

Then you enqueue an item ('stop') on queue, but the other queue waits forever... 

wiebeCARYA_0-1683277090769.png

Message 2 of 5
(1,178 Views)

I'd really, really advice very strongly against naming queues.

 

Naming a queue creates a global resource, and globals are never a good thing and named global resources are even worse. In this case, naming the queues adds nothing.

 

In stead, label the type control. You'll see this label in the help when you hover over the queue wire.

Message 3 of 5
(1,172 Views)

Thank you. Ok I didn't know that. So the problem was with how I used the Queues. I see that I don't need dequeue in every case. So instead of having one dequeue outside the case structure, I moved it to all the cases that need it inside the case structure, and then the program works fine. There was an additional error, but that I solved by using flush queue and release queue. The problem was I clicked on one of the drinks say hot chocolate, but I decide I don't want it then I clicked print bill, everything will be reset except the queue. The queue will still have hot chocolate. So for the next order when I enter say espresso, the previous hot chocolate was coming in. But that was solved by using flush queue when you press print bill. And finally used release queue when we press stop. So now the whole program is complete, and I have an idea of OOP and inheritance. I have uploaded the corrected version. If anyone wants to take a look and suggest some feedback, kindly let me know. Thank you. 

Message 4 of 5
(1,108 Views)

An additional trick is to enqueue clusters, containing the command enum, and a variant or class! providing additional information.

 

You can even enqueue just the class, e.g. a command class. The class could have an execute method, so the 2nd loop can simply execute the enqueued command, and dd will take care of handling the specified command,

0 Kudos
Message 5 of 5
(968 Views)