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

📄 pksw_periph_proc_ref.pr.c

📁 OPNET odb_lab_ref-baseline
💻 C
字号:
/* Process model C form file: pksw_periph_proc_ref.pr.c */
/* Portions of this file copyright 1992-2002 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
static const char pksw_periph_proc_ref_pr_c [] = "MIL_3_Tfile_Hdr_ 91A 30A op_runsim 7 3F8978BE 3F8978BE 1 TRACY tracy 0 0 none none 0 0 none 0 0 0 0 0 0                                                                                                                                                                                                                                                                                                                                                                                                                        ";
#include <string.h>



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

#if defined (__cplusplus)
extern "C" {
#endif
FSM_EXT_DECS
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif


/* Header Block */

/* packet stream definitions */
#define RCV_IN_STRM 0
#define SRC_IN_STRM 1
#define XMT_OUT_STRM 0

/* transition macros */
#define SRC_ARRVL (op_intrpt_type () == \
OPC_INTRPT_STRM && op_intrpt_strm () == SRC_IN_STRM)

#define RCV_ARRVL (op_intrpt_type () == \
OPC_INTRPT_STRM && op_intrpt_strm () == RCV_IN_STRM)

/* End of Header Block */


#if !defined (VOSD_NO_FIN)
#undef	BIN
#undef	BOUT
#define	BIN		FIN_LOCAL_FIELD(last_line_passed) = __LINE__ - _block_origin;
#define	BOUT	BIN
#define	BINIT	FIN_LOCAL_FIELD(last_line_passed) = 0; _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 */
	Distribution *	         		address_dist;
	Stathandle	             		ete_gsh;
	} pksw_periph_proc_ref_state;

#define pr_state_ptr            		((pksw_periph_proc_ref_state*) SimI_Mod_State_Ptr)
#define address_dist            		pr_state_ptr->address_dist
#define ete_gsh                 		pr_state_ptr->ete_gsh

/* This macro definition 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
#define FIN_PREAMBLE	pksw_periph_proc_ref_state *op_sv_ptr = pr_state_ptr;


/* No Function Block */

enum { _block_origin = __LINE__ };

/* 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 pksw_periph_proc_ref (void);
	Compcode pksw_periph_proc_ref_init (void **);
	void pksw_periph_proc_ref_diag (void);
	void pksw_periph_proc_ref_terminate (void);
	void pksw_periph_proc_ref_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif




/* Process model interrupt handling procedure */


void
pksw_periph_proc_ref (void)
	{
	int _block_origin = 0;
	FIN (pksw_periph_proc_ref ());
	if (1)
		{
		Packet *pkptr;
		double ete_delay;


		FSM_ENTER (pksw_periph_proc_ref)

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (init) enter executives **/
			FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "pksw_periph_proc_ref [init enter execs]")
				FSM_PROFILE_SECTION_IN ("pksw_periph_proc_ref [init enter execs]", state0_enter_exec)
				{
				address_dist = op_dist_load ("uniform_int", 0, 3);
				ete_gsh = op_stat_reg ("ETE delay", OPC_STAT_INDEX_NONE,
					OPC_STAT_GLOBAL);
				
				/* The only purpose of this next call is to make lab2	*/
				/* more sensible (i.e. the first packet's destination	*/
				/* should be nonzero to make the lab interesting!)		*/
				op_dist_outcome (address_dist);
				op_dist_outcome (address_dist);
				op_dist_outcome (address_dist);
				}

				FSM_PROFILE_SECTION_OUT ("pksw_periph_proc_ref [init enter execs]", state0_enter_exec)

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


			/** state (init) transition processing **/
			FSM_TRANSIT_FORCE (2, state2_enter_exec, ;, "default", "", "init", "idle")
				/*---------------------------------------------------------*/



			/** state (xmt) enter executives **/
			FSM_STATE_ENTER_FORCED (1, state1_enter_exec, "xmt", "pksw_periph_proc_ref [xmt enter execs]")
				FSM_PROFILE_SECTION_IN ("pksw_periph_proc_ref [xmt enter execs]", state1_enter_exec)
				{
				pkptr = op_pk_get (SRC_IN_STRM);
				op_pk_nfd_set (pkptr, "dest_address", 
					(int)op_dist_outcome (address_dist));
				
				op_pk_send (pkptr, XMT_OUT_STRM);
				   
				}

				FSM_PROFILE_SECTION_OUT ("pksw_periph_proc_ref [xmt enter execs]", state1_enter_exec)

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


			/** state (xmt) transition processing **/
			FSM_TRANSIT_FORCE (2, state2_enter_exec, ;, "default", "", "xmt", "idle")
				/*---------------------------------------------------------*/



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

				FSM_PROFILE_SECTION_OUT ("pksw_periph_proc_ref [idle enter execs]", state2_enter_exec)

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


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


			/** state (idle) transition processing **/
			FSM_PROFILE_SECTION_IN ("pksw_periph_proc_ref [idle trans conditions]", state2_trans_conds)
			FSM_INIT_COND (SRC_ARRVL)
			FSM_TEST_COND (RCV_ARRVL)
			FSM_DFLT_COND
			FSM_TEST_LOGIC ("idle")
			FSM_PROFILE_SECTION_OUT ("pksw_periph_proc_ref [idle trans conditions]", state2_trans_conds)

			FSM_TRANSIT_SWITCH
				{
				FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;, "SRC_ARRVL", "", "idle", "xmt")
				FSM_CASE_TRANSIT (1, 3, state3_enter_exec, ;, "RCV_ARRVL", "", "idle", "rcv")
				FSM_CASE_TRANSIT (2, 2, state2_enter_exec, ;, "default", "", "idle", "idle")
				}
				/*---------------------------------------------------------*/



			/** state (rcv) enter executives **/
			FSM_STATE_ENTER_FORCED (3, state3_enter_exec, "rcv", "pksw_periph_proc_ref [rcv enter execs]")
				FSM_PROFILE_SECTION_IN ("pksw_periph_proc_ref [rcv enter execs]", state3_enter_exec)
				{
				pkptr = op_pk_get (RCV_IN_STRM);
				ete_delay = op_sim_time () - 
					op_pk_creation_time_get (pkptr);
				
				op_stat_write (ete_gsh, ete_delay);
				op_pk_destroy (pkptr);
				}

				FSM_PROFILE_SECTION_OUT ("pksw_periph_proc_ref [rcv enter execs]", state3_enter_exec)

			/** state (rcv) exit executives **/
			FSM_STATE_EXIT_FORCED (3, "rcv", "pksw_periph_proc_ref [rcv exit execs]")
				FSM_PROFILE_SECTION_IN ("pksw_periph_proc_ref [rcv exit execs]", state3_exit_exec)
				{
				}
				FSM_PROFILE_SECTION_OUT ("pksw_periph_proc_ref [rcv exit execs]", state3_exit_exec)


			/** state (rcv) transition processing **/
			FSM_TRANSIT_FORCE (2, state2_enter_exec, ;, "default", "", "rcv", "idle")
				/*---------------------------------------------------------*/



			}


		FSM_EXIT (0,pksw_periph_proc_ref)
		}
	}

#if defined (__cplusplus)
	extern "C" { 
#endif
	extern VosT_Fun_Status Vos_Catmem_Register (const char * , int , VosT_Void_Null_Proc, VosT_Address *);
	extern VosT_Address Vos_Catmem_Alloc (VosT_Address, size_t);
	extern VosT_Fun_Status Vos_Catmem_Dealloc (VosT_Address);
#if defined (__cplusplus)
	}
#endif


Compcode
pksw_periph_proc_ref_init (void ** gen_state_pptr)
	{
	int _block_origin = 0;
	static VosT_Address	obtype = OPC_NIL;

	FIN (pksw_periph_proc_ref_init (gen_state_pptr))

	if (obtype == OPC_NIL)
		{
		/* Initialize memory management */
		if (Vos_Catmem_Register ("proc state vars (pksw_periph_proc_ref)",
			sizeof (pksw_periph_proc_ref_state), Vos_Vnop, &obtype) == VOSC_FAILURE)
			{
			FRET (OPC_COMPCODE_FAILURE)
			}
		}

	*gen_state_pptr = Vos_Catmem_Alloc (obtype, 1);
	if (*gen_state_pptr == OPC_NIL)
		{
		FRET (OPC_COMPCODE_FAILURE)
		}
	else
		{
		/* Initialize FSM handling */
		((pksw_periph_proc_ref_state *)(*gen_state_pptr))->current_block = 0;

		FRET (OPC_COMPCODE_SUCCESS)
		}
	}



void
pksw_periph_proc_ref_diag (void)
	{
	/* No Diagnostic Block */
	}




void
pksw_periph_proc_ref_terminate (void)
	{
	int _block_origin = __LINE__;

	FIN (pksw_periph_proc_ref_terminate (void))

	Vos_Catmem_Dealloc (pr_state_ptr);

	FOUT
	}


/* Undefine shortcuts to state variables to avoid */
/* syntax error in direct access to fields of */
/* local variable prs_ptr in pksw_periph_proc_ref_svar function. */
#undef address_dist
#undef ete_gsh



void
pksw_periph_proc_ref_svar (void * gen_ptr, const char * var_name, char ** var_p_ptr)
	{
	pksw_periph_proc_ref_state		*prs_ptr;

	FIN (pksw_periph_proc_ref_svar (gen_ptr, var_name, var_p_ptr))

	if (var_name == OPC_NIL)
		{
		*var_p_ptr = (char *)OPC_NIL;
		FOUT
		}
	prs_ptr = (pksw_periph_proc_ref_state *)gen_ptr;

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

	FOUT
	}

⌨️ 快捷键说明

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