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

📄 a_dest_process.pr.c

📁 使用OPNET进行网络建模仿真的实例,分别从进程,节点,项目进行编辑。
💻 C
字号:
/* Process model C form file: a_dest_process.pr.c */
/* Portions of this file copyright 1992-2003 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
const char a_dest_process_pr_c [] = "MIL_3_Tfile_Hdr_ 100A 30A modeler 7 4664C4B9 4664C4B9 1 zhangming2 zhangming 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 8f3 1                                                                                                                                                                                                                                                                                                                                                                                                      ";
#include <string.h>



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



/* Header Block */

#define PKT_ARVL (op_intrpt_type() == OPC_INTRPT_STRM)

/* 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 */
	Stathandle	             		ete_gsh;
	} a_dest_process_state;

#define pr_state_ptr            		((a_dest_process_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define ete_gsh                 		pr_state_ptr->ete_gsh

/* 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	a_dest_process_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 = ((a_dest_process_state *)(tcontext_ptr->mod_state_ptr));
#else
#  define FIN_PREAMBLE_DEC	a_dest_process_state *op_sv_ptr;
#  define FIN_PREAMBLE_CODE	op_sv_ptr = pr_state_ptr;
#endif


/* No Function Block */


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

/* 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 a_dest_process (OP_SIM_CONTEXT_ARG_OPT);
	VosT_Obtype a_dest_process_init (int * init_block_ptr);
	VosT_Address a_dest_process_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
	void a_dest_process_diag (OP_SIM_CONTEXT_ARG_OPT);
	void a_dest_process_terminate (OP_SIM_CONTEXT_ARG_OPT);
	void a_dest_process_svar (void *, const char *, void **);


	VosT_Fun_Status Vos_Define_Object (VosT_Obtype * obst_ptr, const char * name, unsigned int size, unsigned int init_obs, unsigned int inc_obs);
	VosT_Address Vos_Alloc_Object_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype ob_hndl);
	VosT_Fun_Status Vos_Poolmem_Dealloc_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Address ob_ptr);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif




/* Process model interrupt handling procedure */


void
a_dest_process (OP_SIM_CONTEXT_ARG_OPT)
	{

#if !defined (VOSD_NO_FIN)
	int _op_block_origin = 0;
#endif
	FIN_MT (a_dest_process ());
	if (1)
		{
		double ete_delay; 
		double creation_time; 
		double current_time; 
		int stream_index; 
		Packet* pkptr;


		FSM_ENTER_NO_VARS ("a_dest_process")

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (init) enter executives **/
			FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "a_dest_process [init enter execs]")
				FSM_PROFILE_SECTION_IN (a_dest_process [init enter execs], state0_enter_exec)
				{
				/* Register handle for statistic collection. */ 
				ete_gsh = op_stat_reg("ETE delay", OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);
				}

				FSM_PROFILE_SECTION_OUT (a_dest_process [init enter execs], state0_enter_exec)

			/** state (init) exit executives **/
			FSM_STATE_EXIT_FORCED (0, "init", "a_dest_process [init exit execs]")
				FSM_PROFILE_SECTION_IN (a_dest_process [init exit execs], state0_exit_exec)
				{
				}
				FSM_PROFILE_SECTION_OUT (a_dest_process [init exit execs], state0_exit_exec)


			/** state (init) transition processing **/
			FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "init", "ETE_delay")
				/*---------------------------------------------------------*/



			/** state (ETE_delay) enter executives **/
			FSM_STATE_ENTER_FORCED (1, "ETE_delay", state1_enter_exec, "a_dest_process [ETE_delay enter execs]")
				FSM_PROFILE_SECTION_IN (a_dest_process [ETE_delay enter execs], state1_enter_exec)
				{
				/* Get stream index number. */ 
				stream_index = op_intrpt_strm( );
				
				/* Get pointer to packet from stream index. */
				pkptr = op_pk_get(stream_index); 
				
				/* Get creation time of packet. */ 
				creation_time  = op_pk_creation_time_get(pkptr); 
				
				/* Get current simulation time. */ 
				current_time = op_sim_time( );
					
				/* Calculate ETE Delay. */ 
				ete_delay = (current_time - creation_time); 
				
				/* Write statistics. */ 
				op_stat_write(ete_gsh, ete_delay); 
				
				/* Destroy packet. */ 
				op_pk_destroy(pkptr);
				}

				FSM_PROFILE_SECTION_OUT (a_dest_process [ETE_delay enter execs], state1_enter_exec)

			/** state (ETE_delay) exit executives **/
			FSM_STATE_EXIT_FORCED (1, "ETE_delay", "a_dest_process [ETE_delay exit execs]")
				FSM_PROFILE_SECTION_IN (a_dest_process [ETE_delay exit execs], state1_exit_exec)
				{
				}
				FSM_PROFILE_SECTION_OUT (a_dest_process [ETE_delay exit execs], state1_exit_exec)


			/** state (ETE_delay) transition processing **/
			FSM_TRANSIT_ONLY ((PKT_ARVL), 2, state2_enter_exec, ;, ETE_delay, "PKT_ARVL", "", "ETE_delay", "idle")
				/*---------------------------------------------------------*/



			/** state (idle) enter executives **/
			FSM_STATE_ENTER_UNFORCED (2, "idle", state2_enter_exec, "a_dest_process [idle enter execs]")
				FSM_PROFILE_SECTION_IN (a_dest_process [idle enter execs], state2_enter_exec)
				{
				}

				FSM_PROFILE_SECTION_OUT (a_dest_process [idle enter execs], state2_enter_exec)

			/** blocking after enter executives of unforced state. **/
			FSM_EXIT (5,"a_dest_process")


			/** state (idle) exit executives **/
			FSM_STATE_EXIT_UNFORCED (2, "idle", "a_dest_process [idle exit execs]")
				FSM_PROFILE_SECTION_IN (a_dest_process [idle exit execs], state2_exit_exec)
				{
				}
				FSM_PROFILE_SECTION_OUT (a_dest_process [idle exit execs], state2_exit_exec)


			/** state (idle) transition processing **/
			FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "idle", "ETE_delay")
				/*---------------------------------------------------------*/



			}


		FSM_EXIT (0,"a_dest_process")
		}
	}




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




void
a_dest_process_terminate (OP_SIM_CONTEXT_ARG_OPT)
	{

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

	FIN_MT (a_dest_process_terminate ())

	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 a_dest_process_svar function. */
#undef ete_gsh

#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE

#define FIN_PREAMBLE_DEC
#define FIN_PREAMBLE_CODE

VosT_Obtype
a_dest_process_init (int * init_block_ptr)
	{

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

	Vos_Define_Object (&obtype, "proc state vars (a_dest_process)",
		sizeof (a_dest_process_state), 0, 20);
	*init_block_ptr = 0;

	FRET (obtype)
	}

VosT_Address
a_dest_process_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype obtype, int init_block)
	{

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

	ptr = (a_dest_process_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
a_dest_process_svar (void * gen_ptr, const char * var_name, void ** var_p_ptr)
	{
	a_dest_process_state		*prs_ptr;

	FIN_MT (a_dest_process_svar (gen_ptr, var_name, var_p_ptr))

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

	if (strcmp ("ete_gsh" , var_name) == 0)
		{
		*var_p_ptr = (void *) (&prs_ptr->ete_gsh);
		FOUT
		}
	*var_p_ptr = (void *)OPC_NIL;

	FOUT
	}

⌨️ 快捷键说明

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