blob: b47cade19e06c1038f5ae527021e877b6e2cabdd [file]
#include "Server.hh"
#include "Service.hh"
#include "umlrtcommsportrole.hh"
#include "umlrtmessage.hh"
#include "umlrtslot.hh"
#include <cstddef>
#include "umlrtcapsuleclass.hh"
#include "umlrtframeservice.hh"
class UMLRTRtsInterface;
struct UMLRTCommsPort;
Capsule_Server::Capsule_Server( const UMLRTCapsuleClass * cd, UMLRTSlot * st, const UMLRTCommsPort * * border, const UMLRTCommsPort * * internal, bool isStat )
: UMLRTCapsule( NULL, cd, st, border, internal, isStat )
, service( internalPorts[internalport_service] )
, currentState( SPECIAL_INTERNAL_STATE_UNVISITED )
{
stateNames[WaitingForRequests] = "WaitingForRequests";
stateNames[SPECIAL_INTERNAL_STATE_UNVISITED] = "<uninitialized>";
}
void Capsule_Server::bindPort( bool isBorder, int portId, int index )
{
}
void Capsule_Server::unbindPort( bool isBorder, int portId, int index )
{
}
void Capsule_Server::inject( const UMLRTMessage & message )
{
msg = &message;
switch( currentState )
{
case WaitingForRequests:
currentState = state_____WaitingForRequests( &message );
break;
default:
break;
}
}
void Capsule_Server::initialize( const UMLRTMessage & message )
{
msg = &message;
actionchain_____Initial( &message );
currentState = WaitingForRequests;
}
const char * Capsule_Server::getCurrentStateString() const
{
return stateNames[currentState];
}
void Capsule_Server::entryaction_____WaitingForRequests( const UMLRTMessage * msg )
{
#define rtdata ( (void *)msg->getParam( 0 ) )
/* UMLRTGEN-USERREGION-BEGIN platform:/resource/SPPInheritance/SPPInheritance.uml RootElement::Server::WaitingForRequests entry */
log.log("[Server](WaitingForRequests)");
/* UMLRTGEN-USERREGION-END */
#undef rtdata
}
void Capsule_Server::exitaction_____WaitingForRequests( const UMLRTMessage * msg )
{
#define rtdata ( (void *)msg->getParam( 0 ) )
/* UMLRTGEN-USERREGION-BEGIN platform:/resource/SPPInheritance/SPPInheritance.uml RootElement::Server::WaitingForRequests exit */
/* UMLRTGEN-USERREGION-END */
#undef rtdata
}
void Capsule_Server::transitionaction_____TransitionAction1( const UMLRTMessage * msg )
{
#define rtdata ( (void *)msg->getParam( 0 ) )
/* UMLRTGEN-USERREGION-BEGIN platform:/resource/SPPInheritance/SPPInheritance.uml RootElement::Server transition WaitingForRequests,WaitingForRequests,request:service */
log.log("[Server](request) received request on service port");
service.response().send();
log.log("[Server](request) sent response on service port");
/* UMLRTGEN-USERREGION-END */
#undef rtdata
}
void Capsule_Server::actionchain_____Initial( const UMLRTMessage * msg )
{
entryaction_____WaitingForRequests( msg );
}
void Capsule_Server::actionchain_____TransitionAction1( const UMLRTMessage * msg )
{
exitaction_____WaitingForRequests( msg );
transitionaction_____TransitionAction1( msg );
entryaction_____WaitingForRequests( msg );
}
Capsule_Server::State Capsule_Server::state_____WaitingForRequests( const UMLRTMessage * msg )
{
switch( msg->destPort->role()->id )
{
case port_service:
switch( msg->getSignalId() )
{
case Service::signal_request:
actionchain_____TransitionAction1( msg );
return WaitingForRequests;
default:
this->unexpectedMessage();
break;
}
return currentState;
default:
this->unexpectedMessage();
break;
}
return currentState;
}
static const UMLRTCommsPortRole portroles_internal[] =
{
{
Capsule_Server::port_service,
"Service",
"service",
"",
1,
true,
false,
false,
false,
false,
true,
false
},
{
Capsule_Server::port_log,
"Log",
"log",
"",
1,
true,
false,
false,
false,
true,
false,
false
}
};
static void instantiate_Server( const UMLRTRtsInterface * rts, UMLRTSlot * slot, const UMLRTCommsPort * * borderPorts )
{
const UMLRTCommsPort * * internalPorts = UMLRTFrameService::createInternalPorts( slot, &Server );
slot->capsule = new Capsule_Server( &Server, slot, borderPorts, internalPorts, false );
}
const UMLRTCapsuleClass Server =
{
"Server",
NULL,
instantiate_Server,
0,
NULL,
0,
NULL,
2,
portroles_internal
};