📄 eer.pr.c
字号:
/** state (control_recieve) exit executives **/
FSM_STATE_EXIT_FORCED (2, "control_recieve", "EER () [control_recieve exit execs]")
{
}
/** state (control_recieve) transition processing **/
FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "control_recieve", "wait")
/*---------------------------------------------------------*/
/** state (data_recieve) enter executives **/
FSM_STATE_ENTER_FORCED (3, state3_enter_exec, "data_recieve", "EER () [data_recieve enter execs]")
{
self_objid = op_id_self ();
node_objid = op_topo_parent (self_objid);
subnet_objid = op_topo_parent (node_objid);
topo_objid = op_rte_topo_from_objids();
pkptr = op_pk_get (op_intrpt_strm());
op_pk_nfd_get (pkptr, "type", &pktype);
op_pk_nfd_get (pkptr, "source address", &source_address);
op_pk_nfd_get (pkptr, "destination address", &destination_address);
temp_src_objid = op_id_from_userid (subnet_objid, OPC_OBJTYPE_NDFIX,source_address);
temp_dest_objid = op_id_from_userid (subnet_objid, OPC_OBJTYPE_NDFIX, destination_address);
temp_routeset = op_rte_routeset_create (topo_objid, subnet_objid, temp_src_objid, subnet_objid, temp_dest_objid, 5);
temp_min_route = op_rte_routeset_mincost(temp_routeset);
if(userid == destination_address)
{
// printf("EER-->data_recieve; success,uerid=%d,s_node=%d,d_node=%d,op_time=%e\n",userid,source_address,destination_address,op_sim_time());
// getchar();
total_burst_receive_count++;
hop_count += op_rte_route_num_nodes(temp_min_route);
burst_size = op_pk_total_size_get(pkptr);
total_burst_size += (burst_size * (double)hop_count);
}
else
{
// printf("EER-->data_recieve; failed,uerid=%d,s_node=%d,d_node=%d,op_time=%e\n",userid,source_address,destination_address,op_sim_time());
total_burst_receive_but_count++;
}
op_pk_destroy(pkptr);
}
/** state (data_recieve) exit executives **/
FSM_STATE_EXIT_FORCED (3, "data_recieve", "EER () [data_recieve exit execs]")
{
}
/** state (data_recieve) transition processing **/
FSM_TRANSIT_FORCE (1, state1_enter_exec, ;, "default", "", "data_recieve", "wait")
/*---------------------------------------------------------*/
/** state (end) enter executives **/
FSM_STATE_ENTER_UNFORCED (4, state4_enter_exec, "end", "EER () [end enter execs]")
{
self_objid = op_id_self ();
node_objid = op_topo_parent (self_objid);
op_ima_obj_attr_get(self_objid, "filename", &filename);
if(userid==6)
{
avg_hop_count = (float)(hop_count/(float)total_burst_receive_count) ;
strcpy(temp_file_name,"D:/result/");
strcat(temp_file_name,filename);
in = fopen(temp_file_name,"a");
fprintf(in,"total_burst_receive_cound = %d \n", total_burst_receive_count);
fprintf(in,"total_burst_receive_but_cound = %d \n",total_burst_receive_but_count);
fprintf(in,"total_bcp_receive_count = %d \n",total_bcp_receive_count);
fprintf(in,"total_bcp_receive_but_count = %d \n",total_bcp_receive_but_count);
fprintf(in,"avg_hop_count_success = %f \n",avg_hop_count);
fprintf(in,"total_burst_size = %f \n",total_burst_size);
fclose(in);
printf("total_burst_receive_cound=%d,userid=%d\n", total_burst_receive_count,userid);
printf("total_burst_receive_but_cound=%d,userid=%d\n",total_burst_receive_but_count,userid);
printf("total_bcp_receive_count=%d,userid=%d\n",total_bcp_receive_count,userid);
printf("total_bcp_receive_but_count=%d\n",total_bcp_receive_but_count);
//in = fopen("D:/result/1.txt","a");
//fprintf(in,"hello\n");
//fclose(in);
//in = fopen("D:/result/1.txt","a");
//fprintf(in,"aaaaa\n");
//fclose(in);
}
}
/** blocking after enter executives of unforced state. **/
FSM_EXIT (9,EER)
/** state (end) exit executives **/
FSM_STATE_EXIT_UNFORCED (4, "end", "EER () [end exit execs]")
{
}
/** state (end) transition processing **/
FSM_TRANSIT_MISSING ("end")
/*---------------------------------------------------------*/
}
FSM_EXIT (0,EER)
}
}
#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
EER_init (void ** gen_state_pptr)
{
int _block_origin = 0;
static VosT_Address obtype = OPC_NIL;
FIN (EER_init (gen_state_pptr))
if (obtype == OPC_NIL)
{
/* Initialize memory management */
if (Vos_Catmem_Register ("proc state vars (EER)",
sizeof (EER_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 */
((EER_state *)(*gen_state_pptr))->current_block = 0;
FRET (OPC_COMPCODE_SUCCESS)
}
}
void
EER_diag (void)
{
/* No Diagnostic Block */
}
void
EER_terminate (void)
{
int _block_origin = __LINE__;
FIN (EER_terminate (void))
if (1)
{
int total_node_num = 0;
//int node_num = 0;
//int link_num = 0;
char node_name[20];
int i,j,k;
Objid node_objid_ptr, link_objid,tx_objid;
Route* min_route;
int subnet_id_ptr, node_id_ptr;
int strm_num, channel_count1, link_count;
double pk_size;
Objid temp_tx_objid;
int cur_port, difference_time, reservation_flag, temp_difference_time, cur_channel;
int d_time;
CHANNEL_INFOR * temp_channel_infor;
int temp_outstrm_num,cur_por,temp_occupy_count;
int output_strm;
int pktype;
Packet* pkptr_burst;
Packet* pkptr;
int source_address;
int destination_address;
Route* pk_rptr;
double start_time;
double dtime_time;
double cur_time;
int subnet_ids[10];
int node_ids[20];
int num_nodes;
Objid strm_objid;
int channel_num;
Objid temp_src_objid, temp_dest_objid;
Route_Set* temp_routeset;
Route* temp_min_route;
FILE * in;
char filename[20];
char temp_file_name[20];
double burst_size = 0;
Topology * topo_objid;
Objid self_objid,node_objid,subnet_objid;
/* 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 EER_svar function. */
#undef userid
#undef routing_table
#undef node_for_schedule
#undef link_num
#undef channel_count
#undef PROC_TIME
#undef RATE
void
EER_svar (void * gen_ptr, const char * var_name, char ** var_p_ptr)
{
EER_state *prs_ptr;
FIN (EER_svar (gen_ptr, var_name, var_p_ptr))
if (var_name == OPC_NIL)
{
*var_p_ptr = (char *)OPC_NIL;
FOUT;
}
prs_ptr = (EER_state *)gen_ptr;
if (strcmp ("userid" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->userid);
FOUT;
}
if (strcmp ("routing_table" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->routing_table);
FOUT;
}
if (strcmp ("node_for_schedule" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->node_for_schedule);
FOUT;
}
if (strcmp ("link_num" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->link_num);
FOUT;
}
if (strcmp ("channel_count" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->channel_count);
FOUT;
}
if (strcmp ("PROC_TIME" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->PROC_TIME);
FOUT;
}
if (strcmp ("RATE" , var_name) == 0)
{
*var_p_ptr = (char *) (&prs_ptr->RATE);
FOUT;
}
*var_p_ptr = (char *)OPC_NIL;
FOUT;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -