XNSim/XNModels/XNGroundHandling/XNGroundHandling.cpp

131 lines
5.0 KiB
C++
Raw Normal View History

2025-04-28 12:25:20 +08:00
#include "XNGroundHandling.h"
#include "XNGroundHandling_p.h"
#include <XNCore/XNModelManager.h>
#include <XNCore/XNDDSManager.h>
2025-05-22 08:53:29 +08:00
XN_MODEL_INITIALIZE(XNGroundHandling)
2025-04-28 12:25:20 +08:00
2025-05-22 08:53:29 +08:00
XNGroundHandling::XNGroundHandling() : XNModelObject(new XNGroundHandlingPrivate())
2025-04-28 12:25:20 +08:00
{
}
XNGroundHandling::~XNGroundHandling()
{
}
2025-05-22 08:53:29 +08:00
XNGroundHandling::XNGroundHandling(PrivateType *p) : XNModelObject(p)
2025-04-28 12:25:20 +08:00
{
}
2025-05-22 08:53:29 +08:00
void XNGroundHandling::Initialize()
2025-04-28 12:25:20 +08:00
{
2025-05-22 08:53:29 +08:00
T_D();
XNModelObject::Initialize();
2025-04-28 12:25:20 +08:00
if (d->_dynamicLib) {
2025-05-22 08:53:29 +08:00
d->_fun = (FunctionType)dlsym(d->_dynamicLib, d->_entryPointName.c_str());
2025-04-28 12:25:20 +08:00
if (!d->_fun) {
2025-05-22 08:53:29 +08:00
LOG_WARNING("Failed to resolve SACSCGroundHandlingEntry");
2025-04-28 12:25:20 +08:00
}
}
//add other initial code here
}
2025-05-22 08:53:29 +08:00
void XNGroundHandling::PrepareForExecute()
2025-04-28 12:25:20 +08:00
{
2025-05-22 08:53:29 +08:00
T_D();
XNModelObject::PrepareForExecute();
2025-04-28 12:25:20 +08:00
//add your initial data code here
d->_data.input_ground = new input_ground_S();
d->_data.input_ground->l_04_i_gdcomac_brake_torq_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.input_ground->l_04_i_gdcomac_brake_torq_f8[i] = new double[2];
}
d->_data.input_ground->l_04_i_gdcomac_gear_f8 = new double[3];
d->_data.input_ground->l_04_i_gdcomac_gsteer_f8 = new double[3];
d->_data.input_ground->l_04_i_gdcomac_tire_pres_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.input_ground->l_04_i_gdcomac_tire_pres_f8[i] = new double[2];
}
d->_data.input_ground->l_04_i_gdcomac_contdep_f8 = new double[7];
d->_data.input_ground->l_04_i_gdcomac_brake_temp_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.input_ground->l_04_i_gdcomac_brake_temp_f8[i] = new double[2];
}
d->_data.input_ground->l_04_i_gdcomac_tire_tburst_l1 = new unsigned char *[3];
for (int i = 0; i < 3; i++) {
d->_data.input_ground->l_04_i_gdcomac_tire_tburst_l1[i] = new unsigned char[2];
}
d->_data.input_ground->l_04_i_gdcomac_tire_tflat_l1 = new unsigned char *[3];
for (int i = 0; i < 3; i++) {
d->_data.input_ground->l_04_i_gdcomac_tire_tflat_l1[i] = new unsigned char[2];
}
d->_data.input_ground->l_04_i_gdcomac_rcon_ci_f8 = new double[14];
d->_data.output_ground = new output_ground_S();
d->_data.output_ground->l_04_o_gdcomac_fygs_f8 = new double[3];
d->_data.output_ground->l_04_o_gdcomac_mzgs_f8 = new double[3];
d->_data.output_ground->l_04_o_gdcomac_mu_f8 = new double[3];
d->_data.output_ground->l_04_o_gdcomac_dstroke_f8 = new double[3];
d->_data.output_ground->l_04_o_gdcomac_sr_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_sr_f8[i] = new double[2];
}
d->_data.output_ground->l_04_o_gdcomac_sy_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_sy_f8[i] = new double[2];
}
d->_data.output_ground->l_04_o_gdcomac_sx_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_sx_f8[i] = new double[2];
}
d->_data.output_ground->l_04_o_gdcomac_xft_f8 = new double[3];
d->_data.output_ground->l_04_o_gdcomac_yft_f8 = new double[3];
d->_data.output_ground->l_04_o_gdcomac_zft_f8 = new double[3];
d->_data.output_ground->l_04_o_gdcomac_tire_vel_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_tire_vel_f8[i] = new double[2];
}
d->_data.output_ground->l_04_o_gdcomac_tire_temp_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_tire_temp_f8[i] = new double[2];
}
d->_data.output_ground->l_04_o_gdcomac_tire_burst_l1 = new unsigned char *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_tire_burst_l1[i] = new unsigned char[2];
}
d->_data.output_ground->l_04_o_gdcomac_utirew_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_utirew_f8[i] = new double[2];
}
d->_data.output_ground->l_04_o_gdcomac_vtirew_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_vtirew_f8[i] = new double[2];
}
d->_data.output_ground->l_04_o_gdcomac_whl_omega_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_whl_omega_f8[i] = new double[2];
}
d->_data.output_ground->l_04_o_gdcomac_dstruc_f8 = new double[6];
d->_data.output_ground->l_04_o_gdcomac_nd_f8 = new double[3];
d->_data.output_ground->l_04_o_gdcomac_wor_par_f8 = new double[3];
d->_data.output_ground->l_04_o_gdcomac_vczt_f8 = new double *[3];
for (int i = 0; i < 3; i++) {
d->_data.output_ground->l_04_o_gdcomac_vczt_f8[i] = new double[2];
}
d->_inputInterface.Initialize(GetFramework(), GetUniqueId(), 1);
d->_outputInterface.Initialize(GetFramework(), GetUniqueId(), 2);
d->_heartbeatInterface.Initialize(GetFramework(), GetUniqueId(), 2);
2025-04-28 12:25:20 +08:00
}
void XNGroundHandling::StepUpdate()
{
2025-05-22 08:53:29 +08:00
T_D();
2025-04-28 12:25:20 +08:00
XNModelObject::StepUpdate();
if (d->_fun) {
//add your input code here
2025-05-22 08:53:29 +08:00
d->_inputInterface.getData(d->_data.input_ground);
2025-04-28 12:25:20 +08:00
d->_fun(&d->_data);
2025-05-22 08:53:29 +08:00
d->_outputInterface.setData(d->_data.output_ground);
d->_heartbeatInterface.setData(&d->_data);
2025-04-28 12:25:20 +08:00
//add your output code here
}
2025-05-22 08:53:29 +08:00
}