LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LVOOP: All "To More Specific Class" calls in Project throw error 1448

Hi guys--

 

I'm not entirely new to LVOOP, but I've never seen this before.  After a morning of hacking and testing on a project, suddenly every attempt to cast a Parent to a Child Class is throwing Error 1448 "Bad Type Cast...", despite the Class Hierarchy being obviously intact.  I even set up a simple test case with a hierarchy of LV Object-->Test Parent-->Test Child, and I still get the error.  I opened up a fresh project and ran the same test (just to check my sanity), and the same test worked with no errors.

 

Am I looking at some kind of project-wide corruption?  Anybody know of a fix for this kind of thing?

 

Thanks a bunch, and have a great day.

Message 1 of 7
(3,387 Views)

can you attach your test code? This way people can try it on their machines. Have you tried to control + shift + click run arrow to force a recompile? Have you tried the "obvious" things like shut down LabVIEW or reboot your computer?

0 Kudos
Message 2 of 7
(3,382 Views)

I'm having this same issue.  Restart LV, reboot.  This seems to be rooted in some basic misunderstand I have of things.  What am I missing here?  See attached.

CLA, CTA
Not my tempo... AGAIN!
0 Kudos
Message 3 of 7
(3,139 Views)

You cannot arbitrarily cast a parent into a child.  You have to start with the child class from initialization.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 7
(3,133 Views)

Indeed, that appears to be the case.  But the use of the word "arbitrary" is a bit misleading.  Why is this "arbitrary"?  The two classes have a relationship, and that relationship is inheritance. 

 

What I'm really asking isn't whether or not you can do this, it's clear you can't, unless you start with the child class.  "WHY can't I do this?" is what I'm really asking.  If I know, a priori when I'm writing the code what base class I will start with, but will dynamically choose the child, why can I not just use class constants and cast in this manner?

 

Thanks for your thoughts and feedback!

CLA, CTA
Not my tempo... AGAIN!
0 Kudos
Message 5 of 7
(3,117 Views)

For the reclassification to work, you need to have the correct internal data structures, else any attempt to use the child functions will fail.

So why use it?

It's used to be able to use class specific functions from generalized code.

It's good if you e.g. have several inheritance levels and writes the general code with the base class. As you might have noticed, it has a tendency to gather up lots of "dummy" functions only usable for a few subclasses. With reclassification you can access/code from another inheritance level.

 

E.g. in a project i did, all intruments were of an Instrument class, this was a pretty empty class but allowed us to have dynamic instrument lists of Instruments of different types. At measurement time we'd request get(instrName) and then reclassify to the instrument type we needed (it was ofcourse created as that type) to get the reading.

 

Did that make sense?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 7
(3,106 Views)

GarryG wrote:  "WHY can't I do this?" is what I'm really asking.

Because the inheritance does not go backwards.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 7
(3,093 Views)