From 37fe174cbba1fc3b11977735f1ef9631e750002c Mon Sep 17 00:00:00 2001 From: Byeonggil Jun Date: Thu, 11 Jan 2024 14:34:05 -0700 Subject: [PATCH] Make the python script to receive and process start and time properly --- util/tracing/trace_to_csv.c | 12 ++++++------ util/tracing/visualization/README.md | 2 +- util/tracing/visualization/fedsd.py | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/util/tracing/trace_to_csv.c b/util/tracing/trace_to_csv.c index 6fdddc0bc..2dee57935 100644 --- a/util/tracing/trace_to_csv.c +++ b/util/tracing/trace_to_csv.c @@ -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 { diff --git a/util/tracing/visualization/README.md b/util/tracing/visualization/README.md index 4b8de0ed8..cee3eb5a4 100644 --- a/util/tracing/visualization/README.md +++ b/util/tracing/visualization/README.md @@ -41,7 +41,7 @@ fedsd -r -f If the trace is too long, the target time interval can be specified. Running `fedsd` with `-s ` will show the messages with the tag later than or equal to the start time and with `-e ` 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 -e +fedsd -s -e ``` 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. diff --git a/util/tracing/visualization/fedsd.py b/util/tracing/visualization/fedsd.py index b03f6e0ca..34eeb1ad3 100644 --- a/util/tracing/visualization/fedsd.py +++ b/util/tracing/visualization/fedsd.py @@ -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. @@ -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)