Академический Документы
Профессиональный Документы
Культура Документы
Tutorial
Release 2.1
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.
Preface
Welcome to the Rhapsody in MicroC Tutorial, Release 2.1. This manual is designed to be a stand-alone introduction to the use of Rhapsody in MicroC (RiMC) in developing an embedded software project. A copy of this manual is also available online. This document is part of the core document set for Rhapsody in MicroC. This core document set includes the following documents: Rhapsody in MicroC Administrator s 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 electronic reference documents. This On-Line Reference Library consists of a collection of reference manuals and other documents provided in the Adobe Acrobat document format. A Master List document serves as the gateway to individual documents in the Reference Library. This gateway document is available from the main RiMC menu, from the on-line help, or directly1 when opened through the Acrobat Reader. Hard Copies of any of the on-line reference documents can be generated by printing the manual from the Acrobat reader.
1. Look for the document file named: MAGDOCS.PDF
Rhapsody in MicroC
iii
Whe re t o Fi nd I nf orm at io n
As mentioned earlier, the Rhapsody in MicroC documentation set 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 core document 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 list information that became available only after the other documents went to press. Hard copy manuals for other modules optional to the core RiMC product only include Release Notes, the Standard License Statement, and Errata Sheets (as needed). The balance of the modules document set is supplied in an electronic format. On-Line Help On-line Help is available throughout RiMC. To access this Help Information, you can use the Help menu items or the Help buttons on various screens. The help files have been designed to conform with the standard Windows NT 4.0 help engine, including full indexing, searching, printing, and hypertext
iv
Rhapsody in MicroC
links. For complete details please see the Help>Help on Help item in the RiMC main menu. Using the On-line Reference Library There are many reference documents available that focus on specific features and/or options for RiMC. Some additional documents are included that were written originally for Statemate MAGNUM, but which apply to RiMC. All of these documents make up an extensive library that is too large to print and store on a bookshelf. In fact, there is so much information available that it is sometimes difficult to find a specific piece of information. To solve these problems we have provided this reference library in the format of Adobe Acrobat Documents. Using the Adobe Acrobat Reader (supplied with your RiMC installation) you can view, search, print, and jump to cross references in other documents with ease. If you have not used the Acrobat Reader, an on-line guide is available from the Readers help menu. Documents within the reference library are accessed through a Master List document which serves as a gateway to the entire library. These documents are also used as additional reference material to support on-line help topics. Both the Master List and the on-line help are available from inside the RiMC main application. On-line help is also available throughout the application and its many modules. The latest versions of the Acrobat Reader (for all platforms) are available directly from Adobes website: www.adobe.com There is no charge for the viewer. If you download the viewer yourself, please be sure to select the version with extended search capabilities. This version will allow you to search multiple documents simultaneously.
Rhapsody in MicroC
Conv e nt ions
This book uses the following type conventions:
Type Style command1>command2 Description The greater-than (>) symbol leads you to the next 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 is used for variable names that you should replace with actual names. For example, you should replace filename with the name of an actual file. Italics also indicate titles of referenced documents. Courier type is used for file names, directory names, keywords, code, and system output.
Italic type
Courier type
vi
Rhapsody in MicroC
Support
Su pport
The I-Logix Technical Support Help Desk provides assistance with installation, application issues, product defect reporting, and documentation questions. Technical support engineers, in conjunction with sales application engineers, assist prospective customers with product evaluations and provide timely responses to user issues. This ensures maximum productivity. The Technical Support Help Desk can be contacted in four different ways: email, the internet, by phone, or by fax. E-Mail and Web For the quickest and most effective response from anywhere in the world, contact Technical Support by filling out the support form found on our website at http://www.ilogix.com. You may also contact us via e-mail at the following address: support@ilogix.com. European customers should use eurosup@ilogix.com. In either case, if you use email to contact us, it is very important that you include the following information along with the description of your problem: Contact Information: Your Name: E-mail address: Phone: Company: Location:
Software Information:
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:
Rhapsody in MicroC
vii
viii
Rhapsody in MicroC
Support
NOTES
Rhapsody in MicroC
ix
Rhapsody in MicroC
Co nt e n t s
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
Statemate MAGNUM
xi
xii
Statemate MAGNUM
Statemate MAGNUM
xiii
xiv
Statemate MAGNUM
Introduction
Welcome to the Rhapsody in MicroC Tutorial. This tutorial will introduce you to the basic techniques required to use Rhapsody in MicroC (RiMC) by guiding you through a series of exercises. Each exercise will focus on familiarizing you with a basic set of skills necessary for using RiMCs core features. Because the focus of these exercises is on the mechanics of the RiMC tool, it is not intended to teach you the fine points of design methodology. However, additional information to use in learning more about modeling and design methodology has been provided for individual study. Please refer to the following documents which may be found online in the RiMC Reference Library: Modeling Reactive Systems with Statecharts: The Statemate Approach, by David Harel and Michal Politi, I-Logix P/N 2005. Statemate MAGNU M Methodology and Style Guidelines, Version 1.2, I-Logix P/N D-1100-51B, 08/97
Goa l s
At the completion of this tutorial you will have learned the following skills: How to start Rhapsody in MicroC. Creating a new project. Using Activity Charts to describe the functional view of a model.
Rhapsody in MicroC 15
Using the Data Dictionary to define textual elements and 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 an executable running under Windows NT. Using test vectors to automate your code testing.
16
Rhapsody in MicroC
Rhapsody in MicroC
17
18
Rhapsody in MicroC
Getting Started
Lesson
Goa l s fo r t hi s Les s on
In this lesson you will learn to: Start Rhapsody in MicroC Create a new project
Rhapsody in MicroC
19
Getting Started
Name : TRAFFIC_LIGHT or whatever you prefer. Databank : path to the databank directory (to use the browser click the [] button at the end of the line). If you are using this Tutorial in a training class, the instructor 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
20
Rhapsody in MicroC
3. Click OK. The Open Project form appears with the project you just created selected.
4. Fill in the form as follows: Workarea : path to the workarea directory (to use the browser click the [] button at the end of the line). If you are using this Tutorial in a training class, the instructor 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. One user may have multiple workareas per project. Unlike databanks, workareas are stored on a local disk; they are not shared.
Rhapsody in MicroC
21
Getting Started
5. Click OK. The project opens and various tool icons appear in the Rhapsody in MicroC main widow.
Re vi ew
In this lesson, you have learned how to start a new project. In doing that, you have also learned how to get the main screen of RiMC to appear with all available tools ready to use.
22
Rhapsody in MicroC
In this lesson you will create the top level Activity Chart for the Traffic Light System. An Activity Chart represents the functional view of a system. It consists of the following elements: Activities Control Activities The functions in the system. Links to Statecharts that control other activities or that represent an activitys behavior.
External Activities Elements outside of the system to which the activities interface. Data Flows Exchanges of data between activities.
While creating the Activity Chart, you will functionally decompose the Traffic Light System into activities and show the external environment of the system using external activities. You will also use data flows to represent the exchange of information between activities. The finished Activity Chart will look like this:
O NLIN E HELP
Rhapsody in MicroC has extensive online help available. Most tool windows (graphics editors, dialogs, etc.) have a Help menu item or a Help Button that calls up the context sensitive online help system. In Windows NT, the standard NT help engine is used, just like other Windows applications. And in the various versions of unix, the HyperHelp engine provides the same functionality as the NT help engine. In both cases, the online help is augmented by a library of online documents in Adobe Acrobat format. These documents can be opened through the List of Books menu item or as specific resources 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, and then choose the on Window menu item, the help window will open and the main topic for the Activity Chart Graphics Editor will appear. The illustration of the Graphic Editors main window has hot spots that supply additional information about the individual components of the editors main window. You will know that you are over a hot spot when the mouse cursor changes from an arrow to a pointing hand icon. If you position the mouse cursor over the button bar near the top of the window and click the Select mouse button, you will see a new window open with information like that shown above.
24 Rhapsody in MicroC
ONLINE HELP
Rhapsody in MicroC
25
Fill in the fields as follows: Type : Activity Chart Usage : Regular Name Pattern: TRAFFIC_LIGHT_CONTROLLER 3. Click the New button. The Activity Chart Graphic Editor appears.
Speed Buttons
Message Area
26
Rhapsody in MicroC
ONLINE HELP
3. Name the TRAFFIC_LIGHT activity. While the Create Internal Activity mode is still active, type the activity name in uppercase or lowercase. The letters you are typing appear in the graphics drawing area. Move the name to the desired location inside the activity box. Click the left mouse button. The name is changed to uppercase letters and becomes associated with the activity in which it resides.
Rhapsody in MicroC
27
28
Rhapsody in MicroC
ONLINE HELP
Rhapsody in MicroC
29
To adjust the position of a label, place the cursor over the label, hold down the middle mouse button, move the label, and release the button.
2. Draw and label three additional data flows shown below: RED_LIGHT, YELLOW_LIGHT, and GREEN_LIGHT.
30
Rhapsody in MicroC
Review
Re vi ew
In this lesson, you have learned how to create the top level Activity Chart for the Traffic Light System. You have learned to create control activities, external activities, and to specify and name the data flows between activities.
Rhapsody in MicroC
31
32
Rhapsody in MicroC
In this lesson you will learn how to define the elements and attributes in your design using a tool called the Data Dictionary. The textual elements in your design can be defined as any one of the following types: Event Condition Data-Item Edge trigger or impulse Level trigger or Boolean Integer, real, string, bit, bit-array, record, union, or user-defined type
Information-Flow Container used to group elements together The design attributes for activities can be defined as any one of the following types: Regular Task ISR Hierarchical or functionally decomposed Executed by scheduler Interrupt Service Routine
Rhapsody in MicroC
33
2. The Data Dictionary Browser window opens.(Only the top half is shown here.)
34
Rhapsody in MicroC
3. In the top of the window select the following items (as shown above): Textual Type: All Structure: All Undefined (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 of undefined textual elements. 5. Click the Select All button to highlight all the elements in the list. 6. Click the Data Dict button to open the Data Dictionary Editor window on those elements.
Rhapsody in MicroC
35
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 to Condition and save each change. 4. Click File>Exit.
Step 3. De fi ning Ac ti v it ie s
1. Open the Activity Chart TRAFFIC_LIGHT_CONTROLLER. 2. Select the external activity INPUTS by clicking on it with the left mouse button. At the same time, select the external activity OUTPUTS by holding down the Ctrl key and clicking on it.
36
Rhapsody in MicroC
4. The Data Dictionary Editor opens. For both elements, set the Type to Environment and save the changes.
Rhapsody in MicroC
37
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.
38
Rhapsody in MicroC
Review
10. Click TRAFFIC_LIGHT. 11. Click OK in the Design Attribute window. 12. Click Save in the Data Dictionary Editor and File>Exit .
Re vi ew
In this lesson, you have learned to use the Data Dictionary to define elements and attributes. You have learned that textual elements can be: Events, Conditions, Data-Items, or Information-Flows. You have also learned how to define design attributes such as Regular, Task, or ISR types.
Rhapsody in MicroC
39
40
Rhapsody in MicroC
Creating Statecharts
Lesson
Goa l f or t hi s Le ss on
In this lesson you will learn how to create a Statechart, which represents the Behavioral View of a system. It consists of the following elements: States Transitions Represent the states the functions can be in within the system. Show the paths the system can take to get from one state to another.
Rhapsody in MicroC
41
Creating Statecharts
Step 1. Cre a ti ng a S t a te c ha rt
1. Open the activity chart TRAFFIC_LIGHT_CONTROLLER . 2. Select the state TRAFFIC_LIGHT_CTRL .
5. The graphic editor opens with the basic state TRAFFIC_LIGHT_CTRL already drawn. You can develop the statechart from this starting point.
42
Rhapsody in MicroC
Speed Buttons
Message Area
Step 2. Dra wi ng S t a te s
1. Move the name TRAFFIC_LIGHT_CTRL to the top, right-hand corner of the state. 2. Select the Create State icon from the Statechart graphic editor.
Rhapsody in MicroC
43
Creating Statecharts
3. Draw and name three additional states: RED , GREEN , and YELLOW as shown.
The technique for drawing states is the same as that for activities. Place the cursor at the desired location of the upper, left hand corner, click and hold the left mouse button, and drag the cursor (+) to the lower, right hand corner. Release the mouse button and the outline of the state becomes solid.
The technique for naming states is also the same as that for activities. Type the state name in uppercase or lowercase.
Move the name to the desired location inside the state box. Click the left mouse button.
44
Rhapsody in MicroC
The syntax of a transition label is trigger/action . In this case, the trigger is the CHANGE event. The action consists of two statements that assign values to the conditions GREEN_LIGHT and RED_LIGHT.
Rhapsody in MicroC
45
Creating Statecharts
The technique for labelling transitions is also the same as that for data flows. While the Create Transition mode is still active: Type the transition label. Press the Enter key to continue on a new line. Position the crosshair (+) just touching the line. Click the left mouse button to associate the label with the transition. The label changes to uppercase.
To adjust the position of a label, place the cursor over it, hold down the middle mouse button, move the label, and release the button.
YELLOW to RED
CHANGE/RED_LIGHT:=TRUE; YELLOW_LIGHT:=FALSE
46
Rhapsody in MicroC
Review
Re vi ew
In this lesson, you learned how to create a Statechart, which represents the Behavioral View of a system. It consists of States that represent the states the functions can be in within the system, and Transitions that show the paths the system can take to get from one state to another.
Creating Statecharts
48
Rhapsody in MicroC
Creating Panels
Lesson
Goa l s fo r t hi s Les s on:
In this lesson you will create a panel, which is a graphical user interface 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:
Rhapsody in MicroC
49
Creating Panels
Step 1. Cre a ti ng a P a ne l
1. Click the Panel Editor icon in the Main Window of Rhapsody in MicroC.
2. The Open Panel window appears. Enter the Panel Name LIGHT_CTRL_PNL and click OK.
50
Rhapsody in MicroC
Speed Buttons
Message Area
Creating Panels
3. While the Create Pushbutton mode is still active, type the label and move it to the desired 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 automatically change to uppercase. They retain the case in which they are typed.
3. Draw two more Lamp interactors under the first one. You can use Edit>Copy and Edit>Paste to duplicate the first Lamp. 4. Draw a rectangle around the Lamps.
52
Rhapsody in MicroC
5. Select the top Lamp interactor and click Tools>Properties... 6. The Bindings/Properties window appears.
7. Select Highlight Color and click Choose... The Color Viewer window opens. 8. Select RED from the list and click OK . 9. Select the bottom Lamp interactor and set the Highlight Color to GREEN .
Rhapsody in MicroC
53
Creating Panels
54
Rhapsody in MicroC
The Element 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 click OK . The Pushbutton is now bound to the event 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.
Rhapsody in MicroC
55
Creating Panels
Re vi ew
In this lesson, you have learned how to use the Panel Graphics Editor (PGE) to create a panel for your design. The PGE is a very important tool because it can be used to give you a virtual interface into your application. It can be set up to provide ways to input data and displays the results of program operation. The layout of your panel can emulate your targets interface or provide additional features useful for development and debugging of your application.
56
Rhapsody in MicroC
In this lesson you will execute the Traffic Light model you just designed. 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.
Rhapsody in MicroC
57
2. The New Compilation Profile window opens. 3. Type in a profile name (such as TEST01) and click OK .
58
Rhapsody in MicroC
2. The Workarea Browser opens. 3. Select the top level activity chart TAIL_LIGHT_ CONTROLLER .
Rhapsody in MicroC
59
4. Return to the Profile window and click the Module TAIL_LIGHT, so it is highlighted. 5. Click the Add Selected Chart to Selected Module icon.
2. In the Code Generation Profile, click on the Add Selected Panel icon. 3. The panel is added to the profile.
60
Rhapsody in MicroC
2. The Output Directory window opens. 3. Select OK to accept the default directory.
Rhapsody in MicroC
61
4. The Generate Code for Profile dialog appears and the code is generated. 5. Click Dismiss to close the dialog.
62
Rhapsody in MicroC
Rhapsody in MicroC
63
64
Rhapsody in MicroC
Review
8. To end the run, simply close the panel. 9. The GBA server prints this error message. Click OK .
Re vi 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
Rhapsody in MicroC
65
66
Rhapsody in MicroC
In this lesson, you will learn how to test the dynamic behavior of the developed application non-interactively, using test vector inputs and outputs. You will: Generate Test Vectors. Stream the inputs and outputs to disk for post analysis. Reuse Test Vectors for subsequent simulations.
Rhapsody in MicroC
67
Step 2. Vi ew S t re a min g V ec t or Da ta
1. Regenerate and recompile the code. 2. Run the model. 3. Press the CHANGE button and watch the Command Prompt window to see the Test Driver stream the data to the standard output.
Setting these environment variables redirects the standard input and output to files, making it possible to post-process the results.
68
Rhapsody in MicroC
2. Run the model. 3. The Run Command dialog opens. 4. Select dos_box.bat and Click Open .
6. Type the name of the executable image (in this case, test01.exe ). 7. Once the model is running, click the CHANGE button several times to ensure that the Test Driver gets some data. 8. Stop the model.
Rhapsody in MicroC
69
9. Test Vector files have been created in the working directory (see the Command Prompt window above).
The files are both of a similar format and are explained in the following table.
Time Absolute or Relative. Default is Absolute. Variable Name Variable Type As in Data Dictionary. See table below. Variable Value Comments The new value it is set to. As shown in file.
Identifier 0 1 2 3 4 5
70
Rhapsody in MicroC
6 7 8 9
2. Rename the file TESTDRIVER_INPUT_FROM_PNL_FILE.txt to TESTDRIVER_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 press the CHANGE button ! The Test Driver will use TESTDRIVER_IN_FILE.txt to stimulate the model. The output will be streamed to disk as before.
Rhapsody in MicroC
71
Re vi 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 embedded applications.
72
Rhapsody in MicroC
Index
A
activities, 33 ISR, 33 regular, 34 task, 33 Activity Chart, 23 advanced training,
E
edge trigger, 33 embedded system development,
16
16
F
functional decomposition,
B
Binding panel elements, Boolean, 33
23
G
54
Generate Code, Graphic Editors,
61 , 62 25
C
Code Generation Profile, Compilation Profile, 67 Control Activities, 28
I
57 , 65
impulse,
33
D
Data Dictionary, 16 Data Dictionary Browser, 34 Data Dictionary Editor, 35 David Harel, 15 drawing activities, 27 drawing control activities, 28
L
level trigger,
33
M
Microsoft Visual C++, 16 , 57 Modeling Reactive Systems with Statecharts, 15 Module Name, 59
Statemate MAGNUM
73
mouse buttons,
17
O
online help, 24 Help>on Help,
drawing transitions, 45 graphic editor, 43 , 51, 52 States, 41 Transitions, 41 Statemate MAGNUM Methodology and Style Guidelines,
15
24
P
panel, 49 Panel Graphic Editor, 50 project new, 20 , 22 proprietary information, ii
T
textual elements, 33 condition, 33 data-item, 33 event, 33 information-flow, 33 top level chart, 23 trademarks, ii
S
Statechart creating, Statecharts
W
41
Workarea Browser,
59
74
Statemate MAGNUM