LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware Abstraction Layer using Object Oriented Programming: Adapting to different output type interface

Solved!
Go to solution

You can make a malleable VI which can use a type specifier to link to a (non-inherited, non-dynamic dispatch) NAMED method of a class.

 

If you give all of your different Datatypes a method "Read Result.vi" but these are static dispatch, you can create a malleable VI to automatically link to this named method of a class.

 

http://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/vim_adapting_to_input_classes/

0 Kudos
Message 11 of 26
(881 Views)

@Intaris wrote:

You can make a malleable VI which can use a type specifier to link to a (non-inherited, non-dynamic dispatch) NAMED method of a class.

 

If you give all of your different Datatypes a method "Read Result.vi" but these are static dispatch, you can create a malleable VI to automatically link to this named method of a class.

 

http://zone.ni.com/reference/en-XX/help/371361R-01/lvconcepts/vim_adapting_to_input_classes/


I almost mentioned the malleable VI.

 

Do note that you won't get run time polymorphism with that, just compiler time polymorphism. So the vim will accept anything that fits, but you can't put it in an array. You need interfaces for that.

0 Kudos
Message 12 of 26
(877 Views)

Just to clarify, you can put multiple Objects of the same class into an array and still do this, you just can't put DIFFERENT types into an array and expect the malleable VI to work, because it goes on the Wire type which becomes the nearest ancestor for mixed class arrays.

 

There are some other limited cases where this still works.

Message 13 of 26
(871 Views)

wiebe@CARYA wrote:

3) Wait for LV2020.

So you'll have G interfaces to work with. This means you can add functionality to classes that are not in the same hierarchy. The lack of interfaces has been holding back HAL development a bit... See this site.

 


First I'm hearing about this...

 

source

0 Kudos
Message 14 of 26
(853 Views)

@BertMcMahan wrote:

wiebe@CARYA wrote:

3) Wait for LV2020.

So you'll have G interfaces to work with. This means you can add functionality to classes that are not in the same hierarchy. The lack of interfaces has been holding back HAL development a bit... See this site.

 


First I'm hearing about this...

 

source


Yes, very exciting!

0 Kudos
Message 15 of 26
(851 Views)

In fact, that is just an example to explain the situation. My project is also similar with that. A DAQ can generate a waveform type data. But another hardware will generate an array of double type. Obviously, they are different type data.

0 Kudos
Message 16 of 26
(830 Views)

Thank you for your answer. But I am not really aware of it. What do you mean of visualize? Is that a parent class? I think variants are not a good option since they will generate run-time errors. But could you please give more detail of number 4.

0 Kudos
Message 17 of 26
(829 Views)

I learned about mallieble vi. But as mentioned, it is not polymorphic vi. there will be run-time issue.

0 Kudos
Message 18 of 26
(816 Views)

@champion2019 wrote:

I learned about mallieble vi. But as mentioned, it is not polymorphic vi. there will be run-time issue.


It is polymorphic, but at compile time. For instance, a simple increment is polymorphic. It will adapt (morph) to a double or an integer (poly). A vim does this too, so it is polymorphic.

 

You have to balance between the two options:

+ Rigid structure, and compile time error .

+ Flexibility, and run-time errors.

 

You're asking for polymorphism in a was that everything fits everything. That automatically means no compile time errors. If you want compile time errors, a structure where everything fits won't do it.

 

Put it in another way, you're asking to program your way out of the rigid strict typed data. The penalty is that the compile doesn't know about the strict types anymore, and you'll lose compiler time errors.

0 Kudos
Message 19 of 26
(786 Views)

Well, I might get how to do that. Here is a link that exactly described this issue. And it is a little bit hard for me to understand. But finally I figured it out. 

https://forums.ni.com/t5/LabVIEW/Display-different-measurement-data-types-with-dynamic-dispatched/m-...

0 Kudos
Message 20 of 26
(765 Views)