Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Beginners-Issue: Can not read out data from a class

Solved!
Go to solution

Hello everybody,

and please forgive me to bother you with such a simple issue -- but I am at a loss -- I just can not bring this simple code (see attached sreenshots) to work, and I really do not know why.

I can write data (i.e. a string)  into a class (as checked with a probe), but I can not read the string out again. When I check with a probe on the class-cluster before the read-vi., the string is always empty (""). But after the write.vi the probe showed that the string was there before.

Any help is greatly appreciated, thanks a lot.

With kind regards,

B

0 Kudos
Message 1 of 8
(5,387 Views)
Solution
Accepted by topic author bernp

Hey B,

You're reading the instance, which you're creating at the beginning of the while loop. Try a shift register

A little add on:

The information won't be available in the parent actor core. In the moment, when you split the wire, you're creating a new instance of that class. If you want to write information to the instance of your parent actor core, you need to create an accessor message and send the information to the parent actor class with that message.

Regards,

Michael

0 Kudos
Message 2 of 8
(4,412 Views)

If you want each loop to start with the value from the last iteration you need a feedback node or a shift register for your class wire.  Right now each iteration is using the initial value of the class object since it is a standard tunnel.  I would right click the tunnel in and choose "replace with shift register".  You will need to wire the output wire from your write method to the shift register on the right of the loop (after you create the shift register there will be one on the right).

Casey

Casey Lamers


Phoenix, LLC


casey.lamers@phoenixwi.com


CLA, LabVIEW Champion


Check Out the Software Engineering Processes, Architecture, and Design track at NIWeek. 2018 I guarantee you will learn things you can use daily! I will be presenting!

0 Kudos
Message 3 of 8
(4,412 Views)

Hello MMike,

:-)... that´s it... thanks.

Somehow I thought that in a Class the data is always there and up-to-date.. But apparently it (the class) only has those data in it that were present at the time of creating the concrete instance... if I understand that correctly....

Thanks!!!

🙂

Best,

B

0 Kudos
Message 4 of 8
(4,412 Views)

I understand... thanks for your answer.

🙂

0 Kudos
Message 5 of 8
(4,412 Views)

That is the big By-Ref vs By-Value question. If your class was storing data in a DVR, A single elemet Queue or some other by referen e me hanism, you would have been able to read it without using the shift register.

0 Kudos
Message 6 of 8
(4,412 Views)

Yeah! This is, what made it difficult to me getting into LVOOP. But basically you have to see an instance of a class as variable, while the class is the data type. I never use this, but I think you could create a control for the class and manipulate the data by reference.

0 Kudos
Message 7 of 8
(4,412 Views)

mike-o-tronic wrote:

Yeah! This is, what made it difficult to me getting into LVOOP. But basically you have to see an instance of a class as variable, while the class is the data type. I never use this, but I think you could create a control for the class and manipulate the data by reference.

You... could. Please don't. You'll just get yourself into a bind where you're asking for help solving your race condition problems. If you need by-reference, use the Data Value References.

Message 8 of 8
(4,412 Views)