#include "XNWeightBalance.h" #include "XNWeightBalance_p.h" #include XN_MODEL_INITIALIZE(XNWeightBalance) XNWeightBalance::XNWeightBalance() : XNModelObject(new XNWeightBalancePrivate()) { } XNWeightBalance::~XNWeightBalance() { } XNWeightBalance::XNWeightBalance(PrivateType *p) : XNModelObject(p) { } void XNWeightBalance::Initialize() { T_D(); SuperType::Initialize(); if (d->_dynamicLib) { d->_fun = (FunctionType)dlsym(d->_dynamicLib, d->_entryPointName.c_str()); if (!d->_fun) { LOG_WARNING( "Failed to resolve _Z28SACSCWeightBalanceEntryPointP20ComacDataStructure_S"); } } /* 在这里进行其它初始化 */ } void XNWeightBalance::PrepareForExecute() { T_D(); SuperType::PrepareForExecute(); InitializeData(); d->_inputInterface.Initialize(GetFramework(), GetUniqueId(), 1); d->_outputInterface.Initialize(GetFramework(), GetUniqueId(), 2); d->_heartbeatInterface.Initialize(GetFramework(), GetUniqueId(), 2); /* 在这里进行其它运行前准备工作 */ } void XNWeightBalance::StepUpdate() { T_D(); SuperType::StepUpdate(); if (d->_fun) { d->_inputInterface.getData(d->_data.input_weight); d->_fun(&d->_data); d->_outputInterface.setData(d->_data.output_weight); d->_heartbeatInterface.setData(&d->_data); } /* 在这里进行其它运行时计算 */ } void XNWeightBalance::InitializeData() { T_D(); d->_data.input_weight = new input_weight_S; // TODO: 在这里初始化输入数据 d->_data.input_weight->l_04_i_wbcomac_acset_tankfuel_f4 = new float[20]; d->_data.input_weight->l_04_i_wbcomac_eng_efsep_l1 = new unsigned char[4]; d->_data.input_weight->l_04_i_wbcomac_fuel_f8 = new double[20]; d->_data.input_weight->l_04_i_wbcomac_kice_f8 = new double[20]; d->_data.output_weight = new output_weight_S; // TODO: 在这里初始化输出数据 d->_data.output_weight->l_04_o_wbcomac_fuel_cmd_f8 = new double[20]; d->_data.output_weight->l_04_o_wbcomac_ice_eng_f8 = new double[4]; d->_data.weightbody_model_heartbeat = 0; } void XNWeightBalance::ReleaseData() { T_D(); if (d->_data.input_weight) { // TODO: 在这里释放输入数据 if (d->_data.input_weight->l_04_i_wbcomac_acset_tankfuel_f4) { delete[] d->_data.input_weight->l_04_i_wbcomac_acset_tankfuel_f4; } if (d->_data.input_weight->l_04_i_wbcomac_eng_efsep_l1) { delete[] d->_data.input_weight->l_04_i_wbcomac_eng_efsep_l1; } if (d->_data.input_weight->l_04_i_wbcomac_fuel_f8) { delete[] d->_data.input_weight->l_04_i_wbcomac_fuel_f8; } if (d->_data.input_weight->l_04_i_wbcomac_kice_f8) { delete[] d->_data.input_weight->l_04_i_wbcomac_kice_f8; } delete d->_data.input_weight; d->_data.input_weight = nullptr; } if (d->_data.output_weight) { // TODO: 在这里释放输出数据 if (d->_data.output_weight->l_04_o_wbcomac_fuel_cmd_f8) { delete[] d->_data.output_weight->l_04_o_wbcomac_fuel_cmd_f8; } if (d->_data.output_weight->l_04_o_wbcomac_ice_eng_f8) { delete[] d->_data.output_weight->l_04_o_wbcomac_ice_eng_f8; } delete d->_data.output_weight; d->_data.output_weight = nullptr; } }