操作系统:Windows 10
代码分析工具:Scientific.Toolworks.Understand.5.0
在control_thread.cc的controlThread这个类名上右键选择Cluster Callby,则出现该类的成员方法以及外部调用关系:
注:在分析的时候,建议将utils/front-end-cal下的main.cc从工程移除,不然它会和主main.cc混淆。
在ControlThread类的init中:
void ControlThread::init()
{}
这几句这工具分析不出来,我们可以知道,最重要的就是它实例化了一个GNSSFlowgraph。
将主线无关的东西隐去,可以得到:
这个GNSSBlockFactory是整个程序非常重要的一个类,单独解说。
之所以称之为Factory,是继承自GNURadio的说法,在这里批量制造模块。
它的构造函数是空的,里面一堆的东西都是为信号处理模块服务的。
其中最重要的函数是GetBlock:
std::unique_ptr
std::shared_ptr
std::string role,
std::string implementation, unsigned int in_streams,
unsigned int out_streams, gr::msg_queue::sptr queue)
{
std::unique_ptr
...}
调用GetBlock的时候,其实是将配置文件里的implementation与已定义的算法模块名称逐个比较,如果有匹配项,则创建模块对象:
else if (implementation.compare("GPS_L1_CA_PCPS_Acquisition") == 0)
{
std::unique_ptr
out_streams));
block = std::move(block_);
}
而三个特殊函数:GetAcqBlock、GetTrkBlock、GetTlmBlock,其实也是各做了一部分事情,就是比较implementation与Acq、Trk、Tlm模块名是否一致,一致则创建模块实例。
而谁来调用它呢?GetChannel_XX,事实上每个GetChannel_XX函数都调用了一遍这几个函数,最后return了一个channel对象:
std::unique_ptr
std::unique_ptr
std::unique_ptr
std::unique_ptr
这几句很关键,第一句GetBlock实现创建block_;
if (implementation.compare("Pass_Through") == 0)
{第二句GetAcqBlock实现创建block_;
if (implementation.compare("GPS_L1_CA_PCPS_Acquisition") == 0)
{
std::unique_ptr
out_streams));
block = std::move(block_);
}
第三、四句类似。
那么问题来了,这个GetChannel_XX是哪里调用的呢?这里:
GetChannels(),它又是哪里调用的呢?事实上是GNSSFlowgraph的init调用的
通过对象block_factory_调用了几乎所有的成员函数,当然,GetChannel_XX是通过GetChannels调用的。