Publish Subscriber

LabVIEW software project design, UML, state machines, software modules, OOP

Publish Subscriber

Postby Eugen Graf on 19 Nov 2007, 04:46

This is my realisation of topic based Publish/Subscribe Software Design Pattern.

http://en.wikipedia.org/wiki/Publish/subscribe
http://en.wikipedia.org/wiki/Observer_pattern

The dispatcher is the main task of this pattern, which administrates a topic table. If any (Queue- Notifier- User Event- and TCP/IP based) client starts, it should register himself by the dispatcher, so the dispatcher adds them into the topic table. The next step the client should do - is to subscribe to topics. If the dispatcher receives a message from any client, it looks which clients want to receive this message and send it only to this clients. So you can rediuce some data traffic in your programm. If a client is no more interested in a topic, it can unsubscribe from this topic. If a client want to be removed from the table, it should unregister.

So you can dynamically start/stop clients and realize a software, which is plugin able.

Supporting TCP/IP protocoll gives you a chance to communicate between programm modules, different applications, and different computers over network. Therefore you can connect two or more dispatchers and select topics, which you want to send or receive. This feature gives you a big advantage - remote debugging.
Attachments
Pubsub_v1_0_1.zip
(499.03 KiB) Downloaded 2191 times
User avatar
Eugen Graf
guru
guru
 
Posts: 6492
Joined: 13 Nov 2007, 03:20
Location: Saarbrücken
Medals: 4
Activity (1) Professionalism (1) Silver (1) Black (1)
LabVIEW Version: 2009
Karma: 301
CLAD MOD I/O VIP bloggers internet

Re: Publish Subscriber

Postby Eugen Graf on 10 Jun 2008, 12:29

More explanations:

turbot, you can read more about here

http://forums.lavag.org/publish-subscriber-t7793.html

or ask me what do you want to know about this pattern.

If you have paralell loops in your programm, they should communicate. For communication you can select following:

local variable
global variable
notifier
queue
user event
tcp/ip
...

I implemented in this pattern 4 last communication types, because I don't like any variables.

So the dispatcher have the task to dispatch incomming (over one dispatcher queue) messages to loops interested in. So the dispatcher is the main VI and should be started as first. In the dispatcher you will find a table. Row headers are loop names, column headers are message names and in the table you will see the communication type (one of 4 implemented) of the loop.

If if the dispatcher is started, you can begin to start your tasks (parallel loops). At the start of one task, this task have to say to the dispatcher it's name, it's reference, it's type of communication and which messages it want do receive from the dispatcher. The dispatcher will add this informations into the table. So if any task will send a message to the dispatcher, it look in the table which tasks are interested in this message and will send the message to the interested tasks. All the communication should go over the dispatcher, so it's much easier to debug your programm, because you have all informations about all tasks in your programm on one place. And not only, all messages go over the dispatcher, so you can spy every message from every task, and YOU CAN DO IT REMOTELY from an other PC, because TCP/IP is implemented too.
User avatar
Eugen Graf
guru
guru
 
Posts: 6492
Joined: 13 Nov 2007, 03:20
Location: Saarbrücken
Medals: 4
Activity (1) Professionalism (1) Silver (1) Black (1)
LabVIEW Version: 2009
Karma: 301
CLAD MOD I/O VIP bloggers internet

Re: Publish Subscriber

Postby Eugen Graf on 13 Jun 2008, 21:53

I will start to remake this pattern using OOP. If there are interested people, so answer. :crazy:
User avatar
Eugen Graf
guru
guru
 
Posts: 6492
Joined: 13 Nov 2007, 03:20
Location: Saarbrücken
Medals: 4
Activity (1) Professionalism (1) Silver (1) Black (1)
LabVIEW Version: 2009
Karma: 301
CLAD MOD I/O VIP bloggers internet

Re: Publish Subscriber

Postby turbot on 18 Jun 2008, 07:18

Hi Eugen,

Very glad to receive your email.

The hangup I met last time was caused by the data loop. I should not select same topic in local and remote topic in PubSub_ConnectAsClient.vi at same time.

One thing may need to improve is the local and remote topic list in PubSub_ConnectAsClient.vi should be updated when new client is connected or new subscription is made.

Regards,

Yu Ming
turbot
interested
interested
 
Posts: 3
Joined: 18 Jun 2008, 07:03
Karma: 0

Re: Publish Subscriber

Postby Eugen Graf on 18 Jun 2008, 12:32

turbot wrote:The hangup I met last time was caused by the data loop. I should not select same topic in local and remote topic in PubSub_ConnectAsClient.vi at same time.


Yes, that is right.
Can you explain me what you want to do using this pattern. I think you can solve it on the other way, may be without to connect two or more dispatchers remotely.

turbot wrote:One thing may need to improve is the local and remote topic list in PubSub_ConnectAsClient.vi should be updated when new client is connected or new subscription is made.

Good idea :super:
User avatar
Eugen Graf
guru
guru
 
Posts: 6492
Joined: 13 Nov 2007, 03:20
Location: Saarbrücken
Medals: 4
Activity (1) Professionalism (1) Silver (1) Black (1)
LabVIEW Version: 2009
Karma: 301
CLAD MOD I/O VIP bloggers internet

Re: Publish Subscriber

Postby turbot on 20 Jun 2008, 06:35

What I tried to do is a message system. If any one generate a message or alarm, it need to transfer to all the rest ones. If one of them acknowledge or make an action on the message, the others also need to know it. Also with some data transmission, command and status and transmission.
turbot
interested
interested
 
Posts: 3
Joined: 18 Jun 2008, 07:03
Karma: 0

Re: Publish Subscriber

Postby Eugen Graf on 20 Jun 2008, 17:07

For this issue you need to start one dispatcher on one PC and on other PCs you can start any TCP/IP clients.

That should work without any problems, try it.
User avatar
Eugen Graf
guru
guru
 
Posts: 6492
Joined: 13 Nov 2007, 03:20
Location: Saarbrücken
Medals: 4
Activity (1) Professionalism (1) Silver (1) Black (1)
LabVIEW Version: 2009
Karma: 301
CLAD MOD I/O VIP bloggers internet

Re: Publish Subscriber

Postby turbot on 03 Jul 2008, 10:00

I am trying to do the below:
"One thing may need to improve is the local and remote topic list in PubSub_ConnectAsClient.vi should be updated when new client is connected or new subscription is made."

May you give any suggestion about it?

What I plan to do is when a new subscribtion is made in the case of subscribe in dispatch vi, it will trigger the PubSub_ConnectAsClient.vi to update the local topic list. Also trigger the any connected remote client to update their remote topic list.

Can this be down just using a update topic or change the code inside?
Thanks.

Turbot
turbot
interested
interested
 
Posts: 3
Joined: 18 Jun 2008, 07:03
Karma: 0

Re: Publish Subscriber

Postby maxgod145 on 10 Dec 2008, 22:52

Hi people!I need all what you know about network icq!I'll be thanks for all info!!
User avatar
maxgod145
user
user
 
Posts: 87
Joined: 28 Oct 2008, 21:40
Location: Киев
Medals: 1
Activity (1)
LabVIEW Version: 8,5;8.6
Karma: 6
vision internet students


Return to Design patterns

Who is online

Users browsing this forum: No registered users and 1 guest