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.
The design of the components in AToM 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, 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 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, take the following steps: