📄 initials_cct_rx.pr.c
字号:
/* Process model C form file: initials_cct_rx.pr.c */
/* Portions of this file copyright 1992-2003 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
const char initials_cct_rx_pr_c [] = "MIL_3_Tfile_Hdr_ 100A 30A op_runsim 7 483FBFD9 483FBFD9 1 zhangjuan Administrator 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 */
/* Input stream from bus receiver */
#define IN_STRM 0
/*conditional macros */
#define PKT_RCVD (op_intrpt_type () == OPC_INTRPT_STRM)
#define END_SIM (op_intrpt_type () == OPC_INTRPT_ENDSIM)
/* Global variable */
int subm_pkts = 0;
/* 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 */
int rcvd_pkts;
} initials_cct_rx_state;
#define pr_state_ptr ((initials_cct_rx_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define rcvd_pkts pr_state_ptr->rcvd_pkts
/* 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 initials_cct_rx_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 = ((initials_cct_rx_state *)(tcontext_ptr->mod_state_ptr));
#else
# define FIN_PREAMBLE_DEC initials_cct_rx_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
/* This function gets the received packet, destroys it, */
/* and then logs the incremented received packet total. */
static void proc_pkt (void)
{
Packet* in_pkt;
FIN (proc_pkt ());
/* Get packet from bus receiver input stream */
in_pkt = op_pk_get(IN_STRM);
/* Destroy the received packet */
op_pk_destroy(in_pkt);
/* Increment the count of received packets */
++rcvd_pkts;
FOUT;
}
/* This function writes the end-of-simulation channel */
/* traffic and channel throughput statistics */
static void record_stats (void)
{
double cur_time;
FIN (record_stats ());
cur_time = op_sim_time ();
/* Record final statistics */
op_stat_scalar_write("Channel Traffic G",
(double) subm_pkts / cur_time);
op_stat_scalar_write("Channel Throughput S",
(double) rcvd_pkts / cur_time);
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 initials_cct_rx (OP_SIM_CONTEXT_ARG_OPT);
VosT_Obtype initials_cct_rx_init (int * init_block_ptr);
VosT_Address initials_cct_rx_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
void initials_cct_rx_diag (OP_SIM_CONTEXT_ARG_OPT);
void initials_cct_rx_terminate (OP_SIM_CONTEXT_ARG_OPT);
void initials_cct_rx_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
initials_cct_rx (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
FIN_MT (initials_cct_rx ());
if (1)
{
FSM_ENTER ("initials_cct_rx")
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "initials_cct_rx [init enter execs]")
FSM_PROFILE_SECTION_IN (initials_cct_rx [init enter execs], state0_enter_exec)
{
/* Initialize accumulator */
rcvd_pkts = 0;
}
FSM_PROFILE_SECTION_OUT (initials_cct_rx [init enter execs], state0_enter_exec)
/** state (init) exit executives **/
FSM_STATE_EXIT_FORCED (0, "init", "initials_cct_rx [init exit execs]")
FSM_PROFILE_SECTION_IN (initials_cct_rx [init exit execs], state0_exit_exec)
{
}
FSM_PROFILE_SECTION_OUT (initials_cct_rx [init exit execs], state0_exit_exec)
/** state (init) transition processing **/
FSM_PROFILE_SECTION_IN (initials_cct_rx [init trans conditions], state0_trans_conds)
FSM_INIT_COND (PKT_RCVD)
FSM_TEST_COND (END_SIM)
FSM_TEST_LOGIC ("init")
FSM_PROFILE_SECTION_OUT (initials_cct_rx [init trans conditions], state0_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 1, state1_enter_exec, proc_pkt();, "PKT_RCVD", "proc_pkt()", "init", "idle")
FSM_CASE_TRANSIT (1, 1, state1_enter_exec, record_stats();, "END_SIM", "record_stats()", "init", "idle")
}
/*---------------------------------------------------------*/
/** state (idle) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, "idle", state1_enter_exec, "initials_cct_rx [idle enter execs]")
FSM_PROFILE_SECTION_IN (initials_cct_rx [idle enter execs], state1_enter_exec)
{
}
FSM_PROFILE_SECTION_OUT (initials_cct_rx [idle enter execs], state1_enter_exec)
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,"initials_cct_rx")
/** state (idle) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "idle", "initials_cct_rx [idle exit execs]")
FSM_PROFILE_SECTION_IN (initials_cct_rx [idle exit execs], state1_exit_exec)
{
}
FSM_PROFILE_SECTION_OUT (initials_cct_rx [idle exit execs], state1_exit_exec)
/** state (idle) transition processing **/
FSM_PROFILE_SECTION_IN (initials_cct_rx [idle trans conditions], state1_trans_conds)
FSM_INIT_COND (PKT_RCVD)
FSM_TEST_COND (END_SIM)
FSM_DFLT_COND
FSM_TEST_LOGIC ("idle")
FSM_PROFILE_SECTION_OUT (initials_cct_rx [idle trans conditions], state1_trans_conds)
FSM_TRANSIT_SWITCH
{
FSM_CASE_TRANSIT (0, 1, state1_enter_exec, proc_pkt();, "PKT_RCVD", "proc_pkt()", "idle", "idle")
FSM_CASE_TRANSIT (1, 1, state1_enter_exec, record_stats();, "END_SIM", "record_stats()", "idle", "idle")
FSM_CASE_TRANSIT (2, 1, state1_enter_exec, ;, "default", "", "idle", "idle")
}
/*---------------------------------------------------------*/
}
FSM_EXIT (0,"initials_cct_rx")
}
}
void
initials_cct_rx_diag (OP_SIM_CONTEXT_ARG_OPT)
{
/* No Diagnostic Block */
}
void
initials_cct_rx_terminate (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = __LINE__;
#endif
FIN_MT (initials_cct_rx_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 initials_cct_rx_svar function. */
#undef rcvd_pkts
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#define FIN_PREAMBLE_DEC
#define FIN_PREAMBLE_CODE
VosT_Obtype
initials_cct_rx_init (int * init_block_ptr)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
VosT_Obtype obtype = OPC_NIL;
FIN_MT (initials_cct_rx_init (init_block_ptr))
Vos_Define_Object (&obtype, "proc state vars (initials_cct_rx)",
sizeof (initials_cct_rx_state), 0, 20);
*init_block_ptr = 0;
FRET (obtype)
}
VosT_Address
initials_cct_rx_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype obtype, int init_block)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
initials_cct_rx_state * ptr;
FIN_MT (initials_cct_rx_alloc (obtype))
ptr = (initials_cct_rx_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
initials_cct_rx_svar (void * gen_ptr, const char * var_name, void ** var_p_ptr)
{
initials_cct_rx_state *prs_ptr;
FIN_MT (initials_cct_rx_svar (gen_ptr, var_name, var_p_ptr))
if (var_name == OPC_NIL)
{
*var_p_ptr = (void *)OPC_NIL;
FOUT
}
prs_ptr = (initials_cct_rx_state *)gen_ptr;
if (strcmp ("rcvd_pkts" , var_name) == 0)
{
*var_p_ptr = (void *) (&prs_ptr->rcvd_pkts);
FOUT
}
*var_p_ptr = (void *)OPC_NIL;
FOUT
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -