📄 gpr_billard_mobility.pr.c
字号:
/* Process model C form file: gpr_billard_mobility.pr.c */
/* Portions of this file copyright 1992-2003 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
const char gpr_billard_mobility_pr_c [] = "MIL_3_Tfile_Hdr_ 100A 30A op_runsim 7 42FB0CDA 42FB0CDA 1 zhangzhong jc 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 */
///////////////////////////////////////////////////////////////
// BILLARD MOBILITY HEADER BLOCK
//
// Declaration of every constant, type, library, global
// variables... used by the billard nobility process
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
//////////////////////// INCLUDE //////////////////////////////
///////////////////////////////////////////////////////////////
#include <math.h>
///////////////////////////////////////////////////////////////
///////////////// CONSTANTS DEFINITION ////////////////////////
///////////////////////////////////////////////////////////////
// constant PI for trigonometry
#define PI 3.141592654
///////////////////////////////////////////////////////////////
///////////// TRANSITION MACROS DEFINITION ////////////////////
///////////////////////////////////////////////////////////////
#define MOVE ( op_intrpt_type () == OPC_INTRPT_SELF && bMobile==1)
///////////////////////////////////////////////////////////////
////////////// GLOBAL VARIABLES DECLARATION ///////////////////
///////////////////////////////////////////////////////////////
// variable that define the size of the grid on which the nodes are moving
double XMAX;
double XMIN;
double YMIN;
double YMAX;
// variable which define the node mobilty (speed = STEP_DIST/ POS_TIMER)
double POS_TIMER;
double STEP_DIST;
/* 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 */
Distribution * one;
Objid my_node_id;
Objid my_process_id;
double angle;
Objid my_net_id;
int bMobile;
} gpr_billard_mobility_state;
#define pr_state_ptr ((gpr_billard_mobility_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define one pr_state_ptr->one
#define my_node_id pr_state_ptr->my_node_id
#define my_process_id pr_state_ptr->my_process_id
#define angle pr_state_ptr->angle
#define my_net_id pr_state_ptr->my_net_id
#define bMobile pr_state_ptr->bMobile
/* 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 gpr_billard_mobility_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 = ((gpr_billard_mobility_state *)(tcontext_ptr->mod_state_ptr));
#else
# define FIN_PREAMBLE_DEC gpr_billard_mobility_state *op_sv_ptr;
# define FIN_PREAMBLE_CODE op_sv_ptr = pr_state_ptr;
#endif
/* No Function Block */
#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ };
#endif
/* 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 gpr_billard_mobility (OP_SIM_CONTEXT_ARG_OPT);
VosT_Obtype gpr_billard_mobility_init (int * init_block_ptr);
VosT_Address gpr_billard_mobility_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
void gpr_billard_mobility_diag (OP_SIM_CONTEXT_ARG_OPT);
void gpr_billard_mobility_terminate (OP_SIM_CONTEXT_ARG_OPT);
void gpr_billard_mobility_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
gpr_billard_mobility (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
FIN_MT (gpr_billard_mobility ());
if (1)
{
Evhandle evh;
double altitude,latitude,longitude,
x_pos,y_pos,z_pos,
x,y,z,rand, D, prev_angle;
Compcode comp_code;
FSM_ENTER ("gpr_billard_mobility")
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "gpr_billard_mobility [init enter execs]")
FSM_PROFILE_SECTION_IN (gpr_billard_mobility [init enter execs], state0_enter_exec)
{
///////////////////////////////////////////////////////////////
// BILLARD MOBILITY INIT STATE
//
// Initialize the billard mobility process model (variable,...)
///////////////////////////////////////////////////////////////
char msg_string[120];
// init every id relative to the current process
my_node_id=op_topo_parent (op_id_self());
my_process_id=op_id_self();
my_net_id=op_topo_parent(my_node_id);
op_ima_obj_attr_get(my_node_id,"Mobile",&bMobile);
// read the simulation attributes
op_ima_sim_attr_get(OPC_IMA_DOUBLE, "mobil_POS_TIMER", &POS_TIMER);
op_ima_sim_attr_get(OPC_IMA_DOUBLE, "mobil_STEP_DIST", &STEP_DIST);
op_ima_sim_attr_get(OPC_IMA_DOUBLE, "mobil_XMIN", &XMIN);
op_ima_sim_attr_get(OPC_IMA_DOUBLE, "mobil_XMAX", &XMAX);
op_ima_sim_attr_get(OPC_IMA_DOUBLE, "mobil_YMIN", &YMIN);
op_ima_sim_attr_get(OPC_IMA_DOUBLE, "mobil_YMAX", &YMAX);
// initialize the distributions for the random movements
one=op_dist_load ("uniform",-1,1);
// initilaze the first random direction followed by the node containing the current mobility process
angle=op_dist_outcome (one)*PI;
if (op_prg_odb_ltrace_active ("ztl_debug") == OPC_TRUE)
{
sprintf (msg_string, "move interval is %f ", POS_TIMER);
op_prg_odb_print_major (msg_string, OPC_NIL);
op_prg_odb_bkpt("ztl_mov");
}
// schedule the first "mouvement" interuption
op_intrpt_schedule_self(op_sim_time()+POS_TIMER,0);
}
FSM_PROFILE_SECTION_OUT (gpr_billard_mobility [init enter execs], state0_enter_exec)
/** state (init) exit executives **/
FSM_STATE_EXIT_FORCED (0, "init", "gpr_billard_mobility [init exit execs]")
FSM_PROFILE_SECTION_IN (gpr_billard_mobility [init exit execs], state0_exit_exec)
{
}
FSM_PROFILE_SECTION_OUT (gpr_billard_mobility [init exit execs], state0_exit_exec)
/** state (init) transition processing **/
FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "init", "idle")
/*---------------------------------------------------------*/
/** state (idle) enter executives **/
FSM_STATE_ENTER_UNFORCED (1, "idle", state1_enter_exec, "gpr_billard_mobility [idle enter execs]")
FSM_PROFILE_SECTION_IN (gpr_billard_mobility [idle enter execs], state1_enter_exec)
{
}
FSM_PROFILE_SECTION_OUT (gpr_billard_mobility [idle enter execs], state1_enter_exec)
/** blocking after enter executives of unforced state. **/
FSM_EXIT (3,"gpr_billard_mobility")
/** state (idle) exit executives **/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -