01 the rhapsody framework
TRANSCRIPT
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.11
Specialist Rhapsody
The Rhapsody
Framework
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.12
Framework
The Rhapsody Framework consists of 4 parts: oxf – Execution framework classes (Object
Execution Framework) aom - Framework classes that support
animation (Animation Object Model) tom - Framework classes that support
tracing (Tracing Object Model) omCom - Definitions, macros, namespaces,
types, and methods required by executables that support animation or tracing
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.13
Object eXecution Framework
Operating System Adapter OSFactory OMOSSemaphore OMOSEventFlag OMOSMutex OMProtected
Event-Driven Framework OMReactive OMThread OMEvent OMTimerManager Timeout
Predefined types OMString OMBoolean
Container Classes OMABSContainer OMList OMStaticArray OMCollection OMMap OMIterator
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.14
Simple class withno statechart
“Reactive Class”Composite class orclass with statechart
Active class
OMReactive & OMThread
A reactive class waits for events of type OMEvent.
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.15
OMThread
Each active thread waits on an event queue for events:
void OMThread::execute() { for ( ;; ) { while ( !eventQueue->isEmpty() ) { OMEvent *event = eventQueue->get(); OMReactive *dest = event->getDestination(); dest->takeEvent(); delete event; } eventQueue->pend(); }}
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.16
Base classes
OMProtected is used whenever an operation or relation needs to be protected by a Mutex.
OMEvent is the base class for all events.
OMOSSemaphore is a counting semaphore.
OMOSEventFlag is an event flag
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.17
Using event flags
Declare a flag as : OMOSEventFlag myFlag;
Create using : myFlag = theOSFactory()->createOMOSEventFlag();
Waiting on the flag:myFlag->wait();
Signaling the flag:myFlag->signal();
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.18
OMEvent Instead of using new to create events
each time that an event is to be sent, events can be pre-allocated and used as follows:
Event : evGo(int y) Property : set CG:Event::DeleteAfterConsumption to
FALSE
Allocate : static evGo eventPool[EVENTS] static int iEvent=0;
Sending : eventPool[iEvent].y = 0; itsX->gen(&eventPool[iEvent]);
iEvent=(iEvent+1)% EVENTS;for (int i=0; i < EVENTS; i++) eventPool[i].setDeleteAfterConsume(FALSE);
Build 30713 requires the following:
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.19
Specialist Rhapsody
Rhapsody Framework
Using the framework base classes
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.110
Using the Framework base classes
Often we want to isolate clients and servers.
This can be easily achieved by using Rhapsody’s framework base classes.
Every class with a statechart inherits from OMReactive
Every event inherits from OMEvent.
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.111
ClientServer
A synchronous client server relationship is easy to implement. This example shows how to implement an asynchronous client server relationship so that the server does not need to know about the client.
The client sends an event to the server to request a particular service and sends as parameters, a pointer to itself as well as a pointer to the event that it wants to receive.
Note that the event must be created by the client before it can be passed to the server.
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.112
OMReactive and OMEvent
Note gen since event created here.
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.113
Server IsolationclientPkg::Client serverPkg::Server
evReply()
evRequest(client = 0x00CD35E0, event = 0x00CD3690)
tm(2000) at ROOT.idle
evReply()
evRequest(client = 0x00CD35E0, event = 0x00CD4ED0)
doAction()
doAction()
tm(2000) at ROOT.idle
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.114
Abstract OS The file OS.h lists all the operations that
are needed of an OS. All the operations are virtual and an abstract factory pattern is used to instantiate instances of threads, mutex’s, ...
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.115
Abstract OS : OMOSSemaphore
The file OS.h describes for example the operations signal and wait that can be done on a semaphore:
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.116
NT OS : NTSemaphore
The file NT.h and NT.cpp implement the semaphore for the NT OS as follows:
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.117
VxWorks : VxSemaphore
The Rhapsody Tool Training "Specialist" © I-Logix 1998-1999 v2.118