⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 time_stats.c

📁 一个非常好的人工智能开发工具开源软件
💻 C
字号:
/*** *** See the file "L2_RTI_EO1/disclaimers-and-notices-L2.txt" for  *** information on usage and redistribution of this file,  *** and for a DISCLAIMER OF ALL WARRANTIES. ***//********************************************************************************//*										*//*	time_stats.c								*//*										*//*	Calculates performance statistics such as Tt, Tm, Tl by parsing		*//*	downlink.output files.							*//*										*//********************************************************************************/#include <stdio.h>#include <string.h>#include <stdlib.h>#define BUFFER_SIZE	200FILE	*in, *out;double	To[20];int     cur_scenario;double  Tm, Tt, Tl;void init_scenarios ();void print_results ();void process_file ();void main (int argc, char **argv) {        char * file_in;  file_in = argv[1];  cur_scenario = atoi (argv[2]);    fprintf (stderr, "\n\nDOING SCENARIO %d\n", cur_scenario);  init_scenarios();  in	= fopen (file_in, "r");  if (in)    process_file ();  else {    printf ("Can't open the file\n");    exit(0);  }  fclose (in);  print_results ();}void init_scenarios () {  To [1]	= 9410.000;  To [3]	= 9539.790;  To [6]     	= 2706.900;  To [7]     	= 5000.000;  To [9]     	= 2706.900;  To[10]     	= 5000.000;  To[11]      	= 5167.400;  To[12]      	= 3331.000;  To[13]      	= 5167.400;  To[14]      	= 9000.000;  To[16]      	= 9659.860;  To[18]      	= 9735.290;  To[19]      	= 9766.050;}void process_file () {  double  last_ROS_event;  double  last_FC;  double  last_expiration;  double  last_observation;  double  timestamp;  char    *token, *match_ptr;  char	  line [BUFFER_SIZE+1];  char	  buffer [BUFFER_SIZE+1];  while (last_ROS_event<To[cur_scenario])  {   fgets (line, BUFFER_SIZE, in);   strcpy (buffer, line);   match_ptr = strstr (buffer, "ROS: Frame Update: rcvd@");   if (match_ptr) {     match_ptr = strstr (buffer, "rcvd@");     strtok (match_ptr, " ");     token = strtok (NULL, " ");     if (token) last_ROS_event = atof (token);   }  }  while (!feof(in)) {   fgets (line, BUFFER_SIZE, in);   strcpy (buffer, line);   match_ptr = strstr (buffer, "ROS: Frame Update: rcvd@");   if (match_ptr) {     match_ptr = strstr (buffer, "rcvd@");     strtok (match_ptr, " ");     token = strtok (NULL, " ");     if (token) last_ROS_event = atof (token);   }   strcpy (buffer, line);   match_ptr = strstr (buffer, "findCandidates");   if (match_ptr) {     last_FC = last_ROS_event;   }   strcpy (buffer, line);   match_ptr = strstr (buffer, "observation");   if (match_ptr) {     strtok (match_ptr, ",");     strtok (NULL, ",");     strtok (NULL, ",");     timestamp = atof(strtok (NULL, ",")) + atof(strtok (NULL, ","))/1000000000;     if (timestamp > last_observation) last_observation = timestamp;   }   strcpy (buffer, line);   match_ptr = strstr (buffer, "ROS: Timer expiration rcvd@");   if (match_ptr) {     match_ptr = strstr (buffer, "rcvd@");     strtok (match_ptr, " ");     token = strtok (NULL, " ");     if (token) last_expiration = atof (token);   }   strcpy (buffer, line);   match_ptr = strstr (buffer, "assignment");   if (match_ptr) {     Tm = last_observation;     Tt = last_expiration;     Tl = last_FC;     return;   }  }}void print_results () {  fprintf (stderr, "\nTo = %f\nTm = %f\nTt = %f\nTl = %f\n",		To[cur_scenario], Tm, Tt, Tl);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -