LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

just a *slight* problem with the Factory Pattern (of my own doing, certainly)

Solved!
Go to solution

Hi folks - about 6 months ago I got a lot of help from several of you, and was able to keep limping forward, yay!  Thanks you, mentors!  So now I have a new Factory Pattern challenge.  My "Create My Class.vi" read a motor class file and creates a specific motor class.  Then I read an ini config file that tells me about a motor.  Then I load those parameters into the motor class' data. Everything compiles & runs with no errors.  Oh Joy! (I shamelessly stole the "Create My Class" idea from Daklu over at That Other Place).

 

but wait! the output Motor Class object does NOT, in fact, hold the data I just put in. If I go inside & probe at the output of the (Dyno-Dispatching) "Read & Load Motor Parameters From ini File.vi", yes, my new data is there in the probe.  But at the top level, probing where it "comes out" (the returned object), no data.

 

I have a vague & guilty feeling that I broke the DynoDispatch magic because there is a slight difference between my motor types.  So I guess maybe the compiler doesn't know how to jam my (just a tinch different) motor type into the parent class.

 

Is my conscience telling me the truth here?  I've had the "front panel objects must be the same..." thing drilled into my very soul, but all the bruises on my forehead have healed up.  Yes, my terminals & types are the same - so the compiler is happy, but I was still able to break it!

 

Does  this sound reasonable?  Much thanks for looking, paul

0 Kudos
Message 1 of 3
(1,159 Views)
Solution
Accepted by topic author PaulOfElora

Your data is in there but you're not seeing it if you probe the parent. You can try to use a "To More Specific Class" after loading the child class and downcast to the class that you just loaded and probe that output wire. Of couse you should remove this code after you're convinced. If you used a factory pattern, work only with parent methods in your app and override for child classes)Probe Child Class.png

Lucian
CLA
Message 2 of 3
(1,137 Views)

You're spot on, Lucian, my data is indeed there, lurking in the dark. I figured that when I probe *any* class of wire, I'm going to see *all* of the data on the wire.  I need to better understand this. Thanks much for you help! Paul

0 Kudos
Message 3 of 3
(1,130 Views)