📄 control.pr.c
字号:
/* Process model C form file: CONTROL.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 CONTROL_pr_c [] = "MIL_3_Tfile_Hdr_ 80C 30A modeler 7 427C4691 427C4691 1 wani wani123 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 */
#include "stdlib.h"
#include "string.h"
#include "route.h"
#include <stdio.h>
#define MAX_HOPS 15
#define STOP_SIM 2
#define FAIL_NODE 3
#define FAIL_LINK 4
#define RECOVER_NODE 5
#define RECOVER_LINK 6
#define TRPRT_OUT_STREAM 0
#define LINK_ACTION 0
#define NODE_ACTION 1
#define FAIL 0
#define RECOVER 1
#define BEGSIM (op_intrpt_type () == OPC_INTRPT_BEGSIM)
#define ND_FAIL (remote_int_code == FAIL_NODE)
#define LK_FAIL (remote_int_code == FAIL_LINK)
#define ND_RCOVR (remote_int_code == RECOVER_NODE)
#define LK_RCOVR (remote_int_code == RECOVER_LINK)
#define MAX_NUM_LOOPS 200
List* link_enabled_lptr;
List* link_disabled_lptr;
List* link_non_mesh_lptr;
List* call_router_lptr;
List* mesh_nd_enabled_lptr;
List* mesh_nd_disabled_lptr;
typedef struct
{
double time;
int act_obj_type;
char arg1[128];
char arg2[128];
int act;
int restoration;
} Fail_Table;
/*
double Net_top[NODE_NUM][NODE_NUM]={
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14
{0, 1100, 1600, 0, 0, 0, 0, 2800, 0, 0, 0, 0, 0, 0},
{1100, 0, 600, 1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{1600, 600, 0, 0, 0, 2000, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1000, 0, 0, 600, 0, 0, 0, 0, 0, 2400, 0, 0, 0},
{0, 0, 0, 600, 0, 1100, 800, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 2000, 0, 1100, 0, 0, 0, 1200, 0, 0, 0, 2000, 0},
{0, 0, 0, 0, 800, 0, 0, 700, 0, 0, 0, 0, 0, 0},
{2800, 0, 0, 0, 0, 0, 700, 0, 0, 700, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1200, 0, 0, 0, 900, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 700, 900, 0, 0, 500, 0, 500},
{0, 0, 0, 2400, 0, 0, 0, 0, 0, 0, 0, 800, 0, 800},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 800, 0, 300, 0},
{0, 0, 0, 0, 0, 2000, 0, 0, 0, 0, 0, 300, 0, 300},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 500, 800, 0, 300, 0}
};
double Net_delay[NODE_NUM][NODE_NUM]={
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14
{0, 0.0055, 0.008, 0, 0, 0, 0, 0.014, 0, 0, 0, 0, 0, 0},
{0.0055, 0, 0.003, 0.005, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0.008, 0.003, 0, 0, 0, 0.01, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0.005, 0, 0, 0.003, 0, 0, 0, 0, 0, 0.012, 0, 0, 0},
{0, 0, 0, 0.003, 0, 0.0055, 0.004, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0.01, 0, 0.0055, 0, 0, 0, 0.006, 0, 0, 0, 0.01, 0},
{0, 0, 0, 0, 0.004, 0, 0, 0.0035, 0, 0, 0, 0, 0, 0},
{0.014, 0, 0, 0, 0, 0, 0.0035, 0, 0, 0.0035, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0.006, 0, 0, 0, 0.0045, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0.0035, 0.0045, 0, 0, 0.0025, 0, 0.0025},
{0, 0, 0, 0.012, 0, 0, 0, 0, 0, 0, 0, 0.004, 0, 0.004},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0025, 0.004, 0, 0.0015, 0},
{0, 0, 0, 0, 0, 0.01, 0, 0, 0, 0, 0, 0.0015, 0, 0.0015},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0025, 0.004, 0, 0.0015, 0}
};
*/
int total_temp_hop_count = 0;
/* 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 num_fixed_nodes;
int num_dup_links;
Objid node_objid;
Objid subnet_objid;
int num_call_routers;
int num_lines;
int schedule_num;
List* fail_file_ptr;
Fail_Table* fail_table_ptr;
Fail_Table* schedule_ptr;
int action_obj_type;
int action_obj_index;
int action;
int remote_int_code;
int fail_index;
Objid mesh_node_objid_1;
Objid mesh_process_objid_1;
Objid mesh_node_objid_2;
Objid mesh_process_objid_2;
} CONTROL_state;
#define pr_state_ptr ((CONTROL_state*) SimI_Mod_State_Ptr)
#define num_fixed_nodes pr_state_ptr->num_fixed_nodes
#define num_dup_links pr_state_ptr->num_dup_links
#define node_objid pr_state_ptr->node_objid
#define subnet_objid pr_state_ptr->subnet_objid
#define num_call_routers pr_state_ptr->num_call_routers
#define num_lines pr_state_ptr->num_lines
#define schedule_num pr_state_ptr->schedule_num
#define fail_file_ptr pr_state_ptr->fail_file_ptr
#define fail_table_ptr pr_state_ptr->fail_table_ptr
#define schedule_ptr pr_state_ptr->schedule_ptr
#define action_obj_type pr_state_ptr->action_obj_type
#define action_obj_index pr_state_ptr->action_obj_index
#define action pr_state_ptr->action
#define remote_int_code pr_state_ptr->remote_int_code
#define fail_index pr_state_ptr->fail_index
#define mesh_node_objid_1 pr_state_ptr->mesh_node_objid_1
#define mesh_process_objid_1 pr_state_ptr->mesh_process_objid_1
#define mesh_node_objid_2 pr_state_ptr->mesh_node_objid_2
#define mesh_process_objid_2 pr_state_ptr->mesh_process_objid_2
/* 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 CONTROL_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 CONTROL (void);
Compcode CONTROL_init (void **);
void CONTROL_diag (void);
void CONTROL_terminate (void);
void CONTROL_svar (void *, const char *, char **);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
CONTROL (void)
{
int _block_origin = 0;
FIN (CONTROL ());
if (1)
{
char icon_name[20];
Objid simple_objid;
Objid rec_node_objid;
Objid dest_objid;
Objid src_objid;
Objid self_objid;
Packet* pkptr;
Packet* f_pkptr;
Boolean condition;
Boolean node_condition;
Boolean link_condition;
Objid* rand_node_objid_ptr;
Packet* rand_node_objid_ptr_1;
Objid* traffic_generate_objid_ptr;
Objid* rand_link_objid_ptr;
char node_name[255];
char node0_name[255];
char node1_name[255];
char link_name[255];
char script_filename[255];
char err_str[255];
char f_type[1],f_data[1];
int rand_num;
int num_nds_enabled;
int num_nds_disabled;
int num_links_enabled;
int num_links_disabled;
int userid;
int i,j,k,l,m,x,y;
int comp_flag,exit_flag;
Objid* node_objid_ptr;
Objid* node0_objid_ptr;
Objid* node1_objid_ptr;
Objid* link_objid_ptr;
int interrupt_code;
Objid node0_objid;
Objid node1_objid;
Objid link_objid;
Route_Link* link_ptr;
Objid call_router_objid;
char* line;
List* field_list_ptr;
double node_mtbf;
double node_mttr;
double link_mtbf;
double link_mttr;
double link_cost;
double link_cost_default;
int subnet_ids[16];
int node_ids[16];
int num_nodes;
FILE *fp;
char f_name[50];
int userid0;
int userid1;
int userid2;
int hop_num[15][15];
double Average_hop_num;
int Hop_num;
int include_flag;
Objid temp_objid;
int ef,eff;
Objid temp_src_objid,temp_dest_objid,rx_objid,rx1_objid,tx_objid,tx1_objid;
Objid link1_objid,link_objid1;
int temp_link_count;
int temp_hop_count = 0;
//Objid temp_src_objid, temp_dest_objid;
Route_Set* temp_routeset;
Route* temp_min_route;
int temp_strm_count;
Objid temp_strm_objid;
char temp_char1[20];char temp_char2[20];
char temp_char3[20];char temp_char4[20];
char temp_char5[20];char temp_char6[20];
FSM_ENTER (CONTROL)
FSM_BLOCK_SWITCH
{
/*---------------------------------------------------------*/
/** state (init) enter executives **/
FSM_STATE_ENTER_FORCED_NOLABEL (0, "init", "CONTROL () [init enter execs]")
{
self_objid = op_id_self();
node_objid = op_topo_parent (self_objid);
op_ima_obj_attr_get(node_objid, "user id", &userid);
subnet_objid = op_topo_parent (node_objid);
topo_ptr = op_rte_topo_from_objids ();
/*
for(i = 0;i < 6;i++)
{
for(j = 0;j < 6;j++)
{
temp_src_objid = op_id_from_userid (subnet_objid, OPC_OBJTYPE_NDFIX,i);
temp_dest_objid = op_id_from_userid (subnet_objid, OPC_OBJTYPE_NDFIX, j);
temp_routeset = op_rte_routeset_create (topo_ptr, subnet_objid, temp_src_objid, subnet_objid, temp_dest_objid, 15);
temp_min_route = op_rte_routeset_mincost(temp_routeset);
if(i == j)
{
min_rptr[i][j] = OPC_NIL;
p_min_rptr[i][j] = OPC_NIL;
//primary_num_nodes[i][j] = 0;
//num_routes[i][j] = 0;
}
else
{
temp_hop_count = op_rte_route_num_nodes(temp_min_route);
total_temp_hop_count += temp_hop_count-1;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -