Compare commits

...

15 Commits

Author SHA1 Message Date
069ea0ea37 修改了一些报错消息,并使用数据库存储报错信息,以便后续查阅 2025-06-06 17:03:35 +08:00
25ca69597b 数据监控已经连通,还差绘图和注入功能未实现 2025-06-06 11:02:12 +08:00
3fe2d4aa0e 修复了质量模型中的错误 2025-06-04 15:26:50 +08:00
b2e5036b2c 修复无法调取数据包模型的问题 2025-06-04 14:00:46 +08:00
fefd229495 完成了数据监控页面的界面绘制,功能暂未实现 2025-06-03 16:55:53 +08:00
cf69eddebe 修改了接口的自动生成内容,添加了监控服务的数据采集与注入接口 2025-05-30 14:16:16 +08:00
d5bdea448e 新增QTG和网络监控页面,暂未实现具体功能 2025-05-29 15:43:17 +08:00
a6a6892897 修改了仿真监控和模型监控 2025-05-29 15:18:31 +08:00
04767fe971 增加了引擎的暂停与结束控制 2025-05-29 14:38:09 +08:00
0296daa268 将运行测试和运行仿真合二为一 2025-05-29 10:01:36 +08:00
5ae0ecae52 更新了运行测试页面 2025-05-29 09:26:44 +08:00
7c5021958d 完成构型配置页面 2025-05-28 16:20:01 +08:00
6b2158c26e 模型开发和服务开发页面更新 2025-05-28 10:01:28 +08:00
896b46a1b1 为XNSim添加了可以从数据库直接读取数据进行仿真的能力。现在同时支持数据库和配置文件两种模式 2025-05-27 15:16:11 +08:00
7da7a8a5ee 修改XNEngine支持数据库读取,还未完成 2025-05-26 17:01:23 +08:00
172 changed files with 7979 additions and 11028 deletions

1
.gitignore vendored
View File

@ -38,3 +38,4 @@ build/
#log
log/
logs/
Packages/

View File

@ -0,0 +1,73 @@
{
"files.associations": {
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"chrono": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdint": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"ranges": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"valarray": "cpp",
"variant": "cpp"
}
}

View File

@ -1,4 +1,5 @@
#include "Aerodynamics_heartbeat.hpp"
const std::string XNSim::C909::ATA04::Aerodynamics_heartbeat_Interface::topic_name = "XNSim::C909::ATA04::Aerodynamics_heartbeat";
namespace XNSim::C909::ATA04
{
Aerodynamics_heartbeat_Interface::Aerodynamics_heartbeat_Interface()

View File

@ -3,9 +3,12 @@
#include "XNCore/XNDDSInterface.h"
namespace XNSim::C909::ATA04
{
class Aerodynamics_heartbeat_Interface final : public XNDDSInterface
class Aerodynamics_heartbeat_Interface : public XNDDSInterface
{
public:
using DDSType = XNSim::C909::ATA04::Aerodynamics_heartbeat;
using DDSPubSubType = XNSim::C909::ATA04::Aerodynamics_heartbeatPubSubType;
static const std::string topic_name;
Aerodynamics_heartbeat_Interface();
virtual ~Aerodynamics_heartbeat_Interface();
virtual void Initialize(XNFrameworkPtr framework, uint32_t modelId, uint32_t DDS_type) override;
@ -27,10 +30,11 @@ public:
return;
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();
assign_value_set(data.aero_model_heartbeat(), model_data->aero_model_heartbeat);
assign_value_set(out_data.aero_model_heartbeat(), model_data->aero_model_heartbeat);
sendOutData();
}
private:
XNSim::C909::ATA04::Aerodynamics_heartbeat data;
XNSim::C909::ATA04::Aerodynamics_heartbeat out_data;
protected:
DDSType data;
DDSType out_data;
};
}

View File

@ -1,4 +1,5 @@
#include "Aerodynamics_input.hpp"
const std::string XNSim::C909::ATA04::Aerodynamics_input_Interface::topic_name = "XNSim::C909::ATA04::Aerodynamics_input";
namespace XNSim::C909::ATA04
{
Aerodynamics_input_Interface::Aerodynamics_input_Interface()

View File

@ -3,9 +3,12 @@
#include "XNCore/XNDDSInterface.h"
namespace XNSim::C909::ATA04
{
class Aerodynamics_input_Interface final : public XNDDSInterface
class Aerodynamics_input_Interface : public XNDDSInterface
{
public:
using DDSType = XNSim::C909::ATA04::Aerodynamics_input;
using DDSPubSubType = XNSim::C909::ATA04::Aerodynamics_inputPubSubType;
static const std::string topic_name;
Aerodynamics_input_Interface();
virtual ~Aerodynamics_input_Interface();
virtual void Initialize(XNFrameworkPtr framework, uint32_t modelId, uint32_t DDS_type) override;
@ -53,36 +56,37 @@ public:
return;
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();
assign_value_set(data.l_04_i_aerocomac_alpha_f8(), model_data->l_04_i_aerocomac_alpha_f8);
assign_value_set(data.l_04_i_aerocomac_alpdot_f8(), model_data->l_04_i_aerocomac_alpdot_f8);
assign_value_set(data.l_04_i_aerocomac_beta_f8(), model_data->l_04_i_aerocomac_beta_f8);
assign_value_set(data.l_04_i_aerocomac_press_alt_f8(), model_data->l_04_i_aerocomac_press_alt_f8);
assign_value_set(data.l_04_i_aerocomac_tas_f8(), model_data->l_04_i_aerocomac_tas_f8);
assign_value_set(data.l_04_i_aerocomac_mach_f8(), model_data->l_04_i_aerocomac_mach_f8);
assign_value_set(data.l_04_i_aerocomac_nx_f8(), model_data->l_04_i_aerocomac_nx_f8);
assign_value_set(data.l_04_i_aerocomac_ny_f8(), model_data->l_04_i_aerocomac_ny_f8);
assign_value_set(data.l_04_i_aerocomac_nz_f8(), model_data->l_04_i_aerocomac_nz_f8);
assign_value_set(data.l_04_i_aerocomac_p_f8(), model_data->l_04_i_aerocomac_p_f8);
assign_value_set(data.l_04_i_aerocomac_q_f8(), model_data->l_04_i_aerocomac_q_f8);
assign_value_set(data.l_04_i_aerocomac_r_f8(), model_data->l_04_i_aerocomac_r_f8);
assign_value_set(data.l_04_i_aerocomac_qbar_f8(), model_data->l_04_i_aerocomac_qbar_f8);
assign_value_set(data.l_04_i_aerocomac_blcg_f8(), model_data->l_04_i_aerocomac_blcg_f8);
assign_value_set(data.l_04_i_aerocomac_bscg_f8(), model_data->l_04_i_aerocomac_bscg_f8);
assign_value_set(data.l_04_i_aerocomac_wlcg_f8(), model_data->l_04_i_aerocomac_wlcg_f8);
assign_value_set(data.l_04_i_aerocomac_ail_f8(), model_data->l_04_i_aerocomac_ail_f8);
assign_value_set(data.l_04_i_aerocomac_elv_f8(), model_data->l_04_i_aerocomac_elv_f8);
assign_value_set(data.l_04_i_aerocomac_rud_f8(), model_data->l_04_i_aerocomac_rud_f8);
assign_value_set(data.l_04_i_aerocomac_stab_f8(), model_data->l_04_i_aerocomac_stab_f8);
assign_value_set(data.l_04_i_aerocomac_gear_f8(), model_data->l_04_i_aerocomac_gear_f8);
assign_value_set(data.l_04_i_aerocomac_flap_f8(), model_data->l_04_i_aerocomac_flap_f8);
assign_value_set(data.l_04_i_aerocomac_slat_f8(), model_data->l_04_i_aerocomac_slat_f8);
assign_value_set(data.l_04_i_aerocomac_spl_f8(), model_data->l_04_i_aerocomac_spl_f8);
assign_value_set(data.l_04_i_aerocomac_tnet_f8(), model_data->l_04_i_aerocomac_tnet_f8);
assign_value_set(data.l_04_i_aerocomac_kice_f8(), model_data->l_04_i_aerocomac_kice_f8);
assign_value_set(data.l_04_i_aerocomac_alt_agl_f8(), model_data->l_04_i_aerocomac_alt_agl_f8);
assign_value_set(out_data.l_04_i_aerocomac_alpha_f8(), model_data->l_04_i_aerocomac_alpha_f8);
assign_value_set(out_data.l_04_i_aerocomac_alpdot_f8(), model_data->l_04_i_aerocomac_alpdot_f8);
assign_value_set(out_data.l_04_i_aerocomac_beta_f8(), model_data->l_04_i_aerocomac_beta_f8);
assign_value_set(out_data.l_04_i_aerocomac_press_alt_f8(), model_data->l_04_i_aerocomac_press_alt_f8);
assign_value_set(out_data.l_04_i_aerocomac_tas_f8(), model_data->l_04_i_aerocomac_tas_f8);
assign_value_set(out_data.l_04_i_aerocomac_mach_f8(), model_data->l_04_i_aerocomac_mach_f8);
assign_value_set(out_data.l_04_i_aerocomac_nx_f8(), model_data->l_04_i_aerocomac_nx_f8);
assign_value_set(out_data.l_04_i_aerocomac_ny_f8(), model_data->l_04_i_aerocomac_ny_f8);
assign_value_set(out_data.l_04_i_aerocomac_nz_f8(), model_data->l_04_i_aerocomac_nz_f8);
assign_value_set(out_data.l_04_i_aerocomac_p_f8(), model_data->l_04_i_aerocomac_p_f8);
assign_value_set(out_data.l_04_i_aerocomac_q_f8(), model_data->l_04_i_aerocomac_q_f8);
assign_value_set(out_data.l_04_i_aerocomac_r_f8(), model_data->l_04_i_aerocomac_r_f8);
assign_value_set(out_data.l_04_i_aerocomac_qbar_f8(), model_data->l_04_i_aerocomac_qbar_f8);
assign_value_set(out_data.l_04_i_aerocomac_blcg_f8(), model_data->l_04_i_aerocomac_blcg_f8);
assign_value_set(out_data.l_04_i_aerocomac_bscg_f8(), model_data->l_04_i_aerocomac_bscg_f8);
assign_value_set(out_data.l_04_i_aerocomac_wlcg_f8(), model_data->l_04_i_aerocomac_wlcg_f8);
assign_value_set(out_data.l_04_i_aerocomac_ail_f8(), model_data->l_04_i_aerocomac_ail_f8);
assign_value_set(out_data.l_04_i_aerocomac_elv_f8(), model_data->l_04_i_aerocomac_elv_f8);
assign_value_set(out_data.l_04_i_aerocomac_rud_f8(), model_data->l_04_i_aerocomac_rud_f8);
assign_value_set(out_data.l_04_i_aerocomac_stab_f8(), model_data->l_04_i_aerocomac_stab_f8);
assign_value_set(out_data.l_04_i_aerocomac_gear_f8(), model_data->l_04_i_aerocomac_gear_f8);
assign_value_set(out_data.l_04_i_aerocomac_flap_f8(), model_data->l_04_i_aerocomac_flap_f8);
assign_value_set(out_data.l_04_i_aerocomac_slat_f8(), model_data->l_04_i_aerocomac_slat_f8);
assign_value_set(out_data.l_04_i_aerocomac_spl_f8(), model_data->l_04_i_aerocomac_spl_f8);
assign_value_set(out_data.l_04_i_aerocomac_tnet_f8(), model_data->l_04_i_aerocomac_tnet_f8);
assign_value_set(out_data.l_04_i_aerocomac_kice_f8(), model_data->l_04_i_aerocomac_kice_f8);
assign_value_set(out_data.l_04_i_aerocomac_alt_agl_f8(), model_data->l_04_i_aerocomac_alt_agl_f8);
sendOutData();
}
private:
XNSim::C909::ATA04::Aerodynamics_input data;
XNSim::C909::ATA04::Aerodynamics_input out_data;
protected:
DDSType data;
DDSType out_data;
};
}

View File

@ -1,4 +1,5 @@
#include "Aerodynamics_output.hpp"
const std::string XNSim::C909::ATA04::Aerodynamics_output_Interface::topic_name = "XNSim::C909::ATA04::Aerodynamics_output";
namespace XNSim::C909::ATA04
{
Aerodynamics_output_Interface::Aerodynamics_output_Interface()

View File

@ -3,9 +3,12 @@
#include "XNCore/XNDDSInterface.h"
namespace XNSim::C909::ATA04
{
class Aerodynamics_output_Interface final : public XNDDSInterface
class Aerodynamics_output_Interface : public XNDDSInterface
{
public:
using DDSType = XNSim::C909::ATA04::Aerodynamics_output;
using DDSPubSubType = XNSim::C909::ATA04::Aerodynamics_outputPubSubType;
static const std::string topic_name;
Aerodynamics_output_Interface();
virtual ~Aerodynamics_output_Interface();
virtual void Initialize(XNFrameworkPtr framework, uint32_t modelId, uint32_t DDS_type) override;
@ -39,22 +42,23 @@ public:
return;
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();
assign_value_set(data.l_04_o_aerocomac_fxb_f8(), model_data->l_04_o_aerocomac_fxb_f8);
assign_value_set(data.l_04_o_aerocomac_fyb_f8(), model_data->l_04_o_aerocomac_fyb_f8);
assign_value_set(data.l_04_o_aerocomac_fzb_f8(), model_data->l_04_o_aerocomac_fzb_f8);
assign_value_set(data.l_04_o_aerocomac_mxb_f8(), model_data->l_04_o_aerocomac_mxb_f8);
assign_value_set(data.l_04_o_aerocomac_myb_f8(), model_data->l_04_o_aerocomac_myb_f8);
assign_value_set(data.l_04_o_aerocomac_mzb_f8(), model_data->l_04_o_aerocomac_mzb_f8);
assign_value_set(data.l_04_o_aerocomac_cls_f8(), model_data->l_04_o_aerocomac_cls_f8);
assign_value_set(data.l_04_o_aerocomac_cl_f8(), model_data->l_04_o_aerocomac_cl_f8);
assign_value_set(data.l_04_o_aerocomac_cd_f8(), model_data->l_04_o_aerocomac_cd_f8);
assign_value_set(data.l_04_o_aerocomac_cm_f8(), model_data->l_04_o_aerocomac_cm_f8);
assign_value_set(data.l_04_o_aerocomac_cr_f8(), model_data->l_04_o_aerocomac_cr_f8);
assign_value_set(data.l_04_o_aerocomac_cy_f8(), model_data->l_04_o_aerocomac_cy_f8);
assign_value_set(data.l_04_o_aerocomac_cn_f8(), model_data->l_04_o_aerocomac_cn_f8);
assign_value_set(out_data.l_04_o_aerocomac_fxb_f8(), model_data->l_04_o_aerocomac_fxb_f8);
assign_value_set(out_data.l_04_o_aerocomac_fyb_f8(), model_data->l_04_o_aerocomac_fyb_f8);
assign_value_set(out_data.l_04_o_aerocomac_fzb_f8(), model_data->l_04_o_aerocomac_fzb_f8);
assign_value_set(out_data.l_04_o_aerocomac_mxb_f8(), model_data->l_04_o_aerocomac_mxb_f8);
assign_value_set(out_data.l_04_o_aerocomac_myb_f8(), model_data->l_04_o_aerocomac_myb_f8);
assign_value_set(out_data.l_04_o_aerocomac_mzb_f8(), model_data->l_04_o_aerocomac_mzb_f8);
assign_value_set(out_data.l_04_o_aerocomac_cls_f8(), model_data->l_04_o_aerocomac_cls_f8);
assign_value_set(out_data.l_04_o_aerocomac_cl_f8(), model_data->l_04_o_aerocomac_cl_f8);
assign_value_set(out_data.l_04_o_aerocomac_cd_f8(), model_data->l_04_o_aerocomac_cd_f8);
assign_value_set(out_data.l_04_o_aerocomac_cm_f8(), model_data->l_04_o_aerocomac_cm_f8);
assign_value_set(out_data.l_04_o_aerocomac_cr_f8(), model_data->l_04_o_aerocomac_cr_f8);
assign_value_set(out_data.l_04_o_aerocomac_cy_f8(), model_data->l_04_o_aerocomac_cy_f8);
assign_value_set(out_data.l_04_o_aerocomac_cn_f8(), model_data->l_04_o_aerocomac_cn_f8);
sendOutData();
}
private:
XNSim::C909::ATA04::Aerodynamics_output data;
XNSim::C909::ATA04::Aerodynamics_output out_data;
protected:
DDSType data;
DDSType out_data;
};
}

View File

@ -1,4 +1,5 @@
#include "GroundHandling_heartbeat.hpp"
const std::string XNSim::C909::ATA04::GroundHandling_heartbeat_Interface::topic_name = "XNSim::C909::ATA04::GroundHandling_heartbeat";
namespace XNSim::C909::ATA04
{
GroundHandling_heartbeat_Interface::GroundHandling_heartbeat_Interface()

View File

@ -3,9 +3,12 @@
#include "XNCore/XNDDSInterface.h"
namespace XNSim::C909::ATA04
{
class GroundHandling_heartbeat_Interface final : public XNDDSInterface
class GroundHandling_heartbeat_Interface : public XNDDSInterface
{
public:
using DDSType = XNSim::C909::ATA04::GroundHandling_heartbeat;
using DDSPubSubType = XNSim::C909::ATA04::GroundHandling_heartbeatPubSubType;
static const std::string topic_name;
GroundHandling_heartbeat_Interface();
virtual ~GroundHandling_heartbeat_Interface();
virtual void Initialize(XNFrameworkPtr framework, uint32_t modelId, uint32_t DDS_type) override;
@ -27,10 +30,11 @@ public:
return;
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();
assign_value_set(data.groundhandling_model_heartbeat(), model_data->groundhandling_model_heartbeat);
assign_value_set(out_data.groundhandling_model_heartbeat(), model_data->groundhandling_model_heartbeat);
sendOutData();
}
private:
XNSim::C909::ATA04::GroundHandling_heartbeat data;
XNSim::C909::ATA04::GroundHandling_heartbeat out_data;
protected:
DDSType data;
DDSType out_data;
};
}

View File

@ -1,4 +1,5 @@
#include "GroundHandling_input.hpp"
const std::string XNSim::C909::ATA04::GroundHandling_input_Interface::topic_name = "XNSim::C909::ATA04::GroundHandling_input";
namespace XNSim::C909::ATA04
{
GroundHandling_input_Interface::GroundHandling_input_Interface()

View File

@ -3,9 +3,12 @@
#include "XNCore/XNDDSInterface.h"
namespace XNSim::C909::ATA04
{
class GroundHandling_input_Interface final : public XNDDSInterface
class GroundHandling_input_Interface : public XNDDSInterface
{
public:
using DDSType = XNSim::C909::ATA04::GroundHandling_input;
using DDSPubSubType = XNSim::C909::ATA04::GroundHandling_inputPubSubType;
static const std::string topic_name;
GroundHandling_input_Interface();
virtual ~GroundHandling_input_Interface();
virtual void Initialize(XNFrameworkPtr framework, uint32_t modelId, uint32_t DDS_type) override;
@ -65,48 +68,49 @@ public:
return;
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();
assign_value_set(data.l_04_i_gdcomac_frz_l1(), model_data->l_04_i_gdcomac_frz_l1);
assign_value_set(data.l_04_i_gdcomac_chocks_l1(), model_data->l_04_i_gdcomac_chocks_l1);
assign_value_set(data.l_04_i_gdcomac_alt_agl_f8(), model_data->l_04_i_gdcomac_alt_agl_f8);
assign_value_set(data.l_04_i_gdcomac_frzflt_l1(), model_data->l_04_i_gdcomac_frzflt_l1);
assign_value_set(data.l_04_i_gdcomac_p_f8(), model_data->l_04_i_gdcomac_p_f8);
assign_value_set(data.l_04_i_gdcomac_q_f8(), model_data->l_04_i_gdcomac_q_f8);
assign_value_set(data.l_04_i_gdcomac_r_f8(), model_data->l_04_i_gdcomac_r_f8);
assign_value_set(data.l_04_i_gdcomac_ug_f8(), model_data->l_04_i_gdcomac_ug_f8);
assign_value_set(data.l_04_i_gdcomac_vg_f8(), model_data->l_04_i_gdcomac_vg_f8);
assign_value_set(data.l_04_i_gdcomac_wg_f8(), model_data->l_04_i_gdcomac_wg_f8);
assign_value_set(data.l_04_i_gdcomac_blcg_f8(), model_data->l_04_i_gdcomac_blcg_f8);
assign_value_set(data.l_04_i_gdcomac_bscg_f8(), model_data->l_04_i_gdcomac_bscg_f8);
assign_value_set(data.l_04_i_gdcomac_wlcg_f8(), model_data->l_04_i_gdcomac_wlcg_f8);
assign_value_set(data.l_04_i_gdcomac_pb_active_l1(), model_data->l_04_i_gdcomac_pb_active_l1);
assign_value_set(data.l_04_i_gdcomac_brake_torq_f8(), model_data->l_04_i_gdcomac_brake_torq_f8);
assign_value_set(data.l_04_i_gdcomac_gear_f8(), model_data->l_04_i_gdcomac_gear_f8);
assign_value_set(data.l_04_i_gdcomac_gsteer_f8(), model_data->l_04_i_gdcomac_gsteer_f8);
assign_value_set(data.l_04_i_gdcomac_tire_pres_f8(), model_data->l_04_i_gdcomac_tire_pres_f8);
assign_value_set(data.l_04_i_gdcomac_onjax_l1(), model_data->l_04_i_gdcomac_onjax_l1);
assign_value_set(data.l_04_i_gdcomac_contdep_f8(), model_data->l_04_i_gdcomac_contdep_f8);
assign_value_set(data.l_04_i_gdcomac_thetag_f8(), model_data->l_04_i_gdcomac_thetag_f8);
assign_value_set(data.l_04_i_gdcomac_phig_f8(), model_data->l_04_i_gdcomac_phig_f8);
assign_value_set(data.l_04_i_gdcomac_rwyrgh_i2(), model_data->l_04_i_gdcomac_rwyrgh_i2);
assign_value_set(data.l_04_i_gdcomac_rwyhdg_f8(), model_data->l_04_i_gdcomac_rwyhdg_f8);
assign_value_set(data.l_04_i_gdcomac_reset_braketemp_l1(), model_data->l_04_i_gdcomac_reset_braketemp_l1);
assign_value_set(data.l_04_i_gdcomac_reset_tirepress_l1(), model_data->l_04_i_gdcomac_reset_tirepress_l1);
assign_value_set(data.l_04_i_gdcomac_temp_c_f8(), model_data->l_04_i_gdcomac_temp_c_f8);
assign_value_set(data.l_04_i_gdcomac_brake_temp_f8(), model_data->l_04_i_gdcomac_brake_temp_f8);
assign_value_set(data.l_04_i_gdcomac_tire_tburst_l1(), model_data->l_04_i_gdcomac_tire_tburst_l1);
assign_value_set(data.l_04_i_gdcomac_tire_tflat_l1(), model_data->l_04_i_gdcomac_tire_tflat_l1);
assign_value_set(data.l_04_i_gdcomac_brk_reset_tpres_l1(), model_data->l_04_i_gdcomac_brk_reset_tpres_l1);
assign_value_set(data.l_04_i_gdcomac_rcon_ci_f8(), model_data->l_04_i_gdcomac_rcon_ci_f8);
assign_value_set(data.l_04_i_gdcomac_pb_towforce_f8(), model_data->l_04_i_gdcomac_pb_towforce_f8);
assign_value_set(data.l_04_i_gdcomac_gsteer_state_i4(), model_data->l_04_i_gdcomac_gsteer_state_i4);
assign_value_set(data.l_04_i_gdcomac_trim_active_l1(), model_data->l_04_i_gdcomac_trim_active_l1);
assign_value_set(data.l_04_i_gdcomac_phi_deg_f8(), model_data->l_04_i_gdcomac_phi_deg_f8);
assign_value_set(data.l_04_i_gdcomac_theta_deg_f8(), model_data->l_04_i_gdcomac_theta_deg_f8);
assign_value_set(data.l_04_i_gdcomac_psi_deg_f8(), model_data->l_04_i_gdcomac_psi_deg_f8);
assign_value_set(data.l_04_i_gdcomac_resetint_l1(), model_data->l_04_i_gdcomac_resetint_l1);
assign_value_set(out_data.l_04_i_gdcomac_frz_l1(), model_data->l_04_i_gdcomac_frz_l1);
assign_value_set(out_data.l_04_i_gdcomac_chocks_l1(), model_data->l_04_i_gdcomac_chocks_l1);
assign_value_set(out_data.l_04_i_gdcomac_alt_agl_f8(), model_data->l_04_i_gdcomac_alt_agl_f8);
assign_value_set(out_data.l_04_i_gdcomac_frzflt_l1(), model_data->l_04_i_gdcomac_frzflt_l1);
assign_value_set(out_data.l_04_i_gdcomac_p_f8(), model_data->l_04_i_gdcomac_p_f8);
assign_value_set(out_data.l_04_i_gdcomac_q_f8(), model_data->l_04_i_gdcomac_q_f8);
assign_value_set(out_data.l_04_i_gdcomac_r_f8(), model_data->l_04_i_gdcomac_r_f8);
assign_value_set(out_data.l_04_i_gdcomac_ug_f8(), model_data->l_04_i_gdcomac_ug_f8);
assign_value_set(out_data.l_04_i_gdcomac_vg_f8(), model_data->l_04_i_gdcomac_vg_f8);
assign_value_set(out_data.l_04_i_gdcomac_wg_f8(), model_data->l_04_i_gdcomac_wg_f8);
assign_value_set(out_data.l_04_i_gdcomac_blcg_f8(), model_data->l_04_i_gdcomac_blcg_f8);
assign_value_set(out_data.l_04_i_gdcomac_bscg_f8(), model_data->l_04_i_gdcomac_bscg_f8);
assign_value_set(out_data.l_04_i_gdcomac_wlcg_f8(), model_data->l_04_i_gdcomac_wlcg_f8);
assign_value_set(out_data.l_04_i_gdcomac_pb_active_l1(), model_data->l_04_i_gdcomac_pb_active_l1);
assign_value_set(out_data.l_04_i_gdcomac_brake_torq_f8(), model_data->l_04_i_gdcomac_brake_torq_f8);
assign_value_set(out_data.l_04_i_gdcomac_gear_f8(), model_data->l_04_i_gdcomac_gear_f8);
assign_value_set(out_data.l_04_i_gdcomac_gsteer_f8(), model_data->l_04_i_gdcomac_gsteer_f8);
assign_value_set(out_data.l_04_i_gdcomac_tire_pres_f8(), model_data->l_04_i_gdcomac_tire_pres_f8);
assign_value_set(out_data.l_04_i_gdcomac_onjax_l1(), model_data->l_04_i_gdcomac_onjax_l1);
assign_value_set(out_data.l_04_i_gdcomac_contdep_f8(), model_data->l_04_i_gdcomac_contdep_f8);
assign_value_set(out_data.l_04_i_gdcomac_thetag_f8(), model_data->l_04_i_gdcomac_thetag_f8);
assign_value_set(out_data.l_04_i_gdcomac_phig_f8(), model_data->l_04_i_gdcomac_phig_f8);
assign_value_set(out_data.l_04_i_gdcomac_rwyrgh_i2(), model_data->l_04_i_gdcomac_rwyrgh_i2);
assign_value_set(out_data.l_04_i_gdcomac_rwyhdg_f8(), model_data->l_04_i_gdcomac_rwyhdg_f8);
assign_value_set(out_data.l_04_i_gdcomac_reset_braketemp_l1(), model_data->l_04_i_gdcomac_reset_braketemp_l1);
assign_value_set(out_data.l_04_i_gdcomac_reset_tirepress_l1(), model_data->l_04_i_gdcomac_reset_tirepress_l1);
assign_value_set(out_data.l_04_i_gdcomac_temp_c_f8(), model_data->l_04_i_gdcomac_temp_c_f8);
assign_value_set(out_data.l_04_i_gdcomac_brake_temp_f8(), model_data->l_04_i_gdcomac_brake_temp_f8);
assign_value_set(out_data.l_04_i_gdcomac_tire_tburst_l1(), model_data->l_04_i_gdcomac_tire_tburst_l1);
assign_value_set(out_data.l_04_i_gdcomac_tire_tflat_l1(), model_data->l_04_i_gdcomac_tire_tflat_l1);
assign_value_set(out_data.l_04_i_gdcomac_brk_reset_tpres_l1(), model_data->l_04_i_gdcomac_brk_reset_tpres_l1);
assign_value_set(out_data.l_04_i_gdcomac_rcon_ci_f8(), model_data->l_04_i_gdcomac_rcon_ci_f8);
assign_value_set(out_data.l_04_i_gdcomac_pb_towforce_f8(), model_data->l_04_i_gdcomac_pb_towforce_f8);
assign_value_set(out_data.l_04_i_gdcomac_gsteer_state_i4(), model_data->l_04_i_gdcomac_gsteer_state_i4);
assign_value_set(out_data.l_04_i_gdcomac_trim_active_l1(), model_data->l_04_i_gdcomac_trim_active_l1);
assign_value_set(out_data.l_04_i_gdcomac_phi_deg_f8(), model_data->l_04_i_gdcomac_phi_deg_f8);
assign_value_set(out_data.l_04_i_gdcomac_theta_deg_f8(), model_data->l_04_i_gdcomac_theta_deg_f8);
assign_value_set(out_data.l_04_i_gdcomac_psi_deg_f8(), model_data->l_04_i_gdcomac_psi_deg_f8);
assign_value_set(out_data.l_04_i_gdcomac_resetint_l1(), model_data->l_04_i_gdcomac_resetint_l1);
sendOutData();
}
private:
XNSim::C909::ATA04::GroundHandling_input data;
XNSim::C909::ATA04::GroundHandling_input out_data;
protected:
DDSType data;
DDSType out_data;
};
}

View File

@ -1,4 +1,5 @@
#include "GroundHandling_output.hpp"
const std::string XNSim::C909::ATA04::GroundHandling_output_Interface::topic_name = "XNSim::C909::ATA04::GroundHandling_output";
namespace XNSim::C909::ATA04
{
GroundHandling_output_Interface::GroundHandling_output_Interface()

View File

@ -3,9 +3,12 @@
#include "XNCore/XNDDSInterface.h"
namespace XNSim::C909::ATA04
{
class GroundHandling_output_Interface final : public XNDDSInterface
class GroundHandling_output_Interface : public XNDDSInterface
{
public:
using DDSType = XNSim::C909::ATA04::GroundHandling_output;
using DDSPubSubType = XNSim::C909::ATA04::GroundHandling_outputPubSubType;
static const std::string topic_name;
GroundHandling_output_Interface();
virtual ~GroundHandling_output_Interface();
virtual void Initialize(XNFrameworkPtr framework, uint32_t modelId, uint32_t DDS_type) override;
@ -60,43 +63,44 @@ public:
return;
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();
assign_value_set(data.l_04_o_gdcomac_frz_l1(), model_data->l_04_o_gdcomac_frz_l1);
assign_value_set(data.l_04_o_gdcomac_ac_on_ground_l1(), model_data->l_04_o_gdcomac_ac_on_ground_l1);
assign_value_set(data.l_04_o_gdcomac_ac_stationary_f8(), model_data->l_04_o_gdcomac_ac_stationary_f8);
assign_value_set(data.l_04_o_gdcomac_alt_tire_f8(), model_data->l_04_o_gdcomac_alt_tire_f8);
assign_value_set(data.l_04_o_gdcomac_zcg_to_tire_f8(), model_data->l_04_o_gdcomac_zcg_to_tire_f8);
assign_value_set(data.l_04_o_gdcomac_fxb_f8(), model_data->l_04_o_gdcomac_fxb_f8);
assign_value_set(data.l_04_o_gdcomac_fyb_f8(), model_data->l_04_o_gdcomac_fyb_f8);
assign_value_set(data.l_04_o_gdcomac_fzb_f8(), model_data->l_04_o_gdcomac_fzb_f8);
assign_value_set(data.l_04_o_gdcomac_mxb_f8(), model_data->l_04_o_gdcomac_mxb_f8);
assign_value_set(data.l_04_o_gdcomac_myb_f8(), model_data->l_04_o_gdcomac_myb_f8);
assign_value_set(data.l_04_o_gdcomac_mzb_f8(), model_data->l_04_o_gdcomac_mzb_f8);
assign_value_set(data.l_04_o_gdcomac_fygs_f8(), model_data->l_04_o_gdcomac_fygs_f8);
assign_value_set(data.l_04_o_gdcomac_mzgs_f8(), model_data->l_04_o_gdcomac_mzgs_f8);
assign_value_set(data.l_04_o_gdcomac_mu_f8(), model_data->l_04_o_gdcomac_mu_f8);
assign_value_set(data.l_04_o_gdcomac_dstroke_f8(), model_data->l_04_o_gdcomac_dstroke_f8);
assign_value_set(data.l_04_o_gdcomac_sr_f8(), model_data->l_04_o_gdcomac_sr_f8);
assign_value_set(data.l_04_o_gdcomac_sy_f8(), model_data->l_04_o_gdcomac_sy_f8);
assign_value_set(data.l_04_o_gdcomac_sx_f8(), model_data->l_04_o_gdcomac_sx_f8);
assign_value_set(data.l_04_o_gdcomac_xft_f8(), model_data->l_04_o_gdcomac_xft_f8);
assign_value_set(data.l_04_o_gdcomac_yft_f8(), model_data->l_04_o_gdcomac_yft_f8);
assign_value_set(data.l_04_o_gdcomac_zft_f8(), model_data->l_04_o_gdcomac_zft_f8);
assign_value_set(data.l_04_o_gdcomac_distngrxcg_f8(), model_data->l_04_o_gdcomac_distngrxcg_f8);
assign_value_set(data.l_04_o_gdcomac_distmgrxcg_f8(), model_data->l_04_o_gdcomac_distmgrxcg_f8);
assign_value_set(data.l_04_o_gdcomac_distmgrzcg_f8(), model_data->l_04_o_gdcomac_distmgrzcg_f8);
assign_value_set(data.l_04_o_gdcomac_tire_vel_f8(), model_data->l_04_o_gdcomac_tire_vel_f8);
assign_value_set(data.l_04_o_gdcomac_tire_burst_l1(), model_data->l_04_o_gdcomac_tire_burst_l1);
assign_value_set(data.l_04_o_gdcomac_tire_temp_f8(), model_data->l_04_o_gdcomac_tire_temp_f8);
assign_value_set(data.l_04_o_gdcomac_wow_l1(), model_data->l_04_o_gdcomac_wow_l1);
assign_value_set(data.l_04_o_gdcomac_utirew_f8(), model_data->l_04_o_gdcomac_utirew_f8);
assign_value_set(data.l_04_o_gdcomac_vtirew_f8(), model_data->l_04_o_gdcomac_vtirew_f8);
assign_value_set(data.l_04_o_gdcomac_whl_omega_f8(), model_data->l_04_o_gdcomac_whl_omega_f8);
assign_value_set(data.l_04_o_gdcomac_dstruc_f8(), model_data->l_04_o_gdcomac_dstruc_f8);
assign_value_set(data.l_04_o_gdcomac_wor_par_f8(), model_data->l_04_o_gdcomac_wor_par_f8);
assign_value_set(data.l_04_o_gdcomac_nd_f8(), model_data->l_04_o_gdcomac_nd_f8);
assign_value_set(out_data.l_04_o_gdcomac_frz_l1(), model_data->l_04_o_gdcomac_frz_l1);
assign_value_set(out_data.l_04_o_gdcomac_ac_on_ground_l1(), model_data->l_04_o_gdcomac_ac_on_ground_l1);
assign_value_set(out_data.l_04_o_gdcomac_ac_stationary_f8(), model_data->l_04_o_gdcomac_ac_stationary_f8);
assign_value_set(out_data.l_04_o_gdcomac_alt_tire_f8(), model_data->l_04_o_gdcomac_alt_tire_f8);
assign_value_set(out_data.l_04_o_gdcomac_zcg_to_tire_f8(), model_data->l_04_o_gdcomac_zcg_to_tire_f8);
assign_value_set(out_data.l_04_o_gdcomac_fxb_f8(), model_data->l_04_o_gdcomac_fxb_f8);
assign_value_set(out_data.l_04_o_gdcomac_fyb_f8(), model_data->l_04_o_gdcomac_fyb_f8);
assign_value_set(out_data.l_04_o_gdcomac_fzb_f8(), model_data->l_04_o_gdcomac_fzb_f8);
assign_value_set(out_data.l_04_o_gdcomac_mxb_f8(), model_data->l_04_o_gdcomac_mxb_f8);
assign_value_set(out_data.l_04_o_gdcomac_myb_f8(), model_data->l_04_o_gdcomac_myb_f8);
assign_value_set(out_data.l_04_o_gdcomac_mzb_f8(), model_data->l_04_o_gdcomac_mzb_f8);
assign_value_set(out_data.l_04_o_gdcomac_fygs_f8(), model_data->l_04_o_gdcomac_fygs_f8);
assign_value_set(out_data.l_04_o_gdcomac_mzgs_f8(), model_data->l_04_o_gdcomac_mzgs_f8);
assign_value_set(out_data.l_04_o_gdcomac_mu_f8(), model_data->l_04_o_gdcomac_mu_f8);
assign_value_set(out_data.l_04_o_gdcomac_dstroke_f8(), model_data->l_04_o_gdcomac_dstroke_f8);
assign_value_set(out_data.l_04_o_gdcomac_sr_f8(), model_data->l_04_o_gdcomac_sr_f8);
assign_value_set(out_data.l_04_o_gdcomac_sy_f8(), model_data->l_04_o_gdcomac_sy_f8);
assign_value_set(out_data.l_04_o_gdcomac_sx_f8(), model_data->l_04_o_gdcomac_sx_f8);
assign_value_set(out_data.l_04_o_gdcomac_xft_f8(), model_data->l_04_o_gdcomac_xft_f8);
assign_value_set(out_data.l_04_o_gdcomac_yft_f8(), model_data->l_04_o_gdcomac_yft_f8);
assign_value_set(out_data.l_04_o_gdcomac_zft_f8(), model_data->l_04_o_gdcomac_zft_f8);
assign_value_set(out_data.l_04_o_gdcomac_distngrxcg_f8(), model_data->l_04_o_gdcomac_distngrxcg_f8);
assign_value_set(out_data.l_04_o_gdcomac_distmgrxcg_f8(), model_data->l_04_o_gdcomac_distmgrxcg_f8);
assign_value_set(out_data.l_04_o_gdcomac_distmgrzcg_f8(), model_data->l_04_o_gdcomac_distmgrzcg_f8);
assign_value_set(out_data.l_04_o_gdcomac_tire_vel_f8(), model_data->l_04_o_gdcomac_tire_vel_f8);
assign_value_set(out_data.l_04_o_gdcomac_tire_burst_l1(), model_data->l_04_o_gdcomac_tire_burst_l1);
assign_value_set(out_data.l_04_o_gdcomac_tire_temp_f8(), model_data->l_04_o_gdcomac_tire_temp_f8);
assign_value_set(out_data.l_04_o_gdcomac_wow_l1(), model_data->l_04_o_gdcomac_wow_l1);
assign_value_set(out_data.l_04_o_gdcomac_utirew_f8(), model_data->l_04_o_gdcomac_utirew_f8);
assign_value_set(out_data.l_04_o_gdcomac_vtirew_f8(), model_data->l_04_o_gdcomac_vtirew_f8);
assign_value_set(out_data.l_04_o_gdcomac_whl_omega_f8(), model_data->l_04_o_gdcomac_whl_omega_f8);
assign_value_set(out_data.l_04_o_gdcomac_dstruc_f8(), model_data->l_04_o_gdcomac_dstruc_f8);
assign_value_set(out_data.l_04_o_gdcomac_wor_par_f8(), model_data->l_04_o_gdcomac_wor_par_f8);
assign_value_set(out_data.l_04_o_gdcomac_nd_f8(), model_data->l_04_o_gdcomac_nd_f8);
sendOutData();
}
private:
XNSim::C909::ATA04::GroundHandling_output data;
XNSim::C909::ATA04::GroundHandling_output out_data;
protected:
DDSType data;
DDSType out_data;
};
}

View File

@ -1,4 +1,5 @@
#include "WeightBalance_heartbeat.hpp"
const std::string XNSim::C909::ATA04::WeightBalance_heartbeat_Interface::topic_name = "XNSim::C909::ATA04::WeightBalance_heartbeat";
namespace XNSim::C909::ATA04
{
WeightBalance_heartbeat_Interface::WeightBalance_heartbeat_Interface()

View File

@ -3,9 +3,12 @@
#include "XNCore/XNDDSInterface.h"
namespace XNSim::C909::ATA04
{
class WeightBalance_heartbeat_Interface final : public XNDDSInterface
class WeightBalance_heartbeat_Interface : public XNDDSInterface
{
public:
using DDSType = XNSim::C909::ATA04::WeightBalance_heartbeat;
using DDSPubSubType = XNSim::C909::ATA04::WeightBalance_heartbeatPubSubType;
static const std::string topic_name;
WeightBalance_heartbeat_Interface();
virtual ~WeightBalance_heartbeat_Interface();
virtual void Initialize(XNFrameworkPtr framework, uint32_t modelId, uint32_t DDS_type) override;
@ -27,10 +30,11 @@ public:
return;
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();
assign_value_set(data.weightbody_model_heartbeat(), model_data->weightbody_model_heartbeat);
assign_value_set(out_data.weightbody_model_heartbeat(), model_data->weightbody_model_heartbeat);
sendOutData();
}
private:
XNSim::C909::ATA04::WeightBalance_heartbeat data;
XNSim::C909::ATA04::WeightBalance_heartbeat out_data;
protected:
DDSType data;
DDSType out_data;
};
}

View File

@ -1,4 +1,5 @@
#include "WeightBalance_input.hpp"
const std::string XNSim::C909::ATA04::WeightBalance_input_Interface::topic_name = "XNSim::C909::ATA04::WeightBalance_input";
namespace XNSim::C909::ATA04
{
WeightBalance_input_Interface::WeightBalance_input_Interface()

View File

@ -3,9 +3,12 @@
#include "XNCore/XNDDSInterface.h"
namespace XNSim::C909::ATA04
{
class WeightBalance_input_Interface final : public XNDDSInterface
class WeightBalance_input_Interface : public XNDDSInterface
{
public:
using DDSType = XNSim::C909::ATA04::WeightBalance_input;
using DDSPubSubType = XNSim::C909::ATA04::WeightBalance_inputPubSubType;
static const std::string topic_name;
WeightBalance_input_Interface();
virtual ~WeightBalance_input_Interface();
virtual void Initialize(XNFrameworkPtr framework, uint32_t modelId, uint32_t DDS_type) override;
@ -49,32 +52,33 @@ public:
return;
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();
assign_value_set(data.l_04_i_wbcomac_theta_deg_f8(), model_data->l_04_i_wbcomac_theta_deg_f8);
assign_value_set(data.l_04_i_wbcomac_gear_mode_l1(), model_data->l_04_i_wbcomac_gear_mode_l1);
assign_value_set(data.l_04_i_wbcomac_acset_gw_f8(), model_data->l_04_i_wbcomac_acset_gw_f8);
assign_value_set(data.l_04_i_wbcomac_acset_cg_f8(), model_data->l_04_i_wbcomac_acset_cg_f8);
assign_value_set(data.l_04_i_wbcomac_acset_tankfuel_f4(), model_data->l_04_i_wbcomac_acset_tankfuel_f4);
assign_value_set(data.l_04_i_wbcomac_acset_totfuel_f8(), model_data->l_04_i_wbcomac_acset_totfuel_f8);
assign_value_set(data.l_04_i_wbcomac_acset_zfw_f8(), model_data->l_04_i_wbcomac_acset_zfw_f8);
assign_value_set(data.l_04_i_wbcomac_acset_zfwcg_f8(), model_data->l_04_i_wbcomac_acset_zfwcg_f8);
assign_value_set(data.l_04_i_wbcomac_eng_efsep_l1(), model_data->l_04_i_wbcomac_eng_efsep_l1);
assign_value_set(data.l_04_i_wbcomac_fuel_f8(), model_data->l_04_i_wbcomac_fuel_f8);
assign_value_set(data.l_04_i_wbcomac_gear_avg_f8(), model_data->l_04_i_wbcomac_gear_avg_f8);
assign_value_set(data.l_04_i_wbcomac_kice_f8(), model_data->l_04_i_wbcomac_kice_f8);
assign_value_set(data.l_04_i_wbcomac_bycglim_l1(), model_data->l_04_i_wbcomac_bycglim_l1);
assign_value_set(data.l_04_i_wbcomac_bygwlim_l1(), model_data->l_04_i_wbcomac_bygwlim_l1);
assign_value_set(data.l_04_i_wbcomac_frz_l1(), model_data->l_04_i_wbcomac_frz_l1);
assign_value_set(data.l_04_i_wbcomac_zcgfrz_l1(), model_data->l_04_i_wbcomac_zcgfrz_l1);
assign_value_set(data.l_04_i_wbcomac_zcgfrz_grfx_l1(), model_data->l_04_i_wbcomac_zcgfrz_grfx_l1);
assign_value_set(data.l_04_i_wbcomac_ycgfrz_l1(), model_data->l_04_i_wbcomac_ycgfrz_l1);
assign_value_set(data.l_04_i_wbcomac_inertfrz_l1(), model_data->l_04_i_wbcomac_inertfrz_l1);
assign_value_set(data.l_04_i_wbcomac_potreq_gw_f8(), model_data->l_04_i_wbcomac_potreq_gw_f8);
assign_value_set(data.l_04_i_wbcomac_potreq_gwcg_f8(), model_data->l_04_i_wbcomac_potreq_gwcg_f8);
assign_value_set(data.l_04_i_wbcomac_phi_deg_f8(), model_data->l_04_i_wbcomac_phi_deg_f8);
assign_value_set(data.l_04_i_wbcomac_psi_deg_f8(), model_data->l_04_i_wbcomac_psi_deg_f8);
assign_value_set(out_data.l_04_i_wbcomac_theta_deg_f8(), model_data->l_04_i_wbcomac_theta_deg_f8);
assign_value_set(out_data.l_04_i_wbcomac_gear_mode_l1(), model_data->l_04_i_wbcomac_gear_mode_l1);
assign_value_set(out_data.l_04_i_wbcomac_acset_gw_f8(), model_data->l_04_i_wbcomac_acset_gw_f8);
assign_value_set(out_data.l_04_i_wbcomac_acset_cg_f8(), model_data->l_04_i_wbcomac_acset_cg_f8);
assign_value_set(out_data.l_04_i_wbcomac_acset_tankfuel_f4(), model_data->l_04_i_wbcomac_acset_tankfuel_f4);
assign_value_set(out_data.l_04_i_wbcomac_acset_totfuel_f8(), model_data->l_04_i_wbcomac_acset_totfuel_f8);
assign_value_set(out_data.l_04_i_wbcomac_acset_zfw_f8(), model_data->l_04_i_wbcomac_acset_zfw_f8);
assign_value_set(out_data.l_04_i_wbcomac_acset_zfwcg_f8(), model_data->l_04_i_wbcomac_acset_zfwcg_f8);
assign_value_set(out_data.l_04_i_wbcomac_eng_efsep_l1(), model_data->l_04_i_wbcomac_eng_efsep_l1);
assign_value_set(out_data.l_04_i_wbcomac_fuel_f8(), model_data->l_04_i_wbcomac_fuel_f8);
assign_value_set(out_data.l_04_i_wbcomac_gear_avg_f8(), model_data->l_04_i_wbcomac_gear_avg_f8);
assign_value_set(out_data.l_04_i_wbcomac_kice_f8(), model_data->l_04_i_wbcomac_kice_f8);
assign_value_set(out_data.l_04_i_wbcomac_bycglim_l1(), model_data->l_04_i_wbcomac_bycglim_l1);
assign_value_set(out_data.l_04_i_wbcomac_bygwlim_l1(), model_data->l_04_i_wbcomac_bygwlim_l1);
assign_value_set(out_data.l_04_i_wbcomac_frz_l1(), model_data->l_04_i_wbcomac_frz_l1);
assign_value_set(out_data.l_04_i_wbcomac_zcgfrz_l1(), model_data->l_04_i_wbcomac_zcgfrz_l1);
assign_value_set(out_data.l_04_i_wbcomac_zcgfrz_grfx_l1(), model_data->l_04_i_wbcomac_zcgfrz_grfx_l1);
assign_value_set(out_data.l_04_i_wbcomac_ycgfrz_l1(), model_data->l_04_i_wbcomac_ycgfrz_l1);
assign_value_set(out_data.l_04_i_wbcomac_inertfrz_l1(), model_data->l_04_i_wbcomac_inertfrz_l1);
assign_value_set(out_data.l_04_i_wbcomac_potreq_gw_f8(), model_data->l_04_i_wbcomac_potreq_gw_f8);
assign_value_set(out_data.l_04_i_wbcomac_potreq_gwcg_f8(), model_data->l_04_i_wbcomac_potreq_gwcg_f8);
assign_value_set(out_data.l_04_i_wbcomac_phi_deg_f8(), model_data->l_04_i_wbcomac_phi_deg_f8);
assign_value_set(out_data.l_04_i_wbcomac_psi_deg_f8(), model_data->l_04_i_wbcomac_psi_deg_f8);
sendOutData();
}
private:
XNSim::C909::ATA04::WeightBalance_input data;
XNSim::C909::ATA04::WeightBalance_input out_data;
protected:
DDSType data;
DDSType out_data;
};
}

View File

@ -1,4 +1,5 @@
#include "WeightBalance_output.hpp"
const std::string XNSim::C909::ATA04::WeightBalance_output_Interface::topic_name = "XNSim::C909::ATA04::WeightBalance_output";
namespace XNSim::C909::ATA04
{
WeightBalance_output_Interface::WeightBalance_output_Interface()

View File

@ -3,9 +3,12 @@
#include "XNCore/XNDDSInterface.h"
namespace XNSim::C909::ATA04
{
class WeightBalance_output_Interface final : public XNDDSInterface
class WeightBalance_output_Interface : public XNDDSInterface
{
public:
using DDSType = XNSim::C909::ATA04::WeightBalance_output;
using DDSPubSubType = XNSim::C909::ATA04::WeightBalance_outputPubSubType;
static const std::string topic_name;
WeightBalance_output_Interface();
virtual ~WeightBalance_output_Interface();
virtual void Initialize(XNFrameworkPtr framework, uint32_t modelId, uint32_t DDS_type) override;
@ -82,65 +85,66 @@ public:
return;
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();
assign_value_set(data.l_04_o_wbcomac_frz_l1(), model_data->l_04_o_wbcomac_frz_l1);
assign_value_set(data.l_04_o_wbcomac_zcgfrz_l1(), model_data->l_04_o_wbcomac_zcgfrz_l1);
assign_value_set(data.l_04_o_wbcomac_zcgfrz_grfx_l1(), model_data->l_04_o_wbcomac_zcgfrz_grfx_l1);
assign_value_set(data.l_04_o_wbcomac_ycgfrz_l1(), model_data->l_04_o_wbcomac_ycgfrz_l1);
assign_value_set(data.l_04_o_wbcomac_inertfrz_l1(), model_data->l_04_o_wbcomac_inertfrz_l1);
assign_value_set(data.l_04_o_wbcomac_gw_f4(), model_data->l_04_o_wbcomac_gw_f4);
assign_value_set(data.l_04_o_wbcomac_cg_f4(), model_data->l_04_o_wbcomac_cg_f4);
assign_value_set(data.l_04_o_wbcomac_blcg_f8(), model_data->l_04_o_wbcomac_blcg_f8);
assign_value_set(data.l_04_o_wbcomac_bscg_f8(), model_data->l_04_o_wbcomac_bscg_f8);
assign_value_set(data.l_04_o_wbcomac_wlcg_f8(), model_data->l_04_o_wbcomac_wlcg_f8);
assign_value_set(data.l_04_o_wbcomac_xcg_f8(), model_data->l_04_o_wbcomac_xcg_f8);
assign_value_set(data.l_04_o_wbcomac_ixx_f8(), model_data->l_04_o_wbcomac_ixx_f8);
assign_value_set(data.l_04_o_wbcomac_ixy_f8(), model_data->l_04_o_wbcomac_ixy_f8);
assign_value_set(data.l_04_o_wbcomac_ixz_f8(), model_data->l_04_o_wbcomac_ixz_f8);
assign_value_set(data.l_04_o_wbcomac_iyy_f8(), model_data->l_04_o_wbcomac_iyy_f8);
assign_value_set(data.l_04_o_wbcomac_iyz_f8(), model_data->l_04_o_wbcomac_iyz_f8);
assign_value_set(data.l_04_o_wbcomac_izz_f8(), model_data->l_04_o_wbcomac_izz_f8);
assign_value_set(data.l_04_o_wbcomac_zfw_f4(), model_data->l_04_o_wbcomac_zfw_f4);
assign_value_set(data.l_04_o_wbcomac_zfwcg_f4(), model_data->l_04_o_wbcomac_zfwcg_f4);
assign_value_set(data.l_04_o_wbcomac_zfw_blcg_f4(), model_data->l_04_o_wbcomac_zfw_blcg_f4);
assign_value_set(data.l_04_o_wbcomac_zfw_wlcg_f4(), model_data->l_04_o_wbcomac_zfw_wlcg_f4);
assign_value_set(data.l_04_o_wbcomac_fuel_cmd_f8(), model_data->l_04_o_wbcomac_fuel_cmd_f8);
assign_value_set(data.l_04_o_wbcomac_fuel_mode_i4(), model_data->l_04_o_wbcomac_fuel_mode_i4);
assign_value_set(data.l_04_o_wbcomac_fuel_ixx_f8(), model_data->l_04_o_wbcomac_fuel_ixx_f8);
assign_value_set(data.l_04_o_wbcomac_fuel_ixy_f8(), model_data->l_04_o_wbcomac_fuel_ixy_f8);
assign_value_set(data.l_04_o_wbcomac_fuel_ixz_f8(), model_data->l_04_o_wbcomac_fuel_ixz_f8);
assign_value_set(data.l_04_o_wbcomac_fuel_iyy_f8(), model_data->l_04_o_wbcomac_fuel_iyy_f8);
assign_value_set(data.l_04_o_wbcomac_fuel_iyz_f8(), model_data->l_04_o_wbcomac_fuel_iyz_f8);
assign_value_set(data.l_04_o_wbcomac_fuel_izz_f8(), model_data->l_04_o_wbcomac_fuel_izz_f8);
assign_value_set(data.l_04_o_wbcomac_l_wt_fuel_f8(), model_data->l_04_o_wbcomac_l_wt_fuel_f8);
assign_value_set(data.l_04_o_wbcomac_ice_airframe_total_f8(), model_data->l_04_o_wbcomac_ice_airframe_total_f8);
assign_value_set(data.l_04_o_wbcomac_ice_eng_f8(), model_data->l_04_o_wbcomac_ice_eng_f8);
assign_value_set(data.l_04_o_wbcomac_ice_eng_total_f8(), model_data->l_04_o_wbcomac_ice_eng_total_f8);
assign_value_set(data.l_04_o_wbcomac_ice_fuselage_f8(), model_data->l_04_o_wbcomac_ice_fuselage_f8);
assign_value_set(data.l_04_o_wbcomac_ice_stab_left_f8(), model_data->l_04_o_wbcomac_ice_stab_left_f8);
assign_value_set(data.l_04_o_wbcomac_ice_stab_right_f8(), model_data->l_04_o_wbcomac_ice_stab_right_f8);
assign_value_set(data.l_04_o_wbcomac_ice_stab_total_f8(), model_data->l_04_o_wbcomac_ice_stab_total_f8);
assign_value_set(data.l_04_o_wbcomac_ice_total_f8(), model_data->l_04_o_wbcomac_ice_total_f8);
assign_value_set(data.l_04_o_wbcomac_ice_total_frac_f8(), model_data->l_04_o_wbcomac_ice_total_frac_f8);
assign_value_set(data.l_04_o_wbcomac_ice_vert_tail_f8(), model_data->l_04_o_wbcomac_ice_vert_tail_f8);
assign_value_set(data.l_04_o_wbcomac_ice_wing_left_f8(), model_data->l_04_o_wbcomac_ice_wing_left_f8);
assign_value_set(data.l_04_o_wbcomac_ice_wing_right_f8(), model_data->l_04_o_wbcomac_ice_wing_right_f8);
assign_value_set(data.l_04_o_wbcomac_ice_wing_total_f8(), model_data->l_04_o_wbcomac_ice_wing_total_f8);
assign_value_set(data.l_04_o_wbcomac_init_l1(), model_data->l_04_o_wbcomac_init_l1);
assign_value_set(data.l_04_o_wbcomac_potmin_gw_f8(), model_data->l_04_o_wbcomac_potmin_gw_f8);
assign_value_set(data.l_04_o_wbcomac_potmax_gw_f8(), model_data->l_04_o_wbcomac_potmax_gw_f8);
assign_value_set(data.l_04_o_wbcomac_potmin_gwcg_f8(), model_data->l_04_o_wbcomac_potmin_gwcg_f8);
assign_value_set(data.l_04_o_wbcomac_potmax_gwcg_f8(), model_data->l_04_o_wbcomac_potmax_gwcg_f8);
assign_value_set(data.l_04_o_wbcomac_min_cg_f4(), model_data->l_04_o_wbcomac_min_cg_f4);
assign_value_set(data.l_04_o_wbcomac_min_gw_f4(), model_data->l_04_o_wbcomac_min_gw_f4);
assign_value_set(data.l_04_o_wbcomac_min_zfw_f4(), model_data->l_04_o_wbcomac_min_zfw_f4);
assign_value_set(data.l_04_o_wbcomac_min_zfwcg_f4(), model_data->l_04_o_wbcomac_min_zfwcg_f4);
assign_value_set(data.l_04_o_wbcomac_max_cg_f4(), model_data->l_04_o_wbcomac_max_cg_f4);
assign_value_set(data.l_04_o_wbcomac_max_gw_f4(), model_data->l_04_o_wbcomac_max_gw_f4);
assign_value_set(data.l_04_o_wbcomac_max_zfw_f4(), model_data->l_04_o_wbcomac_max_zfw_f4);
assign_value_set(data.l_04_o_wbcomac_max_zfwcg_f4(), model_data->l_04_o_wbcomac_max_zfwcg_f4);
assign_value_set(out_data.l_04_o_wbcomac_frz_l1(), model_data->l_04_o_wbcomac_frz_l1);
assign_value_set(out_data.l_04_o_wbcomac_zcgfrz_l1(), model_data->l_04_o_wbcomac_zcgfrz_l1);
assign_value_set(out_data.l_04_o_wbcomac_zcgfrz_grfx_l1(), model_data->l_04_o_wbcomac_zcgfrz_grfx_l1);
assign_value_set(out_data.l_04_o_wbcomac_ycgfrz_l1(), model_data->l_04_o_wbcomac_ycgfrz_l1);
assign_value_set(out_data.l_04_o_wbcomac_inertfrz_l1(), model_data->l_04_o_wbcomac_inertfrz_l1);
assign_value_set(out_data.l_04_o_wbcomac_gw_f4(), model_data->l_04_o_wbcomac_gw_f4);
assign_value_set(out_data.l_04_o_wbcomac_cg_f4(), model_data->l_04_o_wbcomac_cg_f4);
assign_value_set(out_data.l_04_o_wbcomac_blcg_f8(), model_data->l_04_o_wbcomac_blcg_f8);
assign_value_set(out_data.l_04_o_wbcomac_bscg_f8(), model_data->l_04_o_wbcomac_bscg_f8);
assign_value_set(out_data.l_04_o_wbcomac_wlcg_f8(), model_data->l_04_o_wbcomac_wlcg_f8);
assign_value_set(out_data.l_04_o_wbcomac_xcg_f8(), model_data->l_04_o_wbcomac_xcg_f8);
assign_value_set(out_data.l_04_o_wbcomac_ixx_f8(), model_data->l_04_o_wbcomac_ixx_f8);
assign_value_set(out_data.l_04_o_wbcomac_ixy_f8(), model_data->l_04_o_wbcomac_ixy_f8);
assign_value_set(out_data.l_04_o_wbcomac_ixz_f8(), model_data->l_04_o_wbcomac_ixz_f8);
assign_value_set(out_data.l_04_o_wbcomac_iyy_f8(), model_data->l_04_o_wbcomac_iyy_f8);
assign_value_set(out_data.l_04_o_wbcomac_iyz_f8(), model_data->l_04_o_wbcomac_iyz_f8);
assign_value_set(out_data.l_04_o_wbcomac_izz_f8(), model_data->l_04_o_wbcomac_izz_f8);
assign_value_set(out_data.l_04_o_wbcomac_zfw_f4(), model_data->l_04_o_wbcomac_zfw_f4);
assign_value_set(out_data.l_04_o_wbcomac_zfwcg_f4(), model_data->l_04_o_wbcomac_zfwcg_f4);
assign_value_set(out_data.l_04_o_wbcomac_zfw_blcg_f4(), model_data->l_04_o_wbcomac_zfw_blcg_f4);
assign_value_set(out_data.l_04_o_wbcomac_zfw_wlcg_f4(), model_data->l_04_o_wbcomac_zfw_wlcg_f4);
assign_value_set(out_data.l_04_o_wbcomac_fuel_cmd_f8(), model_data->l_04_o_wbcomac_fuel_cmd_f8);
assign_value_set(out_data.l_04_o_wbcomac_fuel_mode_i4(), model_data->l_04_o_wbcomac_fuel_mode_i4);
assign_value_set(out_data.l_04_o_wbcomac_fuel_ixx_f8(), model_data->l_04_o_wbcomac_fuel_ixx_f8);
assign_value_set(out_data.l_04_o_wbcomac_fuel_ixy_f8(), model_data->l_04_o_wbcomac_fuel_ixy_f8);
assign_value_set(out_data.l_04_o_wbcomac_fuel_ixz_f8(), model_data->l_04_o_wbcomac_fuel_ixz_f8);
assign_value_set(out_data.l_04_o_wbcomac_fuel_iyy_f8(), model_data->l_04_o_wbcomac_fuel_iyy_f8);
assign_value_set(out_data.l_04_o_wbcomac_fuel_iyz_f8(), model_data->l_04_o_wbcomac_fuel_iyz_f8);
assign_value_set(out_data.l_04_o_wbcomac_fuel_izz_f8(), model_data->l_04_o_wbcomac_fuel_izz_f8);
assign_value_set(out_data.l_04_o_wbcomac_l_wt_fuel_f8(), model_data->l_04_o_wbcomac_l_wt_fuel_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_airframe_total_f8(), model_data->l_04_o_wbcomac_ice_airframe_total_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_eng_f8(), model_data->l_04_o_wbcomac_ice_eng_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_eng_total_f8(), model_data->l_04_o_wbcomac_ice_eng_total_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_fuselage_f8(), model_data->l_04_o_wbcomac_ice_fuselage_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_stab_left_f8(), model_data->l_04_o_wbcomac_ice_stab_left_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_stab_right_f8(), model_data->l_04_o_wbcomac_ice_stab_right_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_stab_total_f8(), model_data->l_04_o_wbcomac_ice_stab_total_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_total_f8(), model_data->l_04_o_wbcomac_ice_total_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_total_frac_f8(), model_data->l_04_o_wbcomac_ice_total_frac_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_vert_tail_f8(), model_data->l_04_o_wbcomac_ice_vert_tail_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_wing_left_f8(), model_data->l_04_o_wbcomac_ice_wing_left_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_wing_right_f8(), model_data->l_04_o_wbcomac_ice_wing_right_f8);
assign_value_set(out_data.l_04_o_wbcomac_ice_wing_total_f8(), model_data->l_04_o_wbcomac_ice_wing_total_f8);
assign_value_set(out_data.l_04_o_wbcomac_init_l1(), model_data->l_04_o_wbcomac_init_l1);
assign_value_set(out_data.l_04_o_wbcomac_potmin_gw_f8(), model_data->l_04_o_wbcomac_potmin_gw_f8);
assign_value_set(out_data.l_04_o_wbcomac_potmax_gw_f8(), model_data->l_04_o_wbcomac_potmax_gw_f8);
assign_value_set(out_data.l_04_o_wbcomac_potmin_gwcg_f8(), model_data->l_04_o_wbcomac_potmin_gwcg_f8);
assign_value_set(out_data.l_04_o_wbcomac_potmax_gwcg_f8(), model_data->l_04_o_wbcomac_potmax_gwcg_f8);
assign_value_set(out_data.l_04_o_wbcomac_min_cg_f4(), model_data->l_04_o_wbcomac_min_cg_f4);
assign_value_set(out_data.l_04_o_wbcomac_min_gw_f4(), model_data->l_04_o_wbcomac_min_gw_f4);
assign_value_set(out_data.l_04_o_wbcomac_min_zfw_f4(), model_data->l_04_o_wbcomac_min_zfw_f4);
assign_value_set(out_data.l_04_o_wbcomac_min_zfwcg_f4(), model_data->l_04_o_wbcomac_min_zfwcg_f4);
assign_value_set(out_data.l_04_o_wbcomac_max_cg_f4(), model_data->l_04_o_wbcomac_max_cg_f4);
assign_value_set(out_data.l_04_o_wbcomac_max_gw_f4(), model_data->l_04_o_wbcomac_max_gw_f4);
assign_value_set(out_data.l_04_o_wbcomac_max_zfw_f4(), model_data->l_04_o_wbcomac_max_zfw_f4);
assign_value_set(out_data.l_04_o_wbcomac_max_zfwcg_f4(), model_data->l_04_o_wbcomac_max_zfwcg_f4);
sendOutData();
}
private:
XNSim::C909::ATA04::WeightBalance_output data;
XNSim::C909::ATA04::WeightBalance_output out_data;
protected:
DDSType data;
DDSType out_data;
};
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<Model>
<Name>XNGroundHandling</Name>
<Description>ATA04地面操纵模型</Description>
<Author>Jin</Author>
<Version>1.0.0</Version>
<CreateTime>2025-02-19 16:22:17</CreateTime>
<ChangeTime>2025-02-19 16:22:19</ChangeTime>
<Node>0-0</Node>
<Priority>99</Priority>
<MathLib>ATA04_SACSCGroundHandling_2.0.143.1H_20250506/libSACSCGroundHandling.so.2.0.143.1H</MathLib>
<CommandList/>
</Model>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scenario>
<Environment OSName="Debian" Version="11" RTXVersion="preempt-rt" CPUAffinity="0,1" WorkPath="/home/jin/MyCode/XNSim/Release/" ModelsPath="Models/" ServicesPath="Services/" DomainID="10"/>
<Environment OSName="Debian" Version="11" RTXVersion="preempt-rt" CPUAffinity="0,1" PlaneName = "C909" WorkPath="/home/jin/MyCode/XNSim/Release/" ModelsPath="Models/" ServicesPath="Services/" DomainID="10"/>
<ConsoleOutput Debug="1" Info="1" Error="1" Warning="1"/>
<Log Debug="0" Info="1" Error="1" Warning="1"/>
<ModelGroup Name="本体模型组" Freq="120" Priority="99" CPUAff="0">
<Model Name="ATA04气动模型" ClassName="XNAerodynamics"/>
<Model Name="ATA04地面操纵模型" ClassName="XNGroundHandling"/>
<Model Name="ATA04质量模型" ClassName="XNWeightBalance"/>
<Model Name="ATA04数据处理模型" ClassName="XNATA04DataProcessor"/>
<Model Name="ATA04气动模型" ClassName="XNAerodynamics" Version="1.0.0.0"/>
<Model Name="ATA04地面操纵模型" ClassName="XNGroundHandling" Version="1.0.0.0"/>
<Model Name="ATA04质量模型" ClassName="XNWeightBalance" Version="1.0.0.0"/>
<Model Name="ATA04数据处理模型" ClassName="XNATA04DataProcessor" Version="1.0.0.0"/>
</ModelGroup>
<ServicesList>
<Service Name="UDP通信服务" ClassName="XNUDPService"/>
<Service Name="UDP通信服务" ClassName="XNUDPService" Version="1.0.0.0"/>
</ServicesList>
</Scenario>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Service>
<Name>XNUDPService</Name>
<Description>UDP通信服务</Description>
<Author>Jin</Author>
<Version>1.0.0</Version>
<CreateTime>2025-02-04 10:00:00</CreateTime>
<ChangeTime>2025-02-04 10:00:00</ChangeTime>
<CommandList>
<Command Name="TestCmd" Description="Test" Call="TestCall"/>
</CommandList>
<UDP>
<LocalPort>12345</LocalPort>
<TargetHost>127.0.0.1</TargetHost>
<TargetPort>54321</TargetPort>
</UDP>
</Service>

Binary file not shown.

Binary file not shown.

BIN
Release/database/LogInfo.db Normal file

Binary file not shown.

Binary file not shown.

View File

@ -40,6 +40,8 @@
# include <array>
# include <cstring>
# include <iostream>
# include <sqlite3.h>
# include <nlohmann/json.hpp>
#endif
#include <fastdds/dds/domain/DomainParticipant.hpp>
@ -53,6 +55,8 @@
#include <fastcdr/xcdr/optional.hpp>
#define FAST_DDS_MACRO eprosima::fastdds::dds
using XN_JSON = nlohmann::json;
/**
* @brief Hz
*/
@ -91,13 +95,6 @@ struct PERIOD_INFO {
*/
using XNTimePoint = std::chrono::system_clock::time_point;
/**
* @brief ISO格式的时间字符串转换为系统时间点
* @param timeStr ISO格式的时间字符串 (YYYY-MM-DDTHH:mm:ss)
* @return
*/
extern "C" XNTimePoint XNCORE_EXPORT parseISOTime(const std::string &timeStr);
/**
* @brief
*/
@ -258,3 +255,37 @@ public:
public: \
using ThisType = cls; \
using SuperType = sup;
#define XN_UNUSED(x) (void)x
namespace XNSim
{
template <typename T>
constexpr typename std::underlying_type<T>::type enumValue(T e)
{
return static_cast<typename std::underlying_type<T>::type>(e);
}
/**
* @brief ISO格式的时间字符串转换为系统时间点
* @param timeStr ISO格式的时间字符串 (YYYY-MM-DDTHH:mm:ss)
* @return
*/
extern "C" XNTimePoint XNCORE_EXPORT parseISOTime(const std::string &timeStr);
extern "C" std::vector<std::string> XNCORE_EXPORT split(const std::string &str,
const std::string &delim);
extern "C" std::string XNCORE_EXPORT getFileNameWithoutExt(const std::string &path);
extern "C" int XNCORE_EXPORT safe_stoi(const std::string &str, int defaultValue = 0);
inline std::string getStringFromSqlite3(sqlite3_stmt *stmt, int column)
{
const char *text = reinterpret_cast<const char *>(sqlite3_column_text(stmt, column));
if (text == nullptr) {
return "";
}
return std::string(text);
}
} // namespace XNSim

View File

@ -39,13 +39,14 @@ public:
* @param varNames:
* @return:
*/
std::unordered_map<std::string, std::string> getStringData(std::vector<std::string> varNames);
std::unordered_map<std::string, std::string>
getStringData(const std::vector<std::string> &varNames);
/**
* @brief
* @param data:
*/
void setDataByString(std::unordered_map<std::string, std::string> data);
void setDataByString(const std::unordered_map<std::string, std::string> &data);
protected:
/**
@ -54,7 +55,7 @@ protected:
* @return
*/
template <typename T>
XNByteArray getByteArray(eprosima::fastcdr::optional<T> data)
XNByteArray getByteArray(const eprosima::fastcdr::optional<T> &data)
{
XNByteArray result(getTypeSize<T>());
@ -74,7 +75,7 @@ protected:
}
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"Type must be arithmetic or std::array");
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 78");
}
return result;
@ -108,7 +109,7 @@ protected:
setByteArrayFromStdArray(data.value(), thisArray);
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"Type must be arithmetic or std::array");
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 112");
}
}
@ -125,10 +126,13 @@ protected:
for (std::size_t i = 0; i < N; ++i) {
if constexpr (std::is_arithmetic_v<T>) {
std::memcpy(result.data() + i * getTypeSize<T>(), &data[i], getTypeSize<T>());
} else {
} else if constexpr (is_std_array_v<T>) {
XNByteArray subArray = getByteArrayFromStdArray(data[i]);
std::memcpy(result.data() + i * getTypeSize<T>(), subArray.data(),
getTypeSize<T>());
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 135");
}
}
@ -149,9 +153,12 @@ protected:
for (std::size_t i = 0; i < N; ++i) {
if constexpr (std::is_arithmetic_v<T>) {
std::memcpy(&data[i], byteArray.data() + i * getTypeSize<T>(), getTypeSize<T>());
} else {
} else if constexpr (is_std_array_v<T>) {
XNByteArray subArray(byteArray.data() + i * getTypeSize<T>(), getTypeSize<T>());
setByteArrayFromStdArray(data[i], subArray);
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 160");
}
}
}
@ -162,13 +169,13 @@ protected:
* @return:
*/
template <typename T>
std::string getString(eprosima::fastcdr::optional<T> data)
std::string getString(const eprosima::fastcdr::optional<T> &data)
{
if constexpr (std::is_arithmetic_v<T>) {
if (data) {
return std::to_string(data.value());
} else {
return std::to_string(0);
return "Unknown";
}
} else if constexpr (is_std_array_v<T>) {
if (data) {
@ -177,6 +184,9 @@ protected:
T zero = {};
return getStringFromStdArray(zero);
}
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 188");
}
return std::string();
}
@ -206,6 +216,9 @@ protected:
T temp;
setStdArrayFromString(temp, items, 0);
data = temp;
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 220");
}
}
@ -215,7 +228,7 @@ protected:
* @return:
*/
template <typename T, std::size_t N>
std::string getStringFromStdArray(std::array<T, N> data)
std::string getStringFromStdArray(const std::array<T, N> &data)
{
std::stringstream ss;
for (std::size_t i = 0; i < N; ++i) {
@ -223,8 +236,11 @@ protected:
ss << ",";
if constexpr (std::is_arithmetic_v<T>) {
ss << data[i];
} else {
} else if constexpr (is_std_array_v<T>) {
ss << getStringFromStdArray(data[i]);
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 243");
}
}
return ss.str();
@ -256,60 +272,105 @@ protected:
// 对于嵌套数组,递归处理
start_pos = setStdArrayFromString(data[i], value, start_pos + i);
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"Type must be arithmetic or std::array");
static_assert(
std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 275");
}
} catch (const std::exception &e) {
throw std::runtime_error("Error parsing element " + std::to_string(i) + ": "
+ e.what());
throw std::runtime_error("无法解析第 " + std::to_string(i)
+ " 个元素: " + e.what());
}
}
return start_pos + N;
}
template <typename T1, typename T2>
void assign_value_get(eprosima::fastcdr::optional<T1> &data, T2 &model_data)
void assign_value_get(const eprosima::fastcdr::optional<T1> &data, T2 &model_data)
{
if (data) {
auto temp = data.value();
if constexpr (std::is_arithmetic_v<T1>) {
static_assert(std::is_arithmetic_v<T2>,
"模板参数T2必须是算术类型详见XNDDSInterface.cppline 293");
static_assert(std::is_convertible_v<T1, T2>,
"模板参数T1必须可以转换为T2类型详见XNDDSInterface.cppline 295");
model_data = temp;
} else if constexpr (is_std_array_v<T1>) {
size_t arraySize = array_size_v<T1>;
for (size_t i = 0; i < arraySize; ++i) {
auto temp2 = temp[i];
if constexpr (std::is_arithmetic_v<T2>) {
using array_type = typename T1::value_type;
if constexpr (std::is_arithmetic_v<array_type>) {
model_data[i] = temp2;
} else if constexpr (is_std_array_v<T2>) {
size_t arraySize2 = array_size_v<T2>;
} else if constexpr (is_std_array_v<array_type>) {
size_t arraySize2 = array_size_v<array_type>;
using sub_array_type = typename array_type::value_type;
if constexpr (std::is_arithmetic_v<sub_array_type>) {
for (size_t j = 0; j < arraySize2; ++j) {
model_data[i][j] = temp2[j];
}
} else {
static_assert(std::is_arithmetic_v<sub_array_type>,
"模板参数T1是std::"
"array类型时它的数组嵌套不能超过两层详见XNDDSInterfac"
"e.cppline 313");
}
} else {
static_assert(
std::is_arithmetic_v<array_type> || is_std_array_v<array_type>,
"模板参数T1是std::array类型时它的value_"
"type必须是算术类型或std::array类型详见XNDDSInterface.cppline 320");
}
}
} else {
static_assert(
std::is_arithmetic_v<T1> || is_std_array_v<T1>,
"模板参数T1必须是算术类型或std::array类型详见XNDDSInterface.cppline 326");
}
}
}
template <typename T1, typename T2>
void assign_value_set(eprosima::fastcdr::optional<T1> &data, T2 &model_data)
void assign_value_set(eprosima::fastcdr::optional<T1> &data, const T2 &model_data)
{
if constexpr (std::is_arithmetic_v<T1>) {
static_assert(std::is_arithmetic_v<T2>,
"模板参数T2必须是算术类型详见XNDDSInterface.cppline 337");
static_assert(std::is_convertible_v<T2, T1>,
"模板参数T2必须可以转换为T1类型详见XNDDSInterface.cppline 339");
data = model_data;
} else if constexpr (is_std_array_v<T1>) {
T1 temp;
size_t arraySize = array_size_v<T1>;
using array_type = typename T1::value_type;
for (size_t i = 0; i < arraySize; ++i) {
if constexpr (std::is_arithmetic_v<typename T1::value_type>) {
if constexpr (std::is_arithmetic_v<array_type>) {
temp[i] = model_data[i];
} else if constexpr (is_std_array_v<typename T1::value_type>) {
size_t arraySize2 = array_size_v<typename T1::value_type>;
} else if constexpr (is_std_array_v<array_type>) {
size_t arraySize2 = array_size_v<array_type>;
using sub_array_type = typename array_type::value_type;
if constexpr (std::is_arithmetic_v<sub_array_type>) {
for (size_t j = 0; j < arraySize2; ++j) {
temp[i][j] = model_data[i][j];
}
} else {
static_assert(std::is_arithmetic_v<sub_array_type>,
"模板参数T1是std::"
"array类型时它的数组嵌套不能超过两层详见XNDDSInterface."
"cppline 357");
}
} else {
static_assert(
std::is_arithmetic_v<array_type> || is_std_array_v<array_type>,
"模板参数T1是std::array类型时它的value_"
"type必须是算术类型或std::array类型详见XNDDSInterface.cppline 364");
}
}
data = temp;
} else {
static_assert(
std::is_arithmetic_v<T1> || is_std_array_v<T1>,
"模板参数T1必须是算术类型或std::array类型详见XNDDSInterface.cppline 371");
}
}
@ -330,10 +391,10 @@ protected:
#define MAP_DATA_FUNC(NAME) \
getDataFunction[#NAME] = [this]() { return getString(data.NAME()); }; \
setDataFunction[#NAME] = [this](std::string value) { \
setDataFunction[#NAME] = [this](const std::string &value) { \
setDataFromString(out_data.NAME(), value); \
}; \
getByteArrayFunction.push_back([this]() { return getByteArray(data.NAME()); }); \
setByteArrayFunction.push_back([this](XNByteArray byteArray, uint32_t &pos) { \
setByteArrayFunction.push_back([this](const XNByteArray &byteArray, uint32_t &pos) { \
setByteArray(out_data.NAME(), byteArray, pos); \
});

View File

@ -77,4 +77,9 @@ struct XNFrameworkPrivate : public XNObjectPrivate {
* @brief XML
*/
std::string scenarioXml;
/**
* @brief ID
*/
uint32_t configId;
};

View File

@ -178,46 +178,59 @@ public:
}
private:
// 辅助函数,用于格式化消息
/**
* @brief
* @tparam T
* @param arg
* @return
*/
template <typename T>
static std::string convertToString(const T &arg)
{
if constexpr (std::is_arithmetic<T>::value) {
if constexpr (std::is_arithmetic_v<T>) {
return std::to_string(arg); // 处理数值类型
} else {
} else if constexpr (std::is_same_v<T, std::string>) {
return arg;
} else if constexpr (std::is_convertible_v<T, std::string>) {
return std::string(arg);
} else if constexpr (std::is_same_v<T, char *> || std::is_same_v<T, const char *>) {
return std::string(arg);
} else {
static_assert(std::is_arithmetic_v<T> || std::is_same_v<T, std::string>
|| std::is_convertible_v<T, std::string> || std::is_same_v<T, char *>
|| std::is_same_v<T, const char *>,
"错误码010211001不支持的类型转换详见XNLogger.cppline 199");
}
}
// 递归变参函数,用于处理多个参数
template <typename T, typename... Args>
static std::string formatMessage(const std::string &message, T arg, Args... args)
/**
* @brief %1%2%3
* @tparam Args
* @param message
* @param args
* @return
*/
template <typename... Args>
static std::string formatMessage(const std::string &message, Args &&...args)
{
// 查找下一个参数占位符
std::string result = message;
size_t paramIndex = 0;
size_t pos = 0;
static_assert(sizeof...(Args) <= 9,
"错误码010211002单条日志参数数量超过限制详见XNLogger.cppline 216");
// 找到当前参数对应的占位符
while (true) {
std::string placeholder = "%" + std::to_string(paramIndex + 1);
pos = result.find(placeholder);
std::string result = message;
// 使用初始化列表展开参数包
int index = 1;
// 使用lambda和std::initializer_list展开参数包
(void)std::initializer_list<int>{(
[&result, &index](const auto &value) {
std::string placeholder = "%" + std::to_string(index++);
size_t pos = result.find(placeholder);
if (pos != std::string::npos) {
// 替换占位符使用placeholder的长度
result.replace(pos, placeholder.length(), convertToString(arg));
break;
result.replace(pos, placeholder.length(), convertToString(value));
}
paramIndex++;
if (paramIndex > 100) { // 防止无限循环
}(args),
0)...};
return result;
}
}
return formatMessage(result, args...);
}
// 基础情况
static std::string formatMessage(const std::string &message) { return message; }
};
/**

View File

@ -61,10 +61,14 @@ public:
* @brief
* @param modelPath: QString类型
* @param className: QString类型
* @param modelVersion: QString类型
* @param initialType: UINT32类型
* @param threadID: UINT32类型线ID
* @details
*/
void LoadModel(const std::string &modelPath, const std::string &className, uint32_t initialType,
uint32_t threadID);
void LoadModel(const std::string &modelPath, const std::string &className,
const std::string &modelVersion, const std::string &planeName,
uint32_t initialType, uint32_t threadID);
/**
* @brief

View File

@ -169,6 +169,18 @@ public:
*/
void SetSetFreq(double setFreq);
/**
* @brief
* @return const std::string&:
*/
const std::string &GetLibPath();
/**
* @brief
* @param sLibPath: std::string类型
*/
void SetLibPath(const std::string &sLibPath);
/**
* @brief
* @details
@ -238,6 +250,10 @@ public:
public:
virtual void RegisterDDSParticipant();
private:
void ParseXml();
void ParseConfig();
};
#define XN_MODEL_INITIALIZE(ClassName) \

View File

@ -76,4 +76,21 @@ public:
* @return false:
*/
virtual bool AnalysisScenarioXml(const std::string &XmlPath, uint32_t initialType);
private:
/**
* @brief
* @param XmlPath: std::string类型
* @return true:
* @return false:
*/
bool ParseScenarioXml(const std::string &XmlPath);
/**
* @brief
* @param ConfigID: std::string类型ID
* @return true:
* @return false:
*/
bool ParseConfig(const std::string &ConfigID);
};

View File

@ -29,7 +29,7 @@ public:
virtual bool Initialize() override;
virtual bool PrepareForExecute() override;
void LoadService(const std::string &servicePath, const std::string &serviceName,
uint32_t initialType);
const std::string &serviceVersion, uint32_t initialType);
public:
XNServiceObjectPtr GetService(uint32_t serviceID);

View File

@ -54,6 +54,10 @@ public:
protected:
XNFrameworkPtr GetFramework() const;
private:
void ParseXml();
void ParseConfig();
};
XNCLASS_PTR_DECLARE(XNServiceObject)

View File

@ -11,4 +11,5 @@ struct XNServiceObjectPrivate : public XNObjectPrivate {
std::unordered_map<std::string, FAST_DDS_MACRO::DataWriter *> _dataWriters;
XNFrameworkPtr pFramework;
uint32_t _initialType;
XN_JSON _otherParams;
};

View File

@ -1 +0,0 @@
libQt6Core.so.6.9.0

Binary file not shown.

View File

@ -1 +0,0 @@
libQt6DBus.so.6.9.0

Binary file not shown.

View File

@ -1 +0,0 @@
libQt6Gui.so.6.9.0

Binary file not shown.

View File

@ -1 +0,0 @@
libQt6Network.so.6.9.0

Binary file not shown.

View File

@ -1 +0,0 @@
libQt6OpenGL.so.6.9.0

Binary file not shown.

View File

@ -1 +0,0 @@
libQt6PrintSupport.so.6.9.0

View File

@ -1 +0,0 @@
libQt6WaylandClient.so.6.9.0

View File

@ -1 +0,0 @@
libQt6Widgets.so.6.9.0

Binary file not shown.

View File

@ -1 +0,0 @@
libQt6XcbQpa.so.6.9.0

Binary file not shown.

View File

@ -1 +0,0 @@
libQt6Xml.so.6.9.0

Binary file not shown.

View File

@ -1 +0,0 @@
libxcb.so.1.1.0

Binary file not shown.

View File

@ -16,8 +16,10 @@ endif()
file(GLOB DDS_XNIDL_SOURCES_CXX "XNIDL/*.cxx")
find_package(nlohmann_json REQUIRED)
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(SQLite3 REQUIRED)
add_library(XNCore SHARED
XNCore_global.h
@ -76,6 +78,8 @@ target_link_libraries(XNCore PRIVATE
pthread
OpenSSL::SSL
OpenSSL::Crypto
nlohmann_json
sqlite3
dl
)

View File

@ -1,5 +1,7 @@
#include "XNCore_global.h"
namespace XNSim
{
XNTimePoint parseISOTime(const std::string &timeStr)
{
std::tm tm = {};
@ -8,3 +10,49 @@ XNTimePoint parseISOTime(const std::string &timeStr)
auto tp = std::chrono::system_clock::from_time_t(std::mktime(&tm));
return tp;
}
// 辅助函数:分割字符串
std::vector<std::string> split(const std::string &str, const std::string &delim)
{
std::vector<std::string> tokens;
size_t prev = 0, pos = 0;
do {
pos = str.find(delim, prev);
if (pos == std::string::npos)
pos = str.length();
std::string token = str.substr(prev, pos - prev);
if (!token.empty())
tokens.push_back(token);
prev = pos + delim.length();
} while (pos < str.length() && prev < str.length());
return tokens;
}
// 辅助函数:获取文件名(不含扩展名)
std::string getFileNameWithoutExt(const std::string &path)
{
size_t lastDot = path.find_last_of('.');
if (lastDot != std::string::npos) {
return path.substr(0, lastDot);
}
return path;
}
/**
* @brief
* @param str
* @param defaultValue
* @return
*/
int safe_stoi(const std::string &str, int defaultValue)
{
if (str.empty()) {
return defaultValue;
}
try {
return std::stoi(str);
} catch (const std::exception &) {
return defaultValue;
}
}
} // namespace XNSim

View File

@ -40,6 +40,8 @@
# include <array>
# include <cstring>
# include <iostream>
# include <sqlite3.h>
# include <nlohmann/json.hpp>
#endif
#include <fastdds/dds/domain/DomainParticipant.hpp>
@ -53,6 +55,8 @@
#include <fastcdr/xcdr/optional.hpp>
#define FAST_DDS_MACRO eprosima::fastdds::dds
using XN_JSON = nlohmann::json;
/**
* @brief Hz
*/
@ -91,13 +95,6 @@ struct PERIOD_INFO {
*/
using XNTimePoint = std::chrono::system_clock::time_point;
/**
* @brief ISO格式的时间字符串转换为系统时间点
* @param timeStr ISO格式的时间字符串 (YYYY-MM-DDTHH:mm:ss)
* @return
*/
extern "C" XNTimePoint XNCORE_EXPORT parseISOTime(const std::string &timeStr);
/**
* @brief
*/
@ -258,3 +255,37 @@ public:
public: \
using ThisType = cls; \
using SuperType = sup;
#define XN_UNUSED(x) (void)x
namespace XNSim
{
template <typename T>
constexpr typename std::underlying_type<T>::type enumValue(T e)
{
return static_cast<typename std::underlying_type<T>::type>(e);
}
/**
* @brief ISO格式的时间字符串转换为系统时间点
* @param timeStr ISO格式的时间字符串 (YYYY-MM-DDTHH:mm:ss)
* @return
*/
extern "C" XNTimePoint XNCORE_EXPORT parseISOTime(const std::string &timeStr);
extern "C" std::vector<std::string> XNCORE_EXPORT split(const std::string &str,
const std::string &delim);
extern "C" std::string XNCORE_EXPORT getFileNameWithoutExt(const std::string &path);
extern "C" int XNCORE_EXPORT safe_stoi(const std::string &str, int defaultValue = 0);
inline std::string getStringFromSqlite3(sqlite3_stmt *stmt, int column)
{
const char *text = reinterpret_cast<const char *>(sqlite3_column_text(stmt, column));
if (text == nullptr) {
return "";
}
return std::string(text);
}
} // namespace XNSim

View File

@ -64,7 +64,7 @@ void XNDDSInterface::setDataByUDPPackage(const XNByteArray &package)
}
std::unordered_map<std::string, std::string>
XNDDSInterface::getStringData(std::vector<std::string> varNames)
XNDDSInterface::getStringData(const std::vector<std::string> &varNames)
{
std::unordered_map<std::string, std::string> result;
@ -82,7 +82,7 @@ XNDDSInterface::getStringData(std::vector<std::string> varNames)
return result;
}
void XNDDSInterface::setDataByString(std::unordered_map<std::string, std::string> data)
void XNDDSInterface::setDataByString(const std::unordered_map<std::string, std::string> &data)
{
std::lock_guard<std::mutex> lock(outDataMutex);
clearOutData();

View File

@ -39,13 +39,14 @@ public:
* @param varNames:
* @return:
*/
std::unordered_map<std::string, std::string> getStringData(std::vector<std::string> varNames);
std::unordered_map<std::string, std::string>
getStringData(const std::vector<std::string> &varNames);
/**
* @brief
* @param data:
*/
void setDataByString(std::unordered_map<std::string, std::string> data);
void setDataByString(const std::unordered_map<std::string, std::string> &data);
protected:
/**
@ -54,7 +55,7 @@ protected:
* @return
*/
template <typename T>
XNByteArray getByteArray(eprosima::fastcdr::optional<T> data)
XNByteArray getByteArray(const eprosima::fastcdr::optional<T> &data)
{
XNByteArray result(getTypeSize<T>());
@ -74,7 +75,7 @@ protected:
}
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"Type must be arithmetic or std::array");
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 78");
}
return result;
@ -108,7 +109,7 @@ protected:
setByteArrayFromStdArray(data.value(), thisArray);
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"Type must be arithmetic or std::array");
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 112");
}
}
@ -125,10 +126,13 @@ protected:
for (std::size_t i = 0; i < N; ++i) {
if constexpr (std::is_arithmetic_v<T>) {
std::memcpy(result.data() + i * getTypeSize<T>(), &data[i], getTypeSize<T>());
} else {
} else if constexpr (is_std_array_v<T>) {
XNByteArray subArray = getByteArrayFromStdArray(data[i]);
std::memcpy(result.data() + i * getTypeSize<T>(), subArray.data(),
getTypeSize<T>());
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 135");
}
}
@ -149,9 +153,12 @@ protected:
for (std::size_t i = 0; i < N; ++i) {
if constexpr (std::is_arithmetic_v<T>) {
std::memcpy(&data[i], byteArray.data() + i * getTypeSize<T>(), getTypeSize<T>());
} else {
} else if constexpr (is_std_array_v<T>) {
XNByteArray subArray(byteArray.data() + i * getTypeSize<T>(), getTypeSize<T>());
setByteArrayFromStdArray(data[i], subArray);
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 160");
}
}
}
@ -162,13 +169,13 @@ protected:
* @return:
*/
template <typename T>
std::string getString(eprosima::fastcdr::optional<T> data)
std::string getString(const eprosima::fastcdr::optional<T> &data)
{
if constexpr (std::is_arithmetic_v<T>) {
if (data) {
return std::to_string(data.value());
} else {
return std::to_string(0);
return "Unknown";
}
} else if constexpr (is_std_array_v<T>) {
if (data) {
@ -177,6 +184,9 @@ protected:
T zero = {};
return getStringFromStdArray(zero);
}
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 188");
}
return std::string();
}
@ -206,6 +216,9 @@ protected:
T temp;
setStdArrayFromString(temp, items, 0);
data = temp;
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 220");
}
}
@ -215,7 +228,7 @@ protected:
* @return:
*/
template <typename T, std::size_t N>
std::string getStringFromStdArray(std::array<T, N> data)
std::string getStringFromStdArray(const std::array<T, N> &data)
{
std::stringstream ss;
for (std::size_t i = 0; i < N; ++i) {
@ -223,8 +236,11 @@ protected:
ss << ",";
if constexpr (std::is_arithmetic_v<T>) {
ss << data[i];
} else {
} else if constexpr (is_std_array_v<T>) {
ss << getStringFromStdArray(data[i]);
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 243");
}
}
return ss.str();
@ -256,60 +272,105 @@ protected:
// 对于嵌套数组,递归处理
start_pos = setStdArrayFromString(data[i], value, start_pos + i);
} else {
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
"Type must be arithmetic or std::array");
static_assert(
std::is_arithmetic_v<T> || is_std_array_v<T>,
"T 必须是算术类型或std::array类型详见XNDDSInterface.cppline 275");
}
} catch (const std::exception &e) {
throw std::runtime_error("Error parsing element " + std::to_string(i) + ": "
+ e.what());
throw std::runtime_error("无法解析第 " + std::to_string(i)
+ " 个元素: " + e.what());
}
}
return start_pos + N;
}
template <typename T1, typename T2>
void assign_value_get(eprosima::fastcdr::optional<T1> &data, T2 &model_data)
void assign_value_get(const eprosima::fastcdr::optional<T1> &data, T2 &model_data)
{
if (data) {
auto temp = data.value();
if constexpr (std::is_arithmetic_v<T1>) {
static_assert(std::is_arithmetic_v<T2>,
"模板参数T2必须是算术类型详见XNDDSInterface.cppline 293");
static_assert(std::is_convertible_v<T1, T2>,
"模板参数T1必须可以转换为T2类型详见XNDDSInterface.cppline 295");
model_data = temp;
} else if constexpr (is_std_array_v<T1>) {
size_t arraySize = array_size_v<T1>;
for (size_t i = 0; i < arraySize; ++i) {
auto temp2 = temp[i];
if constexpr (std::is_arithmetic_v<T2>) {
using array_type = typename T1::value_type;
if constexpr (std::is_arithmetic_v<array_type>) {
model_data[i] = temp2;
} else if constexpr (is_std_array_v<T2>) {
size_t arraySize2 = array_size_v<T2>;
} else if constexpr (is_std_array_v<array_type>) {
size_t arraySize2 = array_size_v<array_type>;
using sub_array_type = typename array_type::value_type;
if constexpr (std::is_arithmetic_v<sub_array_type>) {
for (size_t j = 0; j < arraySize2; ++j) {
model_data[i][j] = temp2[j];
}
} else {
static_assert(std::is_arithmetic_v<sub_array_type>,
"模板参数T1是std::"
"array类型时它的数组嵌套不能超过两层详见XNDDSInterfac"
"e.cppline 313");
}
} else {
static_assert(
std::is_arithmetic_v<array_type> || is_std_array_v<array_type>,
"模板参数T1是std::array类型时它的value_"
"type必须是算术类型或std::array类型详见XNDDSInterface.cppline 320");
}
}
} else {
static_assert(
std::is_arithmetic_v<T1> || is_std_array_v<T1>,
"模板参数T1必须是算术类型或std::array类型详见XNDDSInterface.cppline 326");
}
}
}
template <typename T1, typename T2>
void assign_value_set(eprosima::fastcdr::optional<T1> &data, T2 &model_data)
void assign_value_set(eprosima::fastcdr::optional<T1> &data, const T2 &model_data)
{
if constexpr (std::is_arithmetic_v<T1>) {
static_assert(std::is_arithmetic_v<T2>,
"模板参数T2必须是算术类型详见XNDDSInterface.cppline 337");
static_assert(std::is_convertible_v<T2, T1>,
"模板参数T2必须可以转换为T1类型详见XNDDSInterface.cppline 339");
data = model_data;
} else if constexpr (is_std_array_v<T1>) {
T1 temp;
size_t arraySize = array_size_v<T1>;
using array_type = typename T1::value_type;
for (size_t i = 0; i < arraySize; ++i) {
if constexpr (std::is_arithmetic_v<typename T1::value_type>) {
if constexpr (std::is_arithmetic_v<array_type>) {
temp[i] = model_data[i];
} else if constexpr (is_std_array_v<typename T1::value_type>) {
size_t arraySize2 = array_size_v<typename T1::value_type>;
} else if constexpr (is_std_array_v<array_type>) {
size_t arraySize2 = array_size_v<array_type>;
using sub_array_type = typename array_type::value_type;
if constexpr (std::is_arithmetic_v<sub_array_type>) {
for (size_t j = 0; j < arraySize2; ++j) {
temp[i][j] = model_data[i][j];
}
} else {
static_assert(std::is_arithmetic_v<sub_array_type>,
"模板参数T1是std::"
"array类型时它的数组嵌套不能超过两层详见XNDDSInterface."
"cppline 357");
}
} else {
static_assert(
std::is_arithmetic_v<array_type> || is_std_array_v<array_type>,
"模板参数T1是std::array类型时它的value_"
"type必须是算术类型或std::array类型详见XNDDSInterface.cppline 364");
}
}
data = temp;
} else {
static_assert(
std::is_arithmetic_v<T1> || is_std_array_v<T1>,
"模板参数T1必须是算术类型或std::array类型详见XNDDSInterface.cppline 371");
}
}
@ -330,10 +391,10 @@ protected:
#define MAP_DATA_FUNC(NAME) \
getDataFunction[#NAME] = [this]() { return getString(data.NAME()); }; \
setDataFunction[#NAME] = [this](std::string value) { \
setDataFunction[#NAME] = [this](const std::string &value) { \
setDataFromString(out_data.NAME(), value); \
}; \
getByteArrayFunction.push_back([this]() { return getByteArray(data.NAME()); }); \
setByteArrayFunction.push_back([this](XNByteArray byteArray, uint32_t &pos) { \
setByteArrayFunction.push_back([this](const XNByteArray &byteArray, uint32_t &pos) { \
setByteArray(out_data.NAME(), byteArray, pos); \
});

View File

@ -20,7 +20,7 @@ bool XNDDSManager::Initialize()
d->_status = XNFrameObjectStatus::Initialized;
d->participant_ = nullptr;
d->topics_.clear();
LOG_INFO("XNDDSManager Initialize Success!");
LOG_INFO("DDS管理器初始化成功!");
return true;
}
@ -28,7 +28,7 @@ bool XNDDSManager::PrepareForExecute()
{
T_D();
d->_status = XNFrameObjectStatus::Ready;
LOG_INFO("XNDDSManager is prepared!");
LOG_INFO("DDS管理器准备就绪!");
return true;
}
@ -40,6 +40,6 @@ void XNDDSManager::SetDomainID(uint32_t domainID)
d->participant_ = FAST_DDS_MACRO::DomainParticipantFactory::get_instance()->create_participant(
domainID, participantQos);
if (d->participant_ == nullptr) {
LOG_ERROR("0x2130 Create DomainParticipant Failed!");
LOG_ERROR("0x2130 DDS管理器创建域参与者失败!");
}
}

View File

@ -82,7 +82,7 @@ void XNFramework::SetCpuAffinity(uint32_t cpuAffinity)
bool XNFramework::Initialize(uint32_t initialType)
{
T_D();
LOG_INFO("XNFramework Initialize ...");
LOG_INFO("D01054001主框架正在初始化...");
d->ddsManager->SetFramework(XN_THISPTR);
d->timeManager->SetFramework(XN_THISPTR);
d->threadManager->SetFramework(XN_THISPTR);
@ -92,47 +92,47 @@ bool XNFramework::Initialize(uint32_t initialType)
d->eventManager->SetFramework(XN_THISPTR);
bool ret = d->eventManager->Initialize();
if (!ret) {
LOG_ERROR("XNFramework Initialize Failed!");
LOG_ERROR("B01052001主框架初始化失败");
return false;
}
ret = d->timeManager->Initialize();
if (!ret) {
LOG_ERROR("XNFramework Initialize Failed!");
LOG_ERROR("B01052002主框架初始化失败");
return false;
}
ret = d->ddsManager->Initialize();
if (!ret) {
LOG_ERROR("XNFramework Initialize Failed!");
LOG_ERROR("B01052003主框架初始化失败");
return false;
}
ret = d->serviceManager->Initialize();
if (!ret) {
LOG_ERROR("XNFramework Initialize Failed!");
LOG_ERROR("B01052004主框架初始化失败");
return false;
}
ret = d->threadManager->Initialize();
if (!ret) {
LOG_ERROR("XNFramework Initialize Failed!");
LOG_ERROR("B01052005主框架初始化失败");
return false;
}
ret = d->modelManager->Initialize();
if (!ret) {
LOG_ERROR("XNFramework Initialize Failed!");
LOG_ERROR("B01052006主框架初始化失败");
return false;
}
ret = d->scenarioManager->Initialize();
if (!ret) {
LOG_ERROR("XNFramework Initialize Failed!");
LOG_ERROR("B01052007主框架初始化失败");
return false;
}
LOG_INFO("XNFramework Initialize Success!");
LOG_INFO("XNFramework Analyze Scenario Xml ...");
LOG_INFO("D01054002主框架初始化成功");
LOG_INFO("D01054003开始解析构型文件 ...");
ret = d->scenarioManager->AnalysisScenarioXml(d->scenarioXml, initialType);
if (!ret) {
LOG_ERROR("XNFramework Analyze Scenario Xml Failed!");
LOG_ERROR("B01052008主框架解析构型文件失败");
return false;
}
LOG_INFO("XNFramework Analyze Scenario Xml Success!");
LOG_INFO("D01054004解析构型文件成功");
return true;
}

View File

@ -77,4 +77,9 @@ struct XNFrameworkPrivate : public XNObjectPrivate {
* @brief XML
*/
std::string scenarioXml;
/**
* @brief ID
*/
uint32_t configId;
};

View File

@ -178,46 +178,59 @@ public:
}
private:
// 辅助函数,用于格式化消息
/**
* @brief
* @tparam T
* @param arg
* @return
*/
template <typename T>
static std::string convertToString(const T &arg)
{
if constexpr (std::is_arithmetic<T>::value) {
if constexpr (std::is_arithmetic_v<T>) {
return std::to_string(arg); // 处理数值类型
} else {
} else if constexpr (std::is_same_v<T, std::string>) {
return arg;
} else if constexpr (std::is_convertible_v<T, std::string>) {
return std::string(arg);
} else if constexpr (std::is_same_v<T, char *> || std::is_same_v<T, const char *>) {
return std::string(arg);
} else {
static_assert(std::is_arithmetic_v<T> || std::is_same_v<T, std::string>
|| std::is_convertible_v<T, std::string> || std::is_same_v<T, char *>
|| std::is_same_v<T, const char *>,
"A01021001: 不支持的类型转换详见XNLogger.cppline 199");
}
}
// 递归变参函数,用于处理多个参数
template <typename T, typename... Args>
static std::string formatMessage(const std::string &message, T arg, Args... args)
/**
* @brief %1%2%3
* @tparam Args
* @param message
* @param args
* @return
*/
template <typename... Args>
static std::string formatMessage(const std::string &message, Args &&...args)
{
// 查找下一个参数占位符
std::string result = message;
size_t paramIndex = 0;
size_t pos = 0;
static_assert(sizeof...(Args) <= 9,
"A01021002: 单条日志参数数量超过限制详见XNLogger.cppline 216");
// 找到当前参数对应的占位符
while (true) {
std::string placeholder = "%" + std::to_string(paramIndex + 1);
pos = result.find(placeholder);
std::string result = message;
// 使用初始化列表展开参数包
int index = 1;
// 使用lambda和std::initializer_list展开参数包
(void)std::initializer_list<int>{(
[&result, &index](const auto &value) {
std::string placeholder = "%" + std::to_string(index++);
size_t pos = result.find(placeholder);
if (pos != std::string::npos) {
// 替换占位符使用placeholder的长度
result.replace(pos, placeholder.length(), convertToString(arg));
break;
result.replace(pos, placeholder.length(), convertToString(value));
}
paramIndex++;
if (paramIndex > 100) { // 防止无限循环
}(args),
0)...};
return result;
}
}
return formatMessage(result, args...);
}
// 基础情况
static std::string formatMessage(const std::string &message) { return message; }
};
/**

View File

@ -55,6 +55,7 @@ bool XNModelManager::Initialize()
}
void XNModelManager::LoadModel(const std::string &modelPath, const std::string &className,
const std::string &modelVersion, const std::string &planeName,
uint32_t initialType, uint32_t threadID)
{
T_D();
@ -77,10 +78,17 @@ void XNModelManager::LoadModel(const std::string &modelPath, const std::string &
model->SetFramework(GetFramework());
model->SetInitializeType(initialType);
model->SetThreadID(threadID);
std::string workPath = GetFramework()->GetWorkPath() + "/Packages/";
model->SetLibPath(workPath);
if (initialType == 0) {
// 使用std::filesystem处理路径
std::filesystem::path configPath =
std::filesystem::path(modelPath).parent_path() / (className + ".mcfg");
std::filesystem::path(modelPath).parent_path()
/ (className + "_V" + modelVersion + ".mcfg");
model->SetXmlPath(configPath.string());
} else if (initialType == 1) {
model->SetXmlPath(planeName + "," + className + "," + modelVersion);
}
// 注册模型到管理器
d->ModelMap[modelID] = model;
@ -92,9 +100,10 @@ void XNModelManager::LoadModel(const std::string &modelPath, const std::string &
if (threadID != 0) {
auto framework = GetFramework();
if (framework) {
framework->GetThreadManager()->RegisterFunction(
modelID, std::bind(&XNModelObject::StepUpdate, model.get()), threadID,
model->GetRunFreq(), model->GetRunNode(), model->GetRunPriority());
// 注册到线程管理器 (重复注册了,暂删除)
// framework->GetThreadManager()->RegisterFunction(
// modelID, std::bind(&XNModelObject::StepUpdate, model.get()), threadID,
// model->GetRunFreq(), model->GetRunNode(), model->GetRunPriority());
// 设置模型设置频率
double threadFreq =
framework->GetThreadManager()->GetThreadFreqByID(threadID);

View File

@ -61,10 +61,14 @@ public:
* @brief
* @param modelPath: QString类型
* @param className: QString类型
* @param modelVersion: QString类型
* @param initialType: UINT32类型
* @param threadID: UINT32类型线ID
* @details
*/
void LoadModel(const std::string &modelPath, const std::string &className, uint32_t initialType,
uint32_t threadID);
void LoadModel(const std::string &modelPath, const std::string &className,
const std::string &modelVersion, const std::string &planeName,
uint32_t initialType, uint32_t threadID);
/**
* @brief

View File

@ -192,12 +192,32 @@ void XNModelObject::SetSetFreq(double setFreq)
d->_setFreq = setFreq;
}
const std::string &XNModelObject::GetLibPath()
{
T_D();
return d->_sLibPath;
}
void XNModelObject::SetLibPath(const std::string &sLibPath)
{
T_D();
d->_sLibPath = sLibPath;
}
// 初始化函数
void XNModelObject::Initialize()
{
// 先尝试调取动态库
T_D();
if (d->_initialType == 0) {
ParseXml();
} else {
ParseConfig();
}
}
void XNModelObject::ParseXml()
{
T_D();
// 读取配置文件,设置循环执行函数
std::ifstream file(GetXmlPath());
if (!file.is_open()) {
@ -214,8 +234,7 @@ void XNModelObject::Initialize()
// 读取配置文件的模型参数
const char *modelName = rootNode->FirstChildElement("Name")->GetText();
if (!modelName || std::string(modelName) != GetObjectName()) {
LOG_WARNING(
"0x2162 The model name in the configuration file of model %1 is not consistent "
LOG_WARNING("0x2162 The model name in the configuration file of model %1 is not consistent "
"with the model name in the configuration file of model %2!",
GetObjectName(), modelName ? modelName : "null");
return;
@ -227,25 +246,24 @@ void XNModelObject::Initialize()
// 使用标准C++时间处理
std::string createTimeStr = rootNode->FirstChildElement("CreateTime")->GetText();
std::string changeTimeStr = rootNode->FirstChildElement("ChangeTime")->GetText();
d->_cCreatTime = parseISOTime(createTimeStr);
d->_cChangeTime = parseISOTime(changeTimeStr);
d->_cCreatTime = XNSim::parseISOTime(createTimeStr);
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
std::string funcNode = rootNode->FirstChildElement("Node")->GetText();
d->_runPriority = std::stoi(rootNode->FirstChildElement("Priority")->GetText());
d->_runPriority = XNSim::safe_stoi(rootNode->FirstChildElement("Priority")->GetText());
// 检查运行节点是否是 "x-x" 形式
size_t tmp = funcNode.find('-');
if (tmp == std::string::npos || tmp == 0) {
LOG_WARNING(
"0x2162 The value of the run node attribute in the configuration file of model "
LOG_WARNING("0x2162 The value of the run node attribute in the configuration file of model "
"%1 is not in the x-x format, registration not executed!",
GetObjectName());
return;
}
// 使用标准C++字符串处理
d->_runFreq = std::stoi(funcNode.substr(0, tmp));
d->_runNode = std::stoi(funcNode.substr(tmp + 1));
d->_runFreq = XNSim::safe_stoi(funcNode.substr(0, tmp));
d->_runNode = XNSim::safe_stoi(funcNode.substr(tmp + 1));
// 注册周期性函数
auto framework = GetFramework();
@ -291,6 +309,105 @@ void XNModelObject::Initialize()
}
}
}
void XNModelObject::ParseConfig()
{
T_D();
std::vector<std::string> nameAndVersion = XNSim::split(GetXmlPath(), ",");
std::string planeName = nameAndVersion[0];
std::string modelName = nameAndVersion[1];
std::string modelVersion = nameAndVersion[2];
// 获取数据库路径
std::string dbPath = std::getenv("XNCore");
if (dbPath.empty()) {
LOG_ERROR("0x1015 未设置XNCore环境变量, 引擎将退出!");
return;
}
dbPath += "/database/XNSim.db";
// 打开数据库
sqlite3 *db;
if (sqlite3_open(dbPath.c_str(), &db) != SQLITE_OK) {
LOG_ERROR("0x1016 打开数据库失败: %1", sqlite3_errmsg(db));
return;
}
// 准备SQL语句
std::string sql =
"SELECT * FROM XNModelsVersion WHERE PlaneName = ? AND ClassName = ? AND Version = ?";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
LOG_ERROR("0x1017 准备SQL语句失败: %1", sqlite3_errmsg(db));
sqlite3_close(db);
return;
}
// 绑定参数
if (sqlite3_bind_text(stmt, 1, planeName.c_str(), planeName.length(), nullptr) != SQLITE_OK
|| sqlite3_bind_text(stmt, 2, modelName.c_str(), modelName.length(), nullptr) != SQLITE_OK
|| sqlite3_bind_text(stmt, 3, modelVersion.c_str(), modelVersion.length(), nullptr)
!= SQLITE_OK) {
LOG_ERROR("0x1018 绑定参数失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(stmt);
sqlite3_close(db);
return;
}
// 执行查询
if (sqlite3_step(stmt) != SQLITE_ROW) {
LOG_ERROR("0x1019 未找到机型为%1,模型名称为%2,版本号%3的记录", planeName.c_str(),
modelName.c_str(), modelVersion.c_str());
sqlite3_finalize(stmt);
sqlite3_close(db);
return;
}
d->_sDescription = XNSim::getStringFromSqlite3(stmt, 7);
d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 6);
d->_sVersion = XNSim::getStringFromSqlite3(stmt, 2);
// 解析时间
std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 8);
std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 9);
d->_cCreatTime = XNSim::parseISOTime(createTimeStr);
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
d->_runFreq = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 10));
d->_runNode = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 11));
d->_runPriority = XNSim::safe_stoi(XNSim::getStringFromSqlite3(stmt, 12));
// 注册周期性函数
auto framework = GetFramework();
if (framework) {
auto threadManager = framework->GetThreadManager();
if (threadManager) {
threadManager->RegisterFunction(
GetUniqueId(), std::bind(&XNModelObject::StepUpdate, this), d->_threadID,
d->_runFreq, d->_runNode, d->_runPriority);
}
}
// 加载动态库
std::string mathlib = XNSim::getStringFromSqlite3(stmt, 13);
if (mathlib.length() > 0) {
// 使用标准C++文件路径处理
//std::filesystem::path xmlPath(GetXmlPath());
//d->_sLibPath = xmlPath.parent_path().string() + "/" + mathlib;
std::string libPath = d->_sLibPath + "/" + mathlib;
// 使用标准C++动态库加载
d->_dynamicLib = dlopen(libPath.c_str(), RTLD_LAZY);
if (d->_dynamicLib) { // 动态库加载成功
LOG_INFO("0x2163 模型 %1 加载数据包模型动态库 %2 成功!", GetObjectName(), libPath);
} else {
LOG_WARNING("0x2160 模型 %1 未找到数据包模型动态库 %2, 将不调用数据包模型!",
GetObjectName(), libPath);
d->_dynamicLib = nullptr;
}
}
// TODO: 读取模型命令列表
// 清理资源
sqlite3_finalize(stmt);
sqlite3_close(db);
}
// 单步执行函数

View File

@ -169,6 +169,18 @@ public:
*/
void SetSetFreq(double setFreq);
/**
* @brief
* @return const std::string&:
*/
const std::string &GetLibPath();
/**
* @brief
* @param sLibPath: std::string类型
*/
void SetLibPath(const std::string &sLibPath);
/**
* @brief
* @details
@ -238,6 +250,10 @@ public:
public:
virtual void RegisterDDSParticipant();
private:
void ParseXml();
void ParseConfig();
};
#define XN_MODEL_INITIALIZE(ClassName) \

View File

@ -66,35 +66,19 @@ bool XNScenarioManager::PrepareForExecute()
return true;
}
// 辅助函数:分割字符串
std::vector<std::string> split(const std::string &str, const std::string &delim)
{
std::vector<std::string> tokens;
size_t prev = 0, pos = 0;
do {
pos = str.find(delim, prev);
if (pos == std::string::npos)
pos = str.length();
std::string token = str.substr(prev, pos - prev);
if (!token.empty())
tokens.push_back(token);
prev = pos + delim.length();
} while (pos < str.length() && prev < str.length());
return tokens;
}
// 辅助函数:获取文件名(不含扩展名)
std::string getFileNameWithoutExt(const std::string &path)
{
size_t lastDot = path.find_last_of('.');
if (lastDot != std::string::npos) {
return path.substr(0, lastDot);
}
return path;
}
// 运行环境配置文件解析
bool XNScenarioManager::AnalysisScenarioXml(const std::string &XmlPath, uint32_t initialType)
{
T_D();
if (initialType == 0) {
return ParseScenarioXml(XmlPath);
} else {
return ParseConfig(XmlPath);
}
}
// 解析运行环境描述文件
bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
{
T_D();
std::ifstream file(XmlPath);
@ -114,6 +98,7 @@ bool XNScenarioManager::AnalysisScenarioXml(const std::string &XmlPath, uint32_t
std::string OSName = envInfo->Attribute("OSName");
std::string version = envInfo->Attribute("Version");
std::string kernel = envInfo->Attribute("RTXVersion");
std::string planeName = envInfo->Attribute("PlaneName");
// 设置工作目录
std::string rootPath = envInfo->Attribute("WorkPath");
GetFramework()->SetWorkPath(rootPath);
@ -128,7 +113,7 @@ bool XNScenarioManager::AnalysisScenarioXml(const std::string &XmlPath, uint32_t
GetFramework()->GetDDSManager()->SetDomainID(domainID);
// 读取CPU亲和性
std::string cpuAff = envInfo->Attribute("CPUAffinity");
std::vector<std::string> cpuAffList = split(cpuAff, ",");
std::vector<std::string> cpuAffList = XNSim::split(cpuAff, ",");
//读取服务列表
tinyxml2::XMLElement *serviceList = root->FirstChildElement("ServicesList");
@ -137,10 +122,12 @@ bool XNScenarioManager::AnalysisScenarioXml(const std::string &XmlPath, uint32_t
while (service) {
std::string serviceName = service->Attribute("Name");
std::string libName = service->Attribute("ClassName");
libName = getFileNameWithoutExt(libName);
std::string dynamicLibName = servicePath + "lib" + libName + ".so";
std::string serviceVersion = service->Attribute("Version");
libName = XNSim::getFileNameWithoutExt(libName);
std::string dynamicLibName = servicePath + "/lib" + libName + ".so." + serviceVersion;
// 加载动态库
GetFramework()->GetServiceManager()->LoadService(dynamicLibName, libName, 0);
GetFramework()->GetServiceManager()->LoadService(dynamicLibName, libName,
serviceVersion, 0);
service = service->NextSiblingElement("Service");
}
}
@ -153,14 +140,14 @@ bool XNScenarioManager::AnalysisScenarioXml(const std::string &XmlPath, uint32_t
// 读取模型分组频率
double modelGroupFreq = std::stod(modelGroup->Attribute("Freq"));
// 读取模型分组优先级
int modelGroupPriority = std::stoi(modelGroup->Attribute("Priority"));
int modelGroupPriority = XNSim::safe_stoi(modelGroup->Attribute("Priority"));
if (modelGroupPriority > 99 || modelGroupPriority < 0) {
LOG_ERROR("0x2100 模型分组优先级设置错误,优先级值:%d", modelGroupPriority);
return false;
}
// 读取模型分组CPU亲和性
std::string modelGroupCPUAff = modelGroup->Attribute("CPUAff");
std::vector<std::string> modelGroupCPUAffList = split(modelGroupCPUAff, ",");
std::vector<std::string> modelGroupCPUAffList = XNSim::split(modelGroupCPUAff, ",");
// 验证CPU亲和性
for (const auto &cpu : modelGroupCPUAffList) {
@ -188,10 +175,12 @@ bool XNScenarioManager::AnalysisScenarioXml(const std::string &XmlPath, uint32_t
while (model) {
std::string modelName = model->Attribute("Name");
std::string libName = model->Attribute("ClassName");
libName = getFileNameWithoutExt(libName);
std::string dynamicLibName = modelPath + "lib" + libName + ".so";
std::string modelVersion = model->Attribute("Version");
libName = XNSim::getFileNameWithoutExt(libName);
std::string dynamicLibName = modelPath + "/lib" + libName + ".so." + modelVersion;
// 加载动态库
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, libName, 0, threadID);
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, libName, modelVersion,
planeName, 0, threadID);
model = model->NextSiblingElement("Model");
}
@ -200,3 +189,220 @@ bool XNScenarioManager::AnalysisScenarioXml(const std::string &XmlPath, uint32_t
return true;
}
// 解析构型配置文件
bool XNScenarioManager::ParseConfig(const std::string &ConfigID)
{
T_D();
// 获取数据库路径
std::string XNCorePath = std::getenv("XNCore");
if (XNCorePath.empty()) {
LOG_ERROR("0x1015 未设置XNCore环境变量, 引擎将退出!");
return false;
}
std::string dbPath = XNCorePath + "/database/XNSim.db";
// 打开数据库
sqlite3 *db;
if (sqlite3_open(dbPath.c_str(), &db) != SQLITE_OK) {
LOG_ERROR("0x1016 打开数据库失败: %1", sqlite3_errmsg(db));
return false;
}
// 准备SQL语句
std::string sql = "SELECT * FROM Configuration WHERE ConfID = ?";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
LOG_ERROR("0x1017 准备SQL语句失败: %1", sqlite3_errmsg(db));
sqlite3_close(db);
return false;
}
// 绑定参数
int configIdInt = XNSim::safe_stoi(ConfigID);
if (sqlite3_bind_int(stmt, 1, configIdInt) != SQLITE_OK) {
LOG_ERROR("0x1018 绑定参数失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
// 执行查询
if (sqlite3_step(stmt) != SQLITE_ROW) {
LOG_ERROR("0x1019 未找到配置ID为%1的记录", ConfigID);
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
std::string planeName = XNSim::getStringFromSqlite3(stmt, 1);
std::string osName = XNSim::getStringFromSqlite3(stmt, 3);
std::string version = XNSim::getStringFromSqlite3(stmt, 4);
std::string kernel = XNSim::getStringFromSqlite3(stmt, 5);
std::string rootPath = XNSim::getStringFromSqlite3(stmt, 7);
if (rootPath.empty()) {
LOG_WARNING("0x1020 未设置工作目录,使用默认工作目录: %1", XNCorePath);
rootPath = XNCorePath;
}
GetFramework()->SetWorkPath(rootPath);
// 设置模型库目录
std::string modelPath = rootPath + XNSim::getStringFromSqlite3(stmt, 8);
if (modelPath.empty()) {
LOG_WARNING("0x1020 未设置模型库目录,使用默认模型库目录: %1/Models", XNCorePath);
modelPath = XNCorePath + "/Models";
}
GetFramework()->SetModelPath(modelPath);
// 设置服务库目录
std::string servicePath = rootPath + XNSim::getStringFromSqlite3(stmt, 9);
if (servicePath.empty()) {
LOG_WARNING("0x1020 未设置服务库目录,使用默认服务库目录: %1/Services", XNCorePath);
servicePath = XNCorePath + "/Services";
}
GetFramework()->SetServicePath(servicePath);
// 设置域ID
uint32_t domainID = std::stoul(XNSim::getStringFromSqlite3(stmt, 10));
if (domainID == 0 || domainID > 225) {
LOG_WARNING("0x1020 域ID设置错误使用默认域ID: 10");
domainID = 10;
}
GetFramework()->GetDDSManager()->SetDomainID(domainID);
// 读取CPU亲和性
std::string cpuAff = XNSim::getStringFromSqlite3(stmt, 6);
std::vector<std::string> cpuAffList = XNSim::split(cpuAff, ",");
//查询LoadServices表读取服务信息
std::string servicesSql = "SELECT * FROM LoadServices WHERE ConfID = ?";
sqlite3_stmt *servicesStmt;
if (sqlite3_prepare_v2(db, servicesSql.c_str(), -1, &servicesStmt, nullptr) != SQLITE_OK) {
LOG_ERROR("0x1020 准备LoadServices查询语句失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
// 绑定参数
if (sqlite3_bind_int(servicesStmt, 1, configIdInt) != SQLITE_OK) {
LOG_ERROR("0x1021 绑定LoadServices参数失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(servicesStmt);
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
// 执行查询并处理结果
while (sqlite3_step(servicesStmt) == SQLITE_ROW) {
// 获取服务信息
std::string ClassName = XNSim::getStringFromSqlite3(servicesStmt, 1);
std::string ServiceVersion = XNSim::getStringFromSqlite3(servicesStmt, 2);
std::string ServiceName = XNSim::getStringFromSqlite3(servicesStmt, 3);
ClassName = XNSim::getFileNameWithoutExt(ClassName);
std::string dynamicLibName = servicePath + "/lib" + ClassName + ".so." + ServiceVersion;
// 加载动态库
GetFramework()->GetServiceManager()->LoadService(dynamicLibName, ClassName, ServiceVersion,
1);
}
// 查询LoadModelGroups表读取模型组信息
std::string modelGroupsSql = "SELECT * FROM LoadModelGroups WHERE ConfID = ?";
sqlite3_stmt *modelGroupsStmt;
if (sqlite3_prepare_v2(db, modelGroupsSql.c_str(), -1, &modelGroupsStmt, nullptr)
!= SQLITE_OK) {
LOG_ERROR("0x1020 准备LoadModelGroups查询语句失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(servicesStmt);
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
// 绑定参数
if (sqlite3_bind_int(modelGroupsStmt, 1, configIdInt) != SQLITE_OK) {
LOG_ERROR("0x1021 绑定LoadModelGroups参数失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(modelGroupsStmt);
sqlite3_finalize(servicesStmt);
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
// 执行查询并处理结果
while (sqlite3_step(modelGroupsStmt) == SQLITE_ROW) {
// 获取模型组信息
std::string GroupID = XNSim::getStringFromSqlite3(modelGroupsStmt, 1);
std::string GroupName = XNSim::getStringFromSqlite3(modelGroupsStmt, 2);
double GroupFreq = std::stod(XNSim::getStringFromSqlite3(modelGroupsStmt, 3));
uint32_t GroupPriority = XNSim::safe_stoi(XNSim::getStringFromSqlite3(modelGroupsStmt, 4));
std::string GroupCPUAff = XNSim::getStringFromSqlite3(modelGroupsStmt, 5);
std::vector<std::string> GroupCPUAffList = XNSim::split(GroupCPUAff, ",");
// 验证CPU亲和性
for (const auto &cpu : GroupCPUAffList) {
if (std::find(cpuAffList.begin(), cpuAffList.end(), cpu) == cpuAffList.end()) {
LOG_ERROR("0x2100 模型分组CPU亲和性设置错误CPU亲和性值%s,进程CPU亲和性值%s",
cpu.c_str(), cpuAff.c_str());
sqlite3_finalize(modelGroupsStmt);
sqlite3_finalize(servicesStmt);
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
}
int ThreadCpuAffinity = 0;
for (const auto &cpu : GroupCPUAffList) {
auto it = std::find(cpuAffList.begin(), cpuAffList.end(), cpu);
if (it != cpuAffList.end()) {
ThreadCpuAffinity |= 1 << std::distance(cpuAffList.begin(), it);
}
}
LOG_INFO("0x1021 添加线程池: %1", GroupName);
// 添加线程池
uint32_t threadID = GetFramework()->GetThreadManager()->AddThreadPool(
GroupName, GroupFreq, GroupPriority, ThreadCpuAffinity);
// 准备查询LoadModels表的SQL语句
std::string modelsSql = "SELECT * FROM LoadModels WHERE GroupID = ?";
sqlite3_stmt *modelsStmt = nullptr;
if (sqlite3_prepare_v2(db, modelsSql.c_str(), -1, &modelsStmt, nullptr) != SQLITE_OK) {
LOG_ERROR("0x1022 准备LoadModels查询语句失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(modelGroupsStmt);
sqlite3_finalize(servicesStmt);
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
// 绑定参数
if (sqlite3_bind_int(modelsStmt, 1, XNSim::safe_stoi(GroupID)) != SQLITE_OK) {
LOG_ERROR("0x1023 绑定LoadModels参数失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(modelsStmt);
sqlite3_finalize(modelGroupsStmt);
sqlite3_finalize(servicesStmt);
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
// 执行查询并处理结果
while (sqlite3_step(modelsStmt) == SQLITE_ROW) {
// 获取模型信息
std::string ClassName = XNSim::getStringFromSqlite3(modelsStmt, 1);
std::string ModelVersion = XNSim::getStringFromSqlite3(modelsStmt, 2);
std::string ModelName = XNSim::getStringFromSqlite3(modelsStmt, 3);
ClassName = XNSim::getFileNameWithoutExt(ClassName);
std::string dynamicLibName = modelPath + "/lib" + ClassName + ".so." + ModelVersion;
// 加载动态库
LOG_INFO("0x1021 加载模型: %1", dynamicLibName);
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, ClassName, ModelVersion,
planeName, 1, threadID);
}
// 清理资源
sqlite3_finalize(modelsStmt);
}
// 清理资源
sqlite3_finalize(modelGroupsStmt);
sqlite3_finalize(servicesStmt);
sqlite3_finalize(stmt);
sqlite3_close(db);
return true;
}

View File

@ -76,4 +76,21 @@ public:
* @return false:
*/
virtual bool AnalysisScenarioXml(const std::string &XmlPath, uint32_t initialType);
private:
/**
* @brief
* @param XmlPath: std::string类型
* @return true:
* @return false:
*/
bool ParseScenarioXml(const std::string &XmlPath);
/**
* @brief
* @param ConfigID: std::string类型ID
* @return true:
* @return false:
*/
bool ParseConfig(const std::string &ConfigID);
};

View File

@ -38,7 +38,7 @@ bool XNServiceManager::PrepareForExecute()
}
void XNServiceManager::LoadService(const std::string &servicePath, const std::string &serviceName,
uint32_t initialType)
const std::string &serviceVersion, uint32_t initialType)
{
T_D();
void *handle = dlopen(servicePath.c_str(), RTLD_LAZY);
@ -59,15 +59,26 @@ void XNServiceManager::LoadService(const std::string &servicePath, const std::st
service->SetUniqueId(serviceID);
service->SetObjectName(serviceName);
service->SetFramework(GetFramework());
if (initialType == 0) {
// 使用std::filesystem处理路径
std::filesystem::path configPath =
std::filesystem::path(servicePath).parent_path() / (serviceName + ".scfg");
std::filesystem::path(servicePath).parent_path()
/ (serviceName + "_V" + serviceVersion + ".scfg");
service->SetXmlPath(configPath.string());
} else if (initialType == 1) {
LOG_INFO("0x2176 加载服务: %1", serviceName + "," + serviceVersion);
service->SetXmlPath(serviceName + "," + serviceVersion);
} else {
LOG_WARNING("0x2175 InitialType Error, InitialType: %d", initialType);
dlclose(handle);
return;
}
// 注册服务到管理器
d->ServiceList[serviceID] = service;
service->SetInitializeType(initialType);
// 初始化服务
LOG_INFO("0x2176 初始化服务: %1", serviceName);
service->Initialize();
} else {
LOG_WARNING("0x2173 Service %s Not found in dynamic link library %s!",

View File

@ -29,7 +29,7 @@ public:
virtual bool Initialize() override;
virtual bool PrepareForExecute() override;
void LoadService(const std::string &servicePath, const std::string &serviceName,
uint32_t initialType);
const std::string &serviceVersion, uint32_t initialType);
public:
XNServiceObjectPtr GetService(uint32_t serviceID);

View File

@ -139,6 +139,15 @@ void XNServiceObject::Initialize()
{
T_D();
if (d->_initialType == 0) {
ParseXml();
} else {
ParseConfig();
}
}
void XNServiceObject::ParseXml()
{
T_D();
tinyxml2::XMLDocument doc;
if (doc.LoadFile(GetXmlPath().c_str()) != tinyxml2::XML_SUCCESS) {
LOG_WARNING("Failed to open the service configuration file: %1!", GetXmlPath());
@ -153,8 +162,7 @@ void XNServiceObject::Initialize()
const char *serviceName = rootNode->FirstChildElement("Name")->GetText();
if (serviceName != GetObjectName()) {
LOG_WARNING(
"The service name in the configuration file of service %1 is not consistent "
LOG_WARNING("The service name in the configuration file of service %1 is not consistent "
"with the service name in the configuration file of service %2!",
GetObjectName(), serviceName);
return;
@ -167,8 +175,8 @@ void XNServiceObject::Initialize()
// 解析时间
const char *createTimeStr = rootNode->FirstChildElement("CreateTime")->GetText();
const char *changeTimeStr = rootNode->FirstChildElement("ChangeTime")->GetText();
d->_cCreateTime = parseISOTime(createTimeStr);
d->_cChangeTime = parseISOTime(changeTimeStr);
d->_cCreateTime = XNSim::parseISOTime(createTimeStr);
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
tinyxml2::XMLElement *nodeCmds = rootNode->FirstChildElement("CommandList");
if (nodeCmds) {
@ -180,8 +188,103 @@ void XNServiceObject::Initialize()
// TODO: 处理命令信息
}
}
} else {
}
void XNServiceObject::ParseConfig()
{
T_D();
std::vector<std::string> nameAndVersion = XNSim::split(GetXmlPath(), ",");
std::string serviceName = nameAndVersion[0];
std::string serviceVersion = nameAndVersion[1];
// 获取数据库路径
std::string dbPath = std::getenv("XNCore");
if (dbPath.empty()) {
LOG_ERROR("0x1015 未设置XNCore环境变量, 引擎将退出!");
return;
}
dbPath += "/database/XNSim.db";
// 打开数据库
sqlite3 *db;
if (sqlite3_open(dbPath.c_str(), &db) != SQLITE_OK) {
LOG_ERROR("0x1016 打开数据库失败: %1", sqlite3_errmsg(db));
return;
}
// 准备SQL语句
std::string sql = "SELECT * FROM XNServiceVersion WHERE ClassName = ? AND Version = ?";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
LOG_ERROR("0x1017 准备SQL语句失败: %1", sqlite3_errmsg(db));
sqlite3_close(db);
return;
}
// 绑定参数
if (sqlite3_bind_text(stmt, 1, serviceName.c_str(), serviceName.length(), nullptr) != SQLITE_OK
|| sqlite3_bind_text(stmt, 2, serviceVersion.c_str(), serviceVersion.length(), nullptr)
!= SQLITE_OK) {
LOG_ERROR("0x1018 绑定参数失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(stmt);
sqlite3_close(db);
return;
}
// 执行查询
if (sqlite3_step(stmt) != SQLITE_ROW) {
LOG_ERROR("0x1019 未找到服务名称为%1,版本号%2的记录", serviceName.c_str(),
serviceVersion.c_str());
sqlite3_finalize(stmt);
sqlite3_close(db);
return;
}
d->_sDescription = XNSim::getStringFromSqlite3(stmt, 5);
d->_sAuthor = XNSim::getStringFromSqlite3(stmt, 4);
d->_sVersion = XNSim::getStringFromSqlite3(stmt, 2);
// 解析时间
std::string createTimeStr = XNSim::getStringFromSqlite3(stmt, 6);
std::string changeTimeStr = XNSim::getStringFromSqlite3(stmt, 7);
d->_cCreateTime = XNSim::parseISOTime(createTimeStr);
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
// 读取服务命令列表
std::string commandListStr = XNSim::getStringFromSqlite3(stmt, 8);
if (!commandListStr.empty()) {
try {
XN_JSON commandList = XN_JSON::parse(commandListStr);
if (commandList.is_array()) {
for (const auto &cmd : commandList) {
if (cmd.contains("Name") && cmd.contains("Description")
&& cmd.contains("Call")) {
LOG_INFO("0x1021 服务命令: %1", cmd["Name"].get<std::string>());
// TODO: 处理服务命令信息
// d->_commandList.emplace_back(
// cmd["Name"].get<std::string>(),
// cmd["Description"].get<std::string>(),
// cmd["Call"].get<std::string>()
// );
}
}
}
} catch (const std::exception &e) {
LOG_WARNING("0x1020 解析服务命令列表失败: %1", e.what());
}
}
// 读取其他参数
std::string otherParamsStr = XNSim::getStringFromSqlite3(stmt, 9);
if (!otherParamsStr.empty()) {
try {
d->_otherParams = XN_JSON::parse(otherParamsStr);
} catch (const std::exception &e) {
LOG_WARNING("0x1020 解析其他参数失败: %1", e.what());
}
}
// 清理资源
sqlite3_finalize(stmt);
sqlite3_close(db);
}
void XNServiceObject::PrepareForExecute()

View File

@ -54,6 +54,10 @@ public:
protected:
XNFrameworkPtr GetFramework() const;
private:
void ParseXml();
void ParseConfig();
};
XNCLASS_PTR_DECLARE(XNServiceObject)

View File

@ -11,4 +11,5 @@ struct XNServiceObjectPrivate : public XNObjectPrivate {
std::unordered_map<std::string, FAST_DDS_MACRO::DataWriter *> _dataWriters;
XNFrameworkPtr pFramework;
uint32_t _initialType;
XN_JSON _otherParams;
};

View File

@ -15,6 +15,7 @@ endif()
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(SQLite3 REQUIRED)
add_executable(XNEngine
main.cpp
@ -30,6 +31,7 @@ target_link_libraries(XNEngine PRIVATE
pthread
OpenSSL::SSL
OpenSSL::Crypto
sqlite3
dl
)

View File

@ -16,6 +16,7 @@
#include "../XNCore/XNServiceManager.h"
#include "../XNCore/XNModelManager.h"
#include "../XNCore/XNScenarioManager.h"
#include <sqlite3.h>
// 引擎类构造函数
XNEngine::XNEngine()
@ -55,35 +56,42 @@ void XNEngine::SimControlListener(const XNSim::XNSimControl::XNRuntimeControl &c
}
}
// 设置日志级别
bool XNEngine::SetLogLevel(const std::string &XmlPath)
// 解析配置文件
bool XNEngine::ParseConfig(const std::string &XmlPath)
{
size_t index = XmlPath.find_last_of('.');
if (index != std::string::npos) {
std::string suffix = XmlPath.substr(index);
if (suffix != ".xml" && suffix != ".sce") {
std::cerr << "0x1005 配置文件不是 .xml 或 .sce 文件, 引擎将退出!" << std::endl;
return false;
}
} else {
std::cerr << "0x1006 配置文件没有 .xml 或 .sce 的后缀名, 引擎将退出!" << std::endl;
return false;
}
// 打开配置文件
std::ifstream file(XmlPath);
if (!file.is_open()) {
std::cerr << "0x1003 Failed to open the runtime environment configuration file, "
"the engine will exit!"
<< std::endl;
std::cerr << "0x1007 打开配置文件失败, 引擎将退出!" << std::endl;
return false;
}
// 解析配置文件
tinyxml2::XMLDocument doc;
if (doc.LoadFile(XmlPath.c_str()) != tinyxml2::XML_SUCCESS) {
std::cerr << "0x1004 Failed to parse the runtime environment configuration file, "
"the engine will exit!"
<< std::endl;
std::cerr << "0x1008 解析配置文件失败, 引擎将退出!" << std::endl;
return false;
}
// 获取根元素
tinyxml2::XMLElement *root = doc.FirstChildElement("Scenario");
if (!root) {
std::cerr << "0x1005 Failed to find Scenario element in configuration file!" << std::endl;
std::cerr << "0x1009 配置文件中未找到 Scenario 根元素, 引擎将退出!" << std::endl;
return false;
}
// 顺便读取一下CPU亲和性
int cpus = sysconf(_SC_NPROCESSORS_ONLN);
std::cout << "Current number of CPU cores-> " << cpus << std::endl;
std::cout << "当前CPU核心数-> " << cpus << std::endl;
// 设置CPU亲和性
cpu_set_t mask;
@ -106,30 +114,34 @@ bool XNEngine::SetLogLevel(const std::string &XmlPath)
CPU_SET(index, &mask);
}
} catch (const std::exception &e) {
std::cerr << "Invalid CPU affinity value: " << cpuIndex << std::endl;
std::cerr << "0x1010 无效的CPU亲和性值: " << cpuIndex << std::endl;
}
}
}
}
if (sched_setaffinity(0, sizeof(mask), &mask) == -1) {
std::cerr << "0x1020 Failed to set engine CPU affinity-> " << strerror(errno) << std::endl;
std::cerr << "0x1011 设置引擎CPU亲和性失败-> " << strerror(errno) << std::endl;
return false;
}
std::cout << "Successfully set engine CPU affinity-> " << CPUAffinity << std::endl;
std::cout << "成功设置引擎CPU亲和性-> " << CPUAffinity << std::endl;
// 锁定内存
if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
std::cerr << "0x1021 Failed to lock engine memory-> " << strerror(errno) << std::endl;
std::cerr << "0x1012 锁定引擎内存失败-> " << strerror(errno) << std::endl;
return false;
}
std::cout << "Successfully locked engine memory!" << std::endl;
std::cout << "成功锁定引擎内存!" << std::endl;
// 获取配置文件中的日志元素
bool isDebug = false;
bool isInfo = false;
bool isWarn = false;
bool isError = false;
// 获取配置文件中的控制台输出元素
tinyxml2::XMLElement *consoleOutputNode = root->FirstChildElement("ConsoleOutput");
if (!consoleOutputNode) {
std::cout << "The runtime environment configuration file does not contain "
"the ConsoleOutput element, the Console will Output all Log!"
std::cout << "0x1013 配置文件中未找到 ConsoleOutput 元素, 控制台将输出所有日志!"
<< std::endl;
} else {
// 获取配置文件中的调试日志输出元素
@ -138,9 +150,9 @@ bool XNEngine::SetLogLevel(const std::string &XmlPath)
&& (strcmp(debugConsoleOutput, "true") == 0 || strcmp(debugConsoleOutput, "1") == 0
|| strcmp(debugConsoleOutput, "True") == 0
|| strcmp(debugConsoleOutput, "TRUE") == 0)) {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Debug, true);
isDebug = true;
} else {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Debug, false);
isDebug = false;
}
// 获取配置文件中的信息日志输出元素
@ -149,9 +161,9 @@ bool XNEngine::SetLogLevel(const std::string &XmlPath)
&& (strcmp(infoConsoleOutput, "true") == 0 || strcmp(infoConsoleOutput, "1") == 0
|| strcmp(infoConsoleOutput, "True") == 0
|| strcmp(infoConsoleOutput, "TRUE") == 0)) {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Info, true);
isInfo = true;
} else {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Info, false);
isInfo = false;
}
// 获取配置文件中的警告日志输出元素
@ -160,9 +172,9 @@ bool XNEngine::SetLogLevel(const std::string &XmlPath)
&& (strcmp(warningConsoleOutput, "true") == 0 || strcmp(warningConsoleOutput, "1") == 0
|| strcmp(warningConsoleOutput, "True") == 0
|| strcmp(warningConsoleOutput, "TRUE") == 0)) {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Warning, true);
isWarn = true;
} else {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Warning, false);
isWarn = false;
}
// 获取配置文件中的错误日志输出元素
@ -171,27 +183,26 @@ bool XNEngine::SetLogLevel(const std::string &XmlPath)
&& (strcmp(errorConsoleOutput, "true") == 0 || strcmp(errorConsoleOutput, "1") == 0
|| strcmp(errorConsoleOutput, "True") == 0
|| strcmp(errorConsoleOutput, "TRUE") == 0)) {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Error, true);
isError = true;
} else {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Error, false);
isError = false;
}
}
// 设置控制台输出
SetConsoleOutput(isDebug, isInfo, isWarn, isError);
// 获取配置文件中的日志元素
tinyxml2::XMLElement *logNode = root->FirstChildElement("Log");
if (!logNode) {
std::cout << "The runtime environment configuration file does not contain "
"the Log element, the Log File will record all Log!"
<< std::endl;
std::cout << "0x1014 配置文件中未找到 Log 元素, 日志文件将记录所有日志!" << std::endl;
} else {
// 获取配置文件中的调试日志输出元素
const char *debugLog = logNode->Attribute("Debug");
if (debugLog
&& (strcmp(debugLog, "true") == 0 || strcmp(debugLog, "1") == 0
|| strcmp(debugLog, "True") == 0 || strcmp(debugLog, "TRUE") == 0)) {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Debug, true);
isDebug = true;
} else {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Debug, false);
isDebug = false;
}
// 获取配置文件中的信息日志输出元素
@ -199,9 +210,9 @@ bool XNEngine::SetLogLevel(const std::string &XmlPath)
if (infoLog
&& (strcmp(infoLog, "true") == 0 || strcmp(infoLog, "1") == 0
|| strcmp(infoLog, "True") == 0 || strcmp(infoLog, "TRUE") == 0)) {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Info, true);
isInfo = true;
} else {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Info, false);
isInfo = false;
}
// 获取配置文件中的警告日志输出元素
@ -209,9 +220,9 @@ bool XNEngine::SetLogLevel(const std::string &XmlPath)
if (warningLog
&& (strcmp(warningLog, "true") == 0 || strcmp(warningLog, "1") == 0
|| strcmp(warningLog, "True") == 0 || strcmp(warningLog, "TRUE") == 0)) {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Warning, true);
isWarn = true;
} else {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Warning, false);
isWarn = false;
}
// 获取配置文件中的错误日志输出元素
@ -219,18 +230,73 @@ bool XNEngine::SetLogLevel(const std::string &XmlPath)
if (errorLog
&& (strcmp(errorLog, "true") == 0 || strcmp(errorLog, "1") == 0
|| strcmp(errorLog, "True") == 0 || strcmp(errorLog, "TRUE") == 0)) {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Error, true);
isError = true;
} else {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Error, false);
isError = false;
}
}
// 设置日志级别
SetLogLevel(isDebug, isInfo, isWarn, isError);
// 关闭配置文件
file.close();
// 返回成功
return true;
}
// 设置控制台输出
bool XNEngine::SetConsoleOutput(bool isDebug, bool isInfo, bool isWarn, bool isError)
{
if (isDebug) {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Debug, true);
} else {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Debug, false);
}
if (isInfo) {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Info, true);
} else {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Info, false);
}
if (isWarn) {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Warning, true);
} else {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Warning, false);
}
if (isError) {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Error, true);
} else {
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Error, false);
}
return true;
}
// 设置日志级别
bool XNEngine::SetLogLevel(bool isDebug, bool isInfo, bool isWarn, bool isError)
{
if (isDebug) {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Debug, true);
} else {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Debug, false);
}
if (isInfo) {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Info, true);
} else {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Info, false);
}
if (isWarn) {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Warning, true);
} else {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Warning, false);
}
if (isError) {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Error, true);
} else {
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Error, false);
}
return true;
}
// 发布引擎状态
void XNEngine::PublishEngineStatus()
{
@ -332,31 +398,43 @@ void XNEngine::PublishEngineStatus()
// 写入引擎状态
engineStatusWriter->write(&engineStatus);
// 记录调试日志
LOG_DEBUG("XNEngine Write DDS!");
LOG_DEBUG("引擎运行状态 DDS 写入成功!");
}
}
// 运行引擎
bool XNEngine::Run(const std::string &XmlPath)
bool XNEngine::Run(const std::string &XmlPath, const uint32_t InitializeType)
{
if (!framework) {
return false;
}
// 设置日志级别
bool isReady = SetLogLevel(XmlPath);
// 如果设置日志级别失败
if (InitializeType == 0) {
// 解析配置文件
bool isReady = ParseConfig(XmlPath);
// 如果解析配置文件失败
if (!isReady) {
// 返回失败
return false;
}
} else if (InitializeType == 1) {
// 解析数据库
bool isReady = ParseDataBase(XmlPath);
// 如果解析数据库失败
if (!isReady) {
// 返回失败
return false;
}
}
// 设置场景XML路径
framework->SetScenarioXml(XmlPath);
// 设置CPU亲和性
framework->SetCpuAffinity(CPUAffinity);
// 单次触发初始化信号
bool ret = framework->Initialize(0);
bool ret = framework->Initialize(InitializeType);
// 如果初始化失败
if (!ret) {
LOG_ERROR("0x1012 初始化失败, 引擎将退出!");
// 返回失败
return false;
}
@ -364,17 +442,18 @@ bool XNEngine::Run(const std::string &XmlPath)
// 设置框架状态
frameworkStatus = XNFrameObjectStatus::Initialized;
// 记录信息日志
LOG_INFO("XNEngine Initialize Success!");
LOG_INFO("引擎初始化成功!");
// 如果测试模式
if (isTestMode) {
// 记录信息日志
LOG_INFO("Verification passed!");
LOG_INFO("引擎测试通过!");
// 返回成功
return true;
}
ret = framework->PrepareForExecute();
// 如果准备执行失败
if (!ret) {
LOG_ERROR("0x1013 准备执行失败, 引擎将退出!");
// 返回失败
return false;
}
@ -412,15 +491,117 @@ bool XNEngine::Run(const std::string &XmlPath)
}
} else {
// 记录错误日志
LOG_ERROR("0x1007 Failed to prepare for execution, the engine will exit!");
LOG_ERROR("0x1014 无法发送引擎运行状态, 引擎将退出!");
}
// 返回成功
return true;
}
bool XNEngine::Run(const uint32_t &ConfigId)
// 运行引擎
bool XNEngine::ParseDataBase(const std::string &ConfigId)
{
// 获取数据库路径
std::string dbPath = std::getenv("XNCore");
if (dbPath.empty()) {
LOG_ERROR("0x1015 未设置XNCore环境变量, 引擎将退出!");
return false;
}
dbPath += "/database/XNSim.db";
// 打开数据库
sqlite3 *db;
if (sqlite3_open(dbPath.c_str(), &db) != SQLITE_OK) {
LOG_ERROR("0x1016 打开数据库失败: %1", sqlite3_errmsg(db));
return false;
}
// 准备SQL语句
std::string sql = "SELECT * FROM Configuration WHERE ConfID = ?";
sqlite3_stmt *stmt;
if (sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
LOG_ERROR("0x1017 准备SQL语句失败: %1", sqlite3_errmsg(db));
sqlite3_close(db);
return false;
}
// 绑定参数
int configIdInt = std::stoi(ConfigId);
if (sqlite3_bind_int(stmt, 1, configIdInt) != SQLITE_OK) {
LOG_ERROR("0x1018 绑定参数失败: %1", sqlite3_errmsg(db));
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
// 执行查询
if (sqlite3_step(stmt) != SQLITE_ROW) {
LOG_ERROR("0x1019 未找到配置ID为%1的记录", ConfigId);
sqlite3_finalize(stmt);
sqlite3_close(db);
return false;
}
int cpus = sysconf(_SC_NPROCESSORS_ONLN);
std::cout << "当前CPU核心数-> " << cpus << std::endl;
// 设置CPU亲和性
cpu_set_t mask;
CPU_ZERO(&mask);
CPUAffinity = 0;
// 读取配置信息
std::string CPUAff = XNSim::getStringFromSqlite3(stmt, 6);
//std::string CPUAff = reinterpret_cast<const char *>(sqlite3_column_text(stmt, 6));
std::istringstream iss(CPUAff);
std::string cpuIndex;
while (std::getline(iss, cpuIndex, ',')) {
try {
int index = std::stoi(cpuIndex);
if (index >= 0 && index < cpus) {
CPUAffinity |= (1 << index);
CPU_SET(index, &mask);
}
} catch (const std::exception &e) {
std::cerr << "0x1010 无效的CPU亲和性值: " << cpuIndex << std::endl;
}
}
if (sched_setaffinity(0, sizeof(mask), &mask) == -1) {
std::cerr << "0x1011 设置引擎CPU亲和性失败-> " << strerror(errno) << std::endl;
return false;
}
std::cout << "成功设置引擎CPU亲和性-> " << CPUAffinity << std::endl;
// 锁定内存
if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
std::cerr << "0x1012 锁定引擎内存失败-> " << strerror(errno) << std::endl;
return false;
}
std::cout << "成功锁定引擎内存!" << std::endl;
auto readBoolean = [](sqlite3_stmt *stmt, int column) -> bool {
return sqlite3_column_int(stmt, column) != 0;
};
bool isDebug = readBoolean(stmt, 11);
bool isInfo = readBoolean(stmt, 12);
bool isWarn = readBoolean(stmt, 13);
bool isError = readBoolean(stmt, 14);
SetConsoleOutput(isDebug, isInfo, isWarn, isError);
isDebug = readBoolean(stmt, 15);
isInfo = readBoolean(stmt, 16);
isWarn = readBoolean(stmt, 17);
isError = readBoolean(stmt, 18);
SetLogLevel(isDebug, isInfo, isWarn, isError);
// 清理资源
sqlite3_finalize(stmt);
sqlite3_close(db);
return true;
}
// 设置测试模式

View File

@ -27,25 +27,21 @@ public:
* @brief
*/
~XNEngine();
public:
/**
* @brief 仿
* @param cmd 仿
*/
void SimControlListener(const XNSim::XNSimControl::XNRuntimeControl &cmd);
public:
/**
* @brief
* @param XmlPath XML路径
* @return
*/
bool Run(const std::string &XmlPath);
/**
* @brief
* @param ConfigId ID
* @return
*/
bool Run(const uint32_t &ConfigId);
bool Run(const std::string &XmlPath, const uint32_t InitializeType);
/**
* @brief
* @param isTestMode
@ -54,11 +50,37 @@ public:
private:
/**
* @brief
* @param XmlPath XML路
* @brief
* @param XmlPath
* @return
*/
bool SetLogLevel(const std::string &XmlPath);
bool ParseConfig(const std::string &XmlPath);
/**
* @brief
* @param ConfigId ID
* @return
*/
bool ParseDataBase(const std::string &ConfigId);
/**
* @brief
* @param isDebug
* @param isInfo
* @param isWarn
* @param isError
* @return
*/
bool SetConsoleOutput(bool isDebug, bool isInfo, bool isWarn, bool isError);
/**
* @brief
* @param isDebug
* @param isInfo
* @param isWarn
* @param isError
* @return
*/
bool SetLogLevel(bool isDebug, bool isInfo, bool isWarn, bool isError);
/**
* @brief
*/

