blob: c028df72d53d5fe693741cd949521a3f379ca00d [file] [log] [blame]
Stephan Pleinesb1177672024-05-27 17:48:32 -07001#include <chrono>
2#include <memory>
3
Austin Schuh99f7c6a2024-06-25 22:07:44 -07004#include "absl/flags/flag.h"
Philipp Schrader790cb542023-07-05 21:06:52 -07005
James Kuszmaul5c56ed32022-03-30 15:10:07 -07006#include "aos/configuration.h"
Stephan Pleinesb1177672024-05-27 17:48:32 -07007#include "aos/events/event_loop.h"
James Kuszmaul5c56ed32022-03-30 15:10:07 -07008#include "aos/events/logging/log_writer.h"
James Kuszmaul5c56ed32022-03-30 15:10:07 -07009#include "aos/events/ping_lib.h"
10#include "aos/events/pong_lib.h"
Stephan Pleinesb1177672024-05-27 17:48:32 -070011#include "aos/events/simulated_event_loop.h"
12#include "aos/flatbuffers.h"
Austin Schuh60e77942022-05-16 17:48:24 -070013#include "aos/init.h"
Austin Schuh60e77942022-05-16 17:48:24 -070014#include "aos/testing/path.h"
James Kuszmaul5c56ed32022-03-30 15:10:07 -070015
Austin Schuh99f7c6a2024-06-25 22:07:44 -070016ABSL_FLAG(std::string, output_folder, "",
17 "Name of folder to write the generated logfile to.");
James Kuszmaul5c56ed32022-03-30 15:10:07 -070018
19int 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());
Austin Schuh99f7c6a2024-06-25 22:07:44 -070041 writer.StartLoggingOnRun(absl::GetFlag(FLAGS_output_folder));
James Kuszmaul5c56ed32022-03-30 15:10:07 -070042
43 event_loop_factory.RunFor(std::chrono::seconds(10));
44 return 0;
45}