// {{{RME classifier 'Logical View::SolicitaPacote'

#if defined( PRAGMA ) && ! defined( PRAGMA_IMPLEMENTED )
#pragma implementation "SolicitaPacote.h"
#endif

#include <RTSystem/PVA.h>
#include <SolicitaPacote.h>
#include <CommSolicitaPacote.h>
extern const RTActorClass Operador;
extern const RTActorClass Planejamento;

// {{{RME classifier 'Logical View::SolicitaPacote' tool 'OT::Cpp' property 'ImplementationPreface'
// {{{USR tool 'OT::Cpp' property 'ImplementationPreface'
// }}}USR
// }}}RME

static RTActor * new_SolicitaPacote_Actor( RTController * _rts, RTActorRef * _ref )
{
	return new SolicitaPacote_Actor( _rts, _ref );
}

const RTActorClass SolicitaPacote =
{
	(const RTActorClass *)0
  , "SolicitaPacote"
  , (RTVersionId)0
  , 0
  , (const RTRelayDescriptor *)0
  , new_SolicitaPacote_Actor
};

static const char * const rtg_state_names[] =
{
	"TOP"
  , "Operador_solicitando_pacotes"
  , "Aguardando_PctID"
  , "Enfileirando_Pct"
  , "Transportando_Pct"
  , "PVA_livre"
  , "Pct_localizado"
};

static const RTInterfaceDescriptor rtg_interfaces_operadorR1[] =
{
	{
		"planejamento_comm"
	  , 1
	}
};

static const RTBindingDescriptor rtg_bindings_operadorR1[] =
{
	{
		0
	  , &CommSolicitaPacote::Conjugate::rt_class
	}
};

static const RTInterfaceDescriptor rtg_interfaces_planejamentoR1[] =
{
	{
		"operador_comm"
	  , 1
	}
};

static const RTBindingDescriptor rtg_bindings_planejamentoR1[] =
{
	{
		0
	  , &CommSolicitaPacote::Base::rt_class
	}
};

#define SUPER RTActor

SolicitaPacote_Actor::SolicitaPacote_Actor( RTController * rtg_rts, RTActorRef * rtg_ref )
	: RTActor( rtg_rts, rtg_ref )
{
}

SolicitaPacote_Actor::~SolicitaPacote_Actor( void )
{
}

int SolicitaPacote_Actor::_followOutV( RTBindingEnd & rtg_end, int rtg_compId, int rtg_portId, int rtg_repIndex )
{
	switch( rtg_compId )
	{
	case 1:
		// operadorR1
		switch( rtg_portId )
		{
		case 0:
			// planejamento_comm
			if( rtg_repIndex < 1 )
			{
				// planejamentoR1/operador_comm
				return planejamentoR1._followIn( rtg_end, 0, rtg_repIndex );
			}
			break;
		default:
			break;
		}
	case 2:
		// planejamentoR1
		switch( rtg_portId )
		{
		case 0:
			// operador_comm
			if( rtg_repIndex < 1 )
			{
				// operadorR1/planejamento_comm
				return operadorR1._followIn( rtg_end, 0, rtg_repIndex );
			}
			break;
		default:
			break;
		}
	default:
		break;
	}
	return RTActor::_followOutV( rtg_end, rtg_compId, rtg_portId, rtg_repIndex );
}

INLINE_CHAINS void SolicitaPacote_Actor::chain1_Inicial( void )
{
	// transition ':TOP:Initial:Inicial'
	rtgChainBegin( 1, "Inicial" );
	rtgTransitionBegin();
	rtgTransitionEnd();
	enterState( 2 );
}

void SolicitaPacote_Actor::rtsBehavior( int signalIndex, int portIndex )
{
	for( int stateIndex = getCurrentState(); ; stateIndex = rtg_parent_state[ stateIndex - 1 ] )
		switch( stateIndex )
		{
		case 1:
			// {{{RME classifier 'Logical View::SolicitaPacote' state ':TOP'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					chain1_Inicial();
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			unexpectedMessage();
			return;
			// }}}RME
		case 2:
			// {{{RME classifier 'Logical View::SolicitaPacote' state ':TOP:Operador_solicitando_pacotes'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 3:
			// {{{RME classifier 'Logical View::SolicitaPacote' state ':TOP:Aguardando_PctID'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 4:
			// {{{RME classifier 'Logical View::SolicitaPacote' state ':TOP:Enfileirando_Pct'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 5:
			// {{{RME classifier 'Logical View::SolicitaPacote' state ':TOP:Transportando_Pct'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		default:
			unexpectedState();
			return;
		}
}

const RTActor_class * SolicitaPacote_Actor::getActorData( void ) const
{
	return &SolicitaPacote_Actor::rtg_class;
}

const RTActor_class SolicitaPacote_Actor::rtg_class =
{
	(const RTActor_class *)0
  , rtg_state_names
  , 5
  , SolicitaPacote_Actor::rtg_parent_state
  , &SolicitaPacote
  , 2
  , SolicitaPacote_Actor::rtg_capsule_roles
  , 0
  , (const RTPortDescriptor *)0
  , 0
  , (const RTLocalBindingDescriptor *)0
  , 0
  , (const RTFieldDescriptor *)0
};

const RTStateId SolicitaPacote_Actor::rtg_parent_state[] =
{
	0
  , 1
  , 1
  , 1
  , 1
};

const RTComponentDescriptor SolicitaPacote_Actor::rtg_capsule_roles[] =
{
	{
		"operadorR1"
	  , &Operador
	  , RTOffsetOf( SolicitaPacote_Actor, operadorR1 )
	  , 1
	  , RTComponentDescriptor::Fixed
	  , 1
	  , 1 // cardinality
	  , 1
	  , rtg_interfaces_operadorR1
	  , 1
	  , rtg_bindings_operadorR1
	}
  , {
		"planejamentoR1"
	  , &Planejamento
	  , RTOffsetOf( SolicitaPacote_Actor, planejamentoR1 )
	  , 2
	  , RTComponentDescriptor::Fixed
	  , 1
	  , 1 // cardinality
	  , 1
	  , rtg_interfaces_planejamentoR1
	  , 1
	  , rtg_bindings_planejamentoR1
	}
};

#undef SUPER

// {{{RME classifier 'Logical View::SolicitaPacote' tool 'OT::Cpp' property 'ImplementationEnding'
// {{{USR tool 'OT::Cpp' property 'ImplementationEnding'
// }}}USR
// }}}RME

// }}}RME
