⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 noc_vc_choice_init.pr.c

📁 opnet
💻 C
字号:
/* Process model C form file: NOC_vc_choice_init.pr.c */
/* Portions of this file copyright 1992-2004 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
const char NOC_vc_choice_init_pr_c [] = "MIL_3_Tfile_Hdr_ 105A 30A modeler 7 43980C1F 43980C1F 1 ccslab-yy 严晔 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 a0a 3                                                                                                                                                                                                                                                                                                                                                                                                            ";
#include <string.h>



/* OPNET system definitions */
#include <opnet.h>



/* Header Block */

#define PK_ARRVL (op_intrpt_type () == OPC_INTRPT_STRM)

/* Output stream to VC */
#define VC1 0
#define VC2 1
#define VC3 2
#define VC4 3

  
/* Input stream from receiver */
#define IN_STRM 0



/* End of Header Block */


#if !defined (VOSD_NO_FIN)
#undef	BIN
#undef	BOUT
#define	BIN		FIN_LOCAL_FIELD(_op_last_line_passed) = __LINE__ - _op_block_origin;
#define	BOUT	BIN
#define	BINIT	FIN_LOCAL_FIELD(_op_last_line_passed) = 0; _op_block_origin = __LINE__;
#else
#define	BINIT
#endif /* #if !defined (VOSD_NO_FIN) */



/* State variable definitions */
typedef struct
	{
	/* Internal state tracking for FSM */
	FSM_SYS_STATE
	/* State Variables */
	int	                    		vc1_count                                       ;
	int	                    		vc2_count                                       ;
	int	                    		vc3_count                                       ;
	int	                    		vc4_count                                       ;
	int	                    		vc                                              ;
	} NOC_vc_choice_init_state;

#define pr_state_ptr            		((NOC_vc_choice_init_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define vc1_count               		pr_state_ptr->vc1_count
#define vc2_count               		pr_state_ptr->vc2_count
#define vc3_count               		pr_state_ptr->vc3_count
#define vc4_count               		pr_state_ptr->vc4_count
#define vc                      		pr_state_ptr->vc

/* These macro definitions will define a local variable called	*/
/* "op_sv_ptr" in each function containing a FIN statement.	*/
/* This variable points to the state variable data structure,	*/
/* and can be used from a C debugger to display their values.	*/
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#if defined (OPD_PARALLEL)
#  define FIN_PREAMBLE_DEC	NOC_vc_choice_init_state *op_sv_ptr; OpT_Sim_Context * tcontext_ptr;
#  define FIN_PREAMBLE_CODE	\
		if (VosS_Mt_Perform_Lock) \
			VOS_THREAD_SPECIFIC_DATA_GET (VosI_Globals.simi_mt_context_data_key, tcontext_ptr, SimT_Context *); \
		else \
			tcontext_ptr = VosI_Globals.simi_sequential_context_ptr; \
		op_sv_ptr = ((NOC_vc_choice_init_state *)(tcontext_ptr->mod_state_ptr));
#else
#  define FIN_PREAMBLE_DEC	NOC_vc_choice_init_state *op_sv_ptr;
#  define FIN_PREAMBLE_CODE	op_sv_ptr = pr_state_ptr;
#endif


/* Function Block */


#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ };
#endif


/* End of Function Block */

/* Undefine optional tracing in FIN/FOUT/FRET */
/* The FSM has its own tracing code and the other */
/* functions should not have any tracing.		  */
#undef FIN_TRACING
#define FIN_TRACING

#undef FOUTRET_TRACING
#define FOUTRET_TRACING

#if defined (__cplusplus)
extern "C" {
#endif
	void NOC_vc_choice_init (OP_SIM_CONTEXT_ARG_OPT);
	VosT_Obtype NOC_vc_choice_init_init (int * init_block_ptr);
	VosT_Address NOC_vc_choice_init_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
	void NOC_vc_choice_init_diag (OP_SIM_CONTEXT_ARG_OPT);
	void NOC_vc_choice_init_terminate (OP_SIM_CONTEXT_ARG_OPT);
	void NOC_vc_choice_init_svar (void *, const char *, void **);


	VosT_Obtype Vos_Define_Object_Prstate (const char * _op_name, unsigned int _op_size);
	VosT_Address Vos_Alloc_Object_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype _op_ob_hndl);
	VosT_Fun_Status Vos_Poolmem_Dealloc_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Address _op_ob_ptr);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif




/* Process model interrupt handling procedure */


void
NOC_vc_choice_init (OP_SIM_CONTEXT_ARG_OPT)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	FIN_MT (NOC_vc_choice_init ());
		{
		/* Temporary Variables */
		int head;
		int tail;
		
		/* End of Temporary Variables */


		FSM_ENTER_NO_VARS ("NOC_vc_choice_init")

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (idle) enter executives **/
			FSM_STATE_ENTER_UNFORCED (0, "idle", state0_enter_exec, "NOC_vc_choice_init [idle enter execs]")
				FSM_PROFILE_SECTION_IN ("NOC_vc_choice_init [idle enter execs]", state0_enter_exec)
				{
				vc1_count = 0;
				vc2_count = 0;
				vc3_count = 0;
				vc4_count = 0;
				}
				FSM_PROFILE_SECTION_OUT (state0_enter_exec)

			/** blocking after enter executives of unforced state. **/
			FSM_EXIT (1,"NOC_vc_choice_init")


			/** state (idle) exit executives **/
			FSM_STATE_EXIT_UNFORCED (0, "idle", "NOC_vc_choice_init [idle exit execs]")


			/** state (idle) transition processing **/
			FSM_TRANSIT_ONLY ((PK_ARRVL), 1, state1_enter_exec, ;, idle, "PK_ARRVL", "", "idle", "tx_pkt")
				/*---------------------------------------------------------*/



			/** state (tx_pkt) enter executives **/
			FSM_STATE_ENTER_FORCED (1, "tx_pkt", state1_enter_exec, "NOC_vc_choice_init [tx_pkt enter execs]")
				FSM_PROFILE_SECTION_IN ("NOC_vc_choice_init [tx_pkt enter execs]", state1_enter_exec)
				{
				/* Incoming packet */
				Packet *in_pkt;
				
				/* A packet has arrived form receiver. Acquire */
				/* the packet from the input stream, send the packet to a VC */
				
				 in_pkt = op_pk_get (IN_STRM);
				op_pk_nfd_get_int32 (in_pkt,"head",&head);
				op_pk_nfd_get_int32 (in_pkt,"tail",&tail);
				
				if(head == 1 && tail == 0)
					{
				    if (vc1_count==0)
					  {
						op_pk_send (in_pkt, VC1);
				         ++vc1_count;
						 vc = VC1;
					   }
				    else
				       {
					    if(vc2_count == 0)
					      {
						   op_pk_send (in_pkt, VC2);
				           ++vc2_count;
						   vc = VC2;
						   }
						else
						    {
							 if(vc3_count == 0)
							   {
						        op_pk_send (in_pkt, VC3);
				                ++vc3_count;
							    vc = VC3;
						       }
					        else
								{
							     if (vc4_count == 0)
							       {
						            op_pk_send (in_pkt, VC4);
				                    ++vc4_count;
							        vc = VC4;
						            }
								 }
							}
						}
					}
				
				if(head == 0 && tail== 1)
					{
					switch(vc)
						{
						case VC1: vc1_count=0;break;
						case VC2: vc2_count=0;break;
						case VC3: vc3_count=0;break;
						case VC4: vc4_count=0;break;
						}
					op_pk_send (in_pkt, vc);
					}
				
				    
				}
				FSM_PROFILE_SECTION_OUT (state1_enter_exec)

			/** state (tx_pkt) exit executives **/
			FSM_STATE_EXIT_FORCED (1, "tx_pkt", "NOC_vc_choice_init [tx_pkt exit execs]")


			/** state (tx_pkt) transition processing **/
			FSM_TRANSIT_FORCE (0, state0_enter_exec, ;, "default", "", "tx_pkt", "idle")
				/*---------------------------------------------------------*/



			}


		FSM_EXIT (0,"NOC_vc_choice_init")
		}
	}




void
NOC_vc_choice_init_diag (OP_SIM_CONTEXT_ARG_OPT)
	{
	/* No Diagnostic Block */
	}




void
NOC_vc_choice_init_terminate (OP_SIM_CONTEXT_ARG_OPT)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = __LINE__;
#endif

	FIN_MT (NOC_vc_choice_init_terminate ())


	/* No Termination Block */

	Vos_Poolmem_Dealloc_MT (OP_SIM_CONTEXT_THREAD_INDEX_COMMA pr_state_ptr);

	FOUT
	}


/* Undefine shortcuts to state variables to avoid */
/* syntax error in direct access to fields of */
/* local variable prs_ptr in NOC_vc_choice_init_svar function. */
#undef vc1_count
#undef vc2_count
#undef vc3_count
#undef vc4_count
#undef vc

#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE

#define FIN_PREAMBLE_DEC
#define FIN_PREAMBLE_CODE

VosT_Obtype
NOC_vc_choice_init_init (int * init_block_ptr)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	VosT_Obtype obtype = OPC_NIL;
	FIN_MT (NOC_vc_choice_init_init (init_block_ptr))

	obtype = Vos_Define_Object_Prstate ("proc state vars (NOC_vc_choice_init)",
		sizeof (NOC_vc_choice_init_state));
	*init_block_ptr = 0;

	FRET (obtype)
	}

VosT_Address
NOC_vc_choice_init_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype obtype, int init_block)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	NOC_vc_choice_init_state * ptr;
	FIN_MT (NOC_vc_choice_init_alloc (obtype))

	ptr = (NOC_vc_choice_init_state *)Vos_Alloc_Object_MT (VOS_THREAD_INDEX_COMMA obtype);
	if (ptr != OPC_NIL)
		ptr->_op_current_block = init_block;
	FRET ((VosT_Address)ptr)
	}



void
NOC_vc_choice_init_svar (void * gen_ptr, const char * var_name, void ** var_p_ptr)
	{
	NOC_vc_choice_init_state		*prs_ptr;

	FIN_MT (NOC_vc_choice_init_svar (gen_ptr, var_name, var_p_ptr))

	if (var_name == OPC_NIL)
		{
		*var_p_ptr = (void *)OPC_NIL;
		FOUT
		}
	prs_ptr = (NOC_vc_choice_init_state *)gen_ptr;

	if (strcmp ("vc1_count" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->vc1_count);
		FOUT
		}
	if (strcmp ("vc2_count" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->vc2_count);
		FOUT
		}
	if (strcmp ("vc3_count" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->vc3_count);
		FOUT
		}
	if (strcmp ("vc4_count" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->vc4_count);
		FOUT
		}
	if (strcmp ("vc" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->vc);
		FOUT
		}
	*var_p_ptr = (void *)OPC_NIL;

	FOUT
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -