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

📄 ws_nsf_ete_1.pr.c

📁 实验室前辈用OPNET做的光突发交换网络的仿真实验
💻 C
字号:
/* Process model C form file: WS_NSF_ETE_1.pr.c */
/* Portions of this file copyright 1992-2001 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
static const char WS_NSF_ETE_1_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A modeler 7 3E410B45 3E410B45 1 WS QIU 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 */

extern Anvid	vid;
Anmid			mid;
int				x1;
int				x2;
int				height;
int				width;

/* 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
	} WS_NSF_ETE_1_state;

#define pr_state_ptr            		((WS_NSF_ETE_1_state*) SimI_Mod_State_Ptr)

/* 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	WS_NSF_ETE_1_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 WS_NSF_ETE_1 (void);
	Compcode WS_NSF_ETE_1_init (void **);
	void WS_NSF_ETE_1_diag (void);
	void WS_NSF_ETE_1_terminate (void);
	void WS_NSF_ETE_1_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif




/* Process model interrupt handling procedure */


void
WS_NSF_ETE_1 (void)
	{
	int _block_origin = 0;
	FIN (WS_NSF_ETE_1 ());
	if (1)
		{
		double		max_ete;
		double		duration;
		char		duration_string[128];
		char		max_ete_string[128];
		Objid		own_id;
		


		FSM_ENTER (WS_NSF_ETE_1)

		FSM_BLOCK_SWITCH
			{
			/*---------------------------------------------------------*/
			/** state (init) enter executives **/
			FSM_STATE_ENTER_UNFORCED_NOLABEL (0, "init", "WS_NSF_ETE_1 () [init enter execs]")
				{
				printf("test ete\n");
				/* get the maximum ete-delay expected and simulation duration for drawing the graph in the anim window */
				op_ima_sim_attr_get (OPC_IMA_DOUBLE, "max_ete", &max_ete);
				op_ima_sim_attr_get (OPC_IMA_DOUBLE, "duration", &duration);
				
				/* store the maximum ete-delay and duration to strings */
				sprintf (max_ete_string, "%d", (int) max_ete);
				sprintf (duration_string, "%d", (int) duration);
				
				/* get the size and location of the graph */
				own_id = op_id_self ();
				op_ima_obj_attr_get (own_id, "x position", &x1);
				op_ima_obj_attr_get (own_id, "y position", &x2);
				op_ima_obj_attr_get (own_id, "graph height", &height);
				op_ima_obj_attr_get (own_id, "graph width", &width);
				
				/* draw a graph in the animation window */
				op_anim_igp_line_draw (vid, OPC_ANIM_RETAIN | OPC_ANIM_COLOR_GREEN, x1, x2+height, x1+width, x2+height);
				op_anim_igp_line_draw (vid, OPC_ANIM_RETAIN | OPC_ANIM_COLOR_GREEN, x1, x2+height, x1, x2);
				op_anim_igp_text_draw (vid, OPC_ANIM_RETAIN | OPC_ANIM_COLOR_YELLOW | OPC_ANIM_FONT_OPEN_18 | OPC_ANIM_ALIGNH_CENTER, width/2+x1 , x2, "Average End-to-end Delay (sec)");
				op_anim_igp_text_draw (vid, OPC_ANIM_RETAIN | OPC_ANIM_COLOR_YELLOW | OPC_ANIM_FONT_OPEN_18 | OPC_ANIM_ALIGNH_RIGHT, x1-5, x2-10, max_ete_string);
				op_anim_igp_text_draw (vid, OPC_ANIM_RETAIN | OPC_ANIM_COLOR_YELLOW | OPC_ANIM_FONT_OPEN_18 | OPC_ANIM_ALIGNH_RIGHT, x1-5, height+x2-10, "0.0");
				op_anim_igp_text_draw (vid, OPC_ANIM_RETAIN | OPC_ANIM_COLOR_YELLOW | OPC_ANIM_FONT_OPEN_18 | OPC_ANIM_ALIGNH_CENTER, x1+width, x2+height+5, duration_string);
				op_anim_igp_text_draw (vid, OPC_ANIM_RETAIN | OPC_ANIM_COLOR_YELLOW | OPC_ANIM_FONT_OPEN_18 | OPC_ANIM_ALIGNH_CENTER, x1+5, x2+height+5, "0.0");
				op_anim_igp_text_draw (vid, OPC_ANIM_RETAIN | OPC_ANIM_COLOR_YELLOW | OPC_ANIM_FONT_OPEN_18 | OPC_ANIM_ALIGNH_CENTER, x1+width+5, x2+height+15, "time (sec)");
				
				/* create a macro which draws a line between two points */
				mid = op_anim_macro_create ("dr_ete");
				op_anim_mgp_line_draw (mid, OPC_ANIM_COLOR_WHITE, 
					OPC_ANIM_REG_M_INT, OPC_ANIM_REG_N_INT, OPC_ANIM_REG_O_INT, OPC_ANIM_REG_P_INT);
				op_anim_macro_close (mid);
				}


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


			/** state (init) exit executives **/
			FSM_STATE_EXIT_UNFORCED (0, "init", "WS_NSF_ETE_1 () [init exit execs]")
				{
				}


			/** state (init) transition processing **/
			FSM_TRANSIT_MISSING ("init")
				/*---------------------------------------------------------*/



			}


		FSM_EXIT (0,WS_NSF_ETE_1)
		}
	}

#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
WS_NSF_ETE_1_init (void ** gen_state_pptr)
	{
	int _block_origin = 0;
	static VosT_Address	obtype = OPC_NIL;

	FIN (WS_NSF_ETE_1_init (gen_state_pptr))

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

		FRET (OPC_COMPCODE_SUCCESS)
		}
	}



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




void
WS_NSF_ETE_1_terminate (void)
	{
	int _block_origin = __LINE__;

	FIN (WS_NSF_ETE_1_terminate (void))

	if (1)
		{
		double		max_ete;
		double		duration;
		char		duration_string[128];
		char		max_ete_string[128];
		Objid		own_id;
		

		/* No Termination Block */

		}
	Vos_Catmem_Dealloc (pr_state_ptr);

	FOUT;
	}




void
WS_NSF_ETE_1_svar (void * gen_ptr, const char * var_name, char ** var_p_ptr)
	{

	FIN (WS_NSF_ETE_1_svar (gen_ptr, var_name, var_p_ptr))

	*var_p_ptr = (char *)OPC_NIL;

	FOUT;
	}

⌨️ 快捷键说明

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