View File

@ -24,7 +24,7 @@ int main(int argc, char *argv[])
XNEngine engine;
//检测输入参数个数
if (argc <= 2) {
std::cerr << "0x1000 The input parameters is too less!" << std::endl;
std::cerr << "0x1000 输入参数太少!" << std::endl;
return -1;
}
@ -42,10 +42,7 @@ int main(int argc, char *argv[])
hasConfigPath = true;
i += 2;
} else {
std::cerr << "0x1004 After the -f parameter, the configuration file path is not "
"specified, "
"the engine will exit!"
<< std::endl;
std::cerr << "0x1001 在-f参数后未指定配置文件路径引擎将退出!" << std::endl;
return -1;
}
} else if ("-id" == arg) {
@ -54,52 +51,30 @@ int main(int argc, char *argv[])
hasConfigId = true;
i += 2;
} else {
std::cerr
<< "0x1005 After the -id parameter, the configuration ID is not specified, "
"the engine will exit!"
<< std::endl;
std::cerr << "0x1002 在-id参数后未指定配置ID引擎将退出!" << std::endl;
return -1;
}
} else if ("-test" == arg) {
engine.SetTestMode(true);
i++;
} else {
std::cerr << "0x1007 The parameter " << arg << " is not valid, the engine will exit!"
<< std::endl;
std::cerr << "0x1003 无法识别的参数 " << arg << " ,引擎将退出!" << std::endl;
return -1;
}
}
//检查是否同时包含-f和-id参数
if (hasConfigPath && hasConfigId) {
std::cerr
<< "0x1006 Please specify either -f <config_file> or -id <config_id>, but not both. "
"The engine will exit!"
std::cerr << "0x1004 请指定 -f <config_file> 或 -id <config_id> ,但不要同时指定!"
<< std::endl;
return -1;
}
//检测配置文件格式
if (hasConfigPath) {
size_t index = configPath.find_last_of('.');
if (index != std::string::npos) {
std::string suffix = configPath.substr(index);
if (suffix != ".xml" && suffix != ".sce") {
std::cerr << "0x1001 The configuration file is not a .xml or .sce "
"file, the engine will exit!"
<< std::endl;
return -1;
}
} else {
std::cerr << "0x1002 The configuration file is not a .xml or .sce "
"file, the engine will exit!"
<< std::endl;
return -1;
}
return engine.Run(configPath);
return engine.Run(configPath, 0);
} else if (hasConfigId) {
return engine.Run(configId);
return engine.Run(configId, 1);
}
// 引擎运行
return engine.Run(configId);
return -1;
}

