next up previous contents
Next: 6. USING SVM AND Up: 5. DISTRIBUTED SIMULATION WITH Previous: 5.3 Distributed Simulation on   Contents

5.4 Example

A simple Echo example is studied in the section. There are two components in the system: Sender and Echo. The Sender randomly generates a message and sends it to the message port of the Echo. The Echo sends back this message to the Sender after 1 second. When the Sender receives the message, it sends another random message to the Echo. This loop continues forever.

Figure 5.2: Sender of the Echo example
Image atom3sender.png

Figure 5.3: Echo of the Echo example
Image atom3echo.png

Figure 5.4: Name pattern of the Echo server
Image atom3echopattern.png

Figure 5.5: Port name of the Echo server
Image atom3echoport.png

The design of the components in AToM$^3$ is shown in Figure 5.2 and Figure 5.3. In Figure 5.3, an input/output port named message is defined. The Sender component in Figure 5.2 also defines a port called message. The port of the Sender is connected to the port of the Echo. The name pattern of the server with ID Echo (a name chosen by the designer) is Echo (Figure 5.4). This matches the Echo component only. The link between the Sender port and the server has a property that specify the server port message (Figure 5.5). The enter actions of the Send state of the Sender component is hidden. Those actions import necessary Python libraries and initialize a list of random messages.

When the Sender component is loaded into AToM$^3$, the user may press the ``to SVM Des.'' button to generate a .des file. The user is prompted for a file name. By default, it is the same name as the AToM$^3$ component with postfix changed to .des. Here is the Sender.des generated by the SVM plugin:

# DCharts description generated by SVM-AToM3-plugin, written by Thomas Feng
#   Source: /home/thomas/Backup/Atom3_2.2/DCharts/models/SimpleEcho/Sender.py
#   Date:   January 15, 2004
#   Time:   21:29:44

COMPONENT:
  id = Echo
  name = Echo

PORT:
  name = message
  type = inout

CONNECTIONS:
  message -- Echo.message

STATECHART:
  Send [DS]
  Wait

ENTER:
  N: Send
  O: from random import randint
     Messages=["Hello, everyone!", "Have a nice day!", "How are you today?", "I feel very \
well today!", "The same to you!"]
     MessageNo=len(Messages)


TRANSITION:
  S: Send
  N: Wait
  T: 0 [RTT]
  C: 1
  O: msg=Messages[randint(0, MessageNo-1)]
     [EVENT("message.send", msg)]
     [DUMP("Sent: " + msg)]

TRANSITION:
  S: Wait
  N: Send
  E: message.echo
  C: 1
  O: [DUMP("Received: " + [PARAMS])]

Here is the Echo.des:

# DCharts description generated by SVM-AToM3-plugin, written by Thomas Feng
#   Source: /home/thomas/Backup/Atom3_2.2/DCharts/models/SimpleEcho/Echo.py
#   Date:   January 15, 2004
#   Time:   21:31:4

PORT:
  name = message
  type = inout

CONNECTIONS:

STATECHART:
  Receive [DS]
  Echo

TRANSITION:
  S: Receive
  N: Echo
  E: message.send
  C: 1
  O: msg=[PARAMS]

TRANSITION:
  S: Echo
  N: Receive
  T: 1 [RTT]
  C: 1
  O: [EVENT("message.echo", msg)]

To simulate this example in AToM$^3$, take the following steps:

  1. Install and start PVM (section 5.1).
  2. Compile PYPVM and start SVMDNS (section 5.2).
  3. Start an instance of AToM$^3$ and load Echo.py. Click on ``simulate in SVM''.
  4. Start an instance of AToM$^3$ and load Sender.py. Click on ``simulate in SVM''.
  5. The output box of the Sender component should display such messages as ``sent: xxxxxx'' and ``receive: xxxxxx'', where ``xxxxxx'' is a message. The received message should be the same as the last message being sent.
  6. To stop the simulation and close the SVM simulators, click on the ``Exit'' button.
To simulate this example in SVM, take the following steps:
  1. Start an instance of AToM$^3$ and load Echo.py. Click on ``to SVM Des.'' to generate Echo.des and save it in a user-specified directory. Close AToM$^3$.
  2. Start an instance of AToM$^3$ and load Sender.py. Click on ``to SVM Des.'' to generate Sender.des. Close AToM$^3$.
  3. Install and start PVM (section 5.1).
  4. Compile PYPVM and start SVMDNS (section 5.2).
  5. Change to the directory where Echo.des is in and execute ``svm Echo.des''.
  6. Change to the directory where Sender.des is in and execute ``svm Echo.des''.


next up previous contents
Next: 6. USING SVM AND Up: 5. DISTRIBUTED SIMULATION WITH Previous: 5.3 Distributed Simulation on   Contents
Thomas Huining Feng
2004-04-05