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

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

#include <RTSystem/PVA.h>
#include <CarregarPacote.h>

// {{{RME classifier 'Logical View::CarregarPacote' 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_CarregarPacote_Actor( RTController * _rts, RTActorRef * _ref )
{
	return new CarregarPacote_Actor( _rts, _ref );
}

const RTActorClass CarregarPacote =
{
	(const RTActorClass *)0
  , "CarregarPacote"
  , (RTVersionId)0
  , 1
  , rtg_relays
  , new_CarregarPacote_Actor
};

static const char * const rtg_state_names[] =
{
	"TOP"
  , "Destino_Alcancado"
  , "Pacote_Carregado"
  , "Avisa_Navegação_MCM"
  , "Pacote_Descarregado"
  , "end_fim"
  , "Pacote_detectado"
  , "CP2"
  , "Pacote_descarregado"
  , "Carregar_Outro"
};

#define SUPER RTActor

CarregarPacote_Actor::CarregarPacote_Actor( RTController * rtg_rts, RTActorRef * rtg_ref )
	: RTActor( rtg_rts, rtg_ref )
	, PacoteCerto( true )
	, LocPacote( 0,0 )
	, LocPorta( 0,0 )
	, Destino( false )
	, IDPacote( 0000 )
{
}

CarregarPacote_Actor::~CarregarPacote_Actor( void )
{
}

// {{{RME classifier 'Logical View::CarregarPacote' operation 'QuestionaPacotePresente(bool)'
bool CarregarPacote_Actor::QuestionaPacotePresente( bool pctpresente )
{
	// {{{USR operation 'QuestionaPacotePresente(bool)'
	if (PacoteCerto){
		return true;
	}else{
		return false;
	}
	// }}}USR
}
// }}}RME

// {{{RME classifier 'Logical View::CarregarPacote' operation 'Descarregar(bool)'
bool CarregarPacote_Actor::Descarregar( bool descarregar )
{
	// {{{USR operation 'Descarregar(bool)'
	if (PacoteCerto){
		return true;
	}else{
		return false;
	}
	// }}}USR
}
// }}}RME

// {{{RME classifier 'Logical View::CarregarPacote' operation 'Carregar(bool)'
bool CarregarPacote_Actor::Carregar( bool carregar )
{
	// {{{USR operation 'Carregar(bool)'
	if (PacoteCerto){
		return true;
	}else{
		return false;
	}
	// }}}USR
}
// }}}RME

// {{{RME classifier 'Logical View::CarregarPacote' operation 'ComDestAlcancado(bool)'
char CarregarPacote_Actor::ComDestAlcancado( bool destAlcancado )
{
	// {{{USR operation 'ComDestAlcancado(bool)'
	if (Destino){
		return true;
	}else{
		return false;
	}
	// }}}USR
}
// }}}RME

// {{{RME classifier 'Logical View::CarregarPacote' operation 'ProximaMissao(float,bool)'
void CarregarPacote_Actor::ProximaMissao( float locProxMissao, bool missao )
{
	// {{{USR operation 'ProximaMissao(float,bool)'
	// }}}USR
}
// }}}RME

// {{{RME classifier 'Logical View::CarregarPacote' operation 'Conduzir(char)'
void CarregarPacote_Actor::Conduzir( char conduzir )
{
	// {{{USR operation 'Conduzir(char)'
	// }}}USR
}
// }}}RME

// {{{RME classifier 'Logical View::CarregarPacote' operation 'ComProblema()'
bool CarregarPacote_Actor::ComProblema( void )
{
	// {{{USR operation 'ComProblema()'
	return false;
	// }}}USR
}
// }}}RME

// {{{RME classifier 'Logical View::CarregarPacote' operation 'AvisaCarregado()'
bool CarregarPacote_Actor::AvisaCarregado( void )
{
	// {{{USR operation 'AvisaCarregado()'
	return true;
	// }}}USR
}
// }}}RME

int CarregarPacote_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 CarregarPacote_Actor::chain14_Initial( void )
{
	// transition ':TOP:Initial:Initial'
	rtgChainBegin( 1, "Initial" );
	rtgTransitionBegin();
	rtgTransitionEnd();
	enterState( 2 );
}

