blob: 213aa25865b875f3c1cfce106589ddbd07f0ef3d [file] [log] [blame]
Ravago Jones09067de2023-03-29 18:44:43 -07001#ifndef FRC971_CAN_LOGGER_ASC_LOGGER_H_
2#define FRC971_CAN_LOGGER_ASC_LOGGER_H_
3
4#include <iomanip>
5#include <iostream>
6
7#include "aos/events/event_loop.h"
8#include "frc971/can_logger/can_logging_generated.h"
9#include "gflags/gflags.h"
10#include "glog/logging.h"
11
12namespace frc971 {
13namespace can_logger {
14
15class AscLogger {
16 public:
17 AscLogger(aos::EventLoop *event_loop, const std::string &filename);
18
19 private:
20 void HandleFrame(const CanFrame &frame);
21
22 // This implementation attempts to duplicate the output of can-utils/log2asc
23 void WriteFrame(std::ostream &file, const CanFrame &frame);
24
25 static void WriteHeader(std::ostream &file,
26 aos::realtime_clock::time_point start_time);
27
28 std::optional<aos::monotonic_clock::time_point> first_frame_monotonic_;
29
30 std::ofstream output_;
31
32 aos::EventLoop *event_loop_;
33};
34
35} // namespace can_logger
36} // namespace frc971
37
38#endif // FRC971_CAN_LOGGER_ASC_LOGGER_H_