blob: f56c4296977d10195d86bcc2df4c181e24b9ef28 [file] [log] [blame]
Lee Mracek3e16a862019-01-24 11:15:36 -05001package(default_visibility = ["//visibility:public"])
2
James Kuszmaul5f5e1232020-12-22 20:58:00 -08003load("@npm_bazel_typescript//:defs.bzl", "ts_library")
James Kuszmaul61a971f2020-01-01 15:06:18 -08004load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
James Kuszmaul5f5e1232020-12-22 20:58:00 -08005load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "rollup_bundle")
James Kuszmaul48671362020-12-24 13:54:16 -08006load("@com_github_google_flatbuffers//:build_defs.bzl", "flatbuffer_cc_library", "flatbuffer_ts_library")
7load("//aos:config.bzl", "aos_config")
James Kuszmaul61a971f2020-01-01 15:06:18 -08008
Lee Mracek3e16a862019-01-24 11:15:36 -05009py_library(
10 name = "python_init",
11 srcs = ["__init__.py"],
Philipp Schraderdada1072020-11-24 11:34:46 -080012 target_compatible_with = ["@platforms//os:linux"],
Lee Mracek3e16a862019-01-24 11:15:36 -050013 deps = ["//frc971:python_init"],
14)
James Kuszmaul7daef362019-12-31 18:28:17 -080015
16cc_binary(
17 name = "py_log_reader.so",
18 srcs = ["py_log_reader.cc"],
19 linkshared = True,
Philipp Schraderdada1072020-11-24 11:34:46 -080020 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul7daef362019-12-31 18:28:17 -080021 deps = [
22 "//aos:configuration",
23 "//aos:json_to_flatbuffer",
24 "//aos/events:shm_event_loop",
25 "//aos/events:simulated_event_loop",
Austin Schuhb06f03b2021-02-17 22:00:37 -080026 "//aos/events/logging:log_reader",
James Kuszmaul7daef362019-12-31 18:28:17 -080027 "@com_github_google_glog//:glog",
Austin Schuh085eab92020-11-26 13:54:51 -080028 "@python_repo//:python3.7_lib",
James Kuszmaul7daef362019-12-31 18:28:17 -080029 ],
30)
31
32py_test(
33 name = "log_reader_test",
34 srcs = ["log_reader_test.py"],
35 data = [
36 ":py_log_reader.so",
37 "@sample_logfile//file",
38 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080039 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul7daef362019-12-31 18:28:17 -080040 deps = ["//aos:configuration_fbs_python"],
41)
James Kuszmaul61a971f2020-01-01 15:06:18 -080042
43py_proto_library(
44 name = "plot_config_proto",
45 srcs = ["plot_config.proto"],
Philipp Schraderdada1072020-11-24 11:34:46 -080046 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul61a971f2020-01-01 15:06:18 -080047)
48
49py_binary(
50 name = "plot",
51 srcs = ["plot.py"],
52 data = [
53 ":py_log_reader.so",
54 ] + glob(["plot_configs/**"]),
Philipp Schraderdada1072020-11-24 11:34:46 -080055 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul61a971f2020-01-01 15:06:18 -080056 deps = [
57 ":plot_config_proto",
58 ":python_init",
59 "@matplotlib_repo//:matplotlib3",
60 ],
61)
James Kuszmaul469fd4e2020-01-01 15:49:10 -080062
63py_test(
64 name = "plot_test",
65 srcs = ["plot_test.py"],
66 data = [
67 "@sample_logfile//file",
68 ],
Philipp Schraderdada1072020-11-24 11:34:46 -080069 target_compatible_with = ["@platforms//os:linux"],
James Kuszmaul469fd4e2020-01-01 15:49:10 -080070 deps = [":plot"],
71)
James Kuszmaul5f5e1232020-12-22 20:58:00 -080072
73ts_library(
74 name = "plot_index",
75 srcs = ["plot_index.ts"],
76 target_compatible_with = ["@platforms//os:linux"],
77 deps = [
James Kuszmaul48671362020-12-24 13:54:16 -080078 ":plot_data_utils",
James Kuszmaul5f5e1232020-12-22 20:58:00 -080079 "//aos:configuration_ts_fbs",
80 "//aos/network/www:demo_plot",
81 "//aos/network/www:proxy",
James Kuszmaulac2b6b42021-03-07 22:38:06 -080082 "//frc971/control_loops/drivetrain:down_estimator_plotter",
James Kuszmaulc4ae11c2020-12-26 16:26:58 -080083 "//frc971/control_loops/drivetrain:drivetrain_plotter",
milind upadhyay9bd381d2021-01-23 13:44:13 -080084 "//frc971/control_loops/drivetrain:robot_state_plotter",
James Kuszmaul73fc1352021-04-09 22:31:25 -070085 "//frc971/control_loops/drivetrain:spline_plotter",
James Kuszmaul5f5e1232020-12-22 20:58:00 -080086 "//frc971/wpilib:imu_plotter",
Austin Schuh7d63eab2021-03-06 20:15:02 -080087 "//y2020/control_loops/superstructure:accelerator_plotter",
88 "//y2020/control_loops/superstructure:finisher_plotter",
Austin Schuh2efe1682021-03-06 22:47:15 -080089 "//y2020/control_loops/superstructure:hood_plotter",
James Kuszmaul5f5e1232020-12-22 20:58:00 -080090 ],
91)
92
93rollup_bundle(
94 name = "plot_index_bundle",
95 enable_code_splitting = False,
96 entry_point = "plot_index.ts",
97 target_compatible_with = ["@platforms//os:linux"],
98 deps = [
99 ":plot_index",
100 ],
101)
102
103filegroup(
104 name = "plotter_files",
105 srcs = [
106 "index.html",
107 "plot_index_bundle.min.js",
108 ],
109)
110
111sh_binary(
112 name = "web_plotter",
113 srcs = ["web_plotter.sh"],
114 data = [
115 ":plotter_files",
116 "//aos/network:log_web_proxy_main",
117 ],
118 target_compatible_with = ["@platforms//os:linux"],
119)
120
121sh_binary(
122 name = "live_web_plotter_demo",
123 srcs = ["live_web_plotter_demo.sh"],
124 data = [
125 ":plotter_files",
126 "//aos/network:web_proxy_main",
127 "//aos/network/www:test_config",
128 ],
129 target_compatible_with = ["@platforms//os:linux"],
130)
James Kuszmaul48671362020-12-24 13:54:16 -0800131
132flatbuffer_cc_library(
133 name = "plot_data_fbs",
134 srcs = [
135 "plot_data.fbs",
136 ],
137 gen_reflections = 1,
138 target_compatible_with = ["@platforms//os:linux"],
139)
140
141flatbuffer_ts_library(
142 name = "plot_data_ts_fbs",
143 srcs = [
144 "plot_data.fbs",
145 ],
146 target_compatible_with = ["@platforms//os:linux"],
147)
148
149ts_library(
150 name = "plot_data_utils",
151 srcs = ["plot_data_utils.ts"],
152 visibility = ["//visibility:public"],
153 deps = [
154 ":plot_data_ts_fbs",
155 "//aos:configuration_ts_fbs",
156 "//aos/network/www:aos_plotter",
157 "//aos/network/www:plotter",
158 "//aos/network/www:proxy",
159 "@com_github_google_flatbuffers//ts:flatbuffers_ts",
160 ],
161)
162
163aos_config(
164 name = "plotter",
165 src = "plotter_config.json",
166 flatbuffers = [":plot_data_fbs"],
167 target_compatible_with = ["@platforms//os:linux"],
168 deps = ["//aos/events:config"],
169)
170
171cc_library(
172 name = "in_process_plotter",
173 srcs = ["in_process_plotter.cc"],
174 hdrs = ["in_process_plotter.h"],
James Kuszmaule32fa932021-05-11 21:38:16 -0700175 data = [
176 ":plotter",
177 ":plotter_files",
James Kuszmaul48671362020-12-24 13:54:16 -0800178 ],
179 deps = [
180 ":plot_data_fbs",
181 "//aos/events:simulated_event_loop",
182 "//aos/network:web_proxy",
183 ],
184)
185
186cc_binary(
187 name = "in_process_plotter_demo",
188 srcs = ["in_process_plotter_demo.cc"],
James Kuszmaul48671362020-12-24 13:54:16 -0800189 deps = [
190 ":in_process_plotter",
191 "//aos:init",
192 ],
193)