08-14-2019 11:42 AM
Hi,
I am starting with LVOOP and, after watching all the videos available in youtube and reading the topics available in this link:
I have started to write my own first implementation. I am trying to do a simple waveform generator in which the user select first a type of waveform (constant, ramp, sine) etc, then a pop-up asks for the required input date (amplitude, duration, frequency, etc) and finally the waveform is printed in a chart.
I have designed the class hierarchy as follows:
I have successfully created all the classes and Dynamic Dispatch vis:
And here is where the confusion begins...I want to keep the implementation as simple as possible and have an Override vi for each method (SetWaveformDetails.vi, etc) but as every class has its own internal data, if I try to bundle the input from the user into the data cluster for each class I get an error that the pane connector does not match...
I can work around this by adding a case structure and using To more define class... but then I don't see the advantage of having this implementation vs using subvis...
Is there another way to load data into children class using only Override vis?
Kind regards,
08-14-2019 12:20 PM
I have had the override VIs read data from a configuration file and load up whatever data they need that way. You could possibly also make the override VI be a dialog to allow the user to input the values. Otherwise, yes, you are left with individual VIs to initialize your classes. It is the rest of your application that will reap the benefits of OO.
08-14-2019 01:54 PM
@crossrulz wrote:
I have had the override VIs read data from a configuration file and load up whatever data they need that way. You could possibly also make the override VI be a dialog to allow the user to input the values. Otherwise, yes, you are left with individual VIs to initialize your classes. It is the rest of your application that will reap the benefits of OO.
I would also use either a configuration file or a configuration UI that is opened by the child class.
08-14-2019 04:55 PM
I notice that the terms you use to describe what you want to do, a "popup" to set parameters followed by getting a "waveform" for a chart, are unrelated to your list of methods. Where is your ”popup" method?
08-14-2019 08:55 PM
To solve your immediate issue, you can set the data types of the override VIs as variants, then pass in data that way. The child override VI would then need to convert the variant to the appropriate type (and handle unknown types).
This method isn't ideal as the calling code still needs to know which child method is being called to pass in the appropriate data type, negating the dynamic dispatching benefits of OO. The methods others have mentioned are better OO solutions.
08-22-2019 09:51 AM
Hi, Thanks for your replies and apologies because I can only work On and OFF on this..
@MichaelBalzer wrote:
To solve your immediate issue, you can set the data types of the override VIs as variants, then pass in data that way. The child override VI would then need to convert the variant to the appropriate type (and handle unknown types).
This method isn't ideal as the calling code still needs to know which child method is being called to pass in the appropriate data type, negating the dynamic dispatching benefits of OO. The methods others have mentioned are better OO solutions.
As far as I understood, variants are a big NO, so I will try to stay away from them.
I have decided to create a couple of more classes to try to solve this problem. One is a "data loader" type which basically will take data from somewhere (user input, file or serial port) and load it into the class. Finally I have created another class to determine which type of file to be loaded (in case the load from file option is selected.)
I have followed some of the advice and I have decided to implement the UI based vi for the user input option.
The problem I am having is similar to the example in the Introduction to LVOOP video:
And they propose to have a different class hierarchy to obtain the measurement. However I am getting a bit confused on how to interlink the classes.. is there any example that I could take a look?
Thanks a million for your help