Actor Framework Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Send Message And Wait For Response Variant Output necessary?

Solved!
Go to solution

Hi Guys,

 

I have a ill-formed question. I was trying to use interface messaging but now with Send Message And Wait For Response.vi, which has an output being a variant. Previously, I had been enjoying the fact that interface messages do not couple actors at all (see here, for a related discussion).

 

I was trying to achieve the same no coupling between actors that interface messaging allows, but now with synchronous messaging based off Send Message And Wait For Response.vi. The issue that I'm currently running into seems to be that since the output of Send Message And Wait For Response.vi is a variant, it would seem to be that the calling actor has to know (i.e, is coupled) to its callee and somehow externally know that the callee is putting a string into its output. 

 

Is there a way to send a synchronous message that doesn't use variants? I was kind of hoping to create a message that outputs the correct data type already. 

 

This might be a poorly phrased question, or even fundamentally wrong that I want that behavior...

 


------------------------------------------------------------------------------------

Please join the conversation to keep LabVIEW relevant for future engineers. Price hikes plus SaaS model has many current engineers seriously concerned...

Read the Conversation Here, LabVIEW-subscription-model-for-2022
0 Kudos
Message 1 of 7
(2,589 Views)

Well the actor sending the message needs to process the return data somehow, so it kind of has to know what type to expect.

 

 

Sam Taggart
CLA, CPI, CTD, LabVIEW Champion
DQMH Trusted Advisor
Read about my thoughts on Software Development at sasworkshops.com/blog
GCentral
0 Kudos
Message 2 of 7
(2,577 Views)

Send Message and Wait for Response.vi must have a quite general output, e.g. an variant, so that it can handle all kinds of outputs. But normaly this variant is hiden. In the Do Core.vi  of the interface (IF) reply message  You pack the outputs of our Vi  in a variant and in Send some reply Message.vi, you unpack them again.

It certainly makes sense if the output of your Send reply Msg.vi fits to the IF VI. Because the IF implementing actor simply overwrites the IF VI, it knows nothing about this packing and unpacking process and provides the correct data type, in your case string.

 

P.S.
I am currently converting a project from abstract messages to IF technique, and I am realy excited about this new possibility in LabVIEW! I am deleting a lot of code from my project: abstract messages, their child classes, member variables in classes, their get and set methods. If the names of IF VIs and connector pane fits to the caller Vis, I don't even have to touch the caller except to add the interface in properties.

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

@Taggart wrote:

Well the actor sending the message needs to process the return data somehow, so it kind of has to know what type to expect.


Yeah, I was thinking about that -- it might be just be the way that it is. No way to do a synchronous message that doesn't output a variant, but instead outputs the type of data needed? That way, the message itself enforces the data type at compilation time and would avoid errors regarding data type conversion.


------------------------------------------------------------------------------------

Please join the conversation to keep LabVIEW relevant for future engineers. Price hikes plus SaaS model has many current engineers seriously concerned...

Read the Conversation Here, LabVIEW-subscription-model-for-2022
0 Kudos
Message 4 of 7
(2,547 Views)

You are already doing this, if I understand your picture correctly. You just need to connect the string (...or whatever vi of an actor or an interface defines...) as an output of your send a sync msg.vi .

I attach an example. All my UIs inherit from Viewable Actor. Suppose I want to display a frontpanel of an nested actor in my main UI. I want to resize a subpanel before i do this. My application send a sync msg to NA by calling Send Get Bounds and Position.vi.  Do Core calls NA member vi Get Bounds and Position.  I have to put data in a variant due to interface of Do Core.  In Send Get Bounds and Position i convert variant to concrete data types back. The caller gets the disired data types.

Reply Msg.png

0 Kudos
Message 5 of 7
(2,541 Views)

Ah, I think I'm about to spot my mistake. 

 

What I had been doing (wrongly, I believe): in the actor core of my root actor, calling "Send Message And Wait For Response.vi" with a reply message as its input. I had not been calling 

 

What I think I should be doing (correct, I believe): in the actor core of my root actor, instead calling the send reply message method of my reply message class. That send reply message method itself can do the data formatting, and it fulfils my desire to not do the data formatting in the root actors code.

 

That sound right?

 

See new images.

 


------------------------------------------------------------------------------------

Please join the conversation to keep LabVIEW relevant for future engineers. Price hikes plus SaaS model has many current engineers seriously concerned...

Read the Conversation Here, LabVIEW-subscription-model-for-2022
0 Kudos
Message 6 of 7
(2,533 Views)
Solution
Accepted by WavePacket

I think you are on the right way, but I did not completely understand your last post.

I describe how I proceed with Reply Messages.

  1. Unfortunately, LV does not provide a wizzard for synchronous messages. Therefore I create a normal message and
    change its parent class to "AF:Reply Msg".
  2.  Overwrite Do Core.vi and transfer the code from Do.vi to it. Do.vi can be deleted.
  3. Pack the outputs of actor member vi into variant
  4. In Send Msg.vi replace "Enqueue" with "Send message and wait for response". Be sure to set a default timeout!
  5. Unpack my data from Variant and adjust connector pane
  6. Send the msg by calling adjusted Send Msg.vi
0 Kudos
Message 7 of 7
(2,524 Views)