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 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 13 | namespace frc971::can_logger { |
Ravago Jones | 09067de | 2023-03-29 18:44:43 -0700 | [diff] [blame] | 14 | |
| 15 | class 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 | |
James Kuszmaul | 22248e9 | 2024-02-23 16:46:51 -0800 | [diff] [blame^] | 28 | std::optional<aos::realtime_clock::time_point> first_frame_realtime_; |
Ravago Jones | 09067de | 2023-03-29 18:44:43 -0700 | [diff] [blame] | 29 | |
| 30 | std::ofstream output_; |
| 31 | |
| 32 | aos::EventLoop *event_loop_; |
| 33 | }; |
| 34 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame] | 35 | } // namespace frc971::can_logger |
Ravago Jones | 09067de | 2023-03-29 18:44:43 -0700 | [diff] [blame] | 36 | |
| 37 | #endif // FRC971_CAN_LOGGER_ASC_LOGGER_H_ |