📄 tan_noc_worm_mesh_desgen_22.pr.c
字号:
/* Process model C form file: tan_noc_worm_mesh_desgen_22.pr.c */
/* Portions of this file copyright 1992-2004 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
const char tan_noc_worm_mesh_desgen_22_pr_c [] = "MIL_3_Tfile_Hdr_ 105A 30A modeler 7 49E6901D 49E6901D 1 05934b0918b5482 Administrator 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 */
/* packet stream definitions */
#define RCV_IN_STRM 0
#define XMT_OUT_STRM 0
/* transition macros */
#define RCV_ARRVL (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 */
double address_dist ;
Stathandle packets_generated ;
double sour_address ;
int flag ;
int count ;
int data ;
} tan_noc_worm_mesh_desgen_22_state;
#define pr_state_ptr ((tan_noc_worm_mesh_desgen_22_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define address_dist pr_state_ptr->address_dist
#define packets_generated pr_state_ptr->packets_generated
#define sour_address pr_state_ptr->sour_address
#define flag pr_state_ptr->flag
#define count pr_state_ptr->count
#define data pr_state_ptr->data
/* 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 tan_noc_worm_mesh_desgen_22_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 = ((tan_noc_worm_mesh_desgen_22_state *)(tcontext_ptr->mod_state_ptr));
#else
# define FIN_PREAMBLE_DEC tan_noc_worm_mesh_desgen_22_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
//int dest_address;
static void des_generate(void)
{
Packet * pkptr;
FIN(des_generate());
/*address_dist = op_dist_load ("uniform_int", 1, 15);
pkptr = op_pk_get (RCV_IN_STRM);
if((int)op_dist_outcome (address_dist) == 1)
{op_pk_nfd_set_int32 (pkptr, "dest_address",0);}
else
{op_pk_nfd_set_int32 (pkptr, "dest_address",(int)op_dist_outcome (address_dist));}
*/
pkptr = op_pk_get (RCV_IN_STRM);
op_pk_nfd_get(pkptr, "flag", &flag);
if(flag == 1) {
address_dist = op_dist_uniform(16);
op_pk_nfd_set(pkptr, "sour_address", sour_address);
op_pk_nfd_set(pkptr, "dest_address", (int)(address_dist));
data++;
}
else if(flag == 2) {
op_pk_nfd_set(pkptr, "data", data);
}
else {
op_pk_nfd_set(pkptr, "data", data);
}
op_stat_write (packets_generated,1.0);
op_pk_send (pkptr, XMT_OUT_STRM);
FOUT;
}
/* 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 tan_noc_worm_mesh_desgen_22 (OP_SIM_CONTEXT_ARG_OPT);
VosT_Obtype tan_noc_worm_mesh_desgen_22_init (int * init_block_ptr);
VosT_Address tan_noc_worm_mesh_desgen_22_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
void tan_noc_worm_mesh_desgen_22_diag (OP_SIM_CONTEXT_ARG_OPT);
void tan_noc_worm_mesh_desgen_22_terminate (OP_SIM_CONTEXT_ARG_OPT);
void tan_noc_worm_mesh_desgen_22_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
tan_noc_worm_mesh_desgen_22 (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
FIN_MT (tan_noc_worm_mesh_desgen_22 ());
{
FSM_ENTER ("tan_noc_worm_mesh_desgen_22")
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (INIT) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "INIT", "tan_noc_worm_mesh_desgen_22 [INIT enter execs]")
FSM_PROFILE_SECTION_IN ("tan_noc_worm_mesh_desgen_22 [INIT enter execs]", state0_enter_exec)
{
packets_generated = op_stat_reg ("Packets_total", OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);
// set source address and flag.
sour_address = 10;
flag = 0;
count = 0;
data = 0;
}
FSM_PROFILE_SECTION_OUT (state0_enter_exec)
/** state (INIT) exit executives **/
FSM_STATE_EXIT_FORCED (0, "INIT", "tan_noc_worm_mesh_desgen_22 [INIT exit execs]")
/** state (INIT) transition processing **/
FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "INIT", "st_1")
/*---------------------------------------------------------*/
/** state (st_1) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, "st_1", state1_enter_exec, "tan_noc_worm_mesh_desgen_22 [st_1 enter execs]")
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,"tan_noc_worm_mesh_desgen_22")
/** state (st_1) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "st_1", "tan_noc_worm_mesh_desgen_22 [st_1 exit execs]")
/** state (st_1) transition processing **/
FSM_PROFILE_SECTION_IN ("tan_noc_worm_mesh_desgen_22 [st_1 trans conditions]", state1_trans_conds)
FSM_INIT_COND (RCV_ARRVL)
FSM_DFLT_COND
FSM_TEST_LOGIC ("st_1")
FSM_PROFILE_SECTION_OUT (state1_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 1, state1_enter_exec, des_generate();, "RCV_ARRVL", "des_generate()", "st_1", "st_1")
FSM_CASE_TRANSIT (1, 1, state1_enter_exec, ;, "default", "", "st_1", "st_1")
}
/*---------------------------------------------------------*/
}
FSM_EXIT (0,"tan_noc_worm_mesh_desgen_22")
}
}
void
tan_noc_worm_mesh_desgen_22_diag (OP_SIM_CONTEXT_ARG_OPT)
{
/* No Diagnostic Block */
}
void
tan_noc_worm_mesh_desgen_22_terminate (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = __LINE__;
#endif
FIN_MT (tan_noc_worm_mesh_desgen_22_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 tan_noc_worm_mesh_desgen_22_svar function. */
#undef address_dist
#undef packets_generated
#undef sour_address
#undef flag
#undef count
#undef data
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#define FIN_PREAMBLE_DEC
#define FIN_PREAMBLE_CODE
VosT_Obtype
tan_noc_worm_mesh_desgen_22_init (int * init_block_ptr)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
VosT_Obtype obtype = OPC_NIL;
FIN_MT (tan_noc_worm_mesh_desgen_22_init (init_block_ptr))
obtype = Vos_Define_Object_Prstate ("proc state vars (tan_noc_worm_mesh_desgen_22)",
sizeof (tan_noc_worm_mesh_desgen_22_state));
*init_block_ptr = 0;
FRET (obtype)
}
VosT_Address
tan_noc_worm_mesh_desgen_22_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype obtype, int init_block)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
tan_noc_worm_mesh_desgen_22_state * ptr;
FIN_MT (tan_noc_worm_mesh_desgen_22_alloc (obtype))
ptr = (tan_noc_worm_mesh_desgen_22_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
tan_noc_worm_mesh_desgen_22_svar (void * gen_ptr, const char * var_name, void ** var_p_ptr)
{
tan_noc_worm_mesh_desgen_22_state *prs_ptr;
FIN_MT (tan_noc_worm_mesh_desgen_22_svar (gen_ptr, var_name, var_p_ptr))
if (var_name == OPC_NIL)
{
*var_p_ptr = (void *)OPC_NIL;
FOUT
}
prs_ptr = (tan_noc_worm_mesh_desgen_22_state *)gen_ptr;
if (strcmp ("address_dist" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->address_dist);
FOUT
}
if (strcmp ("packets_generated" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->packets_generated);
FOUT
}
if (strcmp ("sour_address" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->sour_address);
FOUT
}
if (strcmp ("flag" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->flag);
FOUT
}
if (strcmp ("count" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->count);
FOUT
}
if (strcmp ("data" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->data);
FOUT
}
*var_p_ptr = (void *)OPC_NIL;
FOUT
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -