Compare commits
No commits in common. "main" and "XNCore重构分支" have entirely different histories.
main
...
XNCore重构分支
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,4 +38,3 @@ build/
|
||||
#log
|
||||
log/
|
||||
logs/
|
||||
Packages/
|
||||
|
73
Release/IDL/C909_V1/.vscode/settings.json
vendored
73
Release/IDL/C909_V1/.vscode/settings.json
vendored
@ -1,73 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
#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()
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include "XNCore/XNDDSInterface.h"
|
||||
namespace XNSim::C909::ATA04
|
||||
{
|
||||
class Aerodynamics_heartbeat_Interface : public XNDDSInterface
|
||||
class Aerodynamics_heartbeat_Interface final : 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;
|
||||
@ -30,11 +27,10 @@ public:
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
assign_value_set(out_data.aero_model_heartbeat(), model_data->aero_model_heartbeat);
|
||||
sendOutData();
|
||||
assign_value_set(data.aero_model_heartbeat(), model_data->aero_model_heartbeat);
|
||||
}
|
||||
protected:
|
||||
DDSType data;
|
||||
DDSType out_data;
|
||||
private:
|
||||
XNSim::C909::ATA04::Aerodynamics_heartbeat data;
|
||||
XNSim::C909::ATA04::Aerodynamics_heartbeat out_data;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#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()
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include "XNCore/XNDDSInterface.h"
|
||||
namespace XNSim::C909::ATA04
|
||||
{
|
||||
class Aerodynamics_input_Interface : public XNDDSInterface
|
||||
class Aerodynamics_input_Interface final : 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;
|
||||
@ -56,37 +53,36 @@ public:
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
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();
|
||||
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);
|
||||
}
|
||||
protected:
|
||||
DDSType data;
|
||||
DDSType out_data;
|
||||
private:
|
||||
XNSim::C909::ATA04::Aerodynamics_input data;
|
||||
XNSim::C909::ATA04::Aerodynamics_input out_data;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#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()
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include "XNCore/XNDDSInterface.h"
|
||||
namespace XNSim::C909::ATA04
|
||||
{
|
||||
class Aerodynamics_output_Interface : public XNDDSInterface
|
||||
class Aerodynamics_output_Interface final : 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;
|
||||
@ -42,23 +39,22 @@ public:
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
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();
|
||||
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);
|
||||
}
|
||||
protected:
|
||||
DDSType data;
|
||||
DDSType out_data;
|
||||
private:
|
||||
XNSim::C909::ATA04::Aerodynamics_output data;
|
||||
XNSim::C909::ATA04::Aerodynamics_output out_data;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#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()
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include "XNCore/XNDDSInterface.h"
|
||||
namespace XNSim::C909::ATA04
|
||||
{
|
||||
class GroundHandling_heartbeat_Interface : public XNDDSInterface
|
||||
class GroundHandling_heartbeat_Interface final : 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;
|
||||
@ -30,11 +27,10 @@ public:
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
assign_value_set(out_data.groundhandling_model_heartbeat(), model_data->groundhandling_model_heartbeat);
|
||||
sendOutData();
|
||||
assign_value_set(data.groundhandling_model_heartbeat(), model_data->groundhandling_model_heartbeat);
|
||||
}
|
||||
protected:
|
||||
DDSType data;
|
||||
DDSType out_data;
|
||||
private:
|
||||
XNSim::C909::ATA04::GroundHandling_heartbeat data;
|
||||
XNSim::C909::ATA04::GroundHandling_heartbeat out_data;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#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()
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include "XNCore/XNDDSInterface.h"
|
||||
namespace XNSim::C909::ATA04
|
||||
{
|
||||
class GroundHandling_input_Interface : public XNDDSInterface
|
||||
class GroundHandling_input_Interface final : 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;
|
||||
@ -68,49 +65,48 @@ public:
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
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();
|
||||
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);
|
||||
}
|
||||
protected:
|
||||
DDSType data;
|
||||
DDSType out_data;
|
||||
private:
|
||||
XNSim::C909::ATA04::GroundHandling_input data;
|
||||
XNSim::C909::ATA04::GroundHandling_input out_data;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#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()
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include "XNCore/XNDDSInterface.h"
|
||||
namespace XNSim::C909::ATA04
|
||||
{
|
||||
class GroundHandling_output_Interface : public XNDDSInterface
|
||||
class GroundHandling_output_Interface final : 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;
|
||||
@ -63,44 +60,43 @@ public:
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
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();
|
||||
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);
|
||||
}
|
||||
protected:
|
||||
DDSType data;
|
||||
DDSType out_data;
|
||||
private:
|
||||
XNSim::C909::ATA04::GroundHandling_output data;
|
||||
XNSim::C909::ATA04::GroundHandling_output out_data;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#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()
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include "XNCore/XNDDSInterface.h"
|
||||
namespace XNSim::C909::ATA04
|
||||
{
|
||||
class WeightBalance_heartbeat_Interface : public XNDDSInterface
|
||||
class WeightBalance_heartbeat_Interface final : 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;
|
||||
@ -30,11 +27,10 @@ public:
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
assign_value_set(out_data.weightbody_model_heartbeat(), model_data->weightbody_model_heartbeat);
|
||||
sendOutData();
|
||||
assign_value_set(data.weightbody_model_heartbeat(), model_data->weightbody_model_heartbeat);
|
||||
}
|
||||
protected:
|
||||
DDSType data;
|
||||
DDSType out_data;
|
||||
private:
|
||||
XNSim::C909::ATA04::WeightBalance_heartbeat data;
|
||||
XNSim::C909::ATA04::WeightBalance_heartbeat out_data;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#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()
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include "XNCore/XNDDSInterface.h"
|
||||
namespace XNSim::C909::ATA04
|
||||
{
|
||||
class WeightBalance_input_Interface : public XNDDSInterface
|
||||
class WeightBalance_input_Interface final : 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;
|
||||
@ -52,33 +49,32 @@ public:
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
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();
|
||||
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);
|
||||
}
|
||||
protected:
|
||||
DDSType data;
|
||||
DDSType out_data;
|
||||
private:
|
||||
XNSim::C909::ATA04::WeightBalance_input data;
|
||||
XNSim::C909::ATA04::WeightBalance_input out_data;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#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()
|
||||
|
@ -3,12 +3,9 @@
|
||||
#include "XNCore/XNDDSInterface.h"
|
||||
namespace XNSim::C909::ATA04
|
||||
{
|
||||
class WeightBalance_output_Interface : public XNDDSInterface
|
||||
class WeightBalance_output_Interface final : 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;
|
||||
@ -85,66 +82,65 @@ public:
|
||||
return;
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
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();
|
||||
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);
|
||||
}
|
||||
protected:
|
||||
DDSType data;
|
||||
DDSType out_data;
|
||||
private:
|
||||
XNSim::C909::ATA04::WeightBalance_output data;
|
||||
XNSim::C909::ATA04::WeightBalance_output out_data;
|
||||
};
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?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.
@ -1,15 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scenario>
|
||||
<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"/>
|
||||
<Environment OSName="Debian" Version="11" RTXVersion="preempt-rt" CPUAffinity="0,1" 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" 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"/>
|
||||
<Model Name="ATA04气动模型" ClassName="XNAerodynamics"/>
|
||||
<Model Name="ATA04地面操纵模型" ClassName="XNGroundHandling"/>
|
||||
<Model Name="ATA04质量模型" ClassName="XNWeightBalance"/>
|
||||
<Model Name="ATA04数据处理模型" ClassName="XNATA04DataProcessor"/>
|
||||
</ModelGroup>
|
||||
<ServicesList>
|
||||
<Service Name="UDP通信服务" ClassName="XNUDPService" Version="1.0.0.0"/>
|
||||
<Service Name="UDP通信服务" ClassName="XNUDPService"/>
|
||||
</ServicesList>
|
||||
</Scenario>
|
||||
|
@ -1,17 +0,0 @@
|
||||
<?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.
BIN
Release/XNEngine
BIN
Release/XNEngine
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -40,8 +40,6 @@
|
||||
# include <array>
|
||||
# include <cstring>
|
||||
# include <iostream>
|
||||
# include <sqlite3.h>
|
||||
# include <nlohmann/json.hpp>
|
||||
#endif
|
||||
|
||||
#include <fastdds/dds/domain/DomainParticipant.hpp>
|
||||
@ -55,8 +53,6 @@
|
||||
#include <fastcdr/xcdr/optional.hpp>
|
||||
#define FAST_DDS_MACRO eprosima::fastdds::dds
|
||||
|
||||
using XN_JSON = nlohmann::json;
|
||||
|
||||
/**
|
||||
* @brief 默认基频定义,单位 Hz
|
||||
*/
|
||||
@ -95,6 +91,13 @@ 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 系统运行状态枚举类
|
||||
*/
|
||||
@ -255,37 +258,3 @@ 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
|
||||
|
@ -39,14 +39,13 @@ public:
|
||||
* @param varNames: 变量名列表
|
||||
* @return: 变量名到数据的映射
|
||||
*/
|
||||
std::unordered_map<std::string, std::string>
|
||||
getStringData(const std::vector<std::string> &varNames);
|
||||
std::unordered_map<std::string, std::string> getStringData(std::vector<std::string> varNames);
|
||||
|
||||
/**
|
||||
* @brief 批量设置指定变量的数据
|
||||
* @param data: 变量名到数据的映射
|
||||
*/
|
||||
void setDataByString(const std::unordered_map<std::string, std::string> &data);
|
||||
void setDataByString(std::unordered_map<std::string, std::string> data);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -55,7 +54,7 @@ protected:
|
||||
* @return 字节数组
|
||||
*/
|
||||
template <typename T>
|
||||
XNByteArray getByteArray(const eprosima::fastcdr::optional<T> &data)
|
||||
XNByteArray getByteArray(eprosima::fastcdr::optional<T> data)
|
||||
{
|
||||
XNByteArray result(getTypeSize<T>());
|
||||
|
||||
@ -75,7 +74,7 @@ protected:
|
||||
}
|
||||
} else {
|
||||
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"T 必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 78");
|
||||
"Type must be arithmetic or std::array");
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -109,7 +108,7 @@ protected:
|
||||
setByteArrayFromStdArray(data.value(), thisArray);
|
||||
} else {
|
||||
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"T 必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 112");
|
||||
"Type must be arithmetic or std::array");
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,13 +125,10 @@ 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 if constexpr (is_std_array_v<T>) {
|
||||
} else {
|
||||
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.cpp:line 135");
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,12 +149,9 @@ 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 if constexpr (is_std_array_v<T>) {
|
||||
} else {
|
||||
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.cpp:line 160");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,13 +162,13 @@ protected:
|
||||
* @return: 数据(字符串格式)
|
||||
*/
|
||||
template <typename T>
|
||||
std::string getString(const eprosima::fastcdr::optional<T> &data)
|
||||
std::string getString(eprosima::fastcdr::optional<T> data)
|
||||
{
|
||||
if constexpr (std::is_arithmetic_v<T>) {
|
||||
if (data) {
|
||||
return std::to_string(data.value());
|
||||
} else {
|
||||
return "Unknown";
|
||||
return std::to_string(0);
|
||||
}
|
||||
} else if constexpr (is_std_array_v<T>) {
|
||||
if (data) {
|
||||
@ -184,9 +177,6 @@ protected:
|
||||
T zero = {};
|
||||
return getStringFromStdArray(zero);
|
||||
}
|
||||
} else {
|
||||
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"T 必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 188");
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
@ -216,9 +206,6 @@ 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.cpp:line 220");
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,7 +215,7 @@ protected:
|
||||
* @return: 数据(字符串格式)
|
||||
*/
|
||||
template <typename T, std::size_t N>
|
||||
std::string getStringFromStdArray(const std::array<T, N> &data)
|
||||
std::string getStringFromStdArray(std::array<T, N> data)
|
||||
{
|
||||
std::stringstream ss;
|
||||
for (std::size_t i = 0; i < N; ++i) {
|
||||
@ -236,11 +223,8 @@ protected:
|
||||
ss << ",";
|
||||
if constexpr (std::is_arithmetic_v<T>) {
|
||||
ss << data[i];
|
||||
} 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.cpp:line 243");
|
||||
ss << getStringFromStdArray(data[i]);
|
||||
}
|
||||
}
|
||||
return ss.str();
|
||||
@ -272,105 +256,60 @@ protected:
|
||||
// 对于嵌套数组,递归处理
|
||||
start_pos = setStdArrayFromString(data[i], value, start_pos + i);
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"T 必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 275");
|
||||
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"Type must be arithmetic or std::array");
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
throw std::runtime_error("无法解析第 " + std::to_string(i)
|
||||
+ " 个元素: " + e.what());
|
||||
throw std::runtime_error("Error parsing element " + std::to_string(i) + ": "
|
||||
+ e.what());
|
||||
}
|
||||
}
|
||||
return start_pos + N;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void assign_value_get(const eprosima::fastcdr::optional<T1> &data, T2 &model_data)
|
||||
void assign_value_get(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.cpp:line 293");
|
||||
static_assert(std::is_convertible_v<T1, T2>,
|
||||
"模板参数T1必须可以转换为T2类型,详见XNDDSInterface.cpp:line 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];
|
||||
using array_type = typename T1::value_type;
|
||||
if constexpr (std::is_arithmetic_v<array_type>) {
|
||||
auto temp2 = temp[i];
|
||||
if constexpr (std::is_arithmetic_v<T2>) {
|
||||
model_data[i] = temp2;
|
||||
} 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.cpp:line 313");
|
||||
} else if constexpr (is_std_array_v<T2>) {
|
||||
size_t arraySize2 = array_size_v<T2>;
|
||||
for (size_t j = 0; j < arraySize2; ++j) {
|
||||
model_data[i][j] = temp2[j];
|
||||
}
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<array_type> || is_std_array_v<array_type>,
|
||||
"模板参数T1是std::array类型时,它的value_"
|
||||
"type必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 320");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<T1> || is_std_array_v<T1>,
|
||||
"模板参数T1必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 326");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void assign_value_set(eprosima::fastcdr::optional<T1> &data, const T2 &model_data)
|
||||
void assign_value_set(eprosima::fastcdr::optional<T1> &data, T2 &model_data)
|
||||
{
|
||||
if constexpr (std::is_arithmetic_v<T1>) {
|
||||
static_assert(std::is_arithmetic_v<T2>,
|
||||
"模板参数T2必须是算术类型,详见XNDDSInterface.cpp:line 337");
|
||||
static_assert(std::is_convertible_v<T2, T1>,
|
||||
"模板参数T2必须可以转换为T1类型,详见XNDDSInterface.cpp:line 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<array_type>) {
|
||||
if constexpr (std::is_arithmetic_v<typename T1::value_type>) {
|
||||
temp[i] = model_data[i];
|
||||
} 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."
|
||||
"cpp:line 357");
|
||||
} else if constexpr (is_std_array_v<typename T1::value_type>) {
|
||||
size_t arraySize2 = array_size_v<typename T1::value_type>;
|
||||
for (size_t j = 0; j < arraySize2; ++j) {
|
||||
temp[i][j] = model_data[i][j];
|
||||
}
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<array_type> || is_std_array_v<array_type>,
|
||||
"模板参数T1是std::array类型时,它的value_"
|
||||
"type必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 364");
|
||||
}
|
||||
}
|
||||
data = temp;
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<T1> || is_std_array_v<T1>,
|
||||
"模板参数T1必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 371");
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,10 +330,10 @@ protected:
|
||||
|
||||
#define MAP_DATA_FUNC(NAME) \
|
||||
getDataFunction[#NAME] = [this]() { return getString(data.NAME()); }; \
|
||||
setDataFunction[#NAME] = [this](const std::string &value) { \
|
||||
setDataFunction[#NAME] = [this](std::string value) { \
|
||||
setDataFromString(out_data.NAME(), value); \
|
||||
}; \
|
||||
getByteArrayFunction.push_back([this]() { return getByteArray(data.NAME()); }); \
|
||||
setByteArrayFunction.push_back([this](const XNByteArray &byteArray, uint32_t &pos) { \
|
||||
setByteArrayFunction.push_back([this](XNByteArray byteArray, uint32_t &pos) { \
|
||||
setByteArray(out_data.NAME(), byteArray, pos); \
|
||||
});
|
||||
|
@ -77,9 +77,4 @@ struct XNFrameworkPrivate : public XNObjectPrivate {
|
||||
* @brief 场景XML
|
||||
*/
|
||||
std::string scenarioXml;
|
||||
|
||||
/**
|
||||
* @brief 构型ID
|
||||
*/
|
||||
uint32_t configId;
|
||||
};
|
||||
|
@ -178,59 +178,46 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief 将参数转换为字符串
|
||||
* @tparam T 参数类型
|
||||
* @param arg 要转换的参数
|
||||
* @return 转换后的字符串
|
||||
*/
|
||||
// 辅助函数,用于格式化消息
|
||||
template <typename T>
|
||||
static std::string convertToString(const T &arg)
|
||||
{
|
||||
if constexpr (std::is_arithmetic_v<T>) {
|
||||
if constexpr (std::is_arithmetic<T>::value) {
|
||||
return std::to_string(arg); // 处理数值类型
|
||||
} 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.cpp:line 199");
|
||||
return std::string(arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 格式化日志消息,顺序替换%1、%2、%3……
|
||||
* @tparam Args 参数类型
|
||||
* @param message 日志消息
|
||||
* @param args 参数包
|
||||
* @return 格式化后的消息
|
||||
*/
|
||||
template <typename... Args>
|
||||
static std::string formatMessage(const std::string &message, Args &&...args)
|
||||
// 递归变参函数,用于处理多个参数
|
||||
template <typename T, typename... Args>
|
||||
static std::string formatMessage(const std::string &message, T arg, Args... args)
|
||||
{
|
||||
static_assert(sizeof...(Args) <= 9,
|
||||
"错误码:010211002,单条日志参数数量超过限制,详见XNLogger.cpp:line 216");
|
||||
|
||||
// 查找下一个参数占位符
|
||||
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) {
|
||||
result.replace(pos, placeholder.length(), convertToString(value));
|
||||
}
|
||||
}(args),
|
||||
0)...};
|
||||
return result;
|
||||
size_t paramIndex = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
// 找到当前参数对应的占位符
|
||||
while (true) {
|
||||
std::string placeholder = "%" + std::to_string(paramIndex + 1);
|
||||
pos = result.find(placeholder);
|
||||
if (pos != std::string::npos) {
|
||||
// 替换占位符,使用placeholder的长度
|
||||
result.replace(pos, placeholder.length(), convertToString(arg));
|
||||
break;
|
||||
}
|
||||
paramIndex++;
|
||||
if (paramIndex > 100) { // 防止无限循环
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return formatMessage(result, args...);
|
||||
}
|
||||
|
||||
// 基础情况
|
||||
static std::string formatMessage(const std::string &message) { return message; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -61,14 +61,10 @@ 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,
|
||||
const std::string &modelVersion, const std::string &planeName,
|
||||
uint32_t initialType, uint32_t threadID);
|
||||
void LoadModel(const std::string &modelPath, const std::string &className, uint32_t initialType,
|
||||
uint32_t threadID);
|
||||
|
||||
/**
|
||||
* @brief 注册模型信息
|
||||
|
@ -169,18 +169,6 @@ 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 模型默认的周期性执行函数
|
||||
@ -250,10 +238,6 @@ public:
|
||||
|
||||
public:
|
||||
virtual void RegisterDDSParticipant();
|
||||
|
||||
private:
|
||||
void ParseXml();
|
||||
void ParseConfig();
|
||||
};
|
||||
|
||||
#define XN_MODEL_INITIALIZE(ClassName) \
|
||||
|
@ -76,21 +76,4 @@ 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);
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
virtual bool Initialize() override;
|
||||
virtual bool PrepareForExecute() override;
|
||||
void LoadService(const std::string &servicePath, const std::string &serviceName,
|
||||
const std::string &serviceVersion, uint32_t initialType);
|
||||
uint32_t initialType);
|
||||
|
||||
public:
|
||||
XNServiceObjectPtr GetService(uint32_t serviceID);
|
||||
|
@ -54,10 +54,6 @@ public:
|
||||
|
||||
protected:
|
||||
XNFrameworkPtr GetFramework() const;
|
||||
|
||||
private:
|
||||
void ParseXml();
|
||||
void ParseConfig();
|
||||
};
|
||||
|
||||
XNCLASS_PTR_DECLARE(XNServiceObject)
|
||||
|
@ -11,5 +11,4 @@ struct XNServiceObjectPrivate : public XNObjectPrivate {
|
||||
std::unordered_map<std::string, FAST_DDS_MACRO::DataWriter *> _dataWriters;
|
||||
XNFrameworkPtr pFramework;
|
||||
uint32_t _initialType;
|
||||
XN_JSON _otherParams;
|
||||
};
|
||||
|
1
Release/lib/libQt6Core.so.6
Symbolic link
1
Release/lib/libQt6Core.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6Core.so.6.9.0
|
BIN
Release/lib/libQt6Core.so.6.9.0
Executable file
BIN
Release/lib/libQt6Core.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libQt6DBus.so.6
Symbolic link
1
Release/lib/libQt6DBus.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6DBus.so.6.9.0
|
BIN
Release/lib/libQt6DBus.so.6.9.0
Executable file
BIN
Release/lib/libQt6DBus.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libQt6Gui.so.6
Symbolic link
1
Release/lib/libQt6Gui.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6Gui.so.6.9.0
|
BIN
Release/lib/libQt6Gui.so.6.9.0
Executable file
BIN
Release/lib/libQt6Gui.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libQt6Network.so.6
Symbolic link
1
Release/lib/libQt6Network.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6Network.so.6.9.0
|
BIN
Release/lib/libQt6Network.so.6.9.0
Executable file
BIN
Release/lib/libQt6Network.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libQt6OpenGL.so.6
Symbolic link
1
Release/lib/libQt6OpenGL.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6OpenGL.so.6.9.0
|
BIN
Release/lib/libQt6OpenGL.so.6.9.0
Executable file
BIN
Release/lib/libQt6OpenGL.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libQt6PrintSupport.so.6
Symbolic link
1
Release/lib/libQt6PrintSupport.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6PrintSupport.so.6.9.0
|
BIN
Release/lib/libQt6PrintSupport.so.6.9.0
Executable file
BIN
Release/lib/libQt6PrintSupport.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libQt6WaylandClient.so.6
Symbolic link
1
Release/lib/libQt6WaylandClient.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6WaylandClient.so.6.9.0
|
BIN
Release/lib/libQt6WaylandClient.so.6.9.0
Executable file
BIN
Release/lib/libQt6WaylandClient.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libQt6Widgets.so.6
Symbolic link
1
Release/lib/libQt6Widgets.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6Widgets.so.6.9.0
|
BIN
Release/lib/libQt6Widgets.so.6.9.0
Executable file
BIN
Release/lib/libQt6Widgets.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libQt6XcbQpa.so.6
Symbolic link
1
Release/lib/libQt6XcbQpa.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6XcbQpa.so.6.9.0
|
BIN
Release/lib/libQt6XcbQpa.so.6.9.0
Executable file
BIN
Release/lib/libQt6XcbQpa.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libQt6Xml.so.6
Symbolic link
1
Release/lib/libQt6Xml.so.6
Symbolic link
@ -0,0 +1 @@
|
||||
libQt6Xml.so.6.9.0
|
BIN
Release/lib/libQt6Xml.so.6.9.0
Executable file
BIN
Release/lib/libQt6Xml.so.6.9.0
Executable file
Binary file not shown.
1
Release/lib/libxcb.so.1
Symbolic link
1
Release/lib/libxcb.so.1
Symbolic link
@ -0,0 +1 @@
|
||||
libxcb.so.1.1.0
|
BIN
Release/lib/libxcb.so.1.1.0
Executable file
BIN
Release/lib/libxcb.so.1.1.0
Executable file
Binary file not shown.
@ -16,10 +16,8 @@ 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
|
||||
@ -78,8 +76,6 @@ target_link_libraries(XNCore PRIVATE
|
||||
pthread
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
nlohmann_json
|
||||
sqlite3
|
||||
dl
|
||||
)
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
#include "XNCore_global.h"
|
||||
|
||||
namespace XNSim
|
||||
{
|
||||
XNTimePoint parseISOTime(const std::string &timeStr)
|
||||
{
|
||||
std::tm tm = {};
|
||||
@ -10,49 +8,3 @@ 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
|
@ -40,8 +40,6 @@
|
||||
# include <array>
|
||||
# include <cstring>
|
||||
# include <iostream>
|
||||
# include <sqlite3.h>
|
||||
# include <nlohmann/json.hpp>
|
||||
#endif
|
||||
|
||||
#include <fastdds/dds/domain/DomainParticipant.hpp>
|
||||
@ -55,8 +53,6 @@
|
||||
#include <fastcdr/xcdr/optional.hpp>
|
||||
#define FAST_DDS_MACRO eprosima::fastdds::dds
|
||||
|
||||
using XN_JSON = nlohmann::json;
|
||||
|
||||
/**
|
||||
* @brief 默认基频定义,单位 Hz
|
||||
*/
|
||||
@ -95,6 +91,13 @@ 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 系统运行状态枚举类
|
||||
*/
|
||||
@ -255,37 +258,3 @@ 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
|
||||
|
@ -64,7 +64,7 @@ void XNDDSInterface::setDataByUDPPackage(const XNByteArray &package)
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::string>
|
||||
XNDDSInterface::getStringData(const std::vector<std::string> &varNames)
|
||||
XNDDSInterface::getStringData(std::vector<std::string> varNames)
|
||||
{
|
||||
std::unordered_map<std::string, std::string> result;
|
||||
|
||||
@ -82,7 +82,7 @@ XNDDSInterface::getStringData(const std::vector<std::string> &varNames)
|
||||
return result;
|
||||
}
|
||||
|
||||
void XNDDSInterface::setDataByString(const std::unordered_map<std::string, std::string> &data)
|
||||
void XNDDSInterface::setDataByString(std::unordered_map<std::string, std::string> data)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(outDataMutex);
|
||||
clearOutData();
|
||||
|
@ -39,14 +39,13 @@ public:
|
||||
* @param varNames: 变量名列表
|
||||
* @return: 变量名到数据的映射
|
||||
*/
|
||||
std::unordered_map<std::string, std::string>
|
||||
getStringData(const std::vector<std::string> &varNames);
|
||||
std::unordered_map<std::string, std::string> getStringData(std::vector<std::string> varNames);
|
||||
|
||||
/**
|
||||
* @brief 批量设置指定变量的数据
|
||||
* @param data: 变量名到数据的映射
|
||||
*/
|
||||
void setDataByString(const std::unordered_map<std::string, std::string> &data);
|
||||
void setDataByString(std::unordered_map<std::string, std::string> data);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -55,7 +54,7 @@ protected:
|
||||
* @return 字节数组
|
||||
*/
|
||||
template <typename T>
|
||||
XNByteArray getByteArray(const eprosima::fastcdr::optional<T> &data)
|
||||
XNByteArray getByteArray(eprosima::fastcdr::optional<T> data)
|
||||
{
|
||||
XNByteArray result(getTypeSize<T>());
|
||||
|
||||
@ -75,7 +74,7 @@ protected:
|
||||
}
|
||||
} else {
|
||||
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"T 必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 78");
|
||||
"Type must be arithmetic or std::array");
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -109,7 +108,7 @@ protected:
|
||||
setByteArrayFromStdArray(data.value(), thisArray);
|
||||
} else {
|
||||
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"T 必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 112");
|
||||
"Type must be arithmetic or std::array");
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,13 +125,10 @@ 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 if constexpr (is_std_array_v<T>) {
|
||||
} else {
|
||||
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.cpp:line 135");
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,12 +149,9 @@ 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 if constexpr (is_std_array_v<T>) {
|
||||
} else {
|
||||
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.cpp:line 160");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -169,13 +162,13 @@ protected:
|
||||
* @return: 数据(字符串格式)
|
||||
*/
|
||||
template <typename T>
|
||||
std::string getString(const eprosima::fastcdr::optional<T> &data)
|
||||
std::string getString(eprosima::fastcdr::optional<T> data)
|
||||
{
|
||||
if constexpr (std::is_arithmetic_v<T>) {
|
||||
if (data) {
|
||||
return std::to_string(data.value());
|
||||
} else {
|
||||
return "Unknown";
|
||||
return std::to_string(0);
|
||||
}
|
||||
} else if constexpr (is_std_array_v<T>) {
|
||||
if (data) {
|
||||
@ -184,9 +177,6 @@ protected:
|
||||
T zero = {};
|
||||
return getStringFromStdArray(zero);
|
||||
}
|
||||
} else {
|
||||
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"T 必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 188");
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
@ -216,9 +206,6 @@ 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.cpp:line 220");
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,7 +215,7 @@ protected:
|
||||
* @return: 数据(字符串格式)
|
||||
*/
|
||||
template <typename T, std::size_t N>
|
||||
std::string getStringFromStdArray(const std::array<T, N> &data)
|
||||
std::string getStringFromStdArray(std::array<T, N> data)
|
||||
{
|
||||
std::stringstream ss;
|
||||
for (std::size_t i = 0; i < N; ++i) {
|
||||
@ -236,11 +223,8 @@ protected:
|
||||
ss << ",";
|
||||
if constexpr (std::is_arithmetic_v<T>) {
|
||||
ss << data[i];
|
||||
} 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.cpp:line 243");
|
||||
ss << getStringFromStdArray(data[i]);
|
||||
}
|
||||
}
|
||||
return ss.str();
|
||||
@ -272,105 +256,60 @@ protected:
|
||||
// 对于嵌套数组,递归处理
|
||||
start_pos = setStdArrayFromString(data[i], value, start_pos + i);
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"T 必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 275");
|
||||
static_assert(std::is_arithmetic_v<T> || is_std_array_v<T>,
|
||||
"Type must be arithmetic or std::array");
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
throw std::runtime_error("无法解析第 " + std::to_string(i)
|
||||
+ " 个元素: " + e.what());
|
||||
throw std::runtime_error("Error parsing element " + std::to_string(i) + ": "
|
||||
+ e.what());
|
||||
}
|
||||
}
|
||||
return start_pos + N;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void assign_value_get(const eprosima::fastcdr::optional<T1> &data, T2 &model_data)
|
||||
void assign_value_get(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.cpp:line 293");
|
||||
static_assert(std::is_convertible_v<T1, T2>,
|
||||
"模板参数T1必须可以转换为T2类型,详见XNDDSInterface.cpp:line 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];
|
||||
using array_type = typename T1::value_type;
|
||||
if constexpr (std::is_arithmetic_v<array_type>) {
|
||||
auto temp2 = temp[i];
|
||||
if constexpr (std::is_arithmetic_v<T2>) {
|
||||
model_data[i] = temp2;
|
||||
} 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.cpp:line 313");
|
||||
} else if constexpr (is_std_array_v<T2>) {
|
||||
size_t arraySize2 = array_size_v<T2>;
|
||||
for (size_t j = 0; j < arraySize2; ++j) {
|
||||
model_data[i][j] = temp2[j];
|
||||
}
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<array_type> || is_std_array_v<array_type>,
|
||||
"模板参数T1是std::array类型时,它的value_"
|
||||
"type必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 320");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<T1> || is_std_array_v<T1>,
|
||||
"模板参数T1必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 326");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void assign_value_set(eprosima::fastcdr::optional<T1> &data, const T2 &model_data)
|
||||
void assign_value_set(eprosima::fastcdr::optional<T1> &data, T2 &model_data)
|
||||
{
|
||||
if constexpr (std::is_arithmetic_v<T1>) {
|
||||
static_assert(std::is_arithmetic_v<T2>,
|
||||
"模板参数T2必须是算术类型,详见XNDDSInterface.cpp:line 337");
|
||||
static_assert(std::is_convertible_v<T2, T1>,
|
||||
"模板参数T2必须可以转换为T1类型,详见XNDDSInterface.cpp:line 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<array_type>) {
|
||||
if constexpr (std::is_arithmetic_v<typename T1::value_type>) {
|
||||
temp[i] = model_data[i];
|
||||
} 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."
|
||||
"cpp:line 357");
|
||||
} else if constexpr (is_std_array_v<typename T1::value_type>) {
|
||||
size_t arraySize2 = array_size_v<typename T1::value_type>;
|
||||
for (size_t j = 0; j < arraySize2; ++j) {
|
||||
temp[i][j] = model_data[i][j];
|
||||
}
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<array_type> || is_std_array_v<array_type>,
|
||||
"模板参数T1是std::array类型时,它的value_"
|
||||
"type必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 364");
|
||||
}
|
||||
}
|
||||
data = temp;
|
||||
} else {
|
||||
static_assert(
|
||||
std::is_arithmetic_v<T1> || is_std_array_v<T1>,
|
||||
"模板参数T1必须是算术类型或std::array类型,详见XNDDSInterface.cpp:line 371");
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,10 +330,10 @@ protected:
|
||||
|
||||
#define MAP_DATA_FUNC(NAME) \
|
||||
getDataFunction[#NAME] = [this]() { return getString(data.NAME()); }; \
|
||||
setDataFunction[#NAME] = [this](const std::string &value) { \
|
||||
setDataFunction[#NAME] = [this](std::string value) { \
|
||||
setDataFromString(out_data.NAME(), value); \
|
||||
}; \
|
||||
getByteArrayFunction.push_back([this]() { return getByteArray(data.NAME()); }); \
|
||||
setByteArrayFunction.push_back([this](const XNByteArray &byteArray, uint32_t &pos) { \
|
||||
setByteArrayFunction.push_back([this](XNByteArray byteArray, uint32_t &pos) { \
|
||||
setByteArray(out_data.NAME(), byteArray, pos); \
|
||||
});
|
||||
|
@ -20,7 +20,7 @@ bool XNDDSManager::Initialize()
|
||||
d->_status = XNFrameObjectStatus::Initialized;
|
||||
d->participant_ = nullptr;
|
||||
d->topics_.clear();
|
||||
LOG_INFO("DDS管理器初始化成功!");
|
||||
LOG_INFO("XNDDSManager Initialize Success!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ bool XNDDSManager::PrepareForExecute()
|
||||
{
|
||||
T_D();
|
||||
d->_status = XNFrameObjectStatus::Ready;
|
||||
LOG_INFO("DDS管理器准备就绪!");
|
||||
LOG_INFO("XNDDSManager is prepared!");
|
||||
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 DDS管理器创建域参与者失败!");
|
||||
LOG_ERROR("0x2130 Create DomainParticipant Failed!");
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void XNFramework::SetCpuAffinity(uint32_t cpuAffinity)
|
||||
bool XNFramework::Initialize(uint32_t initialType)
|
||||
{
|
||||
T_D();
|
||||
LOG_INFO("D01054001:主框架正在初始化...");
|
||||
LOG_INFO("XNFramework Initialize ...");
|
||||
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("B01052001:主框架初始化失败!");
|
||||
LOG_ERROR("XNFramework Initialize Failed!");
|
||||
return false;
|
||||
}
|
||||
ret = d->timeManager->Initialize();
|
||||
if (!ret) {
|
||||
LOG_ERROR("B01052002:主框架初始化失败!");
|
||||
LOG_ERROR("XNFramework Initialize Failed!");
|
||||
return false;
|
||||
}
|
||||
ret = d->ddsManager->Initialize();
|
||||
if (!ret) {
|
||||
LOG_ERROR("B01052003:主框架初始化失败!");
|
||||
LOG_ERROR("XNFramework Initialize Failed!");
|
||||
return false;
|
||||
}
|
||||
ret = d->serviceManager->Initialize();
|
||||
if (!ret) {
|
||||
LOG_ERROR("B01052004:主框架初始化失败!");
|
||||
LOG_ERROR("XNFramework Initialize Failed!");
|
||||
return false;
|
||||
}
|
||||
ret = d->threadManager->Initialize();
|
||||
if (!ret) {
|
||||
LOG_ERROR("B01052005:主框架初始化失败!");
|
||||
LOG_ERROR("XNFramework Initialize Failed!");
|
||||
return false;
|
||||
}
|
||||
ret = d->modelManager->Initialize();
|
||||
if (!ret) {
|
||||
LOG_ERROR("B01052006:主框架初始化失败!");
|
||||
LOG_ERROR("XNFramework Initialize Failed!");
|
||||
return false;
|
||||
}
|
||||
ret = d->scenarioManager->Initialize();
|
||||
if (!ret) {
|
||||
LOG_ERROR("B01052007:主框架初始化失败!");
|
||||
LOG_ERROR("XNFramework Initialize Failed!");
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("D01054002:主框架初始化成功!");
|
||||
LOG_INFO("D01054003:开始解析构型文件 ...");
|
||||
LOG_INFO("XNFramework Initialize Success!");
|
||||
LOG_INFO("XNFramework Analyze Scenario Xml ...");
|
||||
ret = d->scenarioManager->AnalysisScenarioXml(d->scenarioXml, initialType);
|
||||
if (!ret) {
|
||||
LOG_ERROR("B01052008:主框架解析构型文件失败!");
|
||||
LOG_ERROR("XNFramework Analyze Scenario Xml Failed!");
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("D01054004:解析构型文件成功!");
|
||||
LOG_INFO("XNFramework Analyze Scenario Xml Success!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -77,9 +77,4 @@ struct XNFrameworkPrivate : public XNObjectPrivate {
|
||||
* @brief 场景XML
|
||||
*/
|
||||
std::string scenarioXml;
|
||||
|
||||
/**
|
||||
* @brief 构型ID
|
||||
*/
|
||||
uint32_t configId;
|
||||
};
|
||||
|
@ -178,59 +178,46 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief 将参数转换为字符串
|
||||
* @tparam T 参数类型
|
||||
* @param arg 要转换的参数
|
||||
* @return 转换后的字符串
|
||||
*/
|
||||
// 辅助函数,用于格式化消息
|
||||
template <typename T>
|
||||
static std::string convertToString(const T &arg)
|
||||
{
|
||||
if constexpr (std::is_arithmetic_v<T>) {
|
||||
if constexpr (std::is_arithmetic<T>::value) {
|
||||
return std::to_string(arg); // 处理数值类型
|
||||
} 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.cpp:line 199");
|
||||
return std::string(arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 格式化日志消息,顺序替换%1、%2、%3……
|
||||
* @tparam Args 参数类型
|
||||
* @param message 日志消息
|
||||
* @param args 参数包
|
||||
* @return 格式化后的消息
|
||||
*/
|
||||
template <typename... Args>
|
||||
static std::string formatMessage(const std::string &message, Args &&...args)
|
||||
// 递归变参函数,用于处理多个参数
|
||||
template <typename T, typename... Args>
|
||||
static std::string formatMessage(const std::string &message, T arg, Args... args)
|
||||
{
|
||||
static_assert(sizeof...(Args) <= 9,
|
||||
"A01021002: 单条日志参数数量超过限制,详见XNLogger.cpp:line 216");
|
||||
|
||||
// 查找下一个参数占位符
|
||||
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) {
|
||||
result.replace(pos, placeholder.length(), convertToString(value));
|
||||
}
|
||||
}(args),
|
||||
0)...};
|
||||
return result;
|
||||
size_t paramIndex = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
// 找到当前参数对应的占位符
|
||||
while (true) {
|
||||
std::string placeholder = "%" + std::to_string(paramIndex + 1);
|
||||
pos = result.find(placeholder);
|
||||
if (pos != std::string::npos) {
|
||||
// 替换占位符,使用placeholder的长度
|
||||
result.replace(pos, placeholder.length(), convertToString(arg));
|
||||
break;
|
||||
}
|
||||
paramIndex++;
|
||||
if (paramIndex > 100) { // 防止无限循环
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return formatMessage(result, args...);
|
||||
}
|
||||
|
||||
// 基础情况
|
||||
static std::string formatMessage(const std::string &message) { return message; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,6 @@ 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();
|
||||
@ -78,17 +77,10 @@ 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 + "_V" + modelVersion + ".mcfg");
|
||||
model->SetXmlPath(configPath.string());
|
||||
} else if (initialType == 1) {
|
||||
model->SetXmlPath(planeName + "," + className + "," + modelVersion);
|
||||
}
|
||||
// 使用std::filesystem处理路径
|
||||
std::filesystem::path configPath =
|
||||
std::filesystem::path(modelPath).parent_path() / (className + ".mcfg");
|
||||
model->SetXmlPath(configPath.string());
|
||||
|
||||
// 注册模型到管理器
|
||||
d->ModelMap[modelID] = model;
|
||||
@ -100,10 +92,9 @@ 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);
|
||||
|
@ -61,14 +61,10 @@ 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,
|
||||
const std::string &modelVersion, const std::string &planeName,
|
||||
uint32_t initialType, uint32_t threadID);
|
||||
void LoadModel(const std::string &modelPath, const std::string &className, uint32_t initialType,
|
||||
uint32_t threadID);
|
||||
|
||||
/**
|
||||
* @brief 注册模型信息
|
||||
|
@ -192,222 +192,105 @@ 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()) {
|
||||
LOG_WARNING("0x2161 Failed to open the model configuration file: %1!", GetXmlPath());
|
||||
return;
|
||||
}
|
||||
tinyxml2::XMLDocument doc;
|
||||
doc.LoadFile(GetXmlPath().c_str());
|
||||
tinyxml2::XMLElement *rootNode = doc.FirstChildElement("Model");
|
||||
if (!rootNode) {
|
||||
LOG_WARNING("0x2161 Failed to parse model configuration file: %1!", GetXmlPath());
|
||||
return;
|
||||
}
|
||||
// 读取配置文件的模型参数
|
||||
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 "
|
||||
"with the model name in the configuration file of model %2!",
|
||||
GetObjectName(), modelName ? modelName : "null");
|
||||
return;
|
||||
}
|
||||
d->_sDescription = rootNode->FirstChildElement("Description")->GetText();
|
||||
d->_sAuthor = rootNode->FirstChildElement("Author")->GetText();
|
||||
d->_sVersion = rootNode->FirstChildElement("Version")->GetText();
|
||||
|
||||
// 使用标准C++时间处理
|
||||
std::string createTimeStr = rootNode->FirstChildElement("CreateTime")->GetText();
|
||||
std::string changeTimeStr = rootNode->FirstChildElement("ChangeTime")->GetText();
|
||||
d->_cCreatTime = XNSim::parseISOTime(createTimeStr);
|
||||
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
|
||||
|
||||
std::string funcNode = rootNode->FirstChildElement("Node")->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 "
|
||||
"%1 is not in the x-x format, registration not executed!",
|
||||
GetObjectName());
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用标准C++字符串处理
|
||||
d->_runFreq = XNSim::safe_stoi(funcNode.substr(0, tmp));
|
||||
d->_runNode = XNSim::safe_stoi(funcNode.substr(tmp + 1));
|
||||
|
||||
// 注册周期性函数
|
||||
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::ifstream file(GetXmlPath());
|
||||
if (!file.is_open()) {
|
||||
LOG_WARNING("0x2161 Failed to open the model configuration file: %1!", GetXmlPath());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 加载动态库
|
||||
const char *mathlib = rootNode->FirstChildElement("MathLib")->GetText();
|
||||
if (mathlib && strlen(mathlib) > 0) {
|
||||
// 使用标准C++文件路径处理
|
||||
std::filesystem::path xmlPath(GetXmlPath());
|
||||
d->_sLibPath = xmlPath.parent_path().string() + "/" + mathlib;
|
||||
|
||||
// 使用标准C++动态库加载
|
||||
d->_dynamicLib = dlopen(d->_sLibPath.c_str(), RTLD_LAZY);
|
||||
if (d->_dynamicLib) { // 动态库加载成功
|
||||
LOG_INFO("0x2163 Model %1 loaded algorithm dynamic library %2 successfully!",
|
||||
GetObjectName(), d->_sLibPath);
|
||||
} else {
|
||||
tinyxml2::XMLDocument doc;
|
||||
doc.LoadFile(GetXmlPath().c_str());
|
||||
tinyxml2::XMLElement *rootNode = doc.FirstChildElement("Model");
|
||||
if (!rootNode) {
|
||||
LOG_WARNING("0x2161 Failed to parse model configuration file: %1!", GetXmlPath());
|
||||
return;
|
||||
}
|
||||
// 读取配置文件的模型参数
|
||||
const char *modelName = rootNode->FirstChildElement("Name")->GetText();
|
||||
if (!modelName || std::string(modelName) != GetObjectName()) {
|
||||
LOG_WARNING(
|
||||
"0x2160 Model %1 failed to find algorithm dynamic library %2, will not call "
|
||||
"algorithm!",
|
||||
GetObjectName(), d->_sLibPath);
|
||||
d->_dynamicLib = nullptr;
|
||||
"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;
|
||||
}
|
||||
d->_sDescription = rootNode->FirstChildElement("Description")->GetText();
|
||||
d->_sAuthor = rootNode->FirstChildElement("Author")->GetText();
|
||||
d->_sVersion = rootNode->FirstChildElement("Version")->GetText();
|
||||
|
||||
// 使用标准C++时间处理
|
||||
std::string createTimeStr = rootNode->FirstChildElement("CreateTime")->GetText();
|
||||
std::string changeTimeStr = rootNode->FirstChildElement("ChangeTime")->GetText();
|
||||
d->_cCreatTime = parseISOTime(createTimeStr);
|
||||
d->_cChangeTime = parseISOTime(changeTimeStr);
|
||||
|
||||
std::string funcNode = rootNode->FirstChildElement("Node")->GetText();
|
||||
d->_runPriority = std::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 "
|
||||
"%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));
|
||||
|
||||
// 注册周期性函数
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载动态库
|
||||
const char *mathlib = rootNode->FirstChildElement("MathLib")->GetText();
|
||||
if (mathlib && strlen(mathlib) > 0) {
|
||||
// 使用标准C++文件路径处理
|
||||
std::filesystem::path xmlPath(GetXmlPath());
|
||||
d->_sLibPath = xmlPath.parent_path().string() + "/" + mathlib;
|
||||
|
||||
// 使用标准C++动态库加载
|
||||
d->_dynamicLib = dlopen(d->_sLibPath.c_str(), RTLD_LAZY);
|
||||
if (d->_dynamicLib) { // 动态库加载成功
|
||||
LOG_INFO("0x2163 Model %1 loaded algorithm dynamic library %2 successfully!",
|
||||
GetObjectName(), d->_sLibPath);
|
||||
} else {
|
||||
LOG_WARNING(
|
||||
"0x2160 Model %1 failed to find algorithm dynamic library %2, will not call "
|
||||
"algorithm!",
|
||||
GetObjectName(), d->_sLibPath);
|
||||
d->_dynamicLib = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理指令列表
|
||||
tinyxml2::XMLElement *nodeCmds = rootNode->FirstChildElement("CommandList");
|
||||
if (nodeCmds) {
|
||||
for (tinyxml2::XMLElement *nodeCmd = nodeCmds->FirstChildElement("Command");
|
||||
nodeCmd != nullptr; nodeCmd = nodeCmd->NextSiblingElement("Command")) {
|
||||
const char *cmdName = nodeCmd->Attribute("Name");
|
||||
const char *cmdDescription = nodeCmd->Attribute("Description");
|
||||
const char *cmdCall = nodeCmd->Attribute("Call");
|
||||
// TODO: 处理命令列表
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理指令列表
|
||||
tinyxml2::XMLElement *nodeCmds = rootNode->FirstChildElement("CommandList");
|
||||
if (nodeCmds) {
|
||||
for (tinyxml2::XMLElement *nodeCmd = nodeCmds->FirstChildElement("Command");
|
||||
nodeCmd != nullptr; nodeCmd = nodeCmd->NextSiblingElement("Command")) {
|
||||
const char *cmdName = nodeCmd->Attribute("Name");
|
||||
const char *cmdDescription = nodeCmd->Attribute("Description");
|
||||
const char *cmdCall = nodeCmd->Attribute("Call");
|
||||
// TODO: 处理命令列表
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// 单步执行函数
|
||||
|
@ -169,18 +169,6 @@ 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 模型默认的周期性执行函数
|
||||
@ -250,10 +238,6 @@ public:
|
||||
|
||||
public:
|
||||
virtual void RegisterDDSParticipant();
|
||||
|
||||
private:
|
||||
void ParseXml();
|
||||
void ParseConfig();
|
||||
};
|
||||
|
||||
#define XN_MODEL_INITIALIZE(ClassName) \
|
||||
|
@ -66,19 +66,35 @@ bool XNScenarioManager::PrepareForExecute()
|
||||
return true;
|
||||
}
|
||||
|
||||
// 运行环境配置文件解析
|
||||
bool XNScenarioManager::AnalysisScenarioXml(const std::string &XmlPath, uint32_t initialType)
|
||||
// 辅助函数:分割字符串
|
||||
std::vector<std::string> split(const std::string &str, const std::string &delim)
|
||||
{
|
||||
T_D();
|
||||
if (initialType == 0) {
|
||||
return ParseScenarioXml(XmlPath);
|
||||
} else {
|
||||
return ParseConfig(XmlPath);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
// 解析运行环境描述文件
|
||||
bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
|
||||
// 辅助函数:获取文件名(不含扩展名)
|
||||
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();
|
||||
std::ifstream file(XmlPath);
|
||||
@ -98,7 +114,6 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
|
||||
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);
|
||||
@ -113,7 +128,7 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
|
||||
GetFramework()->GetDDSManager()->SetDomainID(domainID);
|
||||
// 读取CPU亲和性
|
||||
std::string cpuAff = envInfo->Attribute("CPUAffinity");
|
||||
std::vector<std::string> cpuAffList = XNSim::split(cpuAff, ",");
|
||||
std::vector<std::string> cpuAffList = split(cpuAff, ",");
|
||||
|
||||
//读取服务列表
|
||||
tinyxml2::XMLElement *serviceList = root->FirstChildElement("ServicesList");
|
||||
@ -122,12 +137,10 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
|
||||
while (service) {
|
||||
std::string serviceName = service->Attribute("Name");
|
||||
std::string libName = service->Attribute("ClassName");
|
||||
std::string serviceVersion = service->Attribute("Version");
|
||||
libName = XNSim::getFileNameWithoutExt(libName);
|
||||
std::string dynamicLibName = servicePath + "/lib" + libName + ".so." + serviceVersion;
|
||||
libName = getFileNameWithoutExt(libName);
|
||||
std::string dynamicLibName = servicePath + "lib" + libName + ".so";
|
||||
// 加载动态库
|
||||
GetFramework()->GetServiceManager()->LoadService(dynamicLibName, libName,
|
||||
serviceVersion, 0);
|
||||
GetFramework()->GetServiceManager()->LoadService(dynamicLibName, libName, 0);
|
||||
service = service->NextSiblingElement("Service");
|
||||
}
|
||||
}
|
||||
@ -140,14 +153,14 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
|
||||
// 读取模型分组频率
|
||||
double modelGroupFreq = std::stod(modelGroup->Attribute("Freq"));
|
||||
// 读取模型分组优先级
|
||||
int modelGroupPriority = XNSim::safe_stoi(modelGroup->Attribute("Priority"));
|
||||
int modelGroupPriority = std::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 = XNSim::split(modelGroupCPUAff, ",");
|
||||
std::vector<std::string> modelGroupCPUAffList = split(modelGroupCPUAff, ",");
|
||||
|
||||
// 验证CPU亲和性
|
||||
for (const auto &cpu : modelGroupCPUAffList) {
|
||||
@ -175,12 +188,10 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
|
||||
while (model) {
|
||||
std::string modelName = model->Attribute("Name");
|
||||
std::string libName = model->Attribute("ClassName");
|
||||
std::string modelVersion = model->Attribute("Version");
|
||||
libName = XNSim::getFileNameWithoutExt(libName);
|
||||
std::string dynamicLibName = modelPath + "/lib" + libName + ".so." + modelVersion;
|
||||
libName = getFileNameWithoutExt(libName);
|
||||
std::string dynamicLibName = modelPath + "lib" + libName + ".so";
|
||||
// 加载动态库
|
||||
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, libName, modelVersion,
|
||||
planeName, 0, threadID);
|
||||
GetFramework()->GetModelManager()->LoadModel(dynamicLibName, libName, 0, threadID);
|
||||
model = model->NextSiblingElement("Model");
|
||||
}
|
||||
|
||||
@ -189,220 +200,3 @@ bool XNScenarioManager::ParseScenarioXml(const std::string &XmlPath)
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -76,21 +76,4 @@ 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);
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ bool XNServiceManager::PrepareForExecute()
|
||||
}
|
||||
|
||||
void XNServiceManager::LoadService(const std::string &servicePath, const std::string &serviceName,
|
||||
const std::string &serviceVersion, uint32_t initialType)
|
||||
uint32_t initialType)
|
||||
{
|
||||
T_D();
|
||||
void *handle = dlopen(servicePath.c_str(), RTLD_LAZY);
|
||||
@ -59,26 +59,15 @@ 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 + "_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;
|
||||
}
|
||||
// 使用std::filesystem处理路径
|
||||
std::filesystem::path configPath =
|
||||
std::filesystem::path(servicePath).parent_path() / (serviceName + ".scfg");
|
||||
service->SetXmlPath(configPath.string());
|
||||
|
||||
// 注册服务到管理器
|
||||
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!",
|
||||
|
@ -29,7 +29,7 @@ public:
|
||||
virtual bool Initialize() override;
|
||||
virtual bool PrepareForExecute() override;
|
||||
void LoadService(const std::string &servicePath, const std::string &serviceName,
|
||||
const std::string &serviceVersion, uint32_t initialType);
|
||||
uint32_t initialType);
|
||||
|
||||
public:
|
||||
XNServiceObjectPtr GetService(uint32_t serviceID);
|
||||
|
@ -139,152 +139,49 @@ 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());
|
||||
return;
|
||||
}
|
||||
|
||||
tinyxml2::XMLElement *rootNode = doc.RootElement();
|
||||
if (!rootNode) {
|
||||
LOG_WARNING("Invalid XML file format: %1!", GetXmlPath());
|
||||
return;
|
||||
}
|
||||
|
||||
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 "
|
||||
"with the service name in the configuration file of service %2!",
|
||||
GetObjectName(), serviceName);
|
||||
return;
|
||||
}
|
||||
|
||||
d->_sDescription = rootNode->FirstChildElement("Description")->GetText();
|
||||
d->_sAuthor = rootNode->FirstChildElement("Author")->GetText();
|
||||
d->_sVersion = rootNode->FirstChildElement("Version")->GetText();
|
||||
|
||||
// 解析时间
|
||||
const char *createTimeStr = rootNode->FirstChildElement("CreateTime")->GetText();
|
||||
const char *changeTimeStr = rootNode->FirstChildElement("ChangeTime")->GetText();
|
||||
d->_cCreateTime = XNSim::parseISOTime(createTimeStr);
|
||||
d->_cChangeTime = XNSim::parseISOTime(changeTimeStr);
|
||||
|
||||
tinyxml2::XMLElement *nodeCmds = rootNode->FirstChildElement("CommandList");
|
||||
if (nodeCmds) {
|
||||
for (tinyxml2::XMLElement *nodeCmd = nodeCmds->FirstChildElement("Command");
|
||||
nodeCmd != nullptr; nodeCmd = nodeCmd->NextSiblingElement("Command")) {
|
||||
const char *cmdName = nodeCmd->Attribute("Name");
|
||||
const char *cmdDescription = nodeCmd->Attribute("Description");
|
||||
const char *cmdCall = nodeCmd->Attribute("Call");
|
||||
// TODO: 处理命令信息
|
||||
tinyxml2::XMLDocument doc;
|
||||
if (doc.LoadFile(GetXmlPath().c_str()) != tinyxml2::XML_SUCCESS) {
|
||||
LOG_WARNING("Failed to open the service configuration file: %1!", GetXmlPath());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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";
|
||||
tinyxml2::XMLElement *rootNode = doc.RootElement();
|
||||
if (!rootNode) {
|
||||
LOG_WARNING("Invalid XML file format: %1!", GetXmlPath());
|
||||
return;
|
||||
}
|
||||
|
||||
// 打开数据库
|
||||
sqlite3 *db;
|
||||
if (sqlite3_open(dbPath.c_str(), &db) != SQLITE_OK) {
|
||||
LOG_ERROR("0x1016 打开数据库失败: %1", sqlite3_errmsg(db));
|
||||
return;
|
||||
}
|
||||
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 "
|
||||
"with the service name in the configuration file of service %2!",
|
||||
GetObjectName(), serviceName);
|
||||
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;
|
||||
}
|
||||
d->_sDescription = rootNode->FirstChildElement("Description")->GetText();
|
||||
d->_sAuthor = rootNode->FirstChildElement("Author")->GetText();
|
||||
d->_sVersion = rootNode->FirstChildElement("Version")->GetText();
|
||||
|
||||
// 绑定参数
|
||||
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;
|
||||
}
|
||||
// 解析时间
|
||||
const char *createTimeStr = rootNode->FirstChildElement("CreateTime")->GetText();
|
||||
const char *changeTimeStr = rootNode->FirstChildElement("ChangeTime")->GetText();
|
||||
d->_cCreateTime = parseISOTime(createTimeStr);
|
||||
d->_cChangeTime = parseISOTime(changeTimeStr);
|
||||
|
||||
// 执行查询
|
||||
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>()
|
||||
// );
|
||||
}
|
||||
}
|
||||
tinyxml2::XMLElement *nodeCmds = rootNode->FirstChildElement("CommandList");
|
||||
if (nodeCmds) {
|
||||
for (tinyxml2::XMLElement *nodeCmd = nodeCmds->FirstChildElement("Command");
|
||||
nodeCmd != nullptr; nodeCmd = nodeCmd->NextSiblingElement("Command")) {
|
||||
const char *cmdName = nodeCmd->Attribute("Name");
|
||||
const char *cmdDescription = nodeCmd->Attribute("Description");
|
||||
const char *cmdCall = nodeCmd->Attribute("Call");
|
||||
// TODO: 处理命令信息
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
LOG_WARNING("0x1020 解析服务命令列表失败: %1", e.what());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
// 读取其他参数
|
||||
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()
|
||||
|
@ -54,10 +54,6 @@ public:
|
||||
|
||||
protected:
|
||||
XNFrameworkPtr GetFramework() const;
|
||||
|
||||
private:
|
||||
void ParseXml();
|
||||
void ParseConfig();
|
||||
};
|
||||
|
||||
XNCLASS_PTR_DECLARE(XNServiceObject)
|
||||
|
@ -11,5 +11,4 @@ struct XNServiceObjectPrivate : public XNObjectPrivate {
|
||||
std::unordered_map<std::string, FAST_DDS_MACRO::DataWriter *> _dataWriters;
|
||||
XNFrameworkPtr pFramework;
|
||||
uint32_t _initialType;
|
||||
XN_JSON _otherParams;
|
||||
};
|
||||
|
@ -15,7 +15,6 @@ endif()
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(SQLite3 REQUIRED)
|
||||
|
||||
add_executable(XNEngine
|
||||
main.cpp
|
||||
@ -31,7 +30,6 @@ target_link_libraries(XNEngine PRIVATE
|
||||
pthread
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
sqlite3
|
||||
dl
|
||||
)
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "../XNCore/XNServiceManager.h"
|
||||
#include "../XNCore/XNModelManager.h"
|
||||
#include "../XNCore/XNScenarioManager.h"
|
||||
#include <sqlite3.h>
|
||||
|
||||
// 引擎类构造函数
|
||||
XNEngine::XNEngine()
|
||||
@ -56,42 +55,35 @@ void XNEngine::SimControlListener(const XNSim::XNSimControl::XNRuntimeControl &c
|
||||
}
|
||||
}
|
||||
|
||||
// 解析配置文件
|
||||
bool XNEngine::ParseConfig(const std::string &XmlPath)
|
||||
// 设置日志级别
|
||||
bool XNEngine::SetLogLevel(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 << "0x1007 打开配置文件失败, 引擎将退出!" << std::endl;
|
||||
std::cerr << "0x1003 Failed to open the runtime environment configuration file, "
|
||||
"the engine will exit!"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
// 解析配置文件
|
||||
tinyxml2::XMLDocument doc;
|
||||
if (doc.LoadFile(XmlPath.c_str()) != tinyxml2::XML_SUCCESS) {
|
||||
std::cerr << "0x1008 解析配置文件失败, 引擎将退出!" << std::endl;
|
||||
std::cerr << "0x1004 Failed to parse the runtime environment configuration file, "
|
||||
"the engine will exit!"
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
// 获取根元素
|
||||
tinyxml2::XMLElement *root = doc.FirstChildElement("Scenario");
|
||||
if (!root) {
|
||||
std::cerr << "0x1009 配置文件中未找到 Scenario 根元素, 引擎将退出!" << std::endl;
|
||||
std::cerr << "0x1005 Failed to find Scenario element in configuration file!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 顺便读取一下CPU亲和性
|
||||
int cpus = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
std::cout << "当前CPU核心数-> " << cpus << std::endl;
|
||||
std::cout << "Current number of CPU cores-> " << cpus << std::endl;
|
||||
|
||||
// 设置CPU亲和性
|
||||
cpu_set_t mask;
|
||||
@ -114,34 +106,30 @@ bool XNEngine::ParseConfig(const std::string &XmlPath)
|
||||
CPU_SET(index, &mask);
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << "0x1010 无效的CPU亲和性值: " << cpuIndex << std::endl;
|
||||
std::cerr << "Invalid CPU affinity value: " << cpuIndex << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sched_setaffinity(0, sizeof(mask), &mask) == -1) {
|
||||
std::cerr << "0x1011 设置引擎CPU亲和性失败-> " << strerror(errno) << std::endl;
|
||||
std::cerr << "0x1020 Failed to set engine CPU affinity-> " << strerror(errno) << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::cout << "成功设置引擎CPU亲和性-> " << CPUAffinity << std::endl;
|
||||
std::cout << "Successfully set engine CPU affinity-> " << CPUAffinity << std::endl;
|
||||
|
||||
// 锁定内存
|
||||
if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
|
||||
std::cerr << "0x1012 锁定引擎内存失败-> " << strerror(errno) << std::endl;
|
||||
std::cerr << "0x1021 Failed to lock engine memory-> " << strerror(errno) << std::endl;
|
||||
return false;
|
||||
}
|
||||
std::cout << "成功锁定引擎内存!" << std::endl;
|
||||
std::cout << "Successfully locked engine memory!" << std::endl;
|
||||
|
||||
// 获取配置文件中的日志元素
|
||||
bool isDebug = false;
|
||||
bool isInfo = false;
|
||||
bool isWarn = false;
|
||||
bool isError = false;
|
||||
// 获取配置文件中的控制台输出元素
|
||||
tinyxml2::XMLElement *consoleOutputNode = root->FirstChildElement("ConsoleOutput");
|
||||
if (!consoleOutputNode) {
|
||||
std::cout << "0x1013 配置文件中未找到 ConsoleOutput 元素, 控制台将输出所有日志!"
|
||||
std::cout << "The runtime environment configuration file does not contain "
|
||||
"the ConsoleOutput element, the Console will Output all Log!"
|
||||
<< std::endl;
|
||||
} else {
|
||||
// 获取配置文件中的调试日志输出元素
|
||||
@ -150,9 +138,9 @@ bool XNEngine::ParseConfig(const std::string &XmlPath)
|
||||
&& (strcmp(debugConsoleOutput, "true") == 0 || strcmp(debugConsoleOutput, "1") == 0
|
||||
|| strcmp(debugConsoleOutput, "True") == 0
|
||||
|| strcmp(debugConsoleOutput, "TRUE") == 0)) {
|
||||
isDebug = true;
|
||||
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Debug, true);
|
||||
} else {
|
||||
isDebug = false;
|
||||
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Debug, false);
|
||||
}
|
||||
|
||||
// 获取配置文件中的信息日志输出元素
|
||||
@ -161,9 +149,9 @@ bool XNEngine::ParseConfig(const std::string &XmlPath)
|
||||
&& (strcmp(infoConsoleOutput, "true") == 0 || strcmp(infoConsoleOutput, "1") == 0
|
||||
|| strcmp(infoConsoleOutput, "True") == 0
|
||||
|| strcmp(infoConsoleOutput, "TRUE") == 0)) {
|
||||
isInfo = true;
|
||||
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Info, true);
|
||||
} else {
|
||||
isInfo = false;
|
||||
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Info, false);
|
||||
}
|
||||
|
||||
// 获取配置文件中的警告日志输出元素
|
||||
@ -172,9 +160,9 @@ bool XNEngine::ParseConfig(const std::string &XmlPath)
|
||||
&& (strcmp(warningConsoleOutput, "true") == 0 || strcmp(warningConsoleOutput, "1") == 0
|
||||
|| strcmp(warningConsoleOutput, "True") == 0
|
||||
|| strcmp(warningConsoleOutput, "TRUE") == 0)) {
|
||||
isWarn = true;
|
||||
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Warning, true);
|
||||
} else {
|
||||
isWarn = false;
|
||||
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Warning, false);
|
||||
}
|
||||
|
||||
// 获取配置文件中的错误日志输出元素
|
||||
@ -183,26 +171,27 @@ bool XNEngine::ParseConfig(const std::string &XmlPath)
|
||||
&& (strcmp(errorConsoleOutput, "true") == 0 || strcmp(errorConsoleOutput, "1") == 0
|
||||
|| strcmp(errorConsoleOutput, "True") == 0
|
||||
|| strcmp(errorConsoleOutput, "TRUE") == 0)) {
|
||||
isError = true;
|
||||
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Error, true);
|
||||
} else {
|
||||
isError = false;
|
||||
XNLogger::instance().enableConsoleOutput(XNLogger::LogLevel::Error, false);
|
||||
}
|
||||
}
|
||||
// 设置控制台输出
|
||||
SetConsoleOutput(isDebug, isInfo, isWarn, isError);
|
||||
|
||||
// 获取配置文件中的日志元素
|
||||
tinyxml2::XMLElement *logNode = root->FirstChildElement("Log");
|
||||
if (!logNode) {
|
||||
std::cout << "0x1014 配置文件中未找到 Log 元素, 日志文件将记录所有日志!" << std::endl;
|
||||
std::cout << "The runtime environment configuration file does not contain "
|
||||
"the Log element, the Log File will record all 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)) {
|
||||
isDebug = true;
|
||||
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Debug, true);
|
||||
} else {
|
||||
isDebug = false;
|
||||
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Debug, false);
|
||||
}
|
||||
|
||||
// 获取配置文件中的信息日志输出元素
|
||||
@ -210,9 +199,9 @@ bool XNEngine::ParseConfig(const std::string &XmlPath)
|
||||
if (infoLog
|
||||
&& (strcmp(infoLog, "true") == 0 || strcmp(infoLog, "1") == 0
|
||||
|| strcmp(infoLog, "True") == 0 || strcmp(infoLog, "TRUE") == 0)) {
|
||||
isInfo = true;
|
||||
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Info, true);
|
||||
} else {
|
||||
isInfo = false;
|
||||
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Info, false);
|
||||
}
|
||||
|
||||
// 获取配置文件中的警告日志输出元素
|
||||
@ -220,9 +209,9 @@ bool XNEngine::ParseConfig(const std::string &XmlPath)
|
||||
if (warningLog
|
||||
&& (strcmp(warningLog, "true") == 0 || strcmp(warningLog, "1") == 0
|
||||
|| strcmp(warningLog, "True") == 0 || strcmp(warningLog, "TRUE") == 0)) {
|
||||
isWarn = true;
|
||||
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Warning, true);
|
||||
} else {
|
||||
isWarn = false;
|
||||
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Warning, false);
|
||||
}
|
||||
|
||||
// 获取配置文件中的错误日志输出元素
|
||||
@ -230,73 +219,18 @@ bool XNEngine::ParseConfig(const std::string &XmlPath)
|
||||
if (errorLog
|
||||
&& (strcmp(errorLog, "true") == 0 || strcmp(errorLog, "1") == 0
|
||||
|| strcmp(errorLog, "True") == 0 || strcmp(errorLog, "TRUE") == 0)) {
|
||||
isError = true;
|
||||
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Error, true);
|
||||
} else {
|
||||
isError = false;
|
||||
XNLogger::instance().enableFileOutput(XNLogger::LogLevel::Error, 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()
|
||||
{
|
||||
@ -398,43 +332,31 @@ void XNEngine::PublishEngineStatus()
|
||||
// 写入引擎状态
|
||||
engineStatusWriter->write(&engineStatus);
|
||||
// 记录调试日志
|
||||
LOG_DEBUG("引擎运行状态 DDS 写入成功!");
|
||||
LOG_DEBUG("XNEngine Write DDS!");
|
||||
}
|
||||
}
|
||||
|
||||
// 运行引擎
|
||||
bool XNEngine::Run(const std::string &XmlPath, const uint32_t InitializeType)
|
||||
bool XNEngine::Run(const std::string &XmlPath)
|
||||
{
|
||||
if (!framework) {
|
||||
return false;
|
||||
}
|
||||
if (InitializeType == 0) {
|
||||
// 解析配置文件
|
||||
bool isReady = ParseConfig(XmlPath);
|
||||
// 如果解析配置文件失败
|
||||
if (!isReady) {
|
||||
// 返回失败
|
||||
return false;
|
||||
}
|
||||
|
||||
} else if (InitializeType == 1) {
|
||||
// 解析数据库
|
||||
bool isReady = ParseDataBase(XmlPath);
|
||||
// 如果解析数据库失败
|
||||
if (!isReady) {
|
||||
// 返回失败
|
||||
return false;
|
||||
}
|
||||
// 设置日志级别
|
||||
bool isReady = SetLogLevel(XmlPath);
|
||||
// 如果设置日志级别失败
|
||||
if (!isReady) {
|
||||
// 返回失败
|
||||
return false;
|
||||
}
|
||||
// 设置场景XML路径
|
||||
framework->SetScenarioXml(XmlPath);
|
||||
// 设置CPU亲和性
|
||||
framework->SetCpuAffinity(CPUAffinity);
|
||||
// 单次触发初始化信号
|
||||
bool ret = framework->Initialize(InitializeType);
|
||||
bool ret = framework->Initialize(0);
|
||||
// 如果初始化失败
|
||||
if (!ret) {
|
||||
LOG_ERROR("0x1012 初始化失败, 引擎将退出!");
|
||||
// 返回失败
|
||||
return false;
|
||||
}
|
||||
@ -442,18 +364,17 @@ bool XNEngine::Run(const std::string &XmlPath, const uint32_t InitializeType)
|
||||
// 设置框架状态
|
||||
frameworkStatus = XNFrameObjectStatus::Initialized;
|
||||
// 记录信息日志
|
||||
LOG_INFO("引擎初始化成功!");
|
||||
LOG_INFO("XNEngine Initialize Success!");
|
||||
// 如果测试模式
|
||||
if (isTestMode) {
|
||||
// 记录信息日志
|
||||
LOG_INFO("引擎测试通过!");
|
||||
LOG_INFO("Verification passed!");
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
ret = framework->PrepareForExecute();
|
||||
// 如果准备执行失败
|
||||
if (!ret) {
|
||||
LOG_ERROR("0x1013 准备执行失败, 引擎将退出!");
|
||||
// 返回失败
|
||||
return false;
|
||||
}
|
||||
@ -491,117 +412,15 @@ bool XNEngine::Run(const std::string &XmlPath, const uint32_t InitializeType)
|
||||
}
|
||||
} else {
|
||||
// 记录错误日志
|
||||
LOG_ERROR("0x1014 无法发送引擎运行状态, 引擎将退出!");
|
||||
LOG_ERROR("0x1007 Failed to prepare for execution, the engine will exit!");
|
||||
}
|
||||
|
||||
// 返回成功
|
||||
return true;
|
||||
}
|
||||
|
||||
// 运行引擎
|
||||
bool XNEngine::ParseDataBase(const std::string &ConfigId)
|
||||
bool XNEngine::Run(const uint32_t &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;
|
||||
}
|
||||
// 设置测试模式
|
||||
|
@ -27,21 +27,25 @@ 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, const uint32_t InitializeType);
|
||||
|
||||
bool Run(const std::string &XmlPath);
|
||||
/**
|
||||
* @brief 运行引擎
|
||||
* @param ConfigId 构型ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
bool Run(const uint32_t &ConfigId);
|
||||
/**
|
||||
* @brief 设置测试模式
|
||||
* @param isTestMode 是否为测试模式
|
||||
@ -49,38 +53,12 @@ public:
|
||||
void SetTestMode(bool isTestMode);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief 解析配置文件
|
||||
* @param XmlPath 配置文件路径
|
||||
* @return 是否成功
|
||||
*/
|
||||
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 是否输出错误日志
|
||||
* @param XmlPath 场景XML路径
|
||||
* @return 是否成功
|
||||
*/
|
||||
bool SetLogLevel(bool isDebug, bool isInfo, bool isWarn, bool isError);
|
||||
bool SetLogLevel(const std::string &XmlPath);
|
||||
/**
|
||||
* @brief 发布引擎状态
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ int main(int argc, char *argv[])
|
||||
XNEngine engine;
|
||||
//检测输入参数个数
|
||||
if (argc <= 2) {
|
||||
std::cerr << "0x1000 输入参数太少!" << std::endl;
|
||||
std::cerr << "0x1000 The input parameters is too less!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -42,7 +42,10 @@ int main(int argc, char *argv[])
|
||||
hasConfigPath = true;
|
||||
i += 2;
|
||||
} else {
|
||||
std::cerr << "0x1001 在-f参数后,未指定配置文件路径,引擎将退出!" << std::endl;
|
||||
std::cerr << "0x1004 After the -f parameter, the configuration file path is not "
|
||||
"specified, "
|
||||
"the engine will exit!"
|
||||
<< std::endl;
|
||||
return -1;
|
||||
}
|
||||
} else if ("-id" == arg) {
|
||||
@ -51,30 +54,52 @@ int main(int argc, char *argv[])
|
||||
hasConfigId = true;
|
||||
i += 2;
|
||||
} else {
|
||||
std::cerr << "0x1002 在-id参数后,未指定配置ID,引擎将退出!" << std::endl;
|
||||
std::cerr
|
||||
<< "0x1005 After the -id parameter, the configuration ID is not specified, "
|
||||
"the engine will exit!"
|
||||
<< std::endl;
|
||||
return -1;
|
||||
}
|
||||
} else if ("-test" == arg) {
|
||||
engine.SetTestMode(true);
|
||||
i++;
|
||||
} else {
|
||||
std::cerr << "0x1003 无法识别的参数 " << arg << " ,引擎将退出!" << std::endl;
|
||||
std::cerr << "0x1007 The parameter " << arg << " is not valid, the engine will exit!"
|
||||
<< std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//检查是否同时包含-f和-id参数
|
||||
if (hasConfigPath && hasConfigId) {
|
||||
std::cerr << "0x1004 请指定 -f <config_file> 或 -id <config_id> ,但不要同时指定!"
|
||||
<< std::endl;
|
||||
std::cerr
|
||||
<< "0x1006 Please specify either -f <config_file> or -id <config_id>, but not both. "
|
||||
"The engine will exit!"
|
||||
<< std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//检测配置文件格式
|
||||
if (hasConfigPath) {
|
||||
return engine.Run(configPath, 0);
|
||||
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);
|
||||
} else if (hasConfigId) {
|
||||
return engine.Run(configId, 1);
|
||||
return engine.Run(configId);
|
||||
}
|
||||
return -1;
|
||||
// 引擎运行
|
||||
return engine.Run(configId);
|
||||
}
|
||||
|
@ -44,12 +44,9 @@ bool DDSInterfaceGen::generateDDSInterfaceHpp(const std::string &nameSpace,
|
||||
hppFile << "namespace " << nameSpace << std::endl;
|
||||
hppFile << "{" << std::endl;
|
||||
// 3. 写入类声明
|
||||
hppFile << "class " << className << " : public XNDDSInterface" << std::endl;
|
||||
hppFile << "class " << className << " final : 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;
|
||||
@ -85,15 +82,14 @@ 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(out_data." << interface.interfaceName
|
||||
hppFile << "\t\t" << "assign_value_set(data." << interface.interfaceName
|
||||
<< "(), model_data->" << interface.interfaceName << ");" << std::endl;
|
||||
}
|
||||
hppFile << "\t\t" << "sendOutData();" << std::endl;
|
||||
hppFile << "\t" << "}" << std::endl;
|
||||
// 11. 写入私有成员变量
|
||||
hppFile << "" << "protected:" << std::endl;
|
||||
hppFile << "\t" << "DDSType data;" << std::endl;
|
||||
hppFile << "\t" << "DDSType out_data;" << std::endl;
|
||||
hppFile << "" << "private:" << std::endl;
|
||||
hppFile << "\t" << topicType << " data;" << std::endl;
|
||||
hppFile << "\t" << topicType << " out_data;" << std::endl;
|
||||
// 12. 写入类声明结束
|
||||
hppFile << "};" << std::endl;
|
||||
// 13. 写入命名空间结束
|
||||
@ -114,8 +110,6 @@ 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. 写入类构造函数实现
|
||||
|
@ -1,8 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(XNModels)
|
||||
|
||||
add_subdirectory(XNATA04DataProcessor)
|
||||
add_subdirectory(XNAerodynamics)
|
||||
add_subdirectory(XNGroundHandling)
|
||||
add_subdirectory(XNWeightBalance)
|
@ -2,8 +2,6 @@ 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)
|
||||
|
||||
@ -25,14 +23,6 @@ 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
|
||||
@ -55,7 +45,4 @@ install(TARGETS XNATA04DataProcessor
|
||||
file(GLOB CONFIG_FILE "*.mcfg")
|
||||
|
||||
# 使用 install 命令在安装时拷贝配置文件
|
||||
install(FILES ${CONFIG_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
RENAME "XNATA04DataProcessor_V${MODEL_VERSION}.mcfg"
|
||||
)
|
||||
install(FILES ${CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
@ -2,8 +2,6 @@ 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)
|
||||
@ -26,14 +24,6 @@ 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
|
||||
@ -57,7 +47,4 @@ install(TARGETS XNAerodynamics
|
||||
file(GLOB CONFIG_FILE "*.mcfg")
|
||||
|
||||
# 使用 install 命令在安装时拷贝配置文件
|
||||
install(FILES ${CONFIG_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
RENAME "XNAerodynamics_V${MODEL_VERSION}.mcfg"
|
||||
)
|
||||
install(FILES ${CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
@ -2,8 +2,6 @@ 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)
|
||||
@ -26,14 +24,6 @@ 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
|
||||
@ -56,7 +46,4 @@ install(TARGETS XNGroundHandling
|
||||
file(GLOB CONFIG_FILE "*.mcfg")
|
||||
|
||||
# 使用 install 命令在安装时拷贝配置文件
|
||||
install(FILES ${CONFIG_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
RENAME "XNGroundHandling_V${MODEL_VERSION}.mcfg"
|
||||
)
|
||||
install(FILES ${CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
@ -2,8 +2,6 @@ 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)
|
||||
@ -26,14 +24,6 @@ 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
|
||||
@ -57,7 +47,4 @@ install(TARGETS XNWeightBalance
|
||||
file(GLOB CONFIG_FILE "*.mcfg")
|
||||
|
||||
# 使用 install 命令在安装时拷贝配置文件
|
||||
install(FILES ${CONFIG_FILE}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
||||
RENAME "XNWeightBalance_V${MODEL_VERSION}.mcfg"
|
||||
)
|
||||
install(FILES ${CONFIG_FILE} DESTINATION ${CMAKE_INSTALL_PREFIX})
|
@ -49,10 +49,6 @@ 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()
|
||||
|
6
XNMonitorServer/.vscode/settings.json
vendored
6
XNMonitorServer/.vscode/settings.json
vendored
@ -69,10 +69,6 @@
|
||||
"thread": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"any": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"fstream": "cpp",
|
||||
"valarray": "cpp"
|
||||
"typeinfo": "cpp"
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user