RMC Tutorial.pdf
-
Upload
laurentiu-iacob -
Category
Documents
-
view
276 -
download
1
Transcript of RMC Tutorial.pdf
-
7/27/2019 RMC Tutorial.pdf
1/74
Riverside Drive
ndover, MA 01810
.S.A.
in MicroC
Tutorial
Release 2.1
-
7/27/2019 RMC Tutorial.pdf
2/74
Copyright Notice and Proprietary Information
Copyright 2000 by I-Logix Inc. Printed in the United States of America.
3 Riverside Drive, Andover, MA 01810 U.S.A.
All rights reserved.
The software described in this document is furnished under a license and may be used or copied only in
accordance with the terms of such license. Statemate software contains proprietary information, as well
as trade secrets of I-Logix Inc., and is protected under international copyright law. Reproduction,
adaptation, or translation, in whole or in part, by any means graphic, electronic or mechanical, including
photocopying, recording, taping, or storage in an information retrieval system of any part of this work
covered by copyright is prohibited without prior written permission of the copyright owner, except as
allowed under the copyright laws.
This product or products depicted herein may be protected by one or more U.S. or international patents
or pending patents.
The information in this manual is subject to change without notice. I-Logix assumes no responsibility or
liability for any errors contained herein or direct, indirect, special, incidental or consequential damages in
conjunction with the furnishing, performance, or use of this material.
Restricted Rights Legend:. Use, duplication, or disclosure by the government is subject to restrictions
set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at
DFARS 252.227-7013 (October 1988) and FAR 52.227-19 (June 1987).
Trademarks
Statemate is a registered trademark of I-Logix Inc. I-Logix and the I-Logix logo are trademarks of I-Logix
Inc.
Microsoft, MS, and MS-DOS are registered trademarks, and Windows and Windows NT are trademarks
of Microsoft Corporation.
X Window System is a trademark and product of the Massachusetts Institute of Technology.
Sun, SunOS, Solaris, OpenWindows, and NFS are trademarks or registered trademarks of Sun
Microsystems, Inc.
Other products mentioned may be trademarks or registered trademarks of their respective companies.
Part No. 2170
Printed in the United States of America
-
7/27/2019 RMC Tutorial.pdf
3/74
Rhapsody in MicroC iii
Welcome to the Rhapsody in MicroC Tutorial, Release 2.1. Thismanual is designed to be a stand-alone introduction to the useof Rhapsody in MicroC (RiMC) in developing an embeddedsoftware project. A copy of this manual is also available online.
This document is part of the core document set for Rhapsody inMicroC. This core document set includes the followingdocuments:
Rhapsody in MicroC Administrators Guide
Rhapsody in MicroC Quick Reference Guide
Modeling Reactive Systems with Statemate
Rhapsody in MicroC On-Line Help
Rhapsody in MicroC Tutorial Miscellaneous Errata Sheets, Release Notes, and
other secondary documents
In addition, your software includes a collection of electronicreference documents. This On-Line Reference Library consistsof a collection of reference manuals and other documentsprovided in the Adobe Acrobat document format. A MasterList document serves as the gateway to individual documents inthe Reference Library. This gateway document is available fromthe main RiMC menu, from the on-line help, or directly1 whenopened through the Acrobat Reader. Hard Copies of any of theon-line reference documents can be generated by printing themanual from the Acrobat reader.
1. Look for the document file named: MAGDOCS.PDF
Preface
-
7/27/2019 RMC Tutorial.pdf
4/74
iv Rhapsody in MicroC
W h e r e t o F i n d I n f o r m a t i o n
As mentioned earlier, the Rhapsody in MicroC documentationset typically consists of three principle parts:
Printed Hard-copy documents and manuals
On-line Help
On-line Reference Library
Hard-Copy Documents & Manuals
Except for product versions delivered electronically, the coredocument set includes the following hard-copy documents:
Release Notes
Standard License Statement
Installation Guide
Tutorial
Note: In the case of products delivered electronically, all
documents will be included in an electronic format.
There may also be a collection of Errata Sheets that listinformation that became available only after the otherdocuments went to press.
Hard copy manuals for other modules optional to the coreRiMC product only include Release Notes, the Standard LicenseStatement, and Errata Sheets (as needed). The balance of themodules document set is supplied in an electronic format.
On-Line Help
On-line Help is available throughout RiMC. To access this HelpInformation, you can use the Help menu items or the Help
buttons on various screens. The help files have been designed toconform with the standard Windows NT 4.0 help engine,including full indexing, searching, printing, and hypertext
-
7/27/2019 RMC Tutorial.pdf
5/74
Rhapsody in MicroC v
Where to Find Information
links. For complete details please see the Help>Help on Helpitem in the RiMC main menu.
Using the On-line Reference LibraryThere are many reference documents available that focus onspecific features and/or options for RiMC. Some additionaldocuments are included that were written originally forStatemate MAGNUM, but which apply to RiMC. All of thesedocuments make up an extensive library that is too large toprint and store on a bookshelf. In fact, there is so muchinformation available that it is sometimes difficult to find aspecific piece of information. To solve these problems we have
provided this reference library in the format of Adobe AcrobatDocuments. Using the Adobe Acrobat Reader (supplied withyour RiMC installation) you can view, search, print, and jumpto cross references in other documents with ease. If you havenot used the Acrobat Reader, an on-line guide is available fromthe Readers help menu.
Documents within the reference library are accessed through aMaster List document which serves as a gateway to the entirelibrary. These documents are also used as additional reference
material to support on-line help topics. Both the Master List andthe on-line help are available from inside the RiMC mainapplication. On-line help is also available throughout theapplication and its many modules.
The latest versions of the Acrobat Reader (for all platforms) areavailable directly from Adobes website: www.adobe.comThere is no charge for the viewer. If you download the vieweryourself, please be sure to select the version with extendedsearch capabilities. This version will allow you to search
multiple documents simultaneously.
-
7/27/2019 RMC Tutorial.pdf
6/74
vi Rhapsody in MicroC
C o n ven ti o n s
This book uses the following type conventions:
Type Style Description
command1>command2 The greater-than (>) symbol leads you to thenext item in a menu sequence. For example,
File > Exit means to first select File from the
menu bar, then select Exit from the File menu.
Italic type Italic type is used for variable names that you
should replace with actual names. For
example, you should replace filenamewith the
name of an actual file. Italics also indicate titles
of referenced documents.
Courier type Courier type is used for file names, directory
names, keywords, code, and system output.
-
7/27/2019 RMC Tutorial.pdf
7/74
Rhapsody in MicroC vii
Support
Su p p o r t
The I-Logix Technical Support Help Desk provides assistancewith installation, application issues, product defect reporting,
and documentation questions. Technical support engineers, inconjunction with sales application engineers, assist prospectivecustomers with product evaluations and provide timelyresponses to user issues. This ensures maximum productivity.
The Technical Support Help Desk can be contacted in fourdifferent ways: email, the internet, by phone, or by fax.
E-Mail and Web
For the quickest and most effective response from anywhere inthe world, contact Technical Support by filling out the supportform found on our website at http://www.ilogix.com.
You may also contact us via e-mail at the following address:[email protected]. European customers should [email protected]. In either case, if you use email to contactus, it is very important that you include the followinginformation along with the description of your problem:
Contact Information:
Software Information:
Your Name:E-mail address:Phone:Company:Location:
Version and Build number of Rhapsody in MicroC:Operating system:Version and/or Patch Level or Service Pack applied:Any third-party tools you are using:
-
7/27/2019 RMC Tutorial.pdf
8/74
viii Rhapsody in MicroC
Computer System Information:
Details of your problem:
Please describe the nature of the problem, and the exactsequence of steps that caused or shows the problem. Also noteany error messages that you have received.
Telephone Support
You can reach the helpdesk at 978-682-4884, Monday throughFriday, 8:30 am till 5:30 pm Eastern Standard Time.
European customers should call Technical Support at I-LogixUK Ltd., Monday through Friday, 9:00 am to 5:30 pm UK time.Their phone number is +44 (1249) 446-448.
Fax Support
Faxes can be sent to 978-682-5995.
European customers should send faxes to +44 (1249) 447-373.
Computer Model:Processor speed:RAM:Free disk space:
-
7/27/2019 RMC Tutorial.pdf
9/74
Rhapsody in MicroC ix
Support
NOTES
-
7/27/2019 RMC Tutorial.pdf
10/74
x Rhapsody in MicroC
-
7/27/2019 RMC Tutorial.pdf
11/74
Statemate MAGNUM xi
Contents
Preface ........................................................................... iii
Introduction ................................................................... 15
Getting Started .......................................................... ..... 19
Creating the Top Level ActivityChart ............................. 23
Defining Elements and Attributes ................................ 33
Creating Statecharts ....................................................... 41
Creating Panels .............................................................. 49
Executing the Model ...................................................... 57
Using the Test Driver ..................................................... 67
Index .............................................................................. 73
-
7/27/2019 RMC Tutorial.pdf
12/74
xii Statemate MAGNUM
-
7/27/2019 RMC Tutorial.pdf
13/74
Statemate MAGNUM xiii
-
7/27/2019 RMC Tutorial.pdf
14/74
xiv Statemate MAGNUM
-
7/27/2019 RMC Tutorial.pdf
15/74
Rhapsody in MicroC 15
Introduction
Welcome to the Rhapsody in MicroC Tutorial. This tutorial willintroduce you to the basic techniques required to use Rhapsodyin MicroC (RiMC) by guiding you through a series of exercises.Each exercise will focus on familiarizing you with a basic set ofskills necessary for using RiMCs core features.
Because the focus of these exercises is on the mechanics of theRiMC tool, it is not intended to teach you the fine points ofdesign methodology. However, additional information to usein learning more about modeling and design methodology has
been provided for individual study. Please refer to thefollowing documents which may be found online in the RiMCReference Library:
Modeling Reactive Systems with Statecharts: The StatemateApproach, by David Harel and Michal Politi, I-LogixP/N 2005.
Statemate MAGNUM Methodology and Style Guidelines,Version 1.2, I-Logix P/N D-1100-51B, 08/97
Go al s
At the completion of this tutorial you will have learned thefollowing skills:
How to start Rhapsody in MicroC.
Creating a new project.
Using Activity Charts to describe the functional viewof a model.
-
7/27/2019 RMC Tutorial.pdf
16/74
16 Rhapsody in MicroC
Using the Data Dictionary to define textual elementsand design attributes.
Using Statecharts to describe the behavioral view of
a model. Creating graphical panels to mock up the user
interface of the system design.
Setting up the C Code Generator to produce anexecutable running under Windows NT.
Using test vectors to automate your code testing.
W h o T h i s T u t o r i a l I s F o r
This tutorial is intended for any Software Developers whowants to learn how to use Rhapsody in MicroC. Users may ormay not have previous experience with I-Logix StatemateMAGNUM automated system design tools, or with embeddedsystem development. That experience might be helpful, but it isnot necessary.
This tutorial is not intended to be a primer on embeddedsystems development. Rather, it is simply intended to be a basic
teaching aid on the mechanics of using the Rhapsody in MicroCtool. Any user seeking training in embedded system designshould read any of the better technical books on the subject orenroll in a suitable seminar or college course.
Advanced training with Rhapsody in MicroC, and the otherdevelopment tools offered by I-Logix, is also available. Contactyour sales representative for additional information.
Pr e-T u to r i al C h eckl i st
The following must be installed on your computer:
Rhapsody in MicroC
Microsoft Visual C++ V5.0 or later.
-
7/27/2019 RMC Tutorial.pdf
17/74
Rhapsody in MicroC 17
Using the Mouse Buttons
U s i n g t h e M o u s e B u t t o n s
It is necessary to briefly describehow to use the mouse buttons. It
is assumed that you are using a 3-button mouse. On this mouse, theLeft button is called the Select
button. This button is used forselecting elements, icons andmenu items. It is also used forplacing the starting points for transitions. Wherever you see tothe direction to select an item, do so with a left mouse click.
The Middle button is called the Transferbutton. This button isused for moving elements. It is also used for placing the endingpoint for transitions.
The Right button is called the Menu button. When this buttonis held down, a pop-up menu is displayed. When this is simplyclicked, it deselects the selected item.
T h e E x a m p l e P r o j e c t
The example project is a traffic light with red, yellow, and greenindicators. The design is extremely simple so you can fullyconcentrate on learning Rhapsody in MicroC, rather than on thedesign problem itself.
-
7/27/2019 RMC Tutorial.pdf
18/74
18 Rhapsody in MicroC
-
7/27/2019 RMC Tutorial.pdf
19/74
Rhapsody in MicroC 19
Lesson
11Getting Started
G oa l s f o r t h i s L es s o n
In this lesson you will learn to:
Start Rhapsody in M icroC
Create a new project
Step 1. Star ti n g R h ap so d y i n M i cr o C
Start RiMC by clicking onStart>Programs>Rhapsody inMicroC>RMC.
If RiMC does not start, refer to theTroubleshooting section of the
Rhapsody in MicroCAdministrators Guide.
-
7/27/2019 RMC Tutorial.pdf
20/74
Getting Started
20 Rhapsody in MicroC
Step 2. C r eati n g a N ew Pr o j ect
1. From the main window, clickthe File>New Project.... The
Create New Project formappears.
2. Fill in the form as shown:
Name: TRAFFIC_LIGHT or whatever you prefer.
Databank: path to the databank directory (to use thebrowser click the [] button at the end of the line) . Ifyou are using this Tutorial in a training class, theinstructor will tell you where to put the databank.
The Databank is a shared directory for all users involved in a
specified project. It may be located on a network drive. This is
where releases of a model will be saved. Its highly recommended
that it not be shared with other projects or applications.
OS Implementation: MAINLOOP_SC
-
7/27/2019 RMC Tutorial.pdf
21/74
Rhapsody in MicroC 21
Goals for this Lesson
3. Click OK. The Open Project form appears with theproject you just created selected.
4. Fill in the form as follows:
Workarea: path to the workarea directory (to use thebrowser click the [] button at the end of the line) . Ifyou are using this Tutorial in a training class, theinstructor will tell you where to put the workarea.
The Workarea is your personal working directory. Each user
involved in a project needs to create at least one workarea. Oneuser may have multiple workareas per project. Unlike databanks,
workareas are stored on a local disk; they are not shared.
-
7/27/2019 RMC Tutorial.pdf
22/74
Getting Started
22 Rhapsody in MicroC
5. Click OK. The project opens and various tool iconsappear in the Rhapsody in MicroC main widow.
R evi ew
In this lesson, you have learned how to start a new project. Indoing that, you have also learned how to get the main screen ofRiMC to appear with all available tools ready to use.
You are now ready to proceed to Lesson 2...
-
7/27/2019 RMC Tutorial.pdf
23/74
Rhapsody in MicroC 23
Lesson
22Creating the Top
Level ActivityChart
G o a l f o r t h i s L e s s o n
In this lesson you will create the top level Activity Chart for theTraffic Light System. An Activity Chart represents thefunctionalview of a system. It consists of the following elements:
While creating the Activity Chart, you will functionallydecompose the Traffic Light System into activities and show theexternal environment of the system using external activities.You will also use data flows to represent the exchange ofinformation between activities. The finished Activity Chart willlook like this:
Use the illustration as a guide as you draw your own chart.
Activities The functions in the system.
Control Activities Links to Statecharts that control otheractivities or that represent an activitys
behavior.
External Activities Elements outside of the system to whichthe activities interface.
Data Flows Exchanges of data between activities.
-
7/27/2019 RMC Tutorial.pdf
24/74
Creating the Top Level ActivityChart
24 Rhapsody in MicroC
O N L I N E H E L P
Rhapsody in MicroC has extensive online help available. Most tool windows
(graphics editors, dialogs, etc.) have a Help menu item or a Help Button thatcalls up the context sensitive online help system. In Windows NT, thestandard NT help engine is used, just like other Windows applications. Andin the various versions of unix, the HyperHelp engine provides the samefunctionality as the NT help engine. In both cases, the online help isaugmented by a library of online documents in Adobe Acrobat format. Thesedocuments can be opened through the List of Books menu item or as specificresources for further information from within an online help topic.
For example, if you drop down the Help menu list in the
main window of the Activity Chart Graphic Editor, andthen choose the on Window menu item, the helpwindow will open and the main topic for the ActivityChart Graphics Editor will appear.
The illustrationof the GraphicEditors mainwindow hashot spots that
supplyadditionalinformationabout theindividualcomponents ofthe editorsmain window.You will know
that you areover a hot spotwhen the mousecursor changes from an arrow to a pointing hand icon. If you position themouse cursor over the button bar near the top of the window and click theSelect mouse button, you will see a new window open with information likethat shown above.
-
7/27/2019 RMC Tutorial.pdf
25/74
Rhapsody in MicroC 25
ONLINE HELP
Step 1. C r eati n g an A cti vi ty C h ar t
1. Select the Graphic Editors icon from the main window.
2. The OpenChart dialogappears.
-
7/27/2019 RMC Tutorial.pdf
26/74
Creating the Top Level ActivityChart
26 Rhapsody in MicroC
Fill in the fields as follows:
Type: Activity Chart
Usage: Regular
Name Pattern: TRAFFIC_LIGHT_CONTROLLER
3. Click the New button. The Activity Chart G raphicEditor appears.
Speed
Buttons
DrawingElementButtons
~ Graphics Drawing Area ~
MessageArea
Help Information Area
-
7/27/2019 RMC Tutorial.pdf
27/74
Rhapsody in MicroC 27
ONLINE HELP
Step 2. D r awi n g an I n ter n al A cti vi ty
1. Select the C r e a t e I n t e r n a l A c t i v i t y iconfrom the graphic editor. Notice the tool tips
that appear as you hold the cursor over thedrawing buttons.
2. Draw the TRAFFIC_LIGHT activity.
3. Name the TRAFFIC_LIGHT activity.
Place the cursor at the desiredlocation of the upper, left handcorner of the activity. Click and holdthe left mouse button while draggingthe crosshair (+) cursor to the lower,
right hand corner of the activity. Adashed outline stretches with the cursorto show the shape of the activity.
Release the mouse button at the lower,right hand corner of the activity. Theoutline of the activity becomes solid.
While the Create Internal Activity modeis still active, type the activity name inuppercase or lowercase. The letters youare typing appear in the graphicsdrawing area.
Move the name to the desired locationinside the activity box. Click the leftmouse button. The name is changed touppercase letters and becomesassociated with the activity in which itresides.
-
7/27/2019 RMC Tutorial.pdf
28/74
Creating the Top Level ActivityChart
28 Rhapsody in MicroC
Step 3. D r awi n g a C o n tr o l A cti vi ty
1. Select the C r e a t e C o n t r o l A c t i v i t y iconfrom the graphic editor.
2. Draw and label theTRAFFIC_LIGHT_CTRL activityinside the TRAFFIC_LIGHTactivity using the same methodsas in Step 2.
Step 4. D r awi n g Exter n al A cti vi ti es
1. Select the Create External Activity icon fromthe graphic editor.
2. Draw and label two external activities:INPUTS and OUTPUTS. Use the figure
below as a guide.
-
7/27/2019 RMC Tutorial.pdf
29/74
Rhapsody in MicroC 29
ONLINE HELP
Step 5. D r awi n g D ata F l o ws
1. Select the Cr e a te D a ta F lo w button from thegraphic editor.
2. Draw a data flow from INPUTS toTRAFFIC_LIGHT.
To draw straight horizontal or vertical lines, hold down the Shiftkey
while moving the cursor. You can click the leftmouse button several
times to mark corners on the way to the destination.
Place the cursor (+)on the right edge ofthe INPUTS box andclick the left mouse
button. As you movethe cursor, a dashed
line stretches toshow the shape ofthe data flow.
Move the cursor to theright edge of theTRAFFIC_LIGHT boxand click the middle
button. The data flowarrow becomes solid.
-
7/27/2019 RMC Tutorial.pdf
30/74
Creating the Top Level ActivityChart
30 Rhapsody in MicroC
Step 6. L ab el l i n g D ata F l o ws
1. Label the data flow CHANGE.While the Create DataFlow mode is still active:
To adjust the position of a label, place the cursor over the label, hold
down themiddle mouse button, move the label, and release the
button.
2. Draw and label three additional data flows shownbelow: RED_LIGHT, YELLOW_LIGHT, andGREEN_LIGHT.
Type the data flowlabel. Move the cursorto the data flow withthe crosshair (+) justtouching the line.
Click the left mousebutton to associate thelabel with the dataflow. The labelchanges to uppercase.
-
7/27/2019 RMC Tutorial.pdf
31/74
Rhapsody in MicroC 31
Review
Step 7. C h ecki n g Yo u r M o d el
In the Activity Chart GraphicEditor menus, select
Tools>Check Model. Youshould see the following messageat the bottom of the screen. If not,go back and check your work.
R evi ew
In this lesson, you have learned how to create the top levelActivity Chart for the Traffic Light System. You have learned tocreate control activities, external activities, and to specify andname the data flows between activities.
You are now ready to proceed to Lesson 3...
-
7/27/2019 RMC Tutorial.pdf
32/74
Creating the Top Level ActivityChart
32 Rhapsody in MicroC
-
7/27/2019 RMC Tutorial.pdf
33/74
Rhapsody in MicroC 33
Lesson
33Defining Elements
and Attributes
G oa l f o r t h i s L e ss o n:
In this lesson you will learn how to define the elements andattributes in your design using a tool called the Data Dictionary.
The textual elements in your design can be defined as any oneof the following types:
The design attributes for activities can be defined as any one ofthe following types:
Event Edge trigger or impulse
Condition Level trigger or Boolean
Data-Item Integer, real, string, bit, bit-array,record, union, or user-defined type
Information-Flow Container used to group elements
together
Regular Hierarchical or functionallydecomposed
Task Executed by scheduler
ISR Interrupt Service Routine
-
7/27/2019 RMC Tutorial.pdf
34/74
Defining Elements and Attributes
34 Rhapsody in MicroC
Step 1. I d en ti fyi n g U n d efi n ed El emen ts
1. Select the Data Dictionary Browser icon from theRhapsody in MicroC main window.
2. The Data Dictionary Browser window opens.(Only thetop half is shown here.)
-
7/27/2019 RMC Tutorial.pdf
35/74
Rhapsody in MicroC 35
Goal for this Lesson:
3. In the top of the window select the following items (asshown above):
Textual
Type: AllStructure: AllUndefined (deselect Defined)Used (deselect Not Used)In Chart/GDS: TAIL_LIGHT_CONTROLLER.
In the bottom of the window (shown below):
4. Click the Create New List button to display a list ofundefined textual elements.
5. Click the Select All button to highlight all t he elementsin the list.
6. Click the Data Dict button to open the Data DictionaryEditor window on those elements.
-
7/27/2019 RMC Tutorial.pdf
36/74
Defining Elements and Attributes
36 Rhapsody in MicroC
Step 2. R eso l vi n g U n d efi n ed El emen ts
1. The list of undefined elements appears in the DataDictionary Editor. The first element in the list (in this
case CHANGE) is already selected for you.
2. Set the Type to Event and click the Save & Next button.
3. For the other three elements (GREEN_LIGHT,RED_LIGHT, and YELLOW_LIGHT), set the Type toCondition and save each change.
4. Click File>Exit.
Step 3. D efi n i n g A cti vi ti es
1. Open the Activity ChartTRAFFIC_LIGHT_CONTROLLER.
2. Select the external activity INPUTS by clicking on itwith the left mouse button. At the same time, select theexternal activity OUTPUTS by holding down the Ctrlkey and clicking on it.
-
7/27/2019 RMC Tutorial.pdf
37/74
Rhapsody in MicroC 37
Goal for this Lesson:
3. Click Tools>Data Dictionary.
4. The Data Dictionary Editor opens. For both elements,set the Type to Environment and save the changes.
Step 4. D efi n i n g D esi g n A ttr i b u tes
1. In the Activity Chart TRAFFIC_LIGHT_CONTROLLER,select the activity TRAFFIC_LIGHT.
-
7/27/2019 RMC Tutorial.pdf
38/74
Defining Elements and Attributes
38 Rhapsody in MicroC
2. Click Tools>Data Dictionary.
3. Click Design Attributes...
4. Set the Type to Task, click OK , and save the change.
A Task is an activity that the schedule executes. Note that the name
of the Activity in the graphic editor now has an asterisk (*) appended
to it to indicate that it is a Task.
5. In the Activity Chart TRAFFIC_LIGHT_CONTROLLER,select the data flow label CHANGE.
6. Click Tools>Data Dictionary.
7. Click the Design Attributes... button.
8. Select Its Task and click Choose...
-
7/27/2019 RMC Tutorial.pdf
39/74
Rhapsody in MicroC 39
Review
9. The Choose window opens.
10. Click TRAFFIC_LIGHT.
11. Click OK in the Design Attribute window.
12. Click Save in the Data Dictionary Editor and File>Exit.
R evi ew
In this lesson, you have learned to use the Data Dictionary todefine elements and attributes. You have learned that textualelements can be: Events, Conditions, Data-Items, orInformation-Flows. You have also learned how to definedesign attributes such as Regular, Task, or ISR types.
You are now ready to proceed to Lesson 4...
-
7/27/2019 RMC Tutorial.pdf
40/74
Defining Elements and Attributes
40 Rhapsody in MicroC
-
7/27/2019 RMC Tutorial.pdf
41/74
Rhapsody in MicroC 41
Lesson
44Creating
Statecharts
G o a l f o r t h i s L e s s o n
In this lesson you will learn how to create a Statechart, whichrepresents the Behavioral View of a system. It consists of thefollowing elements:
The finished Statechart will look like this:
Use the illustration as a guide as you draw your own chart.
States Represent the states the functionscan be in within the system.
Transitions Show the paths the system can taketo get from one state to another.
-
7/27/2019 RMC Tutorial.pdf
42/74
Creating Statecharts
42 Rhapsody in MicroC
Step 1. C r eati n g a Statech ar t
1. Open the activity chartTRAFFIC_LIGHT_CONTROLLER.
2. Select the stateTRAFFIC_LIGHT_CTRL.
3. Click File>Create Sub-Chart.
4. Select Statechart andclick OK .
5. The graphic editor opens with the basic stateTRAFFIC_LIGHT_CTRL already drawn. You candevelop the statechart from this starting point.
-
7/27/2019 RMC Tutorial.pdf
43/74
Rhapsody in MicroC 43
Goal for this Lesson
Step 2. D r awi n g States
1. Move the name TRAFFIC_LIGHT_CTRL to the top,right-hand corner of the state.
2. Select theCreate State
icon from theStatechart graphic editor.
Speed
Buttons
DrawingElementButtons
~ Graphics Drawing Area ~
MessageArea
Help Information Area
-
7/27/2019 RMC Tutorial.pdf
44/74
Creating Statecharts
44 Rhapsody in MicroC
3. Draw and name three additional states: RED, GREEN,and YELLOW as shown.
The technique for drawing states is the same as that foractivities.
The technique for naming states is also the same as thatfor activities.
Place the cursor at the desiredlocation of the upper, left handcorner, click and hold the leftmouse button, and drag the cursor(+) to the lower, right hand corner.
Release the mouse button and the
outline of the state becomes solid.
Type the state name in uppercaseor lowercase.
Move the name to the desiredlocation inside the state box. Clickthe left mouse button.
-
7/27/2019 RMC Tutorial.pdf
45/74
Rhapsody in MicroC 45
Goal for this Lesson
Step 3. D r awi n g T r an si ti o n s
1. Select the Create Transition icon from theStatechart graphic editor.
2. Draw a transition from RED to GREEN. Thetechnique for drawing transitions is the same as that fordata flows.
To draw straight horizontal or vertical lines, hold down the Shiftkey
while moving the cursor. You can click the leftmouse button several
times to mark corners on the way to the destination.
Step 4. L ab el l i n g T r an si ti o n s
1. Label the transition from RED to GREEN as follows:
CHANGE/GREEN_LIGHT:=TRUE;
RED_LIGHT:=FALSE
The syntax of a transition label istrigger/action. In this case, the
trigger is the CHANGE event. The action consists of two statements
that assign values to the conditions GREEN_LIGHT andRED_LIGHT.
Place the cursor (+)on the right edge ofthe RED box andclick the left mouse
button.
Move the cursor to theright edge of theGREEN box and clickthe middle button.The transition arrow
becomes solid.
-
7/27/2019 RMC Tutorial.pdf
46/74
Creating Statecharts
46 Rhapsody in MicroC
The technique for labelling transitions is also the sameas that for data flows. While the Create Transition modeis still active:
To adjust the position of a label, place the cursor over it, hold down
themiddle mouse button, move the label, and release the button.
2. Draw andlabel twoadditionaltransitions as
shown:
Type the transitionlabel. Press the Enterkey to continue on anew line. Position thecrosshair (+) justtouching the line.
Click the left mousebutton to associate thelabel with the
transition. The labelchanges to uppercase.
GREEN to YELLOW CHANGE/YELLOW_LIGHT:=TRUE;GREEN_LIGHT:=FALSE
YELLOW to RED CHANGE/RED_LIGHT:=TRUE;YELLOW_LIGHT:=FALSE
-
7/27/2019 RMC Tutorial.pdf
47/74
Rhapsody in MicroC 47
Review
Step 5. D r awi n g th e D efau l t T r an si ti o n
1. Select the Create Default Transition iconfrom the Statechart graphic editor.
2. Draw andlabel thedefaulttransition a sshown.
Step 6. C h ecki n g Yo u r M o d el
Select Tools>Check Model. Youshould see the following message atthe bottom of the screen. If not, go backand check your work.
R evi ew
In this lesson, you learned how to create a Statechart, which
represents the Behavioral View of a system. It consists ofStatesthat represent the states the functions can be in within thesystem, and Transitions that show the paths the system cantake to get from one state to another.
You are now ready to proceed to Lesson 5...
/RED_LIGHT:=true;
GREEN_LIGHT:=false;
YELLOW_LIGHT:=false
-
7/27/2019 RMC Tutorial.pdf
48/74
Creating Statecharts
48 Rhapsody in MicroC
-
7/27/2019 RMC Tutorial.pdf
49/74
Rhapsody in MicroC 49
Lesson
55Creating Panels
G oa l s f o r t h i s L es s o n:
In this lesson you will create a panel, which is a graphical userinterface for testing your design. You will:
Create a new panel Draw interactors
Bind Panel Elements to Model Elements
The finished panel will look like this:
Use the illustration as a guide as you draw your own panel.
-
7/27/2019 RMC Tutorial.pdf
50/74
Creating Panels
50 Rhapsody in MicroC
Step 1. C r eati n g a Pan el
1. Click the Panel Editor icon in the Main Window ofRhapsody in MicroC.
2. The Open Panel window appears. Enter the PanelName LIGHT_CTRL_PNL and click OK.
3. The Panel Graphic Editor opens.
-
7/27/2019 RMC Tutorial.pdf
51/74
Rhapsody in MicroC 51
Goals for this Lesson:
Step 2. D r awi n g a Pu sh b u tto n I n ter acto r
1. Select the Pushbutton icon from the PanelGraphic Editor.
2. The technique for drawing a pushbutton isthe same as that for an activity or state.Place the cursor at the desired location of theupper, left hand corner, click and hold theleft mouse button, and drag the cursor (+)to the lower, right hand corner.
Speed
Buttons
DrawingElementButtons
~ Graphics Drawing Area ~
MessageArea
Help Information Area
-
7/27/2019 RMC Tutorial.pdf
52/74
Creating Panels
52 Rhapsody in MicroC
3. While the Create Pushbutton mode is stillactive, type the label and move it to thedesired location inside the pushbutton box.Click the left mouse button. The name becomes
associated with the interactor in which it resides.
Note that interactor labels (unlike other labels) do not automaticallychange to uppercase. They retain the case in which they are typed.
Step 3. D r awi n g L amp I n ter acto r s
1. Select the Lamp icon from the Panel GraphicEditor.
2. Draw a Lamp interactor to theleft of the Pushbutton. There isno need to label the Lamp.
3. Draw two more Lampinteractors under the first one.You can use Edit>Copy andEdit>Paste to duplicate the first
Lamp.
4. Draw a rectangle around theLamps.
-
7/27/2019 RMC Tutorial.pdf
53/74
Rhapsody in MicroC 53
Goals for this Lesson:
5. Select the top Lamp interactor andclick Tools>Properties...
6. The Bindings/Properties window
appears.
7. Select Highlight Color andclick Choose... The ColorViewer window opens.
8. Select RED from the listand click OK.
9. Select the bottom Lampinteractor and set theHighlight Color toGREEN.
-
7/27/2019 RMC Tutorial.pdf
54/74
Creating Panels
54 Rhapsody in MicroC
Step 4. B i n d i n g to M o d el El emen ts
1. Select the Pushbutton interactor.
2. Click Tools>Bind.
3. The Bindings/Properties windowopens.
Note that the Bind Method is set toInput by default.
4. Select Controlled by and click Choose...
-
7/27/2019 RMC Tutorial.pdf
55/74
Rhapsody in MicroC 55
Goals for this Lesson:
5. The Element Selection for Panel window appears.
TheElement Selection window is very similar to the Data
Dictionary Browser in that you can create lists of elements to choose
from.
6. Select CHANGE in the element list and clickOK. The Pushbutton is now bound to theevent and thus will cause CHANGE to occur
whenever pushed.7. Bind the three Lamp interactors (from the
top down) to the conditions RED_LIGHT,YELLOW_LIGHT, and GREEN_LIGHT.
-
7/27/2019 RMC Tutorial.pdf
56/74
Creating Panels
56 Rhapsody in MicroC
8. Click Tools>Check Bindings tocheck your work.
R evi ew
In this lesson, you have learned how to use the Panel GraphicsEditor (PGE) to create a panel for your design.
The PGE is a very important tool because it can be used to giveyou a virtual interface into your application. It can be set up toprovide ways to input data and displays the results of program
operation. The layout of your panel can emulate your targetsinterface or provide additional features useful for developmentand debugging of your application.
You are now ready to proceed to Lesson 6...
-
7/27/2019 RMC Tutorial.pdf
57/74
Rhapsody in MicroC 57
Lesson
66Executing the
Model
G oa l f o r t h i s L e ss o n:
In this lesson you will execute the Traffic Light model you justdesigned. You will:
create a Code Generation Profile set up the correct properties for your code
generate, link, and compile the code
run the executable image
You need to have Microsoft Visual C++ 5.0 or later installed.
-
7/27/2019 RMC Tutorial.pdf
58/74
Executing the Model
58 Rhapsody in MicroC
Step 1. C r eati n g a C o d e Gen er ati o n Pr o fi l e
1. In the main window of Rhapsody in MicroC, click onthe Micro C Code Generation icon.
2. The New Compilation Profilewindow opens.
3. Type in a profile name (such as
TEST01) and click OK .
4. The Code
GenerationProfile Editoropens.
-
7/27/2019 RMC Tutorial.pdf
59/74
Rhapsody in MicroC 59
Goal for this Lesson:
Step 2. C r eati n g a M o d u l e
1. Click on the MOD icon. The Create Modulewindow opens.
2. Enter TRAFFIC_LIGHT andclick OK .
3. The CodeGenerationProfile nowcontains aModule.
Step 3. A d d i ng C h a rt s t o t h e M o d ul e
1. Click the Connect to Workarea Browsericon.
2. The WorkareaBrowser opens.
3. Select the toplevel activity
chartTAIL_LIGHT_CONTROLLER.
-
7/27/2019 RMC Tutorial.pdf
60/74
Executing the Model
60 Rhapsody in MicroC
4. Return to theProfile windowand click theModule
TAIL_LIGHT,so it ishighlighted.
5. Click the AddSelected Chart to Selected Module icon.
6. The charts areadded to the
profile.
Step 4. A d d i ng a P a n e l t o t h e M o d u le
1. In the Workarea Browser, select the panel from the listof files.
2. In the Code Generation Profile, click on the
Add Selected Panel icon.3. The panel is added to the profile.
-
7/27/2019 RMC Tutorial.pdf
61/74
Rhapsody in MicroC 61
Goal for this Lesson:
Step 5. Setti n g th e T ar g et C o n fi g u r ati o n
1. Click the Options>TargetConfiguration menu item in
the Profile editor window.
2. In the Target Configurationdialog, selectMAINLOOP_SC_NT.
3. Click OK.
Step 6. Gen er ati n g C o d e
1. Click the Generate Code for Current Profileicon in the Profile Editor window.
2. The Output Directorywindow opens.
3. Select OK to acceptthe default directory.
-
7/27/2019 RMC Tutorial.pdf
62/74
Executing the Model
62 Rhapsody in MicroC
4. The GenerateCode for Profiledialog appearsand the code is
generated.
5. Click Dismiss toclose the dialog.
Step 7. C o mp i l i n g th e Gen er ated C o d e
1. Click the Compile Generated Code icon inthe Code Generation Profile Editor window.
2. The SelectedMakefile
dialog opens.
3. Click Open toaccept thedefaultmakefile.
-
7/27/2019 RMC Tutorial.pdf
63/74
Rhapsody in MicroC 63
Goal for this Lesson:
4. A Command Prompt window appears as the code iscompiled and linked.
5. Type exit to close the window.
-
7/27/2019 RMC Tutorial.pdf
64/74
Executing the Model
64 Rhapsody in MicroC
Step 8. R u n n i n g t h e Execu tab l e I mag e
1. Click Tools>OpenGBA to start the
GBA (GraphicalBack Animation)server. You canminimize thiswindow or selectcharts to animate.
2. Click the ExecuteCompiled Code icon in the Code Generation
Profile Editor window.
3. The RunCommand dialogappears.
4. Click Open.
5. A CommandPrompt windowappears.
6. Wait for theexecutable tostart. (It may notstart immediately.)
7. Click the CHANGE button and watch the Traffic Light.
-
7/27/2019 RMC Tutorial.pdf
65/74
Rhapsody in MicroC 65
Review
8. To end the run, simply close the panel.
9. The GBA server prints this error message. Click OK .
R evi ew
In this lesson, you learned how to:
create a Code Generation Profile
set up the correct properties for your code generate, link, and compile the code
run the executable image
You are now ready to proceed to Lesson 7...
-
7/27/2019 RMC Tutorial.pdf
66/74
Executing the Model
66 Rhapsody in MicroC
-
7/27/2019 RMC Tutorial.pdf
67/74
Rhapsody in MicroC 67
Lesson
77Using the Test
Driver
G o a l f o r t h i s L e s s o n
In this lesson, you will learn how to test the dynamic behaviorof the developed application non-interactively, using test vectorinputs and outputs. You will:
Generate Test Vectors.
Stream the inputs and outputs to disk for postanalysis.
Reuse Test Vectors for subsequent simulations.
Step 1. En ab l e th e T est D r i ver
1. Stop any executing models by closing the Panel
window.
2. If it is not already running, start the GBA server.
3. Open the Compilation Profile.
4. Click Options>Settings...
5. The Properties for CodeGeneration dialog opens.
6. Click the Test
Driver tab.7. Click Enable
and OK .
-
7/27/2019 RMC Tutorial.pdf
68/74
Using the Test Driver
68 Rhapsody in MicroC
Step 2. Vi ew Str eami n g Vecto r D ata
1. Regenerate and recompile the code.
2. Run the model.3. Press the CHANGE button and watch the Command
Prompt window to se e the Test Driver stream the datato the standard output.
4. Stop the model.
Step 3. C r eate T est Vecto r F i l es
1. Use a text editor such as Notepad to create thefollowing batch file named dos_box.bat in the workingdirectory (as shown in the Command Prompt windowabove.)
Setting these environment variables redirects the standard input and
output to files, making it possible to post-process the results.
-
7/27/2019 RMC Tutorial.pdf
69/74
Rhapsody in MicroC 69
Goal for this Lesson
2. Run the model.
3. The RunCommand
dialog opens.4. Select
dos_box.batand ClickOpen.
5. A Command Prompt window opens.
6. Type the name of the executable image (in this case,test01.exe).
7. Once the model is running, click the CHANGE buttonseveral times to ensure that the Test Driver gets somedata.
8. Stop the model.
-
7/27/2019 RMC Tutorial.pdf
70/74
Using the Test Driver
70 Rhapsody in MicroC
9. Test Vector files have been created in the workingdirectory (see the Command Prompt window above).
The files are both of a similar format and are explained
in the following table.
Tim e Va riab le Na me Va riable Typ e Va riab le Va lue Comm ents
Absolute orRelative.Default isAbsolute.
As in DataDictionary.
See tablebelow.
The new valueit is set to.
As shown infile.
Data Type Identifier
INTEGER_DATA_ITEM 0REAL_DATA_ITEM 1
BIT 2
BIT_ARRAY 3
STRING_DATA_ITEM 4
CONDITION 5
-
7/27/2019 RMC Tutorial.pdf
71/74
Rhapsody in MicroC 71
Goal for this Lesson
Step 4. R u n t h e M o d e l U s i n g a T e s t V e c t o r
1. Edit dos_box.bat and enable the line that wascommented out.
2. Rename the fileTESTDRIVER_INPUT_FROM_PNL_FILE.txttoTESTDRIVER_IN_FILE.txt .
3. Edit TESTDRIVER_IN_FILE.txt and modify the header(the first line) as shown.
4. Run the executable model as before but do not pressthe CHANGE button! The Test Driver will useTESTDRIVER_IN_FILE.txt to stimulate the model. Theoutput will be streamed to disk as before.
EVENT 6
STATE 7
ACTIVITY 8
ENUM_DATA_ITEM 9
-
7/27/2019 RMC Tutorial.pdf
72/74
Using the Test Driver
72 Rhapsody in MicroC
R evi ew
You have now used a test vector to automate your code testing.The inputs and outputs are all recorded for post processing.
This feature greatly improves the testing of embeddedapplications.
Congratulations!
You just finished your first design!
-
7/27/2019 RMC Tutorial.pdf
73/74
Statemate MAGNUM 73
Index
A
activities, 33ISR, 33regular, 34task, 33
Activity Chart, 23advanced training, 16
B
Bindingpanel elements, 54
Boolean, 33
C
Code Generation Profile, 57 , 65Compilation Profile, 67Control Activities, 28
D
Data Dictionary, 16Data Dictionary Browser, 34Data Dictionary Editor, 35David Harel, 15drawing activities, 27drawing control activities, 28
E
edge trigger, 33embedded system development, 16
F
functional decomposition, 23
G
Generate Code, 61 , 62
Graphic Editors, 25
I
impulse, 33
L
level trigger, 33
M
Microsoft Visual C++, 16, 57Modeling Reactive Systems with
Statecharts, 15Module Name, 59
-
7/27/2019 RMC Tutorial.pdf
74/74
mouse buttons, 17
O
online help, 24Help>on Help, 24
P
panel, 49Panel Graphic Editor, 50project
new, 20 , 22
proprietary information, ii
S
Statechartcreating, 41
Statecharts
drawing transitions, 45graphic editor, 43 , 51, 52States, 41
Transitions, 41Statemate MAGNUM
Methodology and Style Guidelines, 15
T
textual elements, 33condition, 33data-item, 33event, 33information-flow, 33
top level chart, 23trademarks, ii
W
Workarea Browser, 59