LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reference to a variable

Hello,

 

I'm a medium ability LabVIEW person, been doing it for about 2 years now so I can do the basics but still have a lot to learn.  I've been a C++ guy in a past life so I'm wondering if someone can help me with a pointers and/or references question in LabVIEW.

 

I'm trying to create a DataLogging Object in Labview.  Its fairly simple, all it really has to do is write a row of numeric data to a SQLite database every time someone calls DataLogger.Log().  The row is an array of floating point values as private variables within the class, with a timestamp.  I understand that this will write the values inside the array each time DataLogger.Log() is called and they must be updated by calling another method to push new values into those properties as the program runs so that new values are pushed in before the next call to .Log().  That part I've pretty much figured out, including the SQLite writes.  The idea is that at the beginning of the program, you create a DataLogger object, and all the variables in the program it will be logging as controls or local variables, then when its time, you call the Log() method and everything gets written to database, with a timestamp.

 

Back in my C++ days I could create a reference or pointer to some other variable OUTSIDE the class so that when you call .Log() it de-references all those pointers to outside variables to get up-to-date values and then those are written to the database file.  This is much better IMHO than calling some DataLogger method to copy values into a private array of variables, which are then copied to database.

 

Is there some way to have an array of pointers or references to these outside variables in LabVIEW?  I did a lot of reading but didn't get very far.  Help is appreciated.  Thanks.

 

-John C.

0 Kudos
Message 1 of 5
(3,436 Views)

You can pass in references to front panel objects such as numeric controls/indicators to the object at initialization.  You can store them as an array of control references.  But then you will have to use property nodes to get their values, which can be REALLY slow.  Or you could use the Get Control Values By Index function.  I have not used that function, so I do not know the details but it is supposed to be faster than using the value property nodes.


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 2 of 5
(3,426 Views)

Sounds good to me.  Got an example?

 

0 Kudos
Message 3 of 5
(3,424 Views)

A DVR (Data Value Reference) is *partly* analogous to the C++ reference / pointer you mention.  There's a special LabVIEW structure known as the In-Place Element which is needed to dereference the DVR and operate on the data it refers to.

 

Here's some further description.

 

Having said all that, LabVIEW is a visual language that has traditionally been about *dataflow*.   Using a DVR in the manner you describe is not really "in the spirit" of LabVIEW where the syntax for data is a wired connection showing function A that *outputs* it (and is responsible for the latest modification to it) and function B that *inputs* it (and operates on it *after* function A is done modifying it).

 

If you wrote a C++ program where your code was indented in non-standard and kinda misleading ways, you'd hinder the ability of another C++ programmer to understand it.  Speaking for myself at least, I'd be hindered in my ability to understand LabVIEW code where class data could be changed outside the class in a module that never directly calls a class member function.

 

   It's not that code of that style can't work, it's that it would be unconventional-looking and thus harder to debug and maintain.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy coming to an end (finally!). Permanent license pricing remains WIP. Tread carefully.
0 Kudos
Message 4 of 5
(3,409 Views)

OK, that mostly makes sense, I'll give it a try.

 

I'm used to writing small program and code that runs fast, in C or C++, sometimes for embedded apps and you can do whatever you want but its also all on you if something goes wrong.  LabVIEW on a big OS like Windows is a lot different and I'm still getting there.

 

I also cringe when I see all the overhead involved in doing some things with LV, but it is what it is and without all the structure LV gives you I'd never get anything done.  Thanks.

0 Kudos
Message 5 of 5
(3,395 Views)