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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Class Conflict On Object Wires

Does anyone know why I get a class conflict when doing the below:

ClassConflitBroken.png

All of the above objects desend from a common ancestor.  

 

I can fix it doing this:

ClassConflitFixed.png

Is this the correct way to get around it?   Do I lose the child specific member data when I recast it as the more specific class?

0 Kudos
Message 1 of 17
(3,896 Views)

HI,

 

Is the VI a dynamic dispatch?

-------
Mark Ramsdale
-------
0 Kudos
Message 2 of 17
(3,888 Views)

You can see that not all classes inherit from BRSIGHT, because there's a coercion dot on all inputs going into the build array primitive. If they all inherited from it, then the first terminal would not have a coercion node.

 

In the specific case of the code you show, this works because the first element (which is the one you take) IS a BRSIGHT, so casting it returns no error. If it wouldn't be a BRSIGHT, you would get an error out of the cast and a default BRSIGHT object. It's important to understand that the cast node doesn't change the object - the object always carries all of its data, regardless of the type of the wire it's on. Casting only changes the type of the wire, but the actual object on the wire has to be of the same class as the object wired to the type terminal.


___________________
Try to take over the world!
Message 3 of 17
(3,877 Views)

Here is the class hierarchy:

 hierarchy.png

 

0 Kudos
Message 4 of 17
(3,867 Views)

Hi,

 

I'll assume that the VI is a dynamic.  You probably have to put the parent level VI in place of what appears to be a child level dynamic dispatch VI.

 

If the VI is not dynamic, I don't think you can randomly wire up different object wires, maybe if the terminal is the parent object, but I don't think so.

 

 

-------
Mark Ramsdale
-------
0 Kudos
Message 5 of 17
(3,861 Views)

The "does not work" version (as posted by Yair) is casting all of your children to the parent type.

 

You can only use the Parent methods for a parent type wire.

 

When you cast the ref, the wire looks like the child so the child method is legit provided the selected class is the target class OR one of IT'S children.

 

So add the method you are trying to invoke to tha parent class. For all of the classes the Prent method will be used UNLESS the class selected has it own over-ride version.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 17
(3,856 Views)

I've attached my upper level architecture so its easier to understand what I'm trying to do.  I have a main acquisition loop (the bottom loop) and a GUI loop (the top loop). I have 7 video tests that all decend from a common ancestor.  These objects are converted to data references ( to avoid copying the objects when forking the wires) and then sent to each loop.  The top GUI loop allows the user to change what test is being applied to incoming video, and also allows the user to poke the various test objects to do interesting things (like read test values, set thresholds, etc).  Is this not how I should architect this?  Note I am not show the logic that selects the index of the object reference array, you'll just have to imagine it there 🙂

 

arch.png

0 Kudos
Message 7 of 17
(3,852 Views)

Did you see my post before posting the more complicated reply?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 17
(3,848 Views)

No, I didn't see your post before I posted again. However, I was under the impression that by overriding, I can make my children have more and more specific functions while retaining the common data between them.  What good is it if I have to include over rideable functions in my parent that are specific to my children?  I might as well just make seperate classes that don't share data.

 

I tried casting to a more specific class where needed, I just get this cryptic error:

 

err2.png

err2txt.png

0 Kudos
Message 9 of 17
(3,843 Views)
Sorry I was just trying to help. I will stay out of this thread. Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 17
(3,834 Views)