Skip to content

Commit

Permalink
Make the python script to receive and process start and time properly
Browse files Browse the repository at this point in the history
  • Loading branch information
byeonggiljun committed Jan 11, 2024
1 parent 22431ba commit 37fe174
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions util/tracing/trace_to_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,28 +450,28 @@ int process_args(int argc, const char* argv[], char** root, instant_t* start_tim
} else if (strcmp(arg, "-s") == 0) {
// sscanf(argv[++i], "%ld", start_time);
if (argc < i + 2) {
printf("-s needs time and units.");
usage(argc, argv);
printf("-s needs time value and unit.");
usage();
return -1;
}
const char* time_spec = argv[i++];
const char* units = argv[i++];
*start_time = string_to_instant(time_spec, units);
if (*start_time == -1) {
usage(argc, argv);
usage();
return -1;
}
} else if (strcmp(arg, "-e") == 0) {
if (argc < i + 2) {
printf("-e needs time and units.");
usage(argc, argv);
printf("-e needs time value and unit.");
usage();
return -1;
}
const char* time_spec = argv[i++];
const char* units = argv[i++];
*end_time = string_to_instant(time_spec, units);
if (*end_time == -1) {
usage(argc, argv);
usage();
return -1;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion util/tracing/visualization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fedsd -r <rti.lft> -f <federate__f1.lft> <federate__f2.lft>
If the trace is too long, the target time interval can be specified. Running `fedsd` with `-s <start_time>` will show the messages with the tag later than or equal to the start time and with `-e <end_time>` will show the messages with the tag strictly earlier than the end_time. Here, the time unit of `start_time` and `end_time` is `nsec`.

```bash
fedsd -s <start_time> -e <end_time>
fedsd -s <start_time_value> <time_unit> -e <end_time_value> <time_unit>
```

The output is an html file named `trace_svg.html` (in the current directory) that contains the sequence of interactions between the federates and the RTI.
12 changes: 6 additions & 6 deletions util/tracing/visualization/fedsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@
help='RTI\'s lft trace file.')
parser.add_argument('-f','--federates', nargs='+',
help='List of the federates\' lft trace files.')
parser.add_argument('-s', '--start', type=str,
help='Elapsed logical time (nsec) to start visualization')
parser.add_argument('-e', '--end', type=str,
help='Elapsed logical time (nsec) to end visualization')
parser.add_argument('-s', '--start', type=str, nargs=2,
help='Elapsed logical time that targets to start visualization. [time_value time_unit]')
parser.add_argument('-e', '--end', type=str, nargs=2,
help='Elapsed logical time that targets to end visualization. [time_value time_unit]')

# Events matching at the sender and receiver ends depend on whether they are tagged
# (the elapsed logical time and microstep have to be the same) or not.
Expand Down Expand Up @@ -389,9 +389,9 @@ def convert_lft_file_to_csv(lft_file, start_time, end_time):

subprocess_args = ['trace_to_csv', lft_file]
if (start_time != None):
subprocess_args.extend(['-s', start_time])
subprocess_args.extend(['-s', start_time[0], start_time[1]])
if (end_time != None):
subprocess_args.extend(['-e', end_time])
subprocess_args.extend(['-e', end_time[0], end_time[1]])

convert_process = subprocess.run(subprocess_args, stdout=subprocess.DEVNULL)

Expand Down

0 comments on commit 37fe174

Please sign in to comment.