Apollo 10.0
自动驾驶开放平台
apollo::cyber::record::Info类 参考

#include <info.h>

apollo::cyber::record::Info 的协作图:

Public 成员函数

 Info ()
 
 ~Info ()
 
bool Display (const std::string &file)
 

详细描述

在文件 info.h34 行定义.

构造及析构函数说明

◆ Info()

apollo::cyber::record::Info::Info ( )

在文件 info.cc30 行定义.

30{}

◆ ~Info()

apollo::cyber::record::Info::~Info ( )

在文件 info.cc32 行定义.

32{}

成员函数说明

◆ Display()

bool apollo::cyber::record::Info::Display ( const std::string &  file)

在文件 info.cc34 行定义.

34 {
35 RecordFileReader file_reader;
36 if (!file_reader.Open(file)) {
37 AERROR << "open record file error. file: " << file;
38 return false;
39 }
40 proto::Header hdr = file_reader.GetHeader();
41
42 std::cout << setiosflags(std::ios::left);
43 std::cout << setiosflags(std::ios::fixed);
44
45 int w = 16;
46 // file name
47 std::cout << std::setw(w) << "record_file: " << file << std::endl;
48
49 // version
50 std::cout << std::setw(w) << "version: " << hdr.major_version() << "."
51 << hdr.minor_version() << std::endl;
52
53 // time and duration
54 auto begin_time_s = static_cast<double>(hdr.begin_time()) / 1e9;
55 auto end_time_s = static_cast<double>(hdr.end_time()) / 1e9;
56 auto duration_s = end_time_s - begin_time_s;
57 auto begin_time_str = UnixSecondsToString(static_cast<int>(begin_time_s));
58 auto end_time_str = UnixSecondsToString(static_cast<int>(end_time_s));
59 std::cout << std::setw(w) << "duration: " << duration_s << " Seconds"
60 << std::endl;
61 std::cout << std::setw(w) << "begin_time: " << begin_time_str << std::endl;
62 std::cout << std::setw(w) << "end_time: " << end_time_str << std::endl;
63
64 // size
65 std::cout << std::setw(w) << "size: " << hdr.size() << " Bytes";
66 if (hdr.size() >= kGB) {
67 std::cout << " (" << static_cast<float>(hdr.size()) / kGB << " GB)";
68 } else if (hdr.size() >= kMB) {
69 std::cout << " (" << static_cast<float>(hdr.size()) / kMB << " MB)";
70 } else if (hdr.size() >= kKB) {
71 std::cout << " (" << static_cast<float>(hdr.size()) / kKB << " KB)";
72 }
73 std::cout << std::endl;
74
75 // is_complete
76 std::cout << std::setw(w) << "is_complete:";
77 if (hdr.is_complete()) {
78 std::cout << "true";
79 } else {
80 std::cout << "false";
81 }
82 std::cout << std::endl;
83
84 // message_number
85 std::cout << std::setw(w) << "message_number: " << hdr.message_number()
86 << std::endl;
87
88 // channel_number
89 std::cout << std::setw(w) << "channel_number: " << hdr.channel_number()
90 << std::endl;
91
92 // read index section
93 if (!file_reader.ReadIndex()) {
94 AERROR << "read index section of the file fail. file: " << file;
95 return false;
96 }
97
98 // channel info
99 std::cout << std::setw(w) << "channel_info: " << std::endl;
100 proto::Index idx = file_reader.GetIndex();
101 for (int i = 0; i < idx.indexes_size(); ++i) {
102 ChannelCache* cache = idx.mutable_indexes(i)->mutable_channel_cache();
103 if (idx.mutable_indexes(i)->type() == proto::SectionType::SECTION_CHANNEL) {
104 std::cout << std::setw(w) << "";
105 std::cout << resetiosflags(std::ios::right);
106 std::cout << std::setw(50) << cache->name();
107 std::cout << setiosflags(std::ios::right);
108 std::cout << std::setw(8) << cache->message_number();
109 std::cout << std::setw(0) << " messages: ";
110 std::cout << cache->message_type();
111 std::cout << std::endl;
112 }
113 }
114 file_reader.Close();
115 return true;
116}
#define AERROR
Definition log.h:44
std::string UnixSecondsToString(uint64_t unix_seconds, const std::string &format_str="%Y-%m-%d-%H:%M:%S")

该类的文档由以下文件生成: