📄 pksw_nd_proc1.pr.c
字号:
/* Process model C form file: pksw_nd_proc1.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_nd_proc1_pr_c [] = "MIL_3_Tfile_Hdr_ 81A 30A op_runsim 7 45AA5E8C 45AA5E8C 1 yg Administrator 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 macro */
#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)
#define END_SIM op_intrpt_type() == OPC_INTRPT_ENDSIM
/* 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;
int pk_count;
char my_name[48];
} pksw_nd_proc1_state;
#define pr_state_ptr ((pksw_nd_proc1_state*) SimI_Mod_State_Ptr)
#define address_dist pr_state_ptr->address_dist
#define ete_gsh pr_state_ptr->ete_gsh
#define pk_count pr_state_ptr->pk_count
#define my_name pr_state_ptr->my_name
/* 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_nd_proc1_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_nd_proc1 (void);
Compcode pksw_nd_proc1_init (void **);
void pksw_nd_proc1_diag (void);
void pksw_nd_proc1_terminate (void);
void pksw_nd_proc1_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
pksw_nd_proc1 (void)
{
int _block_origin = 0;
FIN (pksw_nd_proc1 ());
if (1)
{
Packet *pkptr;
double ete_delay;
char tmpstr[128];
FSM_ENTER (pksw_nd_proc1)
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "pksw_nd_proc1 () [init enter execs]")
{
address_dist = op_dist_load ("uniform_int", 0, 3);
ete_gsh = op_stat_reg("ETE delay", OPC_STAT_INDEX_NONE,OPC_STAT_GLOBAL);
op_ima_obj_attr_get (op_topo_parent(op_id_self()),"name",my_name);
pk_count = 0;
}
/** state (init) exit executives **/
FSM_STATE_EXIT_FORCED (0, "init", "pksw_nd_proc1 () [init exit execs]")
{
}
/** 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_nd_proc1 () [xmt enter execs]")
{
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);
}
/** state (xmt) exit executives **/
FSM_STATE_EXIT_FORCED (1, "xmt", "pksw_nd_proc1 () [xmt exit execs]")
{
}
/** 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_nd_proc1 () [idle enter execs]")
{
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (5,pksw_nd_proc1)
/** state (idle) exit executives **/
FSM_STATE_EXIT_UNFORCED (2, "idle", "pksw_nd_proc1 () [idle exit execs]")
{
}
/** state (idle) transition processing **/
FSM_INIT_COND (SRC_ARRVL)
FSM_TEST_COND (RCV_ARRVL)
FSM_TEST_COND (END_SIM)
FSM_DFLT_COND
FSM_TEST_LOGIC ("idle")
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, 4, state4_enter_exec, ;, "END_SIM", "", "idle", "end")
FSM_CASE_TRANSIT (3, 2, state2_enter_exec, ;, "default", "", "idle", "idle")
}
/*---------------------------------------------------------*/
/** state (rcv) enter executives **/
FSM_STATE_ENTER_FORCED (3, state3_enter_exec, "rcv", "pksw_nd_proc1 () [rcv enter execs]")
{
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);
pk_count++;
op_pk_destroy (pkptr);
}
/** state (rcv) exit executives **/
FSM_STATE_EXIT_FORCED (3, "rcv", "pksw_nd_proc1 () [rcv exit execs]")
{
}
/** state (rcv) transition processing **/
FSM_TRANSIT_FORCE (2, state2_enter_exec, ;, "default", "", "rcv", "idle")
/*---------------------------------------------------------*/
/** state (end) enter executives **/
FSM_STATE_ENTER_UNFORCED (4, state4_enter_exec, "end", "pksw_nd_proc1 () [end enter execs]")
{
sprintf (tmpstr, "Node %s: received %d packets.",my_name,pk_count);
op_sim_message (tmpstr, "");
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (9,pksw_nd_proc1)
/** state (end) exit executives **/
FSM_STATE_EXIT_UNFORCED (4, "end", "pksw_nd_proc1 () [end exit execs]")
{
}
/** state (end) transition processing **/
FSM_TRANSIT_MISSING ("end")
/*---------------------------------------------------------*/
}
FSM_EXIT (0,pksw_nd_proc1)
}
}
#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_nd_proc1_init (void ** gen_state_pptr)
{
int _block_origin = 0;
static VosT_Address obtype = OPC_NIL;
FIN (pksw_nd_proc1_init (gen_state_pptr))
if (obtype == OPC_NIL)
{
/* Initialize memory management */
if (Vos_Catmem_Register ("proc state vars (pksw_nd_proc1)",
sizeof (pksw_nd_proc1_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_nd_proc1_state *)(*gen_state_pptr))->current_block = 0;
FRET (OPC_COMPCODE_SUCCESS)
}
}
void
pksw_nd_proc1_diag (void)
{
/* No Diagnostic Block */
}
void
pksw_nd_proc1_terminate (void)
{
int _block_origin = __LINE__;
FIN (pksw_nd_proc1_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_nd_proc1_svar function. */
#undef address_dist
#undef ete_gsh
#undef pk_count
#undef my_name
void
pksw_nd_proc1_svar (void * gen_ptr, const char * var_name, char ** var_p_ptr)
{
pksw_nd_proc1_state *prs_ptr;
FIN (pksw_nd_proc1_svar (gen_ptr, var_name, var_p_ptr))
if (var_name == OPC_NIL)
{
*var_p_ptr = (char *)OPC_NIL;
FOUT;
}
prs_ptr = (pksw_nd_proc1_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;
}
if (strcmp ("pk_count" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->pk_count);
FOUT;
}
if (strcmp ("my_name" , var_name) == 0)
{
*var_p_ptr = (char *) (prs_ptr->my_name);
FOUT;
}
*var_p_ptr = (char *)OPC_NIL;
FOUT;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -