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

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

#include <RTSystem/DetectarPacoteComponent.h>
#include <DetectarPacote.h>
#include <Pacote.h>

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

static const RTRelayDescriptor rtg_relays[] =
{
	{
		"NewPort1"
	  , &Dados::Base::rt_class
	  , 1 // cardinality
	}
};

static RTActor * new_DetectarPacote_Actor( RTController * _rts, RTActorRef * _ref )
{
	return new DetectarPacote_Actor( _rts, _ref );
}

const RTActorClass DetectarPacote =
{
	(const RTActorClass *)0
  , "DetectarPacote"
  , (RTVersionId)0
  , 1
  , rtg_relays
  , new_DetectarPacote_Actor
};

static const char * const rtg_state_names[] =
{
	"TOP"
  , "Aguardando_ler_um_codigo"
  , "Leu_um_codigo"
  , "Codigo_valido"
  , "Pode_carregar_pacote"
  , "Validar"
  , "Codigo_procurado"
};

#define SUPER RTActor

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

DetectarPacote_Actor::~DetectarPacote_Actor( void )
{
}

// {{{RME classifier 'Logical View::DetectarPacote' operation 'EnviarMsgCentral()'
void DetectarPacote_Actor::EnviarMsgCentral( void )
{
	// {{{USR operation 'EnviarMsgCentral()'
	// }}}USR
}
// }}}RME

// {{{RME classifier 'Logical View::DetectarPacote' operation 'HabilitarCarregarPacote()'
void DetectarPacote_Actor::HabilitarCarregarPacote( void )
{
	// {{{USR operation 'HabilitarCarregarPacote()'
	// }}}USR
}
// }}}RME

int DetectarPacote_Actor::_followInV( RTBindingEnd & rtg_end, int rtg_portId, int rtg_repIndex )
{
	switch( rtg_portId )
	{
	case 0:
		// NewPort1
		if( rtg_repIndex < 1 )
		{
			rtg_end.port = &NewPort1;
			rtg_end.index = rtg_repIndex;
			return 1;
		}
		break;
	default:
		break;
	}
	return RTActor::_followInV( rtg_end, rtg_portId, rtg_repIndex );
}

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

void DetectarPacote_Actor::rtsBehavior( int signalIndex, int portIndex )
{
	for( int stateIndex = getCurrentState(); ; stateIndex = rtg_parent_state[ stateIndex - 1 ] )
		switch( stateIndex )
		{
		case 1:
			// {{{RME classifier 'Logical View::DetectarPacote' 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::DetectarPacote' state ':TOP:Aguardando_ler_um_codigo'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 3:
			// {{{RME classifier 'Logical View::DetectarPacote' state ':TOP:Leu_um_codigo'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 4:
			// {{{RME classifier 'Logical View::DetectarPacote' state ':TOP:Codigo_valido'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 5:
			// {{{RME classifier 'Logical View::DetectarPacote' state ':TOP:Pode_carregar_pacote'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		default:
			unexpectedState();
			return;
		}
}

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

const RTActor_class DetectarPacote_Actor::rtg_class =
{
	(const RTActor_class *)0
  , rtg_state_names
  , 5
  , DetectarPacote_Actor::rtg_parent_state
  , &DetectarPacote
  , 0
  , (const RTComponentDescriptor *)0
  , 1
  , DetectarPacote_Actor::rtg_ports
  , 0
  , (const RTLocalBindingDescriptor *)0
  , 1
  , DetectarPacote_Actor::rtg_DetectarPacote_fields
};

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

const RTPortDescriptor DetectarPacote_Actor::rtg_ports[] =
{
	{
		"NewPort1"
	  , (const char *)0
	  , &Dados::Base::rt_class
	  , RTOffsetOf( DetectarPacote_Actor, DetectarPacote_Actor::NewPort1 )
	  , 1 // cardinality
	  , 1
	  , RTPortDescriptor::End
	  , RTPortDescriptor::NotificationDisabled
	  , RTPortDescriptor::RegisterNotPermitted
	  , RTPortDescriptor::PublicVisibility
	  , RTPortDescriptor::Wired
	}
};

const RTFieldDescriptor DetectarPacote_Actor::rtg_DetectarPacote_fields[] =
{
	// {{{RME classifier 'Logical View::DetectarPacote' classAttribute 'Codigo'
	{
		"Codigo"
	  , RTOffsetOf( DetectarPacote_Actor, Codigo )
		// {{{RME classifier 'Logical View::DetectarPacote' classAttribute 'Codigo' tool 'OT::CppTargetRTS' property 'TypeDescriptor'
	  , &RTType_long
		// }}}RME
		// {{{RME classifier 'Logical View::DetectarPacote' classAttribute 'Codigo' tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'
	  , (const RTTypeModifier *)0
		// }}}RME
	}
	// }}}RME
};
#undef SUPER

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

// }}}RME