View File

@ -44,9 +44,12 @@ bool DDSInterfaceGen::generateDDSInterfaceHpp(const std::string &nameSpace,
hppFile << "namespace " << nameSpace << std::endl;
hppFile << "{" << std::endl;
// 3. 写入类声明
hppFile << "class " << className << " final : public XNDDSInterface" << std::endl;
hppFile << "class " << className << " : public XNDDSInterface" << std::endl;
hppFile << "{" << std::endl;
hppFile << "public:" << std::endl;
hppFile << "\t" << "using DDSType = " << topicType << ";" << std::endl;
hppFile << "\t" << "using DDSPubSubType = " << topicType << "PubSubType;" << std::endl;
hppFile << "\t" << "static const std::string topic_name;" << std::endl;
// 4. 写入构造函数和析构函数
hppFile << "\t" << className << "();" << std::endl;
hppFile << "\t" << "virtual ~" << className << "();" << std::endl;
@ -82,14 +85,15 @@ bool DDSInterfaceGen::generateDDSInterfaceHpp(const std::string &nameSpace,
hppFile << "\t\t" << "std::lock_guard<std::mutex> lock(outDataMutex);" << std::endl;
hppFile << "\t\t" << "clearOutData();" << std::endl;
for (const auto &interface : interfaceData) {
hppFile << "\t\t" << "assign_value_set(data." << interface.interfaceName
hppFile << "\t\t" << "assign_value_set(out_data." << interface.interfaceName
<< "(), model_data->" << interface.interfaceName << ");" << std::endl;
}
hppFile << "\t\t" << "sendOutData();" << std::endl;
hppFile << "\t" << "}" << std::endl;
// 11. 写入私有成员变量
hppFile << "" << "private:" << std::endl;
hppFile << "\t" << topicType << " data;" << std::endl;
hppFile << "\t" << topicType << " out_data;" << std::endl;
hppFile << "" << "protected:" << std::endl;
hppFile << "\t" << "DDSType data;" << std::endl;
hppFile << "\t" << "DDSType out_data;" << std::endl;
// 12. 写入类声明结束
hppFile << "};" << std::endl;
// 13. 写入命名空间结束
@ -110,6 +114,8 @@ bool DDSInterfaceGen::generateDDSInterfaceCxx(const std::string &nameSpace,
// 1. 写入引用头文件
cxxFile << "#include \"" << structName << ".hpp\"" << std::endl;
// 2. 写入命名空间
cxxFile << "const std::string " << nameSpace << "::" << className << "::topic_name = \""
<< topicType << "\";" << std::endl;
cxxFile << "namespace " << nameSpace << std::endl;
cxxFile << "{" << std::endl;
// 3. 写入类构造函数实现

8
XNModels/CMakeLists.txt Executable file
View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.16)
project(XNModels)
add_subdirectory(XNATA04DataProcessor)
add_subdirectory(XNAerodynamics)
add_subdirectory(XNGroundHandling)
add_subdirectory(XNWeightBalance)

View File

@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(XNATA04DataProcessor LANGUAGES CXX)
set(MODEL_VERSION "1.0.0.0")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -23,6 +25,14 @@ add_library(XNATA04DataProcessor SHARED
XNATA04DataProcessor_p.h
)
set_target_properties(XNATA04DataProcessor PROPERTIES
LIBRARY_OUTPUT_NAME "libXNATA04DataProcessor.so.${MODEL_VERSION}"
PREFIX ""
SUFFIX ""
SKIP_BUILD_RPATH TRUE
BUILD_WITH_INSTALL_RPATH TRUE
)
target_link_libraries(XNATA04DataProcessor PRIVATE
${XNCore_PATH}/lib/libXNCore.so
${XNCore_PATH}/lib/libC909_V1_Interface.so
@ -45,4 +55,7 @@ install(TARGETS XNATA04DataProcessor
file(GLOB CONFIG_FILE "*.mcfg")
# 使 install
install(FILES ${CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES ${CONFIG_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}
RENAME "XNATA04DataProcessor_V${MODEL_VERSION}.mcfg"
)

View File

@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(XNAerodynamics LANGUAGES CXX)
set(MODEL_VERSION "1.0.0.0")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -24,6 +26,14 @@ add_library(XNAerodynamics SHARED
XNAerodynamics_p.h
)
set_target_properties(XNAerodynamics PROPERTIES
LIBRARY_OUTPUT_NAME "libXNAerodynamics.so.${MODEL_VERSION}"
PREFIX ""
SUFFIX ""
SKIP_BUILD_RPATH TRUE
BUILD_WITH_INSTALL_RPATH TRUE
)
target_link_libraries(XNAerodynamics PRIVATE
${XNCore_PATH}/lib/libXNCore.so
${XNCore_PATH}/lib/libC909_V1_Interface.so
@ -47,4 +57,7 @@ install(TARGETS XNAerodynamics
file(GLOB CONFIG_FILE "*.mcfg")
# 使 install
install(FILES ${CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES ${CONFIG_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}
RENAME "XNAerodynamics_V${MODEL_VERSION}.mcfg"
)

View File

@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(XNGroundHandling LANGUAGES CXX)
set(MODEL_VERSION "2.0.143.1")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -24,6 +26,14 @@ add_library(XNGroundHandling SHARED
XNGroundHandling_p.h
)
set_target_properties(XNGroundHandling PROPERTIES
LIBRARY_OUTPUT_NAME "libXNGroundHandling.so.${MODEL_VERSION}"
PREFIX ""
SUFFIX ""
SKIP_BUILD_RPATH TRUE
BUILD_WITH_INSTALL_RPATH TRUE
)
target_link_libraries(XNGroundHandling PRIVATE
${XNCore_PATH}/lib/libXNCore.so
${XNCore_PATH}/lib/libC909_V1_Interface.so
@ -46,4 +56,7 @@ install(TARGETS XNGroundHandling
file(GLOB CONFIG_FILE "*.mcfg")
# 使 install
install(FILES ${CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES ${CONFIG_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}
RENAME "XNGroundHandling_V${MODEL_VERSION}.mcfg"
)

View File

@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.16)
project(XNWeightBalance LANGUAGES CXX)
set(MODEL_VERSION "1.0.0.0")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -24,6 +26,14 @@ add_library(XNWeightBalance SHARED
XNWeightBalance_p.h
)
set_target_properties(XNWeightBalance PROPERTIES
LIBRARY_OUTPUT_NAME "libXNWeightBalance.so.${MODEL_VERSION}"
PREFIX ""
SUFFIX ""
SKIP_BUILD_RPATH TRUE
BUILD_WITH_INSTALL_RPATH TRUE
)
target_link_libraries(XNWeightBalance PRIVATE
${XNCore_PATH}/lib/libXNCore.so
${XNCore_PATH}/lib/libC909_V1_Interface.so
@ -47,4 +57,7 @@ install(TARGETS XNWeightBalance
file(GLOB CONFIG_FILE "*.mcfg")
# 使 install
install(FILES ${CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES ${CONFIG_FILE}
DESTINATION ${CMAKE_INSTALL_PREFIX}
RENAME "XNWeightBalance_V${MODEL_VERSION}.mcfg"
)

View File

@ -49,6 +49,10 @@ void XNWeightBalance::PrepareForExecute()
{
T_D();
XNModelObject::PrepareForExecute();
InitializeData();
d->_inputInterface.Initialize(GetFramework(), GetUniqueId(), 1);
d->_outputInterface.Initialize(GetFramework(), GetUniqueId(), 2);
d->_heartbeatInterface.Initialize(GetFramework(), GetUniqueId(), 2);
}
void XNWeightBalance::StepUpdate()

View File

@ -69,6 +69,10 @@
"thread": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp"
"typeinfo": "cpp",
"any": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"valarray": "cpp"
}
}

Some files were not shown because too many files have changed in this diff Show More