LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot Write via Control Ref into Class VI

Solved!
Go to solution

LV2013 SP1, Win7

 

I'm an old hand at LabVIEW, and at object-oriented programming in other languages, but fairly new at LVOOP.

 

 

This code worked fine until I put the user interface part into a CLASS.

 

I'm trying to read a (TDMS) file and populate a series of controls WITHOUT KNOWING THEIR DATA TYPES.

 

Simply pass an array of control refs to a VI, and later tell it to save to a file.  The VI constructs TDMS Property names from the control labels, and gets their values as variants, suitable to write to a file.

When reading, the names in the file are matched up to the control labels, and the controls SHOULD BE populated.

 

As I said, this worked fine before I put it into a CLASS.

 

 

Here is the UI in question - there are four controls I wish to save/restore.

This is within a class.

I collect the four references, and pass them to a PARENT CLASS method

F1.PNG

 

 

 

Here is the PARENT class method - it simply passes the Control refs to a non-class method, which remembers them via a "signature" identifier.

F2.PNG

 

 

 

Here is the READ part of that Property Storage Manager.

All properties in the file have been read into arrays.  Here we match up a given control's NAME with a name from the file, and set the value of the control once we find a matching name.

 

F3.PNG

 

 

But it doesn't work.  The control's value is not changed.

 

Here is a debugging log excerpt:

F4.PNG

 

I KNOW that the Control Ref is correct, because the NAME that is logged comes from the CONTROL REF itself.  The names are not remembered.

The VALUE in that debug log comes from the file.

There is no error shown.

But whatever is in the control on the panel is NOT affected.

The setting the label text color to green is just a debugging attempt - it does NOT affect the control either.

 

Is there some sort of security "shield" that prevents me writing to a control inside a class?

 

Seems like that should cause an error, if so.

 

Again, this worked fine before classes were involved...

 

Anything else I am missing?

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 1 of 7
(3,235 Views)

Forgot to mention, that the root VI is in one PPL (.lvlibp), the parent class is in a different PPL, the child class is in a different PPL.

 

Not sure if that affects anything.

 

Before I used classes, the root VI was in one PPL and the UI part was in another, and it worked.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

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

Hmmm.  A light begins to flicker

 

 

Here is the complete class.   The only thing I want to show is the ADDON UI method.  

F1.PNG

 

That's actually put into a subpanel, so that the controller can handle mundane stuff like menus and window position saving, without each addon having to do those things.

 

Here is the controller code, which inserts an addon into a subpanel and waits for it.

 

F2.PNG

 

 

But before I insert it, I need to find out the SIZE of the UI part, so I do this:

F3.PNG

 

This code was scrounged from the non-class version.

 

It seems like that is WRONG - I'm opening ANOTHER copy of the one VI. and using that to get the panel bounds, which is fine, but THAT is the one I am inserting into the SubPanel !

 

Thre might be TWO copies of the UI running - one properly running in the object, and this one which is apparently an orphan.

 

The low level code is working properly, I bet - it is writing the values to the controls that are invisible. Nobody touches the ones that are showing.

 

Hmmm.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 7
(3,219 Views)

Yes, that has to be it.

 

A TIMER on the front panel fails to run.

 

The VI that I'm putting into the SubPanel is NOT the one that is actually running.

 

So....

 

Given a path to a PPL, how can I get a REFERENCE to a VI that is part of that class, in order to:

1... Get its panel size.

2... Insert into a SubPanel.

 

?

 

F3.PNG

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 4 of 7
(3,214 Views)
Solution
Accepted by topic author CoastalMaineBird

I suppose I can:

1... Open a separate reference (and then close it) just to get the panel size.

2... Pass a REF to the SUBPANEL into the class, and have the UI method insert itself into the subpanel.

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 7
(3,206 Views)

Yes - that was ineed the problem.

F9.PNG

 

Thanks, folks !

 

You guys are the best !

 

😉

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 7
(3,197 Views)

I'll just park my avatar here for posterity..... Smiley Tongue

0 Kudos
Message 7 of 7
(3,194 Views)