Www.ilogix.com © I-Logix 1999-2004 Rhapsody C++ V5.0.1 17/01/2004 E1-1 Exercise 2 : Count Down.

Slides:



Advertisements
Similar presentations
Interaction Design: Visio
Advertisements

Introduction to Macro Introduction to Visual Basic for Application Recording a Macro Looking at the code of Recorded Macro.
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Essential Rhapsody in C++
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
1 CA202 Spreadsheet Application Combining Data from Multiple Sources Lecture # 6.
Advanced Microsoft Word Hosted by Jared Hoffman Topics Keyboard Shortcuts Customizing Toolbars and Menus Auto Format & Auto Correct Tabs Inserting Pictures.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 Bas-1 Essential Rhapsody in C++ Section 2 Basic Level.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
אביב תשס"ה JCTתיכון תוכנה: ד"ר ראובן גלנט1 פרק 8 נקודות חשובות בתרגילים 7-9.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 Adv-1 Essential Rhapsody in C++ Section 4 Advanced Level Modified.
Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-1 Section 4 Advanced Level Concurrency.
Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Int-1 Section 3 Intermediate Inherited Sensor.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
© I-Logix Rhapsody C++ V /01/2004 E1-1 Exercise 3 : Dishwasher.
The Rhapsody in C++ Tool Training "Essential" © I-Logix v2.3 25/9/2000 Int-1 Essential Rhapsody in C++ Section 3 Intermediate Level.
Rhapsody in C++ Tool Training "Essential" © I-Logix v3.0 1/29/2001 Adv-1 Section 4 Advanced Level Multiplicity.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Creating a Console Application with Visual Studio
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 4: Working with Forms.
Controls General Discussion. VB Controls Visual Basic Controls A control is the generic name for any object placed on a form Controls may be images,
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
A First Program Using C#
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
6 Copyright © 2004, Oracle. All rights reserved. Working with Data Blocks and Frames.
1 I-Logix Professional Services Specialist Rhapsody IDF (Interrupt Driven Framework) CPU External Code RTOS OXF Framework Rhapsody Generated.
1 Pertemuan 03 Using Layers and Symbols Matakuliah: U0344 / DESKTOP 1 Tahun: 2006.
Nachos Phase 1 Code -Hints and Comments
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
Spreadsheets in Finance and Forecasting Presentation 9 Macros.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Chapter 10 Fireworks: Part II The Web Warrior Guide to Web Design Technologies.
Interaction Design Interaction Design - Joan Cahill - Visio Interaction Design: Visio.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
Windows Tutorial Common Objects ACOS: 1, 4. Using the Taskbar 1. Using the taskbar, you can switch between open programs and between open documents within.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Rhapsody V4.2 "Specialist" Tool Training © I-Logix /08/20031 Specialist Rhapsody Getting Rhapsody In C generated code to run.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
1 NORMA Lab. 5 Duplicating Object Type and Predicate Shapes Finding Displayed Shapes Using the Diagram Spy Using Multiple Windows Using the Context Window.
1 What to do before class starts??? Download the sample database from the k: drive to the u: drive or to your flash drive. The database is named “FormBelmont.accdb”
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Eclipse debugger.
Chapter Two Creating a First Project in Visual Basic.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Sequence Diagrams And Collaboration Diagrams HungNM.
Using Advanced Options Lesson 14 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft Word 2013.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
1 Fields Sacramento City College Engineering Design Technology.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 4 Slide 1 Slide 1 What we'll cover here l Using the debugger: Starting the debugger Setting.
Getting Started with Word & Saving Guided Lesson.
Statechart Diagrams. Creating a Statechart Diagram A Statechart diagram shows the life cycle of a single object, from the time that it is created until.
Introduction to Microsoft Excel Macros COE 201- Computer Proficiency.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
© I-Logix Rhapsody C++ V /01/2004E1-1 “Essential” Tool Training Basic Rhapsody Basic Rhapsody Rhapsody in C++ V /01/04.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
When the program is first started a wizard will start to setup your Lemming App. Enter your company name and owner in the fields designated “Company Name”
XP Tutorial 3 Creating Animations. XP New Perspectives on Macromedia Flash MX Elements of Animation Layers are used to organize the content of.
Important terms Black-box testing White-box testing Regression testing
Important terms Black-box testing White-box testing Regression testing
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Essential Rhapsody in C++
Presentation transcript:

