提交 eb07d2c4 编写于 作者: Y yaoweifeng01 提交者: Xiangquan Xiao

cyber: fix lint & add record info tools for python

上级 d5210144
...@@ -163,6 +163,7 @@ class PyReader { ...@@ -163,6 +163,7 @@ class PyReader {
std::condition_variable msg_cond_; std::condition_variable msg_cond_;
}; };
using PyMsgWrapPtr = std::shared_ptr<apollo::cyber::message::PyMessageWrap>;
class PyService { class PyService {
public: public:
PyService(const std::string& service_name, const std::string& data_type, PyService(const std::string& service_name, const std::string& data_type,
...@@ -175,7 +176,7 @@ class PyService { ...@@ -175,7 +176,7 @@ class PyService {
const std::shared_ptr<const apollo::cyber::message::PyMessageWrap>& const std::shared_ptr<const apollo::cyber::message::PyMessageWrap>&
request, request,
std::shared_ptr<apollo::cyber::message::PyMessageWrap>& response) { std::shared_ptr<apollo::cyber::message::PyMessageWrap>& response) {
this->cb(request, response); response = this->cb(request);
}; };
service_ = node_->CreateService<apollo::cyber::message::PyMessageWrap, service_ = node_->CreateService<apollo::cyber::message::PyMessageWrap,
apollo::cyber::message::PyMessageWrap>( apollo::cyber::message::PyMessageWrap>(
...@@ -201,9 +202,9 @@ class PyService { ...@@ -201,9 +202,9 @@ class PyService {
} }
private: private:
void cb(const std::shared_ptr<const apollo::cyber::message::PyMessageWrap>& PyMsgWrapPtr cb(
request, const std::shared_ptr<const apollo::cyber::message::PyMessageWrap>&
std::shared_ptr<apollo::cyber::message::PyMessageWrap>& response) { request) {
std::lock_guard<std::mutex> lg(msg_lock_); std::lock_guard<std::mutex> lg(msg_lock_);
request_cache_.push_back(request->data()); request_cache_.push_back(request->data());
...@@ -218,9 +219,9 @@ class PyService { ...@@ -218,9 +219,9 @@ class PyService {
response_cache_.pop_front(); response_cache_.pop_front();
} }
std::shared_ptr<apollo::cyber::message::PyMessageWrap> m; PyMsgWrapPtr response;
m.reset(new apollo::cyber::message::PyMessageWrap(msg, data_type_)); response.reset(new apollo::cyber::message::PyMessageWrap(msg, data_type_));
response = m; return response;
} }
apollo::cyber::Node* node_; apollo::cyber::Node* node_;
......
# ****************************************************************************
# Copyright 2018 The Apollo Authors. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ****************************************************************************
# -*- coding: utf-8 -*-
"""Module for example of record."""
import time
import sys
from cyber_py import cyber
from cyber_py import record
from cyber.proto import record_pb2
from google.protobuf.descriptor_pb2 import FileDescriptorProto
def print_channel_info(file_path):
freader = record.RecordReader(file_path)
channels = freader.get_channellist()
header_msg = freader.get_headerstring()
header = record_pb2.Header()
header.ParseFromString(header_msg)
print ""
print "++++++++++++Begin Channel Info Statistics++++++++++++++"
print "-" * 40
print "record version: %d.%d" % (header.major_version, header.minor_version)
print "record message_number: ", header.message_number
print "record file size(Byte) ", header.size
print "chunk_number: ", header.chunk_number
print "channel counts: ", len(channels)
print "-" * 40
counts = 1
for channel in channels:
desc = freader.get_protodesc(channel)
print "[", counts , "]", "channel name: ", channel, "; desc size is ", len(desc)
counts = counts + 1
# print desc
print "++++++++++++Finish Channel Info Statistics++++++++++++++"
print ""
if __name__ == '__main__':
cyber.init()
rec_file = (sys.argv[1])
print_channel_info(rec_file)
cyber.shutdown()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册