04-06-2020 05:54 PM
Waking a thread from a perfectly good 7 year nap... I *think* I'm trying to the same sort of thing, but simpler. When one downcasts a child class, but then the result is also needed on the grandparent class, does one do it the way I'm showing here? Still very uncomfortably muddled about all this LVOOP business, I'm afraid. Thanks! paul
04-06-2020 06:34 PM
You might be better served by opening a new thread as it looked like the previous thread was mostly about getting data from a parent to a descendant, but you're just trying to load in a specific type without regard to the data contained within it.
Can I infer from the screenshot that you're trying to do an abstraction layer where you issue generic commands to a Controller and Motor and so if you wanted to switch to a different vendor of motion controller all the code except the device type would remain the same?
If so, what you're doing looks like it will work if all you're trying to get from the code is a type. If you want to bring in any data, then that's more complicated.
04-06-2020 07:05 PM
Good idea Kyle, will do. I'll also flesh out my plan a bit later tonight
04-06-2020 08:10 PM
It looks like you're using "To More Specific Class" when you cast from a specific child to a more generic parent. You should use "To More Generic Class". The parent is *more generic* than the child.
(I recall either a thread around here or a conversation with a colleague some years ago where it was found that one of those two functions worked correctly regardless of whether the cast was *actually* to more specific or to more generic. But the other one didn't. That's my memory of it anyway, I don't have code handy to test it out.)
-Kevin P
04-06-2020 08:44 PM
I'll take Kyle's suggestion and start a new thread (although this stuff is banging around all over the forum, I can't seem to get a clear enough picture.