18
CCA Common Component Architecture CCA Forum Tutorial Working Group http://www.cca-forum.org/tutorials/ A Simple CCA Component Application

CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

Embed Size (px)

DESCRIPTION

3 CCA Common Component Architecture A Simple CCA Component Application Goals To show how CCA components are used to build an application to numerically integrate a continuous function using two different integration techniques.

Citation preview

Page 1: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

CCACommon Component Architecture

CCA Forum Tutorial Working Grouphttp://www.cca-forum.org/tutorials/

A Simple CCA Component Application

Page 2: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

2

A Simple CCA Component ApplicationCCACommon Component Architecture

Module Overview

• What the example does: the math.• From math to components: the architecture.• The making of components: inheritance and

ports.• Framework-component interactions.• Putting it all together: the Ccafeine ways.• The application in action.

Page 3: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

3

A Simple CCA Component ApplicationCCACommon Component Architecture

Goals

To show how CCA components are used to build an application to numerically integrate a continuous function using two different integration techniques.

Page 4: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

4

A Simple CCA Component ApplicationCCACommon Component Architecture

The Math: Integrator (1)

)2

()(1

1

n

j

jjb

a

xxf

nabdxxf

The midpoint numerical integrator

a b x

)(xf

Page 5: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

5

A Simple CCA Component ApplicationCCACommon Component Architecture

The Math: Integrator (2)

The Monte Carlo integrator

N

in

b

a

xfNab

dxxf1

)(11)(

baxn ,in ddistributely Uniformalxa b

)(xf

Page 6: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

6

A Simple CCA Component ApplicationCCACommon Component Architecture

Example Architecture

LinearFunction

FunctionPort

FunctionPort

MidpointIntegrator

IntegratorPort

NonLinearFunction

FunctionPort

PiFunction

FunctionPort

Go

Driver

IntegratorPort

RandomGeneratorPort

RandomGeneratorFunctionPort

MonteCarloIntegrator

IntegratorPort

RandomGeneratorPort

Page 7: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

7

A Simple CCA Component ApplicationCCACommon Component Architecture

Pluggability: Scenario 1

LinearFunction

FunctionPort

FunctionPort

MidpointIntegrator

IntegratorPort

NonLinearFunction

FunctionPort

PiFunction

FunctionPort

Go

Driver

IntegratorPort

RandomGeneratorPort

RandomGeneratorFunctionPort

MonteCarloIntegrator

IntegratorPort

RandomGeneratorPort

Page 8: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

8

A Simple CCA Component ApplicationCCACommon Component Architecture

Pluggability: Scenario 1

LinearFunction

FunctionPort

FunctionPort

MidpointIntegrator

IntegratorPort

NonLinearFunction

FunctionPort

PiFunction

FunctionPort

Go

Driver

IntegratorPort

RandomGeneratorPort

RandomGeneratorFunctionPort

MonteCarloIntegrator

IntegratorPort

RandomGeneratorPort

Page 9: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

9

A Simple CCA Component ApplicationCCACommon Component Architecture

MonteCarloIntegrator in Details

FunctionPort

MonteCarloIntegrator

IntegratorPort

RandomGeneratorPort

What makes it a component?Inheritance from gov:cca::component

integrators::ccaports::Integrator gov::cca::Component

MonteCarloIntegrator

Inheritance Tree

Where does IntegratorPort come from? Inheritance from integrators::ccaports::Integrator

Relevant files:MonteCarloIntegrator_CCA.hIntegrator_CCA.hFunction_CCA.hRandomGenerator_CCA.h

Page 10: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

10

A Simple CCA Component ApplicationCCACommon Component Architecture

Notes

• Inheritance from gov::cca::Component furnishes the only method known to the framework: setServices()

• “Provides” ports are interfaces that need to inherit from gov::cca::Port

• A component need to have access to definitions of methods in the ports it “Uses” , hence the need to include Function_CCA.h and RandomGenerator_CCA.h

Page 11: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

11

A Simple CCA Component ApplicationCCACommon Component Architecture

The Framework Role

• Framework-to-Component: setServices()– Called after the component is constructed.– The component’s chance to identify:

• Ports it provides – addProvidesPort()• Ports it uses – addUsesPort()

– Component should not acquire the port here – Reason: it may not be there yet !!!!.

– Also used to “shutdown” the component.

Page 12: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

12

A Simple CCA Component ApplicationCCACommon Component Architecture

Component-to-Framework

• Mainly through Services object passed through setServices().

• createPortInfo(): – portName, portType, portProperties.

• addProvidesPort(), registerUsesPort(): – Component “pointer”, PortInfo

• getPort(): – Called by the using component.– Matching using portType (not name).

• releasePort(), removeProvidesPort(): – When all is done.

Page 13: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

13

A Simple CCA Component ApplicationCCACommon Component Architecture

When are calls made??Framework

MonteCarloIntegrator

PiFunction

Create MonteCarloIntegrator

setServices()

create

addProvidesPort()

registerUsesPort()

Create PiFunction

createsetServices()addProvidesPort() integrate()

getPort()

evaluate()

setServices()

integrate()

setServices()

Page 14: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

14

A Simple CCA Component ApplicationCCACommon Component Architecture

Notes

• Relevant code : MonteCarloIntegrator_CCA.cc

• getPort() is called immediately before the port is used.

• The framework only knows gov::cca::Port , hence the dynamic_cast<>.

• Making a port call: it’s just a regular virtual call.

Page 15: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

15

A Simple CCA Component ApplicationCCACommon Component Architecture

Putting it all together

• Getting the application to do something:– Assembling the components into an app.– Launching the Application.

• App. assembly:– Framework need to be told what components to use, and

where to find them.– Framework need to be told which uses port connects to

which provides port.

• App execution: the GO port:– Special provides port used to launch the application (after

connections are made).

Page 16: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

16

A Simple CCA Component ApplicationCCACommon Component Architecture

Oh Component , where art thou?.Which components, and how to create them

Questions?. Ask Rob

Page 17: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

17

A Simple CCA Component ApplicationCCACommon Component Architecture

App. Assembly The Ccafeine wayCommand line “script”

GUI Interface

Page 18: CCA Common Component Architecture CCA Forum Tutorial Working Group A Simple CCA Component Application

18

A Simple CCA Component ApplicationCCACommon Component Architecture

And now, our feature presentation.