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

更多...

#include <timer_component.h>

类 apollo::cyber::TimerComponent 继承关系图:
apollo::cyber::TimerComponent 的协作图:

Public 成员函数

 TimerComponent ()
 
 ~TimerComponent () override
 
bool Initialize (const TimerComponentConfig &config) override
 init the component by protobuf object.
 
void Clear () override
 
bool Process ()
 
uint32_t GetInterval () const
 
- Public 成员函数 继承自 apollo::cyber::ComponentBase
virtual ~ComponentBase ()
 
virtual bool Initialize (const ComponentConfig &config)
 
virtual void Shutdown ()
 
template<typename T >
bool GetProtoConfig (T *config) const
 

额外继承的成员函数

- Public 类型 继承自 apollo::cyber::ComponentBase
template<typename M >
using Reader = cyber::Reader< M >
 
- Protected 成员函数 继承自 apollo::cyber::ComponentBase
virtual bool Init ()=0
 
const std::string & ConfigFilePath () const
 
void LoadConfigFiles (const ComponentConfig &config)
 
void LoadConfigFiles (const TimerComponentConfig &config)
 
- Protected 属性 继承自 apollo::cyber::ComponentBase
std::atomic< bool > is_shutdown_ = {false}
 
std::shared_ptr< Nodenode_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

TimerComponent is a timer component. Your component can inherit from Component, and implement Init() & Proc(), They are called by the CyberRT frame.

在文件 timer_component.h35 行定义.

构造及析构函数说明

◆ TimerComponent()

apollo::cyber::TimerComponent::TimerComponent ( )

在文件 timer_component.cc25 行定义.

25{}

◆ ~TimerComponent()

apollo::cyber::TimerComponent::~TimerComponent ( )
override

在文件 timer_component.cc27 行定义.

27{}

成员函数说明

◆ Clear()

void apollo::cyber::TimerComponent::Clear ( )
overridevirtual

重载 apollo::cyber::ComponentBase .

在文件 timer_component.cc68 行定义.

68{ timer_.reset(); }

◆ GetInterval()

uint32_t apollo::cyber::TimerComponent::GetInterval ( ) const

在文件 timer_component.cc70 行定义.

70{ return interval_; }

◆ Initialize()

bool apollo::cyber::TimerComponent::Initialize ( const TimerComponentConfig config)
overridevirtual

init the component by protobuf object.

参数
configwhich is define in 'cyber/proto/component_conf.proto'
返回
returns true if successful, otherwise returns false

重载 apollo::cyber::ComponentBase .

在文件 timer_component.cc36 行定义.

36 {
37 if (!config.has_name() || !config.has_interval()) {
38 AERROR << "Missing required field in config file.";
39 return false;
40 }
41 node_.reset(new Node(config.name()));
42 LoadConfigFiles(config);
43 if (!Init()) {
44 return false;
45 }
46 interval_ = config.interval();
47
48 auto role_attr = std::make_shared<proto::RoleAttributes>();
49 role_attr->set_node_name(config.name());
50 role_attr->set_channel_name(statistics::TIMER_COMPONENT_CHAN_NAME);
51 statistics::Statistics::Instance()->RegisterChanVar(*role_attr);
52
53 std::shared_ptr<TimerComponent> self =
54 std::dynamic_pointer_cast<TimerComponent>(shared_from_this());
55 auto func = [self, role_attr]() {
56 auto start_time = Time::Now().ToNanosecond();
57 self->Process();
58 auto end_time = Time::Now().ToNanosecond();
59 // sampling proc latency in microsecond
60 statistics::Statistics::Instance()->SamplingProcLatency<
61 uint64_t>(*role_attr, (end_time-start_time)/1000);
62 };
63 timer_.reset(new Timer(config.interval(), func, false));
64 timer_->Start();
65 return true;
66}
Definition node.h:31
std::shared_ptr< Node > node_
void LoadConfigFiles(const ComponentConfig &config)
uint64_t ToNanosecond() const
convert time to nanosecond.
Definition time.cc:83
static Time Now()
get the current time.
Definition time.cc:57
#define AERROR
Definition log.h:44

◆ Process()

bool apollo::cyber::TimerComponent::Process ( )

在文件 timer_component.cc29 行定义.

29 {
30 if (is_shutdown_.load()) {
31 return true;
32 }
33 return Proc();
34}
std::atomic< bool > is_shutdown_

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