Skip to content

HelloWorldTutorial

mitchell-conrad edited this page Jan 19, 2021 · 1 revision

Table of Contents

HelloWorld Tutorial

This tutorial will guide the user in creating a basic HelloWorld model. The model consists of a Sender and a Receiver component and prints out the contents of the message received.

A complete version of the tutorial model can be found here: File:HelloWorldTutorialModel.graphml.

Defining Interfaces

  1. Select "New Project" from the welcome screen when MEDEA starts up
  2. Go to the Model menu and select "Select Model"
  3. Using the Data Table to the right, change the model's label to "HelloWorld"
    • All available data fields for each entity can be edited using the Data Table (unless they are locked)
  4. Maximise the Interfaces aspect using the button in the top right hand corner of the aspect's title bar
  5. Using the parts dock to the left, add an Aggregate entity
  6. Select the Aggregate entity and change its label to "Message"
    • This can be done by double clicking on either the label of the item on the canvas, or "label" field in the Data Table to the right
  7. Add three Member entities in the Aggregate labelled "Message"
    • This can be done by one of the following methods:
      • Selecting the Member entity from the parts dock to the left
      • Clicking the plus button within the Aggregate entity in the canvas and selecting Member from the menu
      • Right-clicking on the Aggregate entity, selecting "Add Node", and then selecting Member from the menu
  8. Change the Member labels to "instName", "messageID" and "content" respectively
  9. Select the Member labelled "instName" and change the "key" field in the Data Table to "True"
  10. Select the member labelled "messageID" and change the "type" field in the Data Table to "Integer"
    • The default value for "type" in a Member is "String"
  11. Select the Interfaces aspect and add two Components labelled "HelloSender" and "HelloReceiver"
  12. Select the Component labelled "HelloSender" then do the following:
    1. Add an Attribute entity labelled "message"
    2. Add a Publisher Port entity labelled "greeting"
      • When adding a Publisher Port or a Subscriber Port from both the Dock and the right-click menu, a menu will appear displaying a list of Aggregate types the port can use. In this case select the only option - "Message"
  13. Select the Component labelled "HelloReceiver" then do the following:
    1. Add a Subscriber Port using the Aggregate labelled "Message" in the same way as the Publisher Port
    2. Set the label of the Subscriber Port to "greeting"
      • Entities can be expanded/contracted to hide children entities by double-clicking on their icon

Defining Behaviour

  1. Contract the currently visible aspect (Interfaces aspect) using the button in the top right hand corner of the aspect's title bar
    • The View Manager tool on the right, can also be used to hide and show aspects and tool panels in MEDEA
  2. Maximise the Behaviour aspect
    • Here there should be two ComponentImpl entities labelled "HelloSender" and "HelloReceiver"
      • Creating Component entities in the Interfacaces aspect automatically create their corresponding ComponentImpl entities in the Behaviour aspect
      • Feel free to move the entities around so that they are layed out nicely
      • You can also pan the aspects by pressing and holding the right mouse button and then moving it around

Defining HelloSender Behaviour

  1. Select the ComponentImpl labelled "HelloSender"
  2. Add a Periodic Port labelled "tick"
  3. Add a Variable labelled "count" set its "value" field to "0"
  4. Add a ClassInstance of "Component_Info"
  5. Select this Variable then add a Member entity
  6. Select the Member and set its "type" to "Integer"
  7. Select the Periodic Port labelled "tick" and using either the dock or the Workflow button within the entity, add the FunctionCall "Get Name"
  8. Add a Publisher Port Impl
  9. Click and drag from the Data Edge on the right edge of the MemberInstance labelled "Label" inside "Get Name" and drag the edge onto the MemberInstance "instName" inside the "tick" > "greeting" > "Message"
    • Clicking and dragging on Data Edges will highlight all the entities that you can connect the clicked entity to
  10. Connect the Variable labelled "count" to "greeting" > "Message" > "messageID"
  11. Connect the Attribute labelled "message" to "greeting" > "Message" > "content"
  12. Select the ComponentImpl labelled "HelloSender" then add a Setter entity
  13. Inside the Setter, select the InputParameter and set its "label" field to "+="
  14. Select the InputParameter labelled "rhs" and set its"value" field to "1"
  15. Connect the Variable "count" to the Setter > "lhs"

Defining HelloReceiver Behaviour

  1. Select the ComponentImpl labelled "HelloReceiver" then add a ClassInstance of "Utility_Worker"
  2. Select the SubscriberPortImpl labelled "greeting" then add a FunctionCall called "Log"
  3. Select the MemberInstance labelled "Message Format" and set its "value" field to "Received Message[%i] from '%s' = '%s'" (Note - include the double quotes)
  4. Select the InputParamterGroupInstance labelled "Input Parameters" and then add three Optional Parameters
  5. Connect the Optional Parameters to the following MemberInstances inside the "Message" AggregateInstance in this order:
    1. "messageID"
    2. "instName"
    3. "content"
  6. Select "Verbosity" inside the Input Parameters in "Log" and set it to "1"

Defining Assembly

  1. Maximize the Assemblies aspect
  2. Add a ComponentAssembly labelled "HelloWorld_Asm"
  3. Select the ComponentAssembly labelled "HelloWorld_Asm" then add a ComponentInstance using the following:
    1. Right-click "HelloWorld_Asm"
    2. Select "Add Node" from the menu
    3. Select "ComponentInstance" > "HelloSender"
    4. Set the ComponentInstance's label to "Sender"
  4. Using the same method, add another ComponentInstance labelled "Receiver"
  5. Select the AttributeInstance labelled "instName" inside the ComponentInstance labelled "Sender" and set its "value" field to "Sender"
  6. Select the AttributeInstance labelled "message" inside the ComponentInstance labelled "Sender" and set its "value" field to "Hello World!"
  7. Select the AttributeInstance labelled "Frequency" inside the PeriodicPortInstance labelled "tick", and set its "value" field to "1"
  8. Select the PublisherPortInstance labelled "greeting" inside the ComponentInstance labelled "Sender" connect it using the following:
    1. Click on the Assembly Edge on the right edge of "greeting"
      • This will display a list of SubscriberPortInstances that the selected PublisherPortInstance can connect to
    2. Select the SubscriberPortInstance that you want to connect to; in this case there's only one option - "greeting"

Defining Deployment

  1. Show the Assemblies and Hardware aspects next to each other
  2. Go to the Jenkins menu and select "Import Jenkins Nodes"
    • This requires a valid Jenkins Settings
    • This will load in the HardwareNode entities available to deploy ComponentInstance entities to
    • A notification will appear displaying that the request is in progress
    • The notification will then either display a green or red icon based on the success of the import
  3. In the Assemblies aspect, select the "Sender" ComponentInstance
  4. Click on its Deployment Edge on its top right edge, to display the list of HardwareNodes it can connect to
    • ComponentInstance entites can be deployed using either the hardware dock, the right-click menu or its Deployment Edge
    • ComponentAssembly entities can also be deployed, which will deploy any of its un-deployed children to the selected HardwareNode
    • If the ComponentInstance/ComponentAssembly is already connected and you want to change where it's connected to, you will need to disconnect it first in the same way as connecting it
  5. Likewise, deploy the "Receiver" ComponentInstance to a different HardwareNode
  6. Go to the File menu and and select "Save Project"
  7. Save the project as "HelloWorld.graphml"
  8. Deploying Using Jenkins

Clone this wiki locally