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.
06-18-2012 06:31 PM
Does anyone know why I get a class conflict when doing the below:
All of the above objects desend from a common ancestor.
I can fix it doing this:
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?
06-18-2012 09:51 PM
HI,
Is the VI a dynamic dispatch?
06-19-2012 05:20 AM
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.
06-19-2012 10:42 AM
Here is the class hierarchy:
06-19-2012 10:48 AM
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.
06-19-2012 10:52 AM - edited 06-19-2012 10:54 AM
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
06-19-2012 10:56 AM
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 🙂
06-19-2012 10:59 AM
Did you see my post before posting the more complicated reply?
Ben
06-19-2012 11:06 AM
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:
06-19-2012 11:17 AM