Implementation Wrapper
The implementation is instantiated in the Rhapsody model. A class for instantiating the implementation is used, such that executing this model executes the implementation with an interface to Rhapsody animation. The implementation wrapper instantiates the implementation within Rhapsody with identical interfaces as the specification model.
Building an implementation wrapper
The implementation files can be compiled and a library is built using Rhapsody configuration libimplementation::lib::DefaultConfig.
A wrapper implementation has been created based upon this library in order to be able to execute the implementation similarly to the specification model. Therefore, WrappedImplementation::ImplWrapper instantiates an instance of the implementation class cimpl from the library lib.lib (maintained using configuration libimplementation::lib::DefaultConfig) and provides a statechart capable of receiving the same events as the specification model. Note, that class WrappedImplementation::ImplWrapper provides an identical public interface (same ports) as Model::TheCalc (receptions evHandleError() and evHandleReset() are only for local not for public use).
Upon reception of events, WrappedImplementation::ImplWrapper invokes appropriate functionality of cimpl and Model::OutputDevice.
Each of the states in WrappedImplementation::ImplWrapper's statechart has a 'reaction in state', e.g. handle_operand reacts on event evOperand in the following way:
int regno=params->getNo(); if((regno!=1)&&(regno!=2)) { this->handle_error(); this->send(new evHandleError()); } else { if(regno==1) MyCalc.sReg1(params->getVal()); if(regno==2) MyCalc.sReg2(params->getVal()); OUT_PORT(OutputsPt)->Set_DisplayedValue(params->getVal()); }
State handle_computation reacts on event evCompute with the following codeblock:
MyCalc.calc(); if(MyCalc.gErr()) { this->handle_error(); this->send(new evHandleError()); }
Using such a wrapping construction allows the user to execte the same stimuli sequences on both, the specification model, as well as the wrapped implementation. This wrapping construction will later be reused in order to execute the test cases generated from the test model against the implementation.