Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Confusion about sending data to a UI

Solved!
Go to solution

I have been trying to learn the Actor Framework and have made reasonable progress, but I need a little help.  I have a USB 6008 and I simply want to read some Analog In data using  DAQmx.lvclass (parent) and 6008_AI.lvclass (child) and display the waveform on the front panel of the launcher VI.  Seeing as LabVIEW is generally by-value and AF is based on queues I assumed that I could simply have an accessor (or static VI) to write the AI waveform to the class data, create a message to send this to the top and then dequeue the value there, but I cannot see how this is done.

Having read around it would appear that I must either use a reference or create another queue or use user events.  Can I pass data up the actor tree by value or not?

Thanks

Malcolm

Certified LabVIEW Architect and LabVIEW Champion specialising in Noise, Vibration and Harshness
0 Kudos
Message 1 of 8
(6,541 Views)

Yes, you can pass data by value. You would create a public method of the display handling actor to take a waveform input and do what is necessary to display it. Then you would create a message class with this method inside the message class' Do.vi. The message class would have the waveform as part of its private data.

Message 2 of 8
(4,231 Views)

Hi Maxwellb,

I think it is the "do what is necesary to display it" bit that I am having trouble with.  I send the message to read waveforms but there is no 'output' from that.  I cannot see a way to dequeue the message enqueuer output, I have not been able to read directly from the class data (it looks wrong to me anyway) and I cannot dequeue the message queue (or I'm doing it wrong - quite possible).

Thanks anyway,

Malcolm

Certified LabVIEW Architect and LabVIEW Champion specialising in Noise, Vibration and Harshness
0 Kudos
Message 3 of 8
(4,231 Views)
Solution
Accepted by topic author Malcolm_Myers

I create a user event within Actor Core and bundle that into the class data, as below. Then when a message 'NewData' is received by the actor it generates the user event, causing the plot to be updated.

The other way is just to bundle the control ref and use a property node to set the value, but that has drawbacks.

ac.png

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

Hi Malcolm,

I hope I get what you want to do and why it doesn't work. Let me try to help:

In Actor Framework first you should forget about sending. In the first round it's all about receiving. First you have to plan all the receive points in your program.

In your case let's call your actors MAIN and ACQ. MAIN starts first and launches ACQ (for acquisition).

To make it simple your UI will be the Actor Core of MAIN. In that you will have a helper loop (search for it in the forum to see what a helper loop is).

Receiving points:

ACQ: acquire command(Acq) - acquires a given length of data

MAIN: get acquired data(getAcq)

Now create methods for these receiving points. The methods should have only inputs. All effect that these have should happen in the method VIs and outputs to the class's private data.

Now create messages using these methods.

Now, as you have the "Send Message" VIs, you can use these VIs together with the correct Enqueuers to send!

So now you can think of sending.

Probably the Acq method of ACQ should now include the "Send Message" VI of getAcq message for sending the acquired data. Use the correct Enqueuer of MAIN with it. So the data gets into MAIN.

Now you can display it "somehow". You can use either a reference to the graph on the Actor Core and use that in the getAcq method, or use user events to send data to the helper loop in the Actor Core of MAIN.

I hope it helps a bit. If any words seem to be unfamiliar, just search for those here in the forum. All concepts I used are known here already.

Message 5 of 8
(4,231 Views)

Thank you MartinMcD and komorbela,

This answers my question in that there is no direct way to read data that has been sent by a child actor, you need to use either a reference or a user event to do this.  I have seen examples of this but I had wondered if these were used for reasons such as upgradeability.

Thanks again

Malcolm

Certified LabVIEW Architect and LabVIEW Champion specialising in Noise, Vibration and Harshness
0 Kudos
Message 6 of 8
(4,231 Views)

I think the others answered you well, but I want to clarify a couple points so that future brainstorms go smoother.

> Can I pass data up the actor tree by value or not?

Just to be clear about terms... when I and most other people on this forum discuss the "Actor tree", that's referring to the caller-nested actor tree. The inheritance tree of classes is a separate thing. A single actor object can be made up of many levels of inheritance. Passing data between the various Actor Core overrides of a single actor object does have to be done using references because you are triggering interactions between independent loops. It is a situation identical to producer/consumer loops.

Does this picture help clarify?

Untitled.png

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

I have no problem changing values and then reading them in nested actors (e.g. setting a nested USB_6008_AI class to stop from the UI).  I think I just expected that going up the tree would be the same, i.e. I could send the AI waveforms to the top-level actor and then simply display them.  I see now that I need some form of reference or event to do that.

I think the clarification between inheritance and actor nesting is a worthwhile reminder for me.  The picture also helps.  So data transfer is effectively two-dimensional: messaging for nesting and refnums for inheritance.  Hmmm, I'm going to need to change my notes I feel.

I am getting there, it's just taking a little longer than planned.

Thanks

Malcolm

Certified LabVIEW Architect and LabVIEW Champion specialising in Noise, Vibration and Harshness
0 Kudos
Message 8 of 8
(4,231 Views)