66 lines
2.3 KiB
C++
66 lines
2.3 KiB
C++
|
#include "GroundHandling_heartbeat.hpp"
|
|||
|
|
|||
|
namespace XNSim::C909::ATA04
|
|||
|
{
|
|||
|
GroundHandling_heartbeat_Interface::GroundHandling_heartbeat_Interface()
|
|||
|
{
|
|||
|
MAP_DATA_FUNC(groundhandling_model_heartbeat);
|
|||
|
this->header[0] = 0xa6; // XNSim头,0xa6
|
|||
|
this->header[1] = 0xc0; // 机型头,0xc0表示C909
|
|||
|
this->header[2] = 0x04; // 章节头,0x04表示ATA04
|
|||
|
this->header[3] = 0x01; // 模型头,0x01表示GroundHandling
|
|||
|
this->header[4] = 0x02; // 结构体头,0x02表示心跳结构体
|
|||
|
this->header[5] = 0x00; // 数据方向,0x00表示外部输入
|
|||
|
this->header[6] = 0x00; // 数据大小
|
|||
|
this->header[7] = 0x00; // 数据大小
|
|||
|
}
|
|||
|
|
|||
|
GroundHandling_heartbeat_Interface::~GroundHandling_heartbeat_Interface()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
void GroundHandling_heartbeat_Interface::Initialize(XNFrameworkPtr framework, uint32_t modelId,
|
|||
|
uint32_t DDS_type)
|
|||
|
{
|
|||
|
auto ddsManager = framework->GetDDSManager();
|
|||
|
if (!ddsManager) {
|
|||
|
LOG_ERROR("DDSManager is nullptr");
|
|||
|
return;
|
|||
|
}
|
|||
|
if (DDS_type == 0) { // 读取与发送都进行
|
|||
|
dataWriter =
|
|||
|
ddsManager->RegisterPublisher<XNSim::C909::ATA04::GroundHandling_heartbeatPubSubType>(
|
|||
|
"XNSim::C909::ATA04::GroundHandling_heartbeat", modelId);
|
|||
|
ddsManager->RegisterSubscriber<XNSim::C909::ATA04::GroundHandling_heartbeatPubSubType>(
|
|||
|
"XNSim::C909::ATA04::GroundHandling_heartbeat", modelId,
|
|||
|
std::bind(&GroundHandling_heartbeat_Interface::heartbeatListener, this,
|
|||
|
std::placeholders::_1));
|
|||
|
} else if (DDS_type == 1) { // 只读取
|
|||
|
ddsManager->RegisterSubscriber<XNSim::C909::ATA04::GroundHandling_heartbeatPubSubType>(
|
|||
|
"XNSim::C909::ATA04::GroundHandling_heartbeat", modelId,
|
|||
|
std::bind(&GroundHandling_heartbeat_Interface::heartbeatListener, this,
|
|||
|
std::placeholders::_1));
|
|||
|
} else if (DDS_type == 2) { // 只发送
|
|||
|
dataWriter =
|
|||
|
ddsManager->RegisterPublisher<XNSim::C909::ATA04::GroundHandling_heartbeatPubSubType>(
|
|||
|
"XNSim::C909::ATA04::GroundHandling_heartbeat", modelId);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void GroundHandling_heartbeat_Interface::clearOutData()
|
|||
|
{
|
|||
|
this->out_data = XNSim::C909::ATA04::GroundHandling_heartbeat();
|
|||
|
}
|
|||
|
|
|||
|
void GroundHandling_heartbeat_Interface::sendOutData()
|
|||
|
{
|
|||
|
dataWriter->write(&this->out_data);
|
|||
|
}
|
|||
|
|
|||
|
void GroundHandling_heartbeat_Interface::heartbeatListener(
|
|||
|
const XNSim::C909::ATA04::GroundHandling_heartbeat &heartbeat)
|
|||
|
{
|
|||
|
this->data = heartbeat;
|
|||
|
}
|
|||
|
} // namespace XNSim::C909::ATA04
|