Exercise: AADL Project from Scratch
-
The FMIDE customization of the OSATE AADL editor should be installed as described in Tool Tutorial: HAMR Installation and the FMIDE/OSATE installation confirmed to be functioning correctly as in the Tool Tutorial: Loading an Existing AADL Project into OSATE/FMIDE.
-
Understand the concepts of the OSATE/FMIDE Eclipse workspace as presented in Tool Tutorial: AADL OSATE Workspace Concepts
- Learn the basics of using OSATE to create a simple AADL project
- Further solidify the understanding of syntax of AADL software components system, process, and thread
- Learn how to create a instance model diagram of the system (the most common diagram for understanding AADL system/model structure)
In this exercise, you will build an AADL model of a simple producer / consumer system. This will include defining simple threads, processes, and packages.
It is often useful to draw an informal diagram of your system before you start editing models in AADL/OSATE. The figure below is an informal sketch of the system that we will build for this exercise.
-
A producer thread sends a message with two fields to a consumer thread: a value field, and a section field (imagine a section number indicating a particular grouping/bucket of values). Note that these fields are made up just to illustrate technical concepts of AADL structs -- they don't represent any realistic domain modeling.
-
The producer thread is a periodic component -- it will be dispatched periodically to send messages to the consumer.
-
The consumer thread is a sporadic component -- it will be dispatched by the arrival of the message.
-
The producer thread is contained in a producer process; similarly for the consumer. These two processes are integrated to form the top-level system.
- Create HAMR project structure. Create a folder/directory
HAMR-Slang-Tutorials-Prod-Cons
structure matching the image below to hold the AADL project that you will create in this project. This is the standard directory structure that we recommend for all HAMR projects. In this exercise, you won't use thehamr
folder (we will use it in a subsequent exercise in which we add Slang code). You will create your OSATE AADL project in theaadl
folder.
-
Use OSATE menus to create a new AADL project.
Use the OSATE menu option
File / New / AADL Project
as shown below to launch the New AADL Project Dialog.Set the fields in the New Project dialog as shown below (see notes below screenshot).
Notes:
- The
Project name
can be set toHAMR-Slang-Tutorials-Prod-Cons
(or something similar) - The
Use default location
option should be unchecked - The
Location
should be set to theaadl
folder from the Create HAMR project structure activity above.
After OSATE creates the project, confirm that you see the
HAMR-Tutorials-Prod-Cons
project in the AADL Navigator as shown in the screen shot below. - The
-
Create Producer Package. Use the OSATE menu system (e.g., highlight the
HAMR-Tutorials-Prod-Cons
project as shown below, right-click to access the context menu, and theNew AADL Package
option) to create an AADL package calledProducer
.Complete the New Package dialog as in the screenshot shown below.
-
Configure Producer package imports. Using the HAMR package template as guidance, configure the package imports using the
with
clause toProdCons
package Producer public with ProdCons; -- package contents go here end Producer;
-
Create a
ProdCons
package to hold system-level definitions including message type. Using the OSATE menus and HAMR package template (following the steps used in creating theProducer
package above), create aProdCons
package that imports the AADL base types, data model definitions, andProducer
package (theConsumer
import is not used yet, so it is commented out).package ProdCons public public with Base_Types, -- needed when using AADL base types Data_Model, -- needed when defining new types Producer; -- Consumer; -- access to producer and consumer processes -- package contents go here end ProdCons;
-
Create
Message
type for messages sent from producer to consumer. Using the HAMR templates as a guide, use an AADL data component type and implementation in theProdCons
package to create a "struct" data type calledMessage
that has the following two fields.- value, which has type
Base_Types::Integer_32
- section, which has type
Base_Types::Integer_32
- value, which has type
-
Create
ProducerThr
thread in theProducer
package. Using the HAMR templates as a guide, create a thread component typeProducerThr
and implementationProducerThr.i
in theProducer
package.- create an output event data port in the component type named
outMessage
with typeProdCons::Message
- set the dispatch protocol property to
Periodic
- set the period to
1sec
- create an output event data port in the component type named
-
Create
ProducerProc
process in theProducer
package. Using the HAMR templates as a guide, create a process component typeProducerProc
and implementationProducerProc.i
in theProducer
package.- specify an output event data port in the component type named
outMessage
with typeProdCons::Message
- in the component implementation, specify a thread subcomponent instance named
producerThr
using theProducerThr.i
component implementation. - specify a port connection named
msgPTtoPP
that connects theoutMessage
port ofproducerThr
to theoutMessage
port on theProducerProc
interface.
- specify an output event data port in the component type named
-
Create the
Consumer
package. In a similar fashion to the creation of theProducer
package, create aConsumer
package withProdCons
as the only import.
Note: The model for Consumer
artifacts is symmetric to those for Producer
. So for the steps that follow, you may find it convenient to simply copy the Producer
artifacts and edit them to have consumer-based names and to reverse the directionality for ports/connections.
-
Create a
ConsumerThr
thread in theConsumer
package. Using the HAMR templates as a guide, create a thread component typeConsumerThr
and implementationConsumerThr.i
in theConsumer
package.- specify an input event data port in the component type named
inMessage
with typeProdCons::Message
- set the dispatch protocol property to
Sporadic
because we want this thread to be dispatched when a message arrives. - set the period to
1sec
- specify an input event data port in the component type named
-
Create a
ConsumerProc
process in theConsumer
package. Using the HAMR templates as a guide, create a process component typeConsumerProc
and implementationConsumerProc.i
in theConsumer
package.- specify an input event data port in the component type named
inMessage
with typeProdCons::Message
- in the component implementation, specify a thread subcomponent instance named
consumerThr
using theConsumerThr.i
component implementation. - specify a port connection named
msgCPtoCT
that connects theinMessage
port on theConsumerProc
interface to theinMessage
port ofconsumerThr
.
- specify an input event data port in the component type named
Now we return to the ProdCons
package (where we previously defined the Message
type)
to define the integrated system.
-
Create
ProdConsSystem
System. Using the HAMR templates as a guide, create a system component typeProdConsSystem
and a system component implementationProdConsSystem.i
in theProdCons
package.- The body of the component type will be empty because there are no features of the system interface (the system does not "connect to the outside world").
- In the system component implementation, specify an instance of the
Producer::ProducerProc.i
process namedprod
, and specify an instance of theConsumer::ConsumerProc.i
process namedcons
. - Specify a port connection
msgPPtoCP
from theoutMessage
ofprod
to theinMessage
port ofcons
.
At this point, if you have not already done so, you may find it convenient watch the solution video that walks through the construction of the model.
- Create a structure diagram from the system component implementation following the steps illustrated in the solution video. When you have configured the diagram to show all of the subcomponents, etc. it should look something similar to what is shown below.