void CarregarPacote_Actor::rtsBehavior( int signalIndex, int portIndex )
{
	for( int stateIndex = getCurrentState(); ; stateIndex = rtg_parent_state[ stateIndex - 1 ] )
		switch( stateIndex )
		{
		case 1:
			// {{{RME classifier 'Logical View::CarregarPacote' state ':TOP'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					chain14_Initial();
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			unexpectedMessage();
			return;
			// }}}RME
		case 2:
			// {{{RME classifier 'Logical View::CarregarPacote' state ':TOP:Destino_Alcancado'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 3:
			// {{{RME classifier 'Logical View::CarregarPacote' state ':TOP:Pacote_Carregado'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 4:
			// {{{RME classifier 'Logical View::CarregarPacote' state ':TOP:Avisa_Navegação_MCM'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 5:
			// {{{RME classifier 'Logical View::CarregarPacote' state ':TOP:Pacote_Descarregado'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		case 6:
			// {{{RME classifier 'Logical View::CarregarPacote' state ':TOP:end_fim'
			switch( portIndex )
			{
			case 0:
				switch( signalIndex )
				{
				case 1:
					return;
				default:
					break;
				}
				break;
			default:
				break;
			}
			break;
			// }}}RME
		default:
			unexpectedState();
			return;
		}
}

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

const RTActor_class CarregarPacote_Actor::rtg_class =
{
	(const RTActor_class *)0
  , rtg_state_names
  , 6
  , CarregarPacote_Actor::rtg_parent_state
  , &CarregarPacote
  , 0
  , (const RTComponentDescriptor *)0
  , 1
  , CarregarPacote_Actor::rtg_ports
  , 0
  , (const RTLocalBindingDescriptor *)0
  , 5
  , CarregarPacote_Actor::rtg_CarregarPacote_fields
};

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

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

const RTFieldDescriptor CarregarPacote_Actor::rtg_CarregarPacote_fields[] =
{
	// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'PacoteCerto'
	{
		"PacoteCerto"
	  , RTOffsetOf( CarregarPacote_Actor, PacoteCerto )
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'PacoteCerto' tool 'OT::CppTargetRTS' property 'TypeDescriptor'
	  , &RTType_bool
		// }}}RME
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'PacoteCerto' tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'
	  , (const RTTypeModifier *)0
		// }}}RME
	}
	// }}}RME
	// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'LocPacote'
  , {
		"LocPacote"
	  , RTOffsetOf( CarregarPacote_Actor, LocPacote )
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'LocPacote' tool 'OT::CppTargetRTS' property 'TypeDescriptor'
	  , &RTType_float
		// }}}RME
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'LocPacote' tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'
	  , (const RTTypeModifier *)0
		// }}}RME
	}
	// }}}RME
	// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'LocPorta'
  , {
		"LocPorta"
	  , RTOffsetOf( CarregarPacote_Actor, LocPorta )
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'LocPorta' tool 'OT::CppTargetRTS' property 'TypeDescriptor'
	  , &RTType_float
		// }}}RME
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'LocPorta' tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'
	  , (const RTTypeModifier *)0
		// }}}RME
	}
	// }}}RME
	// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'Destino'
  , {
		"Destino"
	  , RTOffsetOf( CarregarPacote_Actor, Destino )
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'Destino' tool 'OT::CppTargetRTS' property 'TypeDescriptor'
	  , &RTType_bool
		// }}}RME
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'Destino' tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'
	  , (const RTTypeModifier *)0
		// }}}RME
	}
	// }}}RME
	// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'IDPacote'
  , {
		"IDPacote"
	  , RTOffsetOf( CarregarPacote_Actor, IDPacote )
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'IDPacote' tool 'OT::CppTargetRTS' property 'TypeDescriptor'
	  , &RTType_double
		// }}}RME
		// {{{RME classifier 'Logical View::CarregarPacote' classAttribute 'IDPacote' tool 'OT::CppTargetRTS' property 'GenerateTypeModifier'
	  , (const RTTypeModifier *)0
		// }}}RME
	}
	// }}}RME
};
#undef SUPER

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

// }}}RME
