📄 special_offset_set1.pr.c
字号:
/* Process model C form file: special_offset_set1.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 special_offset_set1_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A modeler 7 4403F75B 4403F75B 1 aurora aurora_plm 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 SPECIAL_offset 1000
#define offset_type 0
#define UNIT_PROC 0.000001
#define CAPACITY 1000000000
#define BUR_COME (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 */
Objid self_objid;
Objid node_objid;
Distribution * offset_dist;
double offset_time;
Packet * bcp_pkptr;
Packet * pkptr;
double cur_time;
int userid;
int pk_type;
} special_offset_set1_state;
#define pr_state_ptr ((special_offset_set1_state*) SimI_Mod_State_Ptr)
#define self_objid pr_state_ptr->self_objid
#define node_objid pr_state_ptr->node_objid
#define offset_dist pr_state_ptr->offset_dist
#define offset_time pr_state_ptr->offset_time
#define bcp_pkptr pr_state_ptr->bcp_pkptr
#define pkptr pr_state_ptr->pkptr
#define cur_time pr_state_ptr->cur_time
#define userid pr_state_ptr->userid
#define pk_type pr_state_ptr->pk_type
/* 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 special_offset_set1_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 special_offset_set1 (void);
Compcode special_offset_set1_init (void **);
void special_offset_set1_diag (void);
void special_offset_set1_terminate (void);
void special_offset_set1_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
special_offset_set1 (void)
{
int _block_origin = 0;
FIN (special_offset_set1 ());
if (1)
{
int dist_time;
double burst_size;
double send_time;
FSM_ENTER (special_offset_set1)
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "special_offset_set1 () [init enter execs]")
{
// Get the user id of the current node
self_objid = op_id_self ();
node_objid = op_topo_parent(self_objid);
op_ima_obj_attr_get(node_objid, "user id", &userid);
//offset_dist = op_dist_load ("uniform_int", 0, 10);
//printf("\nOrdinary_offset_set-->init-->userid:%d\n", userid);
//getchar();
}
/** state (init) exit executives **/
FSM_STATE_EXIT_FORCED (0, "init", "special_offset_set1 () [init exit execs]")
{
}
/** state (init) transition processing **/
FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "init", "wait")
/*---------------------------------------------------------*/
/** state (wait) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, state1_enter_exec, "wait", "special_offset_set1 () [wait enter execs]")
{
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,special_offset_set1)
/** state (wait) exit executives **/
FSM_STATE_EXIT_UNFORCED (1, "wait", "special_offset_set1 () [wait exit execs]")
{
//if(op_intrpt_type() == OPC_INTRPT_STRM)
//{
//pk_type = BUR_STRM;
//}
//printf("WAIT-->userid: %d,strm_num: %d, pk_type: %d\n", userid,op_intrpt_strm(), pk_type);
//getchar();
}
/** state (wait) transition processing **/
FSM_TRANSIT_ONLY ((BUR_COME), 2, state2_enter_exec, ;, "wait", "BUR_COME", "", "wait", "Offset_set")
/*---------------------------------------------------------*/
/** state (Offset_set) enter executives **/
FSM_STATE_ENTER_FORCED (2, state2_enter_exec, "Offset_set", "special_offset_set1 () [Offset_set enter execs]")
{
if(op_intrpt_type() == OPC_INTRPT_STRM)
{
pkptr = op_pk_get(op_intrpt_strm());
burst_size = op_pk_total_size_get(pkptr)/CAPACITY;
offset_time = SPECIAL_offset * UNIT_PROC;
send_time = op_sim_time() + offset_time;
bcp_pkptr = op_pk_create_fmt("BCP_format");
op_pk_nfd_set(bcp_pkptr, "offset", offset_time);
op_pk_nfd_set(bcp_pkptr, "burst_length", burst_size);
op_pk_nfd_set(bcp_pkptr, "send_time", send_time);
op_pk_nfd_set(bcp_pkptr, "offset_type", offset_type);
//op_pk_print(bcp_pkptr);
//printf("special_offset_burst_size: %f\n", burst_size);
op_pk_send(bcp_pkptr, 0);
op_pk_destroy(pkptr);
}
}
/** state (Offset_set) exit executives **/
FSM_STATE_EXIT_FORCED (2, "Offset_set", "special_offset_set1 () [Offset_set exit execs]")
{
}
/** state (Offset_set) transition processing **/
FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "Offset_set", "wait")
/*---------------------------------------------------------*/
}
FSM_EXIT (0,special_offset_set1)
}
}
#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
special_offset_set1_init (void ** gen_state_pptr)
{
int _block_origin = 0;
static VosT_Address obtype = OPC_NIL;
FIN (special_offset_set1_init (gen_state_pptr))
if (obtype == OPC_NIL)
{
/* Initialize memory management */
if (Vos_Catmem_Register ("proc state vars (special_offset_set1)",
sizeof (special_offset_set1_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 */
((special_offset_set1_state *)(*gen_state_pptr))->current_block = 0;
FRET (OPC_COMPCODE_SUCCESS)
}
}
void
special_offset_set1_diag (void)
{
/* No Diagnostic Block */
}
void
special_offset_set1_terminate (void)
{
int _block_origin = __LINE__;
FIN (special_offset_set1_terminate (void))
if (1)
{
int dist_time;
double burst_size;
double send_time;
/* No Termination Block */
}
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 special_offset_set1_svar function. */
#undef self_objid
#undef node_objid
#undef offset_dist
#undef offset_time
#undef bcp_pkptr
#undef pkptr
#undef cur_time
#undef userid
#undef pk_type
void
special_offset_set1_svar (void * gen_ptr, const char * var_name, char ** var_p_ptr)
{
special_offset_set1_state *prs_ptr;
FIN (special_offset_set1_svar (gen_ptr, var_name, var_p_ptr))
if (var_name == OPC_NIL)
{
*var_p_ptr = (char *)OPC_NIL;
FOUT;
}
prs_ptr = (special_offset_set1_state *)gen_ptr;
if (strcmp ("self_objid" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->self_objid);
FOUT;
}
if (strcmp ("node_objid" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->node_objid);
FOUT;
}
if (strcmp ("offset_dist" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->offset_dist);
FOUT;
}
if (strcmp ("offset_time" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->offset_time);
FOUT;
}
if (strcmp ("bcp_pkptr" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->bcp_pkptr);
FOUT;
}
if (strcmp ("pkptr" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->pkptr);
FOUT;
}
if (strcmp ("cur_time" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->cur_time);
FOUT;
}
if (strcmp ("userid" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->userid);
FOUT;
}
if (strcmp ("pk_type" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->pk_type);
FOUT;
}
*var_p_ptr = (char *)OPC_NIL;
FOUT;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -