From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-18-2018 08:23 AM
I have been asking constant doubts about oop and reference in LabVIEW for the past few days. I have finally understood something. So here I post a project. Project is simple. It has a class which has a numeric value as its data. I created VIs for data member access that is both write and read. Write VI writes the numeric value and read VI reads the numeric value. I have done this earlier but nothing happens. That is when everyone told me that when you split a wire you create 2 labview objects. So here I used queues with object oriented programming where I sent the object as a queue to the read and write vis, so that all the vis have the same object. Then i created the main vi outside the class where i entered a number to write numeric vi and then read the same number from read numeric vi without the 2 vis being connected. I was able to do it finally and got the output. Now what I wish is if you could check this project and tell me what can be improved. Are there anything in this that is not perfect. But I am able to get it perfectly the output. So please give it a check. Thanking you.
Solved! Go to Solution.
10-18-2018 08:23 AM
I have been asking constant doubts about oop and reference in LabVIEW for the past few days. I have finally understood something. So here I post a project. Project is simple. It has a class which has a numeric value as its data. I created VIs for data member access that is both write and read. Write VI writes the numeric value and read VI reads the numeric value. I have done this earlier but nothing happens. That is when everyone told me that when you split a wire you create 2 labview objects. So here I used queues with object oriented programming where I sent the object as a queue to the read and write vis, so that all the vis have the same object. Then i created the main vi outside the class where i entered a number to write numeric vi and then read the same number from read numeric vi without the 2 vis being connected. I was able to do it finally and got the output. Now what I wish is if you could check this project and tell me what can be improved. Are there anything in this that is not perfect. But I am able to get it perfectly the output. So please give it a check. Thanking you.
10-18-2018 08:32 AM
Second question : I accidentally posted the same topic twice and I want to delete the other posting of this topic. I will I do that.
10-18-2018 08:32 AM
Can you save the code for a prior version?
10-18-2018 09:13 AM
I have made it for labview 2014 version. Thank you.
10-18-2018 09:14 AM
@paul.r wrote:
Can you save the code for a prior version?
18 is too new for me as well...
10-18-2018 10:03 AM - edited 10-18-2018 10:29 AM
Yes, the code works to do what you want. However it is a convoluted, messy, un intuitive solution with race conditions, and completely breaks the behavior any experienced LabVIEW developer would expect from glancing at your code. I apologize for being harsh, but in other words, it is a horrible solution.
As many other posters have said, if you can more clearly articulate what it is you are trying to do and why, we can help you design a better solution. Assume that your test class is a hardware driver that is taking measurements from some hardware, and you need to get that measurement data to other parts of your code - a UI and data logger for example - a pretty common application. You should design your hardware driver class to be just that - a hardware driver. It interfaces to the hardware. It has a method you can call to get the data it read from the hardware back. That should be the extent of that class. If you design it that way, you can reuse that hardware driver class on another project with the same hardware. The internals of that hardware driver should not be tied to the details of the rest of the application - like you have done in your test class - that test class cannot really be reused, nor can you develop any sort of abstraction around it that would make sense.
Going back to the hardware driver example, use a mechanism external to the class to share that acquired data - put it on a queue outside the class, so that if you decide you would rather use a user event, a custom circular buffer, or some other data transfer mechanism, you can do so.
I uploaded an example class and simply UI to demonstrate this - notice that the HW class is completely removed from the queues or anything about how it is being used. If you had another hardware type you wanted to use, you would just need to design it to match the interface given. Which of the classes is easier to understand? Which one scales to an actual real world use case?