Download presentation
1
Essential Rhapsody in C++
Part One Basic Rhapsody Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
2
Part One: Basic Rhapsody
Setting up Rhapsody in C++ Example : Hello world Example : Count down Properties Example : Dishwasher Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
3
Setting Up Rhapsody Install Visual C (or alternatively Visual Studio .NET or Borland bcc55) Install Rhapsody in C++ V4.1 Install license (License.dat) Create a work directory ex: “C:\Work” Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
4
Before We Start Rhapsody uses C++ which is CASE sensitive. Most of the errors that occur during the training are generally due to entering text incorrectly. During this training, all classes will start with an upper case ex: “Training”. Often during the training course, students take differing lengths of time for completing the exercises. For those students who finish early, there is often an “Extended Exercise”. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
5
C++ Refresher The following concepts (possibly unfamiliar to C users) will be used during the training: Constructor Constructor initializer Operator overloading Destructor New & Delete Inheritance Virtual operations Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
6
Basic Rhapsody Hello World
Part One : Example 1 Basic Rhapsody Hello World Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
7
Creating a Project Start up Rhapsody in C++ (development edition)
Within Rhapsody, use the icon or file->new to create a new project called Hello in directory c:\work Click Yes to create project. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
8
The Browser The browser showing everything in the model is automatically started on opening a project. An Object Model Diagram has also been created and displayed. Browser Object Model Diagram Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
9
Drawing a Class In this Object Model Diagram, use the class icon to draw a class named Display. There are two ways of deleting a class. It can be deleted from just the view “Remove from View” or deleted from the entire model “Delete from Model”. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
10
Adding a constructor Expand the browser to see the class that we have just added. Right-click on this class and “Add New ►Constructor” We don’t need any arguments for our constructor so just click OK. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
11
The Features Window Right-click on the constructor and display the Features. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
12
Adding some code Select the Implementation tab and enter the following: std::cout << "Hello World" << std::endl; Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
13
Renaming a Component In order to generate code, we must first create a component. Expand the Components in the browser and rename the existing component called DefaultComponent to Test Note that this component will generate an executable. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
14
The Test Component Now expand the Configurations and rename the DefaultConfig to Release Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
15
Initial Instance Select the Initialization tab, expand the Default package and select the Display class. This will now create an initial instance of the Display class We will explain the difference between Explicit and Derived later. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
16
Settings We need to select an environment so that Rhapsody knows how to create an appropriate make file. Since we have Microsoft Visual C++ as our compiler, we’ll use the default setting which is Microsoft. We’ll explain later the other settings such as instrumentation Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
17
Renaming our OMD Expand the Object Model Diagrams in the browser and use the features dialog to rename the diagram from Model1 to Overview. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
18
Generating Code We’re now ready to generate code.
First close the Features window (click OK) Save the model then Generate/Make/Run Answer Yes to the question: Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
19
Hello World You should see the following:
Stop the executable by either closing the console window or by using the command If during compilation, there is a problem, then simply double-click on the error to go directly to the diagram or the part of the browser where the error occurred. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
20
The generated files The generated files will be in the directory C:\Work\Hello\Test\Release Display class main make file executable Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
21
Editing the Code We can edit the generated files from within Rhapsody.
Select the class Display in the browser, right-click and select Edit Class Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
22
Modifying the Code We can modify the generated code
In the Display.cpp file change: std::cout << “Hello World” << std::endl; to: std::cout << “Constructed” << std::endl; Transfer the focus to another window to roundtrip the modifications back into the model. Note that the model has been automatically updated. In general the roundtripping works pretty well, but beware not everything can be roundtripped! Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
23
Why doesn’t the constructor show up on the OMD?
It doesn’t show up simply because we added it from the browser To display it on our diagram we can select the class on the Overview OMD, right-click and select Display Options … Select to display All or explicitly select the operation and it will appear. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
24
Displaying the Main and Make
The Main and Make files can be displayed from within Rhapsody by simply right-clicking on the configuration and selecting edit : Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
25
Project Files Generated files for the Test component AutoSave
The model Visual Basic Macros ReverseEngineering Log (appeared when we roundtripped) Event History List (Will be used later when we animate) Rhapsody Work Space Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
26
Basic Rhapsody Count Down
Part One : Example 2 Basic Rhapsody Count Down Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
27
Copying a Project Select File -> Save As
Press to select the Work folder Press to create a new folder Rename “new folder” to “CountDown” Select the new folder “CountDown” Save the project as CountDown.rpy The new CountDown project is opened in Rhapsody with the previous project workspace preserved Each time there is an auto-save, Rhapsody will only save just what has changed since the last auto-save. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
28
תשמור את תקיה של countdown עד אז! שמירה ברשת:
המשך בתרגיל 3 תשמור את תקיה של countdown עד אז! שמירה ברשת: תעתיק את התקיה הראשית של הפרויקט החדש לרשת. תפתח הפרויקט ברשת לוודא שהקבצים לא השתבשו. ליתר ביטחון תשמור את הפרויקט במדיה נשלפת כמו disk on key. אם אין לך disk on key, ליתר ביטחון תעשה את הפרויקט החדש קובץ zip וכדומה ותעתיר אותו לרשת בשום פנים ואופן אל תעבוד בפרויקט ברשת. תעתיק אותו לדיסק המקומי, ורק בסוף תשמור אותו ברשת. Rhapsody in C++ Tool Training "Essential" © I-Logix v /01/2003
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.