📄 pksw_hub_proc.pr.c
字号:
/* Process model C form file: pksw_hub_proc.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_hub_proc_pr_c [] = "MIL_3_Tfile_Hdr_ 81A 30A op_runsim 7 45AA56EF 45AA56EF 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 */
#define PK_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(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 */
int dest_address;
} pksw_hub_proc_state;
#define pr_state_ptr ((pksw_hub_proc_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_proc_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_hub_proc (void);
Compcode pksw_hub_proc_init (void **);
void pksw_hub_proc_diag (void);
void pksw_hub_proc_terminate (void);
void pksw_hub_proc_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
pksw_hub_proc (void)
{
int _block_origin = 0;
FIN (pksw_hub_proc ());
if (1)
{
Packet *pkptr;
FSM_ENTER (pksw_hub_proc)
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (idle) enter executives **/
FSM_STATE_ENTER_UNFORCED (0, state0_enter_exec, "idle", "pksw_hub_proc () [idle enter execs]")
{
dest_address = 0;
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (1,pksw_hub_proc)
/** state (idle) exit executives **/
FSM_STATE_EXIT_UNFORCED (0, "idle", "pksw_hub_proc () [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, ;, "PK_ARRVL", "", "idle", "route_pk")
FSM_CASE_TRANSIT (1, 0, state0_enter_exec, ;, "default", "", "idle", "idle")
}
/*---------------------------------------------------------*/
/** state (route_pk) enter executives **/
FSM_STATE_ENTER_FORCED (1, state1_enter_exec, "route_pk", "pksw_hub_proc () [route_pk enter execs]")
{
pkptr = op_pk_get (op_intrpt_strm());
op_pk_nfd_set (pkptr,"dest_address", dest_address);
op_pk_send (pkptr,dest_address);
}
/** state (route_pk) exit executives **/
FSM_STATE_EXIT_FORCED (1, "route_pk", "pksw_hub_proc () [route_pk exit execs]")
{
}
/** state (route_pk) transition processing **/
FSM_TRANSIT_FORCE (0, state0_enter_exec, ;, "default", "", "route_pk", "idle")
/*---------------------------------------------------------*/
}
FSM_EXIT (0,pksw_hub_proc)
}
}
#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_hub_proc_init (void ** gen_state_pptr)
{
int _block_origin = 0;
static VosT_Address obtype = OPC_NIL;
FIN (pksw_hub_proc_init (gen_state_pptr))
if (obtype == OPC_NIL)
{
/* Initialize memory management */
if (Vos_Catmem_Register ("proc state vars (pksw_hub_proc)",
sizeof (pksw_hub_proc_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_proc_state *)(*gen_state_pptr))->current_block = 0;
FRET (OPC_COMPCODE_SUCCESS)
}
}
void
pksw_hub_proc_diag (void)
{
/* No Diagnostic Block */
}
void
pksw_hub_proc_terminate (void)
{
int _block_origin = __LINE__;
FIN (pksw_hub_proc_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_hub_proc_svar function. */
#undef dest_address
void
pksw_hub_proc_svar (void * gen_ptr, const char * var_name, char ** var_p_ptr)
{
pksw_hub_proc_state *prs_ptr;
FIN (pksw_hub_proc_svar (gen_ptr, var_name, var_p_ptr))
if (var_name == OPC_NIL)
{
*var_p_ptr = (char *)OPC_NIL;
FOUT;
}
prs_ptr = (pksw_hub_proc_state *)gen_ptr;
if (strcmp ("dest_address" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->dest_address);
FOUT;
}
*var_p_ptr = (char *)OPC_NIL;
FOUT;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -