Stephan Pleines | b117767 | 2024-05-27 17:48:32 -0700 | [diff] [blame^] | 1 | #include <chrono> |
| 2 | #include <memory> |
| 3 | |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 4 | #include "gflags/gflags.h" |
| 5 | |
James Kuszmaul | 5c56ed3 | 2022-03-30 15:10:07 -0700 | [diff] [blame] | 6 | #include "aos/configuration.h" |
Stephan Pleines | b117767 | 2024-05-27 17:48:32 -0700 | [diff] [blame^] | 7 | #include "aos/events/event_loop.h" |
James Kuszmaul | 5c56ed3 | 2022-03-30 15:10:07 -0700 | [diff] [blame] | 8 | #include "aos/events/logging/log_writer.h" |
James Kuszmaul | 5c56ed3 | 2022-03-30 15:10:07 -0700 | [diff] [blame] | 9 | #include "aos/events/ping_lib.h" |
| 10 | #include "aos/events/pong_lib.h" |
Stephan Pleines | b117767 | 2024-05-27 17:48:32 -0700 | [diff] [blame^] | 11 | #include "aos/events/simulated_event_loop.h" |
| 12 | #include "aos/flatbuffers.h" |
Austin Schuh | 60e7794 | 2022-05-16 17:48:24 -0700 | [diff] [blame] | 13 | #include "aos/init.h" |
Austin Schuh | 60e7794 | 2022-05-16 17:48:24 -0700 | [diff] [blame] | 14 | #include "aos/testing/path.h" |
James Kuszmaul | 5c56ed3 | 2022-03-30 15:10:07 -0700 | [diff] [blame] | 15 | |
Austin Schuh | 60e7794 | 2022-05-16 17:48:24 -0700 | [diff] [blame] | 16 | DEFINE_string(output_folder, "", |
| 17 | "Name of folder to write the generated logfile to."); |
James Kuszmaul | 5c56ed3 | 2022-03-30 15:10:07 -0700 | [diff] [blame] | 18 | |
| 19 | int main(int argc, char **argv) { |
| 20 | aos::InitGoogle(&argc, &argv); |
| 21 | |
| 22 | const aos::FlatbufferDetachedBuffer<aos::Configuration> config = |
| 23 | aos::configuration::ReadConfig( |
| 24 | aos::testing::ArtifactPath("aos/events/pingpong_config.json")); |
| 25 | |
| 26 | aos::SimulatedEventLoopFactory event_loop_factory(&config.message()); |
| 27 | |
| 28 | // Event loop and app for Ping |
| 29 | std::unique_ptr<aos::EventLoop> ping_event_loop = |
| 30 | event_loop_factory.MakeEventLoop("ping"); |
| 31 | aos::Ping ping(ping_event_loop.get()); |
| 32 | |
| 33 | // Event loop and app for Pong |
| 34 | std::unique_ptr<aos::EventLoop> pong_event_loop = |
| 35 | event_loop_factory.MakeEventLoop("pong"); |
| 36 | aos::Pong pong(pong_event_loop.get()); |
| 37 | |
| 38 | std::unique_ptr<aos::EventLoop> log_writer_event_loop = |
| 39 | event_loop_factory.MakeEventLoop("log_writer"); |
| 40 | aos::logger::Logger writer(log_writer_event_loop.get()); |
| 41 | writer.StartLoggingOnRun(FLAGS_output_folder); |
| 42 | |
| 43 | event_loop_factory.RunFor(std::chrono::seconds(10)); |
| 44 | return 0; |
| 45 | } |