Jump to content

Data flow of objects in a loop


Recommended Posts

Hi guys,

I am very new to labview and it's graphical way of programming.
I am used to programming with code and I love the concepts of object oriented programming.
But here in Labview I don't quite get it yet.
I just have a function (where the "Read data" note is) that updates the data in the object (It reads from a serial connection).
But each time the loop iterates, the previous data is lost.
I don't know how to express it, but I would like to do something like the blue line I draw.
So the function keeps updating itself. 
Is there any way to do this? I've searched for a long time now, but I don't even know how to explain this problem.

 

Thanks in advance!

 

vraag.png

Link to post
Share on other sites

So one thing that might help make it click, is that objects aren't reference based by default.  So you are initializing an object, adding an axis, and then passing that data into a loop.  The data that the loop uses each iteration, does not change it is the same data over and over again.  However if inside that data is a reference to something, then that something can change, and the reference doesn't.  But that feature is only used if the developer of the class used references in the private data of the object.

The class data can be thought of as a cluster (because it is).  So imagine if you weren't using an object, and were just using a cluster.  Would passing in that same cluster to the loop do anything different?  Well if a reference was in that cluster then sure you could write to the reference in the loop, and then the next iteration would have a different value in the reference if you read it.  But if in the cluster is just normal data types like string, numeric, boolean, etc. then it doesn't matter if you are updating that cluster in the loop because the same value is passed in each time.  What Antoine was suggesting was to use a shift register which passes data from one iteration of a loop, to the next.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.