© I-Logix Rhapsody C++ V /01/2004 E1-1 Exercise 2 : Count Down

© I-Logix Rhapsody C++ V /01/2004 E1-2 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 workspace preserved Each time there is auto-save, Rhapsody will only save just what has changed since the last auto-save.

© I-Logix Rhapsody C++ V /01/2004 E1-3 Loading a Rhapsody Project  Either start Rhapsody and select “File->Open …”  Or double-click on the CountDown.rpy file  Or start Rhapsody and drag the.rpy file into Rhapsody The Rhapsody.ini file determines which Rhapsody (C / C++ / J / Ada) will be opened on double-clicking the.rpy file.

© I-Logix Rhapsody C++ V /01/2004 E1-4 Adding an Attribute  To add an attribute double-click on the Display class to bring up the features and select the Attributes tab  Click on to add an attribute count of type int  Set the initial value to 0

© I-Logix Rhapsody C++ V /01/2004 E1-5 Generated Code for an Attribute  Save then edit the code for the Display class Accessor Mutator Initial Value Protected attribute

© I-Logix Rhapsody C++ V /01/2004 E1-6 What’s an Accessor and Mutator?  By default, all attribute data members in Rhapsody are protected  If other classes need access to these attributes, then they must use an Accessor ex: getCount() or Mutator ex: setCount()  This allows the designer of a class, the freedom to change the type of an attribute without having to alert all users of the class. The designer would just need to modify the accessor and mutator.  In most cases, attributes will not need accessors or mutators, we’ll see later how to stop them being generated

© I-Logix Rhapsody C++ V /01/2004 E1-7 Attribute Visibility  Changing the Visibility in the Attribute features dialog changes the mutator and accessor visibility, (not the data member visibility).

© I-Logix Rhapsody C++ V /01/2004 E1-8 CG:CGGeneral:GeneratedCodeInBrowser ברמת הפרויקט סמן/י את ה Property CG:CGGeneral:GeneratedCodeInBrowser

© I-Logix Rhapsody C++ V /01/2004 E1-9 Adding an operation  Using the features for the Display class, select the operations tab and add a new “Primitive Operation” called print

© I-Logix Rhapsody C++ V /01/2004 E1-10 Arguments  Double-click on print to open the features for the print operation  Add an argument “n” of type int

© I-Logix Rhapsody C++ V /01/2004 E1-11 Adding Implementation  Select the “Implementation” tab for the print operation and add: std::cout << “Count = ” << n << std::endl;

© I-Logix Rhapsody C++ V /01/2004 E1-12 Another print operation  In a similar way, add another operation called print, this time with an argument “s” of type char* and with implementation: std::cout << s << std::endl;

© I-Logix Rhapsody C++ V /01/2004 E1-13 Operation isDone()  Add another operation called isDone that returns a bool and has the following implementation: return (0==count); By typing 0==count instead of count==0, enables the compiler to detect the common error of where = is typed instead of ==

© I-Logix Rhapsody C++ V /01/2004 E1-14 Active Code View  Switch on the “Active Code View”  The active code view is context sensitive and is automatically updated as the model is changed. The window also changes dynamically to show the generated code for the highlighted model element. Note that although leaving the active code view always open is useful, it does slow down model manipulation since the code will get regenerated anytime any model element gets modified.

© I-Logix Rhapsody C++ V /01/2004 E1-15 Using the print operation  In the Active Code View, (Make sure you’ve selected the Implementation), change the code for our constructor to use the print operation  Change the focus to another window such as the browser and check that this modification has been automatically round- tripped  Save  Generate / Make / Run Implementation

© I-Logix Rhapsody C++ V /01/2004 E1-16 Adding a Statechart  We’d like to get our Display class to count down from 2 to 0 in intervals of 200ms  In order to do so, we need to give some behavior to our class, we can do this by adding a statechart  Right-Click on the Display class and select “New Statechart”

© I-Logix Rhapsody C++ V /01/2004 E1-17 Simple Statechart  Draw the following statechart: actions timeout guards terminator condition connector transition state default transition 2;

© I-Logix Rhapsody C++ V /01/2004 E1-18 Transitions  Once a transition has been drawn, there are two ways in which to enter information  In text format ex: [isDone()]/print(“Done”);  By the features of the transition (activated by double-clicking or right-clicking on the transition) An empty line forces the action to appear on a new line

