blob: 3addb4049bb4c6afb328742a0d67e409d584bd36 [file]
#include "B.hh"
#include "P.hh"
#include "umlrtcommsportrole.hh"
#include "umlrtmessage.hh"
#include "umlrtslot.hh"
#include <cstddef>
#include "umlrtcapsuleclass.hh"
#include "umlrtframeservice.hh"
class UMLRTRtsInterface;
struct UMLRTCommsPort;
Capsule_B::Capsule_B( const UMLRTCapsuleClass * cd, UMLRTSlot * st, const UMLRTCommsPort * * border, const UMLRTCommsPort * * internal, bool isStat )
: UMLRTCapsule( NULL, cd, st, border, internal, isStat )
, p( borderPorts[borderport_p] )
, currentState( SPECIAL_INTERNAL_STATE_UNVISITED )
{
stateNames[State1] = "State1";
stateNames[State2] = "State2";
stateNames[SPECIAL_INTERNAL_STATE_TOP] = "<top>";
stateNames[SPECIAL_INTERNAL_STATE_UNVISITED] = "<uninitialized>";
}
void Capsule_B::bindPort( bool isBorder, int portId, int index )
{
if( isBorder )
switch( portId )
{
case borderport_p:
UMLRTFrameService::sendBoundUnbound( borderPorts, borderport_p, index, true );
break;
}
}
void Capsule_B::unbindPort( bool isBorder, int portId, int index )
{
if( isBorder )
switch( portId )
{
case borderport_p:
UMLRTFrameService::sendBoundUnbound( borderPorts, borderport_p, index, false );
UMLRTFrameService::disconnectPort( borderPorts[borderport_p], index );
break;
}
}
void Capsule_B::inject( const UMLRTMessage & message )
{
msg = &message;
switch( currentState )
{
case State1:
currentState = state_____State1( &message );
break;
case State2:
currentState = state_____State2( &message );
break;
default:
break;
}
}
void Capsule_B::initialize( const UMLRTMessage & message )
{
msg = &message;
actionchain_____TransitionAction0( &message );
currentState = State1;
}
const char * Capsule_B::getCurrentStateString() const
{
return stateNames[currentState];
}
void Capsule_B::update_state( Capsule_B::State newState )
{
currentState = newState;
}
void Capsule_B::entryaction_____State1( const UMLRTMessage * msg )
{
#define rtdata ( (void *)msg->getParam( 0 ) )
/* UMLRTGEN-USERREGION-BEGIN platform:/resource/CurrentStateUpdate1/CurrentStateUpdate1.uml CurrentStateUpdate::B::State1 entry */
log.log("[%s %s - %s](%s)", getTypeName(), getName(), name(), getCurrentStateString());
/* UMLRTGEN-USERREGION-END */
#undef rtdata
}
void Capsule_B::entryaction_____State2( const UMLRTMessage * msg )
{
#define rtdata ( (void *)msg->getParam( 0 ) )
/* UMLRTGEN-USERREGION-BEGIN platform:/resource/CurrentStateUpdate1/CurrentStateUpdate1.uml CurrentStateUpdate::B::State2 entry */
log.log("[%s %s - %s](%s)", getTypeName(), getName(), name(), getCurrentStateString());
exit(0);
/* UMLRTGEN-USERREGION-END */
#undef rtdata
}
void Capsule_B::exitaction_____State1( const UMLRTMessage * msg )
{
#define rtdata ( (void *)msg->getParam( 0 ) )
#undef rtdata
}
void Capsule_B::transitionaction_____TransitionAction1( const UMLRTMessage * msg )
{
#define rtdata ( (void *)msg->getParam( 0 ) )
/* UMLRTGEN-USERREGION-BEGIN platform:/resource/CurrentStateUpdate1/CurrentStateUpdate1.uml CurrentStateUpdate::B transition State1,State2,m:p */
log.log("[%s %s - %s](%s)", getTypeName(), getName(), name(), getCurrentStateString());
/* UMLRTGEN-USERREGION-END */
#undef rtdata
}
void Capsule_B::actionchain_____TransitionAction0( const UMLRTMessage * msg )
{
update_state( State1 );
entryaction_____State1( msg );
}
void Capsule_B::actionchain_____TransitionAction1( const UMLRTMessage * msg )
{
exitaction_____State1( msg );
update_state( SPECIAL_INTERNAL_STATE_TOP );
transitionaction_____TransitionAction1( msg );
update_state( State2 );
entryaction_____State2( msg );
}
Capsule_B::State Capsule_B::state_____State1( const UMLRTMessage * msg )
{
switch( msg->destPort->role()->id )
{
case port_p:
switch( msg->getSignalId() )
{
case P::signal_m:
actionchain_____TransitionAction1( msg );
return State2;
default:
this->unexpectedMessage();
break;
}
return currentState;
default:
this->unexpectedMessage();
break;
}
return currentState;
}
Capsule_B::State Capsule_B::state_____State2( const UMLRTMessage * msg )
{
switch( msg->destPort->role()->id )
{
default:
this->unexpectedMessage();
break;
}
return currentState;
}
static const UMLRTCommsPortRole portroles_border[] =
{
{
Capsule_B::port_p,
"P",
"p",
"",
1,
true,
true,
false,
false,
false,
false,
true
}
};
static const UMLRTCommsPortRole portroles_internal[] =
{
{
Capsule_B::port_log,
"Log",
"log",
"",
0,
false,
false,
false,
false,
true,
false,
false
}
};
static void instantiate_B( const UMLRTRtsInterface * rts, UMLRTSlot * slot, const UMLRTCommsPort * * borderPorts )
{
const UMLRTCommsPort * * internalPorts = UMLRTFrameService::createInternalPorts( slot, &B );
slot->capsule = new Capsule_B( &B, slot, borderPorts, internalPorts, false );
}
const UMLRTCapsuleClass B =
{
"B",
NULL,
instantiate_B,
0,
NULL,
1,
portroles_border,
1,
portroles_internal
};