Apollo 11.0
自动驾驶开放平台
apollo::resource_statistic::ResourceStatisticComponent类 参考

#include <resource_statistic_component.h>

类 apollo::resource_statistic::ResourceStatisticComponent 继承关系图:
apollo::resource_statistic::ResourceStatisticComponent 的协作图:

Public 成员函数

bool Init () override
 
bool Proc () override
 The Proc logic of the component, which called by the CyberRT frame.
 
- Public 成员函数 继承自 apollo::cyber::TimerComponent
 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
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< Node > node_ = nullptr
 
std::string config_file_path_ = ""
 
std::vector< std::shared_ptr< ReaderBase > > readers_
 

详细描述

在文件 resource_statistic_component.h 第 36 行定义.

成员函数说明

◆ Init()

bool apollo::resource_statistic::ResourceStatisticComponent::Init ( )
overridevirtual

实现了 apollo::cyber::ComponentBase.

在文件 resource_statistic_component.cc 第 24 行定义.

24 {
25 // hook: Apollo License Verification: v_apollo_park
26 ResourceStatisticConf conf;
27 if (!ComponentBase::GetProtoConfig(&conf)) {
28 AERROR << "Unable to load resource statistic conf file: " << ComponentBase::ConfigFilePath();
29 return false;
30 }
31 LoadConf(conf);
32 disk_statistic_.SetInterval(GetInterval());
33 // create metric writer
34 metric_writer_ = node_->CreateWriter<ResourceMetrics>(FLAGS_resource_statistic_topic);
35 return true;
36}
std::shared_ptr< Node > node_
void SetInterval(uint32_t interval)
Set timer component interval.
#define AERROR
Definition log.h:44

◆ Proc()

bool apollo::resource_statistic::ResourceStatisticComponent::Proc ( )
overridevirtual

The Proc logic of the component, which called by the CyberRT frame.

返回
returns true if successful, otherwise returns false

实现了 apollo::cyber::TimerComponent.

在文件 resource_statistic_component.cc 第 44 行定义.

44 {
45 auto metrics = std::make_shared<ResourceMetrics>();
46 apollo::common::util::FillHeader(node_->Name(), metrics.get());
47
48 auto cpu_metric = metrics->mutable_cpu();
49 cpu_statistic_.GetCpuMetric(cpu_metric);
50
51 auto gpu_metric = metrics->mutable_gpu();
52 gpu_statistic_.GetGpuMetric(gpu_metric);
53
54 auto mem_metric = metrics->mutable_memory();
55 mem_statistic_.GetMemoryMetric(mem_metric);
56
57 auto disk_metric = metrics->mutable_disk();
58 disk_statistic_.GetDiskMetric(disk_metric);
59
60 metric_writer_->Write(metrics);
61 return true;
62}
bool GetCpuMetric(CpuMetric *cpu_metric)
Get CPU metric and write it into cpu_metric.
bool GetDiskMetric(DiskMetric *disk_metric)
Get Disk metric and write it into disk_metric.
bool GetGpuMetric(GpuMetric *gpu_metric)
Get GPU metric and write it into gpu_metric.
bool GetMemoryMetric(MemoryMetric *mem_metric)
Get memory metric and write it into mem_metric.

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