DwarfMiddlewareTutorialLesson7

Chair for Computer Aided Medical Procedures & Augmented Reality
Lehrstuhl für Informatikanwendungen in der Medizin & Augmented Reality

THIS WEBPAGE IS DEPRECATED - please visit our new website

Up to DwarfMiddlewareTutorial, forward to DwarfMiddlewareTutorialLesson8, back to DwarfMiddlewareTutorialLesson6

Lesson 7: Sending and Receiving Events

In this lesson, you will how services can communicate with events.

Build time receiver and sender

Run make install in (top build directory)/src/tutorials/middleware/lesson7. This will install two new binaries, TimeSender and TimeReceiver. It will also install two new service descriptions:

TimeSender TimeReceiver
<service name="TimeSender" isTemplate="true">
   <ability name="senddate" type="TimeOfDay">
      <connector protocol="PushSupplier"/>
   </ability>
</service>
<service name="TimeReceiver" isTemplate="true">
   <need name="receivedate" type="TimeOfDay"
    minInstances="1" maxInstances="3">
      <connector protocol="PushConsumer"/>
   </need>
</service>

Note the two new communication protocols, PushSupplier and PushConsumer. A PushSupplier sends events, a PushConsumer receives them.

Try it out

In one terminal, run the TimeSender. In another, run the TimeReceiver. The two services will start communicating, showing this image in DIVE:

A string sender and receiver

The TimeSender will periodically send an event:

16:49:38.378 00000 10 TimeSender.cpp       119 TimeSender_impl : preparing event
16:49:38.378 00000 10 TimeSender.cpp       127 TimeSender_impl : getting time
16:49:38.378 00000 10 TimeSender.cpp       138 TimeSender_impl : sending event
16:49:39.387 00000 10 TimeSender.cpp       119 TimeSender_impl : preparing event
16:49:39.388 00000 10 TimeSender.cpp       127 TimeSender_impl : getting time
16:49:39.388 00000 10 TimeSender.cpp       138 TimeSender_impl : sending event

And the TimeReceiver will receive it:

got event with time of day: 16:49:38
got event with time of day: 16:49:39

Debugging the events

In DIVE, click on the sendstrings ability of the TimeSender. Then click on "View Events". A new window will appear, allowing you to see the events sent by the TimeSender. Note that for this, DIVE creates its own little debugging service that itself subscribes to the events sent by the TimeSender. You will see this it you click on "Update" in DIVE.

A string sender and receiver

Exercise 7.1 How many TimeReceivers does one TimeSender connect to?

Exercise 7.2 How many TimeSenders does one TimeReceiver connect to? What happens if you change maxInstances?

How it works


Up to DwarfMiddlewareTutorial, forward to DwarfMiddlewareTutorialLesson8, back to DwarfMiddlewareTutorialLesson6

-- AsaMacWilliams - 12 Nov 2003


Edit | Attach | Refresh | Diffs | More | Revision r1.3 - 17 Mar 2005 - 21:11 - NikolasDoerfler

Lehrstuhl für Computer Aided Medical Procedures & Augmented Reality    rss.gif