Jump to content

2 ways communication between 2 objects


Recommended Posts

Hi,

I need advice on how to exchange messages between 2 classes or 2 objects. So far I am using LVOOP mostly because of data encapsulation and inheritance feature.

Now I need communication between 2 objects A and B running parallel. Each object can send message to another. I can send message one way by using composition relationship. I put one class inside another class cluster, for example B inside A cluster. Then later from inside class A, I can use class B reference to send message to process of class B. But I don't know how to send message back from B to A. Is there any design pattern about this? Or is there any example? I can do this without using class by using name queue but I would like to learn how to do this with LVOOP.

I read about actor framework already but I don't want to use it now seam it's a little bit complicated for my project.

 

Thank you for your time reading and answering my question!

 

Thang Nguyen

Edited by Thang Nguyen
Link to comment

@Mikael: Basicly what you use is a name queue, am I correct? That's how you get the reference to another object. Thank you very much for your time building the example code :)

 

@Shoneill: Thanks for your advice. I will think a way to combine user event in LVOOP. There are some great feature I still want to use from LVOOP.

Link to comment

@Mikael: Basicly what you use is a name queue, am I correct? That's how you get the reference to another object. Thank you very much for your time building the example code :)

Since I'm using the GDS toolkit, it generates >95% of the code, so it took me less than 5 minutes to create this :-)

 

The singleton is storing the Object Reference(DVR) in a 1 element named queue.

The Actor/Active Object Process is also using named queues (based on the DVR Reference number) to store the mechanism to send data to and from the process.

The steps to create this with the GDS tool is:

  1. Create the class: A as a DVR Singleton class
  2. Add Design Pattern Active Object to the class.
  3. Add a “Send Message To Process†method(RequestData.vi) to the class.
  4. Modify the newly created VI/method
  5. Modify the Process VI in the class to handle the message
  6. Clone Class A to B
  7. Modify the Process VI and RequestData.vi in the new class.
  8. Create the Top level Main VI

//Mike

Link to comment

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.