© I-Logix Rhapsody C++ V /01/2004 E1-19 The Timer Mechanism  Rhapsody provides a timer that can be used within the statecharts  tm(200) acts as an event that will be taken 200ms after the state has been entered  On entering into the state, the timer will be started  On exiting from the state, the timer will be stopped The timer uses the OS Tick and so will only generate timeouts that are a multiple of ticks.

© I-Logix Rhapsody C++ V /01/2004 E1-20 Timeouts  If we have a system tick of say 20ms and we ask for a timeout of 65ms, then the resulting timeout will actually be between 80ms and 100ms, depending on when the timeout is started relative to the system tick. If precise timeouts are required, then it is recommended to use a hardware timer in combination with triggered operations. We’ll talk about this later time System tick 20ms 80ms ≤ Timeout ≤ 100ms Start timeoutEnd timeout

© I-Logix Rhapsody C++ V /01/2004 E1-21 Counting Down  Save Generate / Make / Run constructor default transition Don’t forget to close this window, before doing another generate / make / run !

© I-Logix Rhapsody C++ V /01/2004 E1-22 Statechart Symbol  Now that the Display class is “Reactive”, it has a special symbol in both the browser and the OMD.  Also note that the Statechart appears in the browser. A Reactive class is one that reacts to receiving events or timeouts.

© I-Logix Rhapsody C++ V /01/2004 E1-23 Generated Code : Display.h  Use the “Active Code View” to examine the generated code for the Display class. Note that the Display class inherits from OMReactive, which is one of Rhapsody’s framework base classes. This is a class that simply waits for timeouts or events. When it receives a timeout or an event, it calls the rootState_dispatchEvent() operation. Framework includes Framework class Thread on which to wait

© I-Logix Rhapsody C++ V /01/2004 E1-24 Generated Code : Display.cpp  Display::Display(OMThread* p_thread)  The constructor needs to know on which thread to wait  Display::rootState_entDef()  Will be called by startBehavior() to take the initial default transition  Display::rootState_dispatchEvent(short id)  Gets called whenever the object receives an event or timeout  Display::initStatechart()  Initializes the attributes used to manage the Statechart  Display::startBehavior()  Kicks off the behavior of the Statechart, invokes the rootState_entDef() operation

© I-Logix Rhapsody C++ V /01/2004 E1-25 Statechart Implementation  Select the features for the configuration Release  Select the Settings tab and set “Statechart Implementation” from Flat to Reusable  Save / Generate / Examine code The Rhapsody framework allows two ways of implementing statecharts: Reusable which is based on the state design pattern where each state is an object. Results in faster execution and if a lot of statecharts are inherited can result in smaller code. Flat which uses a switch statement. Results in less code that is easier to read, but is slower.

© I-Logix Rhapsody C++ V /01/2004 E1-26 Extended Exercise  Experiment with the line shape of transitions

© I-Logix Rhapsody C++ V /01/2004 E1-27 Design Level Debugging  Up to now we have generated code and executed it, hoping that it works! However as the model gets more and more complicated we need to validate the model  From now on we are going to validate our model by doing design level debugging, this is known as “Animation”  (First we will use tracer)

© I-Logix Rhapsody C++ V /01/2004 E1-28 Section 2 Basic level Tracing

© I-Logix Rhapsody C++ V /01/2004 E1-29 New Configuration for Tracing  Create a new configuration Trace  Create an initial instance of Display

© I-Logix Rhapsody C++ V /01/2004 E1-30 Tracing Settings  In the settings set the instrumentation to Tracing

© I-Logix Rhapsody C++ V /01/2004 E1-31 Executing in Tracing Mode  Select the Trace configuration  Save / Generate / Make / Run  When the DOS Console window appears type help

© I-Logix Rhapsody C++ V /01/2004 E1-32 Tracing Step by Step  The tracing mode can be used to control and to capture what happens during execution.  Type go idle to start the execution  איזה שורת ב Tracer היו מופיעים עם לא היה Statechart?  איזה שורת ב Tracer היו מופיעים עם ה Statechart היה ריק?

© I-Logix Rhapsody C++ V /01/2004 E1-33 Time Stamping  Type timestamp to switch on the time stamping  Type go idle

© I-Logix Rhapsody C++ V /01/2004 E1-34 Tracing the Methods  Type trace #all method to trace just the executed methods  Type go idle By default Rhapsody traces everything. This is the same as the command trace #all all.

© I-Logix Rhapsody C++ V /01/2004 E1-35 Capturing the Trace  Type output myTrace.txt  Type go idle  Type go  Exit the DOS console window

© I-Logix Rhapsody C++ V /01/2004 E1-36 Examining the Trace  Edit the generated trace file C:\Rhapsody\Work\Countdown\Test\Trace\myTrace.txt  Note that the isDone() operation is invoked before the print() operation.

© I-Logix Rhapsody C++ V /01/2004 E1-37 Extended Exercise  Rerun Test.exe and experiment with other trace commands such as:  show Display[0] attributes  break Display[0] attribute[count] ...  More detailed help about the trace mode can be found in the reference guide. The trace is useful for doing regression tests and for debugging purposes because it uses standard IO instead of TCP/IP.

© I-Logix Rhapsody C++ V /01/2004 E1-38 Animation  Create a new configuration by copying the Release configuration. Hold the control key and drag the Release configuration onto the “Configurations” folder  Rename the new configuration Debug  Set the instrumentation to “Animation” Animation

© I-Logix Rhapsody C++ V /01/2004 E1-39 Multiple Configurations  Now that we have more than one configuration, we must select which one we want to use  There are two ways to do this:  Either select the configuration using the following pull-down box  Or right-click on the configuration and select “Set as Active Configuration”

© I-Logix Rhapsody C++ V /01/2004 E1-40 Animating  Make sure that the active configuration is “Debug” before doing Save then Generate / Make / Run Animation Bar Event Queue Call Stack

© I-Logix Rhapsody C++ V /01/2004 E1-41 Animation Tool Bar  Go step  Go  Go Idle  Go Event  Animation Break  Command Prompt  Quit Animation  Threads  Breakpoints  Event Generator  Call Operations  Watch – Display Continuous Update When grayed out, indicates a singled-threaded application

© I-Logix Rhapsody C++ V /01/2004 E1-42 Starting the Animation  Go Step  Note that the Display constructor appears in the Call Stack  Continue to Go Step until the “Executable is Idle” message appears in the Animation window

© I-Logix Rhapsody C++ V /01/2004 E1-43 Animated Browser  In the browser, note that there is now an instance of the Display class  Open “Features in New Window” for this instance and note that the attribute count has been initialized to 10

© I-Logix Rhapsody C++ V /01/2004 E1-44 Animated Statechart  Right-click on the instance to “Open Instance Statechart” Highlighted state If you don’t see a highlighted state, then perhaps you are looking at the statechart of the class rather than the statechart of the instance

© I-Logix Rhapsody C++ V /01/2004 E1-45 Go Idle / Go  Repeatedly do Go Idle or Go and watch the animation until the instance is destroyed. Note that the value of the attribute count also changes and that the transition taken in the statechart is highlighted

© I-Logix Rhapsody C++ V /01/2004 E1-46 Go Idle / Go  מה משמעות של הצבעים השונים ב animated statechart? Note that the value of the attribute count also changes and that the transition taken in the statechart is highlighted

© I-Logix Rhapsody C++ V /01/2004 E1-47 Destructor  Exit the animation and add a Destructor to the Display class with implementation  Save then Generate / Make / Run print(“Destroyed”); Make sure you enter the code into the Implementation and not the Description field !

© I-Logix Rhapsody C++ V /01/2004 E1-48 Sequence Diagrams  From the browser, create a new sequence diagram called “execution”. We will use this sequence diagram to capture what happens as we execute. For this example it doesn’t matter if we select “Analysis” or “Design” mode, we’ll explain the difference later

© I-Logix Rhapsody C++ V /01/2004 E1-49 Adding Instances  Drag the Display class from the browser onto the sequence diagram and add a System Boundary System Boundary

© I-Logix Rhapsody C++ V /01/2004 E1-50 Drawing a Sequence Diagram  Normally we would describe an actual scenario not dissimilar to this one here, however in this case, we are more interested in capturing what actually happens, so we’ll leave that until tomorrow. For our purposes, we only need the system border and the Display instance line. There’s no need to add any operations.

© I-Logix Rhapsody C++ V /01/2004 E1-51 Animated Sequence Diagrams  Start the animation  If there is a sequence diagram open, then Rhapsody will create a new animated sequence diagram based on it.

© I-Logix Rhapsody C++ V /01/2004 E1-52 Extended Exercise  Try adding an extra state “pausing”. Then you’ll be able to see the instance changing states.