CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Software Engineering Gabriel Hugh Elkaim Spring 2013.

Slides:



Advertisements
Similar presentations
Construction process lasts until coding and testing is completed consists of design and implementation reasons for this phase –analysis model is not sufficiently.
Advertisements

Ch-11 Project Execution and Termination. System Testing This involves two different phases with two different outputs First phase is system test planning.
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
Programming Languages and Paradigms The C Programming Language.
1 Homework Reading –Review previous material on “interrupts” Machine Projects –MP4 Due today –Starting on MP5 (Due at start of Class 28) Labs –Continue.
CMPE 293Gabriel Hugh Elkaim 1. CMPE 293Gabriel Hugh Elkaim 2.
CMPE 293Gabriel Hugh Elkaim 1. CMPE 293Gabriel Hugh Elkaim 2.
Functions Most useful programs are much larger than the programs that we have considered so far. To make large programs manageable, programmers modularize.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 6 Functions.
Classes and Objects Systems Programming.
CMPE 118 MECHATRONICS Modular Programming Where the rubber meets the Code.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 Chapter 7 Functions Dale/Weems/Headington. 2 Functions l Control structures l every C++ program must have a function called main l program execution.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition Chapter 6: Functions by.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Lesson 6 Functions Also called Methods CS 1 Lesson 6 -- John Cole1.
SE-565 Software System Requirements More UML Diagrams.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Arrays and Strings Gabriel Hugh Elkaim Spring 2013.
Hardware Interface Design Patterns Ahmet Selman Bozkır – Hacettepe Univ.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2012 CMPE-013/L Functions Gabriel Hugh Elkaim Spring 2012.
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Modules and Scope Gabriel Hugh Elkaim Spring 2013.
Modular Programming Chapter Value and Reference Parameters t Function declaration: void computesumave(float num1, float num2, float& sum, float&
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 3: Requirements Specification, C++ Basics.
1 Chapter 8 Scope, Lifetime, and More on Functions Dale/Weems/Headington.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 6 Functions.
Copyright © 2012 Pearson Education, Inc. Chapter 6: Functions.
Chapter 6: Functions Starting Out with C++ Early Objects
CS212: Object Oriented Analysis and Design Lecture 6: Friends, Constructor and destructors.
1-1 NET+OS Software Group Flash API Multiple flash memory bank support New Flash API introduction Detailed Flash API Function presentation Supporting.
VHDL FLI. FLI Definition FLI routines are C programming language functions that provide procedural access to information within the HDL simulator.
Copyright © 2012 Pearson Education, Inc. Chapter 6: Functions.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Chapter 4 Introduction to Classes, Objects, Methods and strings
CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Computer Systems and “C” Programming Gabriel Hugh Elkaim Spring 2013.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
Starting Out with C++ Early Objects ~~ 7 th Edition by Tony Gaddis, Judy Walters, Godfrey Muganda Modified for CMPS 1044 Midwestern State University 6-1.
1 Brief Version of Starting Out with C++, 4th Brief Edition Chapter 6 Functions.
AP Computer Science A – Healdsburg High School 1 Unit 9 - Why Use Classes - Anatomy of a Class.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
CSci 162 Lecture 10 Martin van Bommel. Procedures vs Objects Procedural Programming –Centered on the procedures or actions that take place in a program.
Chapter Functions 6. Modular Programming 6.1 Modular Programming Modular programming: breaking a program up into smaller, manageable functions or modules.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Brief Edition Chapter 6 Functions.
Chapter 6 Functions. Topics Basics Basics Simplest functions Simplest functions Functions receiving data from a caller Functions receiving data from a.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Using HeaderDoc to make complete documentation as Html file. By Naveed Khalid.
TinyOS Sandeep Gupta. Operating System (OS) What is an OS? Main functions  Process management  Memory management  Resource management Traditional OSs.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 6: Functions.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Lecture 4 – Function (Part 1) FTMK, UTeM – Sem /2014.
Chapter 6 Functions. 6-2 Topics 6.1 Modular Programming 6.2 Defining and Calling Functions 6.3 Function Prototypes 6.4 Sending Data into a Function 6.5.
LonWorks Introduction Hwayoung Chae.
Presentation By :- Nikhil R. Anande ( ) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER.
RealTimeSystems Lab Jong-Koo, Lim
Basic concepts of C++ Presented by Prof. Satyajit De
Week 3-4 Control flow (review) Function definition Program Structures
Homework Reading Machine Projects Labs
Chapter 6: Functions Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Functions.
6 Chapter Functions.
Introduction to Classes and Objects
Control Structures Part 2
COP 3330 Object-oriented Programming in C++
Based on slides created by Bjarne Stroustrup & Tony Gaddis
Standard Version of Starting Out with C++, 4th Edition
Classes and Objects Systems Programming.
Presentation transcript:

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 CMPE-013/L Software Engineering Gabriel Hugh Elkaim Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Modular C Code

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 The three uses of static

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Encapsulation (1.2)

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Encapsulation (2.2)

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 What goes into a header file?

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 What shouldn’t be in a header file?

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Where do you #include the header file?

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Programming Style Issues

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Module Design by Interface Specification View –The module provides Services to the rest of the code Design Activities –Specify the services Describe Functionality –Name the Services –Design the implementation

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Application Programming Interfaces (API) for the ME218c Master modules Module: Communications to UI on PC To avoid hanging up the master during the transmission or reception of messages, this module should implement buffered, interrupt driven transmit and receive. The communications routines for this module will need to be interrupt driven because the UI may send its message at any time. Char InitializeUICommunications(void); Do whatever hardware and software initialization necessary to prepare for communications with the UI on SC1. Void TellUINewUserReady(void); Should send the message to the UI that a new iButton has been inserted and read. Unsigned char IsNameReady(void); Should check to see if a new name is ready from the UI. Return TRUE if a new name is ready, FALSE otherwise. Unsigned char GetNewName( unsigned char NameSpace[]) Should copy the name gotten from the UI into the array NameSpace. The copy operation should copy no more than 16 characters, including the terminating NULL. Should return TRUE if there was a new name ready, FALSE otherwise. A Real Example

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Design the interfaces to modules Design interface for: –Driving the platform –Gathering Sensor data Produce –Public Interface specification –What are the details that are being hidden?

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Hierarchical State Machines Harel Statecharts

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 A Possible Top-Level State Diagram

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Work out State Diagrams to Implement Finding Tape I

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Finding Tape

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Acquiring

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Implementing Hierarchical State Machines What do you need?

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 If current state is state one Execute During function for state one If an event is active If event is event one Execute action function for state one : event one Decide what the next state will be Endif If event is event two Execute action function for state one : event two Decide what the next state will be Endif Repeat the block above as required for each of the possible events affecting this state. If next state is different from current state Execute exit function for state one Execute entry function for new state Modify state variable to reflect the new state Endif Return from state machine function State Machine Function Template

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 /**************************************************************************** Module d:\me218b\Lectures\Lecture 29\SMTemplate.c Description This is a template file for implementing state machines. Notes History When Who What/Why /18/99 10:19 jec built template from MasterMachine.c 02/14/99 10:34 jec Began Coding ****************************************************************************/ /* Include Files */ /* include header files for this state machine as well as any machines at the next lower level in the hierarchy that are sub-machines to this machine */ /* Module Defines */ // define constants for the states and event for this machine /* Module Functions */ /* prototypes for private functions for this machine, things like entry & exit functions. */ /* Module Variables */ // everybody needs a state variable, you may need others as well static unsigned char CurrentState;

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 void RunStateMachine(unsigned char CurrentEvent ) { unsigned char NextState = CurrentState; switch ( CurrentState ) { case STATE_ONE : // If current state is state one DuringStateOne(); //Execute During function for state one if ( CurrentEvent != NO_EVENT ) //If an event is active { switch ( CurrentEvent) { case EVENT_ONE : //If event is event one // Execute action function for state one : event one NextState = STATE_TWO;//Decide what the next state will be break; } // If next state is different from current state if ( NextState != CurrentState) { // Execute exit function for current state // Execute entry function for new state CurrentState = NextState; //Modify state variable } return;

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 /**************************************************************************** Function StartStateMachine Parameters None Returns None Description Does any required initialization for this state machine Notes Author J. Edward Carryer, 2/18/99, 10:38AM ****************************************************************************/ void StartStateMachine ( void ) { CurrentState = ENTRY_STATE; // call the (optional) entry function for the ENTRY_STATE // any other initialization necessary to re-start the state machine }

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013 Questions?

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013

CMPE-013/L: “C” Programming Gabriel Hugh Elkaim – Spring 2013