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

📄 pksw_hub_proc2.pr.c

📁 基于OPNET的网络仿真程序
💻 C
字号:
/* Process model C form file: pksw_hub_proc2.pr.c */
/* Portions of this file copyright 1992, 1996, 1998 by MIL 3, Inc. */



/* This variable carries the header into the object file */
static const char pksw_hub_proc2_pr_c [] = "MIL_3_Tfile_Hdr_ 60L 30A op_runsim 7 3793B3EE 3793B3EE 1 rmaddox dsochuliakova 0 0 none none 0 0 none 0 0 0 0 0 0";


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


/* Header Block */

#define PK_ARRVL (op_intrpt_type () == OPC_INTRPT_STRM)

/* End of Header Block */


#if !defined (VOSD_NO_FIN)
#undef	BIN
#undef	BOUT
#define	BIN		_fstack_local_info.last_line_passed = __LINE__ - _block_origin;
#define	BOUT	BIN
#define	BINIT	_fstack_local_info.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 */
	int	                    		dest_address;
	} pksw_hub_proc2_state;

#define pr_state_ptr            		((pksw_hub_proc2_state*) SimI_Mod_State_Ptr)
#define dest_address            		pr_state_ptr->dest_address

/* 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_hub_proc2_state *op_sv_ptr = pr_state_ptr;


/* No Function Block */

enum { _block_origin = __LINE__ };




/* Process model interrupt handling procedure */


void
pksw_hub_proc2 (void)
	{
	int _block_origin = 0;
	FIN (pksw_hub_proc2 ());
	if (1)
		{
		Packet *pkptr;


		FSM_ENTER (pksw_hub_proc2)

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (idle) enter executives **/
			FSM_STATE_ENTER_UNFORCED (0, state0_enter_exec, "idle", "pksw_hub_proc2 () [idle enter execs]")
				{
				dest_address = 0;
				}


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


			/** state (idle) exit executives **/
			FSM_STATE_EXIT_UNFORCED (0, state0_exit_exec, "idle", "pksw_hub_proc2 () [idle exit execs]")
				{
				}


			/** state (idle) transition processing **/
			FSM_INIT_COND (PK_ARRVL)
			FSM_DFLT_COND
			FSM_TEST_LOGIC ("idle")

			FSM_TRANSIT_SWITCH
				{
				FSM_CASE_TRANSIT (0, 1, state1_enter_exec, ;)
				FSM_CASE_TRANSIT (1, 0, state0_enter_exec, ;)
				}
				/*---------------------------------------------------------*/



			/** state (route_pk) enter executives **/
			FSM_STATE_ENTER_FORCED (1, state1_enter_exec, "route_pk", "pksw_hub_proc2 () [route_pk enter execs]")
				{
				pkptr = op_pk_get (op_intrpt_strm());
				op_pk_nfd_get (pkptr,"dest_address", &dest_address);
				op_pk_send (pkptr,dest_address);
				}


			/** state (route_pk) exit executives **/
			FSM_STATE_EXIT_FORCED (1, state1_exit_exec, "route_pk", "pksw_hub_proc2 () [route_pk exit execs]")
				{
				}


			/** state (route_pk) transition processing **/
			FSM_TRANSIT_FORCE (0, state0_enter_exec, ;)
				/*---------------------------------------------------------*/



			}


		FSM_EXIT (0,pksw_hub_proc2)
		}
	}


Compcode
pksw_hub_proc2_init (void ** gen_state_pptr)
	{
	int _block_origin = 0;
	static VosT_Cm_Obtype	obtype = OPC_NIL;

	extern void				Vos_Vnop (void);

	FIN (pksw_hub_proc2_init (gen_state_pptr))

	if (obtype == OPC_NIL)
		{
		/* Initialize memory management */
		if (Vos_Catmem_Register ("proc state vars (pksw_hub_proc2)",
			sizeof (pksw_hub_proc2_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_hub_proc2_state *)(*gen_state_pptr))->current_block = 0;

		FRET (OPC_COMPCODE_SUCCESS)
		}
	}



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




void
pksw_hub_proc2_terminate (void)
	{
	int _block_origin = __LINE__;

	FIN (pksw_hub_proc2_terminate (void))

	if (1)
		{
		Packet *pkptr;

		/* No Termination Block */

		}
	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_hub_proc2_svar function. */
#undef dest_address



void
pksw_hub_proc2_svar (void * gen_ptr, const char * var_name, char ** var_p_ptr)
	{
	pksw_hub_proc2_state		*prs_ptr;

	FIN (pksw_hub_proc2_svar (gen_ptr, var_name, var_p_ptr))

	*var_p_ptr = (char *)VOS_NIL;
	prs_ptr = (pksw_hub_proc2_state *)gen_ptr;

	if (Vos_String_Equal ("dest_address" , var_name))
		{
		*var_p_ptr = (char *) (&prs_ptr->dest_address);
		goto func_return;
		}

func_return:

	FOUT;
	}

⌨️ 快捷键说明

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