📄 eibdrv_sim.c
字号:
void panel_cb(void *arg,int btn){}void Null_cb(FL_OBJECT *obj,long data){}void create_object_copyright(int x,int y){ FL_OBJECT *obj; fl_ext_formobjects_add_box(FL_EMBOSSED_BOX,x,y,135,80,"", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,x+5,y+5,125,30,"eibdrv_sim", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_set_object_lcolor(obj,FL_BLUE); fl_set_object_lsize(obj,FL_LARGE_SIZE); fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE); fl_set_object_lstyle(obj,FL_NORMAL_STYLE+FL_EMBOSSED_STYLE); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,x+20,y+30,110,20,"Version 0.2.1", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_set_object_lsize(obj,FL_NORMAL_SIZE); fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE); fl_set_object_lstyle(obj,FL_BOLD_STYLE); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,x+10,y+50,120,20,"(C) Wolfgang Tumfart", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_set_object_lalign(obj,FL_ALIGN_RIGHT|FL_ALIGN_INSIDE);}void CloseBtn_cb(FL_OBJECT *obj,long data){ fl_hide_form(obj->form); fl_free_form(obj->form);} FD_ResultsForm *create_form_ResultsForm(Eib_bcu2_sim *sim){ FL_OBJECT *obj; FD_ResultsForm *fdui = (FD_ResultsForm *)fl_calloc(1,sizeof(*fdui)); char helpstring[100]; int i,j,baudrate_index; unsigned long w_upper_limit; unsigned long w_proc_success=0; unsigned long w_proc_total=0; unsigned long w_proc_failed=0; float w_proc_total_percent=0; float w_proc_success_percent=0; unsigned long w_drv_total=0; unsigned long w_drv_success=0; float w_drv_total_percent=0; float w_drv_success_percent=0; unsigned long w_max=0; unsigned long r_proc_total=0; unsigned long r_drv_total=0; unsigned long r_max=0; double h; int h_failed,h_rw; Eib_bcu2_sim_shm local_w_results; Eib_bcu2_sim_shm local_r_results; double diff_time; unsigned long rw_ges; double rw_pt; int lowerbound; int avg_w1time; /* Summarizing the write and read results over all processes */ for (i=0;i<EIB_BUF_ELEMENT_SIZE;i++) { local_w_results.rw[i]=0; local_w_results.w_failed[i]=0; for (j=0;j<sim->sim_parameter->proc_count;j++) { local_w_results.rw[i]+=(sim->shm_results+j)->rw[i]; local_w_results.w_failed[i]+=(sim->shm_results+j)->w_failed[i]; } } local_w_results.tp=0; for (j=0;j<sim->sim_parameter->proc_count;j++) local_w_results.tp+=(sim->shm_results+j)->tp; for (i=0;i<EIB_BUF_ELEMENT_SIZE;i++) { local_r_results.rw[i]=0; for (j=0;j<sim->sim_parameter->proc_count;j++) local_r_results.rw[i]+=(sim->shm_results+sim->sim_parameter->proc_count+j)->rw[i]; } baudrate_index=0; while(baudrate_index<=17) { if (baudrates[baudrate_index][0]==sim->ftstation_settings->symb_baudrate) break; baudrate_index++; } /* Calculation of throughput */ w_upper_limit=(unsigned long)(((double)sim->sim_parameter->run_time*60000)/ sim->sim_parameter->write_interval)*sim->sim_parameter->proc_count; for (i=0;i<EIB_BUF_ELEMENT_SIZE;i++) { w_proc_success+=local_w_results.rw[i]; w_proc_failed+=local_w_results.w_failed[i]; } w_proc_total+=(w_proc_failed+w_proc_success); for (i=1;i<4;i++) w_drv_success+=sim->stat->write[i]; w_drv_total=w_drv_success+sim->stat->write[0]; if (w_upper_limit>0) { w_proc_total_percent=((float)w_proc_total)/w_upper_limit*100; w_drv_total_percent=((float)w_drv_total)/w_upper_limit*100; } if (w_proc_total>0) w_proc_success_percent=((float)w_proc_success)/w_proc_total*100; if (w_drv_total>0) w_drv_success_percent=((float)w_drv_success)/w_drv_total*100; for (i=0;i<EIB_BUF_ELEMENT_SIZE;i++) r_proc_total+=local_r_results.rw[i]; for (i=0;i<3;i++) r_drv_total+=sim->stat->read[i]; fdui->VisForm=fl_bgn_form(FL_NO_BOX,980,675); fl_ext_formobjects_add_box(FL_UP_BOX,0,0,980,675,"", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_labelframe(FL_ENGRAVED_FRAME,20,20,405,115,"Settings", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,30,55,20,"Device", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,90,30,315,20,sim->device, FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,55,55,20,"Mode", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,90,55,315,20, (sim->ftstation_settings->mode==FT_STANDARDMODE ? "Standard Mode" : "Server Mode"), FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,80,55,20,"Baudrate", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%i",baudrates[baudrate_index][1]); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,90,80,315,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,105,55,20,"Port", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,90,105,315,20,sim->ftstation_settings->port, FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_labelframe(FL_ENGRAVED_FRAME,20,155,190,65,"Process Buffer Size", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,165,45,20,"WRITE", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,190,45,20,"READ", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,80,165,45,20,"Size", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,80,190,45,20,"Size", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",sim->ftstation_settings->wpbuf_size); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,115,165,40,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",sim->ftstation_settings->rpbuf_size); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,115,190,40,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_labelframe(FL_ENGRAVED_FRAME,235,155,190,65,"Message Buffer Size", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,245,165,45,20,"WRITE", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,245,190,45,20,"READ", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,295,165,45,20,"Size", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,295,190,45,20,"Size", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",sim->ftstation_settings->outbuf_size); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,330,165,40,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",sim->ftstation_settings->rpbuf_msgbuf_size); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,330,190,40,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_labelframe(FL_ENGRAVED_FRAME,445,20,355,200,"Simulation Parameter", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,455,30,155,20,"Run time (min):", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%i",sim->sim_parameter->run_time); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,615,30,165,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,455,55,155,20,"Write interval (ms):", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%i",sim->sim_parameter->write_interval); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,615,55,165,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,455,80,155,20,"Minimal message length (byte):", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%i",sim->sim_parameter->min_len); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,615,80,165,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,455,105,155,20,"Maximal message length (byte):", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%i",sim->sim_parameter->max_len); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,615,105,165,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,455,130,155,20,"Number of processes:", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%i",sim->sim_parameter->proc_count); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,615,130,165,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,455,155,155,20,"Write Mode:", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,615,155,165,20,get_wmode_text(sim->sim_parameter->wmode), FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,455,180,155,20,"Write Interval:", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,615,180,165,20,get_winterval_text(sim->sim_parameter->winterval), FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); create_object_copyright(820,20); fl_ext_formobjects_add_labelframe(FL_ENGRAVED_FRAME,20,240,405,265,"Write (Process Simulation)", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,250,105,20,"Upper Limit:", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",w_upper_limit); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,140,250,75,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,275,105,20,"Process Throughput:", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",w_proc_total); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,140,275,75,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%3.2f %%",w_proc_total_percent); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,220,275,55,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",w_proc_success); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,280,275,75,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%3.2f %%",w_proc_success_percent); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,360,275,55,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,300,105,20,"Driver Throughput:", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",w_drv_total); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,140,300,75,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%3.2f %%",w_drv_total_percent); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,220,300,55,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",w_drv_success); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,280,300,75,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%3.2f %%",w_drv_success_percent); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,360,300,55,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,30,330,115,20,"Total penalty time (ms):", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",local_w_results.tp); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,170,330,90,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_box(FL_BORDER_BOX,50,360,345,115,"", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); for (i=0;i<EIB_BUF_ELEMENT_SIZE;i++) { sprintf(&helpstring[0],"%i",i+1); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,50+15*i,475,15,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_set_object_lsize(obj,FL_TINY_SIZE); fl_set_object_lalign(obj,FL_ALIGN_CENTER); if (local_w_results.rw[i]+local_w_results.w_failed[i]>w_max) w_max=local_w_results.rw[i]+local_w_results.w_failed[i]; } h=115.0/w_max; for (i=0;i<EIB_BUF_ELEMENT_SIZE;i++) { h_failed=(int)((double)local_w_results.w_failed[i]*h); if (h_failed>0) { fl_ext_formobjects_add_box2(&obj,FL_FRAME_BOX,50+15*i,475-h_failed,15,h_failed,"", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_set_object_color(obj,FL_TOMATO,BOX_COL2); } h_rw=(int)((double)local_w_results.rw[i]*h); if (h_rw>0) { fl_ext_formobjects_add_box2(&obj,FL_FRAME_BOX,50+15*i,475-h_failed-h_rw,15,h_rw,"", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_set_object_color(obj,FL_WHEAT,BOX_COL2); } } fl_ext_formobjects_add_labelframe(FL_ENGRAVED_FRAME,445,240,405,265,"Read (Process Simulation)", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,455,275,105,20,"Process Throughput:", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",r_proc_total); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,565,275,75,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,455,300,105,20,"Driver Throughput:", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); sprintf(&helpstring[0],"%li",r_drv_total); fl_ext_formobjects_add_text(&obj,FL_BORDER_BOX,565,300,75,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_box(FL_BORDER_BOX,475,360,345,115,"", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); for (i=0;i<EIB_BUF_ELEMENT_SIZE;i++) { sprintf(&helpstring[0],"%i",i+1); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,475+15*i,475,15,20,&helpstring[0], FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_set_object_lsize(obj,FL_TINY_SIZE); fl_set_object_lalign(obj,FL_ALIGN_CENTER); if (local_r_results.rw[i]>r_max) r_max=local_r_results.rw[i]; } h=115.0/r_max; for (i=0;i<EIB_BUF_ELEMENT_SIZE;i++) { h_rw=(int)((double)local_r_results.rw[i]*h); if (h_rw>0) { fl_ext_formobjects_add_box2(&obj,FL_FRAME_BOX,475+15*i,475-h_rw,15,h_rw,"", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_set_object_color(obj,FL_WHEAT,BOX_COL2); } } fl_ext_formobjects_add_labelframe(FL_ENGRAVED_FRAME,20,525,405,130,"Write (Driver Statistics)", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,40,535,165,20,"1 - 2 - 3 attempts - failed", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,345,575,60,20,"total writes", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,345,590,60,20,"writes / sec", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_labelframe(FL_ENGRAVED_FRAME,445,525,405,130,"Read (Driver Statistics)", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,465,535,130,20,"0 - 1 - 2 retransmissions", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,770,575,60,20,"total reads", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest); fl_ext_formobjects_add_text(&obj,FL_NO_BOX,770,590,60,20,"reads / sec", FL_RESIZE_NONE,FL_NorthWest,FL_NorthWest);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -