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