LabVIEW对象

时间:2020-03-06 14:46:36  来源:igfitidea点击:

我有一个基类对象数组,在其中键入了许多不同的子类对象,并将其传递给子vi。有什么方法可以找出数组中每个单独元素的对象的原始类型?

谢谢 ...

解决方案

NI对LVOOP进行了很好的概述,这是必须阅读的,因为OO是通过LabVIEW的独特方式实现的。

我们是否尝试过在应用程序控制面板上使用"到更通用的类"和"到更特定的类"功能?

为了后代,这被交叉张贴到LAVA论坛。用户Aristos Queue是LabVIEW原生OO功能的开发者之一,回答如下:

Using a dynamic dispatch method in every class is the recommended way of handling this, although the recommendation is to create a method that does whatever it is you're trying to do. I'm guessing that you're thinking of a dynamic dispatch method that returns a name or ID of the object so you can say, "Is it equal to this? Ok, then it must be this class..." and then you do Action X if it is that class. If you write a dynamic dispatch method ActionX.vi and then override it appropriately, you'll save yourself on performance and have much easier time for code maintenance in the future. 
  
  You can also use the To More Specific node to test if a given object can be downcast to a given type -- this allows for inheritance testing as opposed to the name or ID comparison that only does type equivalence. If the To More Specific node returns an error then it is not of the destination type. 
  
  So your options are (in order of preference):
  
  
  dynamic dispatch method that does the action
  To More Specific node to do type testing
  dynamic dispatch method that returns name/ID of the class of the object
  Get Path of LabVIEW Object.vi (shipped in vi.lib in LabVIEW 8.5 but not added to the palettes until LabVIEW 8.6)