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