594 lines
18 KiB
C
Raw Normal View History

2025-05-22 16:22:48 +08:00
#ifndef CMCLIB_H
#define CMCLIB_H
#include <string>
typedef struct ComacDataStructure_S {
int aero_model_heartbeat;
int weightbody_model_heartbeat;
int groundhandling_model_heartbeat;
double yitim;
struct input_aero_S* input_aero;
struct output_aero_S* output_aero;
struct input_weight_S* input_weight;
struct output_weight_S* output_weight;
struct input_ground_S* input_ground;
struct output_ground_S* output_ground;
};
struct input_weight_S {
double l_04_i_wbcomac_theta_deg_f8;
double l_04_i_wbcomac_phi_deg_f8;
double l_04_i_wbcomac_psi_deg_f8;
unsigned char l_04_i_wbcomac_gear_mode_l1;
double l_04_i_wbcomac_acset_gw_f8;
double l_04_i_wbcomac_acset_cg_f8;
// [0]: left wing tank
// [1]: right wing tan
// [2]: center tank
float* l_04_i_wbcomac_acset_tankfuel_f4;
double l_04_i_wbcomac_acset_totfuel_f8;
double l_04_i_wbcomac_acset_zfw_f8;
double l_04_i_wbcomac_acset_zfwcg_f8;
// [0]: Engine #1
// [1]: Engine #2
unsigned char* l_04_i_wbcomac_eng_efsep_l1;
// [0]: left wing tank
// [1]: right wing tan
// [2]: center tank
double* l_04_i_wbcomac_fuel_f8;
double l_04_i_wbcomac_gear_avg_f8;
// [0]: outboard left wing
// [1]: inboard left wing
// [2]: root left wing
// [3]: root right wing
// [4]: inboard right wing
// [5]: outboard right wing
// [6]: fuselage icing
// [7]: left horizontal tail
// [8]: right horizontal tail
// [9]: vertical tail
// [10]: engine 1
// [11]: engine 2
double* l_04_i_wbcomac_kice_f8;
unsigned char l_04_i_wbcomac_bycglim_l1;
unsigned char l_04_i_wbcomac_bygwlim_l1;
unsigned char l_04_i_wbcomac_frz_l1;
unsigned char l_04_i_wbcomac_zcgfrz_l1;
unsigned char l_04_i_wbcomac_zcgfrz_grfx_l1;
unsigned char l_04_i_wbcomac_ycgfrz_l1;
unsigned char l_04_i_wbcomac_inertfrz_l1;
double l_04_i_wbcomac_potreq_gw_f8;
double l_04_i_wbcomac_potreq_gwcg_f8;
};
struct output_weight_S {
float l_04_o_wbcomac_gw_f4;
float l_04_o_wbcomac_cg_f4;
double l_04_o_wbcomac_xcg_f8;
double l_04_o_wbcomac_blcg_f8;
double l_04_o_wbcomac_bscg_f8;
double l_04_o_wbcomac_wlcg_f8;
double l_04_o_wbcomac_ixx_f8;
double l_04_o_wbcomac_ixy_f8;
double l_04_o_wbcomac_ixz_f8;
double l_04_o_wbcomac_iyy_f8;
double l_04_o_wbcomac_iyz_f8;
double l_04_o_wbcomac_izz_f8;
float l_04_o_wbcomac_zfw_f4;
float l_04_o_wbcomac_zfwcg_f4;
float l_04_o_wbcomac_zfw_blcg_f4;
float l_04_o_wbcomac_zfw_wlcg_f4;
// [0]: left wing tank (if mode is 2)
// [1]: right wing tank (if mode is 2)
// [2]: center tank (if mode is 2)
double* l_04_o_wbcomac_fuel_cmd_f8;
// 0 = backdrive inactive, 1 = total fuel backdrive, 2 = individual fuel tank backdrive
int l_04_o_wbcomac_fuel_mode_i4;
double l_04_o_wbcomac_fuel_ixx_f8;
double l_04_o_wbcomac_fuel_ixy_f8;
double l_04_o_wbcomac_fuel_ixz_f8;
double l_04_o_wbcomac_fuel_iyy_f8;
double l_04_o_wbcomac_fuel_iyz_f8;
double l_04_o_wbcomac_fuel_izz_f8;
double l_04_o_wbcomac_l_wt_fuel_f8;
double l_04_o_wbcomac_ice_airframe_total_f8;
// [0]: Engine #1
// [1]: Engine #2
double* l_04_o_wbcomac_ice_eng_f8;
double l_04_o_wbcomac_ice_eng_total_f8;
double l_04_o_wbcomac_ice_fuselage_f8;
double l_04_o_wbcomac_ice_stab_left_f8;
double l_04_o_wbcomac_ice_stab_right_f8;
double l_04_o_wbcomac_ice_stab_total_f8;
double l_04_o_wbcomac_ice_total_f8;
double l_04_o_wbcomac_ice_total_frac_f8;
double l_04_o_wbcomac_ice_vert_tail_f8;
double l_04_o_wbcomac_ice_wing_left_f8;
double l_04_o_wbcomac_ice_wing_right_f8;
double l_04_o_wbcomac_ice_wing_total_f8;
unsigned char l_04_o_wbcomac_frz_l1;
unsigned char l_04_o_wbcomac_zcgfrz_l1;
unsigned char l_04_o_wbcomac_zcgfrz_grfx_l1;
unsigned char l_04_o_wbcomac_ycgfrz_l1;
unsigned char l_04_o_wbcomac_inertfrz_l1;
unsigned char l_04_o_wbcomac_init_l1;
float l_04_o_wbcomac_min_gw_f4;
float l_04_o_wbcomac_max_gw_f4;
float l_04_o_wbcomac_min_cg_f4; // 0 = Leading Edge MAC, 1 = Trailing Edge MAC
float l_04_o_wbcomac_max_cg_f4; // 0 = Leading Edge MAC, 1 = Trailing Edge MAC
float l_04_o_wbcomac_min_zfw_f4; // 0 = Leading Edge MAC, 1 = Trailing Edge MAC
float l_04_o_wbcomac_max_zfw_f4; // 0 = Leading Edge MAC, 1 = Trailing Edge MAC
float l_04_o_wbcomac_min_zfwcg_f4;
float l_04_o_wbcomac_max_zfwcg_f4;
double l_04_o_wbcomac_potmin_gw_f8; // 0 = Leading Edge MAC, 1 = Trailing Edge MAC
double l_04_o_wbcomac_potmax_gw_f8; // 0 = Leading Edge MAC, 1 = Trailing Edge MAC
double l_04_o_wbcomac_potmin_gwcg_f8;
double l_04_o_wbcomac_potmax_gwcg_f8;
};
struct input_ground_S {
unsigned char l_04_i_gdcomac_frz_l1;
unsigned char l_04_i_gdcomac_chocks_l1; // 1 = A/C on chocks
double l_04_i_gdcomac_alt_agl_f8;
unsigned char l_04_i_gdcomac_frzflt_l1;
double l_04_i_gdcomac_p_f8;
double l_04_i_gdcomac_q_f8;
double l_04_i_gdcomac_r_f8;
double l_04_i_gdcomac_ug_f8;
double l_04_i_gdcomac_vg_f8;
double l_04_i_gdcomac_wg_f8;
double l_04_i_gdcomac_blcg_f8;
double l_04_i_gdcomac_bscg_f8;
double l_04_i_gdcomac_wlcg_f8;
unsigned char l_04_i_gdcomac_pb_active_l1;
double l_04_i_gdcomac_pb_towforce_f8; // "PUSHBACK TOW FORCE"
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_i_gdcomac_brake_torq_f8;
// [0] : Nose gear,
// [1] : Left gear,
// [2] : Right gear
double* l_04_i_gdcomac_gear_f8; // 1 = Gear down / 0 = Gear up
// [0] : Nose gear,
// [1] : Left gear,
// [2] : Right gear
double* l_04_i_gdcomac_gsteer_f8; // Positive: turn right
// [0][0] : Nose gear, Tire left
// [0][1] : Nose gear, Tire right
// [1][0] : Left gear, Tire left
// [1][1] : Left gear, Tire right
// [2][0] : Right gear, Tire left
// [2][1] : Right gear, Tire right
double** l_04_i_gdcomac_tire_pres_f8;
unsigned char l_04_i_gdcomac_onjax_l1; // Positive: turn right
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_i_gdcomac_contdep_f8; // Will be provided according to contamination type.
double l_04_i_gdcomac_thetag_f8;
double l_04_i_gdcomac_phig_f8;
int l_04_i_gdcomac_rwyrgh_i2;// 4 Levels of Roughness. From MIN to MAX.
double l_04_i_gdcomac_rwyhdg_f8;// North-South axis
unsigned char l_04_i_gdcomac_reset_braketemp_l1;
unsigned char l_04_i_gdcomac_reset_tirepress_l1;
double l_04_i_gdcomac_temp_c_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_i_gdcomac_brake_temp_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
unsigned char** l_04_i_gdcomac_tire_tburst_l1; // 1 = Tire is burst
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
unsigned char** l_04_i_gdcomac_tire_tflat_l1; // 1 = Tire is flat
unsigned char l_04_i_gdcomac_brk_reset_tpres_l1; // Reset the tire pressure to the value set from flight control.
// [0]: Dried
// [1]: Wet
// [2]: Flooded
// [3]: Wet with rubber
// [4]: Flooded with ru
// [5]: Melting Slush
// [6]: Freezing Slush
// [7]: Wet Snow
// [8]: Dry Snow
// [9]: Wet Ice
// [10]: Cold Ice
// [11]: Thin Dust/Dirs
// [12]: Thick Dust/Dir
// [13]: White Strip
double* l_04_i_gdcomac_rcon_ci_f8;
int l_04_i_gdcomac_gsteer_state_i4; // 0 = Engaged, 2 = Castoring
unsigned char l_04_i_gdcomac_trim_active_l1;
double l_04_i_gdcomac_theta_deg_f8;
double l_04_i_gdcomac_phi_deg_f8;
double l_04_i_gdcomac_psi_deg_f8;
unsigned char l_04_i_gdcomac_resetint_l1; // when this is true, the ground model should return the default values of the ground parameters
unsigned char l_04_i_gdcomac_eom_wgfrz_l1;
unsigned char l_04_i_gdcomac_eom_vgfrz_l1;
unsigned char l_04_i_gdcomac_eom_ugfrz_l1;
unsigned char l_04_i_gdcomac_eom_pfrz_l1;
unsigned char l_04_i_gdcomac_eom_qfrz_l1;
unsigned char l_04_i_gdcomac_eom_rfrz_l1;
unsigned char l_04_i_gdcomac_eom_hfrz_l1;
unsigned char l_04_i_gdcomac_eom_phifrz_l1;
unsigned char l_04_i_gdcomac_eom_thefrz_l1;
unsigned char l_04_i_gdcomac_eom_psifrz_l1;
};
struct output_ground_S {
unsigned char l_04_o_gdcomac_frz_l1;
unsigned char l_04_o_gdcomac_ac_on_ground_l1; // 1 = A/C is on ground
double l_04_o_gdcomac_ac_stationary_f8; // 1 = A/C is moving / 0 = A/C is stationary
double l_04_o_gdcomac_alt_tire_f8;
double l_04_o_gdcomac_zcg_to_tire_f8;
double l_04_o_gdcomac_fxb_f8;
double l_04_o_gdcomac_fyb_f8;
double l_04_o_gdcomac_fzb_f8;
double l_04_o_gdcomac_mxb_f8;
double l_04_o_gdcomac_myb_f8;
double l_04_o_gdcomac_mzb_f8;
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_o_gdcomac_fygs_f8;
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_o_gdcomac_mzgs_f8;
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_o_gdcomac_mu_f8;
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_o_gdcomac_dstroke_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_o_gdcomac_sr_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_o_gdcomac_sy_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_o_gdcomac_sx_f8;
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_o_gdcomac_xft_f8;
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_o_gdcomac_yft_f8;
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_o_gdcomac_zft_f8;
double l_04_o_gdcomac_distngrxcg_f8;
double l_04_o_gdcomac_distmgrxcg_f8;
double l_04_o_gdcomac_distmgrzcg_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_o_gdcomac_tire_vel_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_o_gdcomac_tire_temp_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
unsigned char** l_04_o_gdcomac_tire_burst_l1;
unsigned char l_04_o_gdcomac_wow_l1;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_o_gdcomac_utirew_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_o_gdcomac_vtirew_f8;
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_o_gdcomac_whl_omega_f8;
// [0] = Nose
// [1] = Left wing
// [2] = Right wing
// [3] = Left Body
// [4] = Right Body
// [5] = Tail
double* l_04_o_gdcomac_dstruc_f8;
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_o_gdcomac_nd_f8;
// [0]: Nose gear
// [1]: Left gear
// [2]: Right gea
double* l_04_o_gdcomac_wor_par_f8; // Only [0]: Nose gear can have yaw / is driven
// [0][0]: Nose gear, Tire left
// [0][1]: Nose gear, Tire right
// [1][0]: Left gear, Tire left
// [1][1]: Left gear, Tire right
// [2][0]: Right gear, Tire left
// [2][1]: Right gear, Tire right
double** l_04_o_gdcomac_vczt_f8;
unsigned char l_04_o_gdcomac_eom_wgfrz_l1; // DISABLE INTEG. OF Z BODY VELOCI
unsigned char l_04_o_gdcomac_eom_vgfrz_l1; // DISABLE INTEG. OF Y BODY VELOCI
unsigned char l_04_o_gdcomac_eom_ugfrz_l1; // DISABLE INTEG. OF X BODY VELOCI
unsigned char l_04_o_gdcomac_eom_pfrz_l1; // DISABLE INTEG. OF BODY AXIS ROL
unsigned char l_04_o_gdcomac_eom_qfrz_l1; // DISABLE INTEG. OF BODY AXIS PIT
unsigned char l_04_o_gdcomac_eom_rfrz_l1; // DISABLE INTEG. OF BODY AXIS YAW
unsigned char l_04_o_gdcomac_eom_hfrz_l1; // DISABLE INTEG. OF ALTITUDE ABOV
unsigned char l_04_o_gdcomac_eom_phifrz_l1; // DISABLE INTEG. OF ROLL ANGLE
unsigned char l_04_o_gdcomac_eom_thefrz_l1; // DISABLE INTEG. OF PITCH ANGLE
unsigned char l_04_o_gdcomac_eom_psifrz_l1; // DISABLE INTEG. OF YAW ANGLE
};
struct output_aero_S {
double l_04_o_aerocomac_fxb_f8;
double l_04_o_aerocomac_fyb_f8;
double l_04_o_aerocomac_fzb_f8;
double l_04_o_aerocomac_mxb_f8;
double l_04_o_aerocomac_myb_f8;
double l_04_o_aerocomac_mzb_f8;
double l_04_o_aerocomac_cls_f8;
double l_04_o_aerocomac_cl_f8;
double l_04_o_aerocomac_cd_f8;
double l_04_o_aerocomac_cm_f8;
double l_04_o_aerocomac_cr_f8;
double l_04_o_aerocomac_cy_f8;
double l_04_o_aerocomac_cn_f8;
};
struct input_aero_S {
// double l_04_i_aerocomac_uprt_swvtx_p_f8; // UPRT Simplified wake vortex rotational wind (Roll)
// double l_04_i_aerocomac_uprt_swvtx_q_f8; // UPRT Simplified wake vortex rotational wind (Pitch)
double l_04_i_aerocomac_alpha_f8;
double l_04_i_aerocomac_alpdot_f8;
double l_04_i_aerocomac_beta_f8;
double l_04_i_aerocomac_press_alt_f8;
double l_04_i_aerocomac_tas_f8;
double l_04_i_aerocomac_mach_f8;
double l_04_i_aerocomac_nx_f8;
double l_04_i_aerocomac_ny_f8;
double l_04_i_aerocomac_nz_f8;
double l_04_i_aerocomac_p_f8;
double l_04_i_aerocomac_q_f8;
double l_04_i_aerocomac_r_f8;
double l_04_i_aerocomac_qbar_f8;
double l_04_i_aerocomac_blcg_f8;
double l_04_i_aerocomac_bscg_f8;
double l_04_i_aerocomac_wlcg_f8;
double l_04_i_aerocomac_stab_f8;
// [0] : left aileron
// [1] : right aileron
double* l_04_i_aerocomac_ail_f8;
// [0] : left elevator
// [1] : right elevator
double* l_04_i_aerocomac_elv_f8;
// [0] : rudder
// [1] : not use
double* l_04_i_aerocomac_rud_f8; // Size = 2
// [0] : Nose Gear
// [1] : Left Main Gear
// [2] : Right Main Gear
double* l_04_i_aerocomac_gear_f8; // Index 1 : Nose Gear
// [0] : left wing flap
// [1] : right wing flap
double* l_04_i_aerocomac_flap_f8;
// [0] : left wing slat
// [1] : right wing slat
double* l_04_i_aerocomac_slat_f8;
// Spoiler 1 (deg +ve TED) // Index 1 to 8 : from left outboard spoiler to right outboard spoiler
// Spoiler 2 (deg +ve TED) // Index 1 to 8 : from left outboard spoiler to right outboard spoiler
// Spoiler 3 (deg +ve TED) // Index 1 to 8 : from left outboard spoiler to right outboard spoiler
// Spoiler 4 (deg +ve TED) // Index 1 to 8 : from left outboard spoiler to right outboard spoiler
// Spoiler 5 (deg +ve TED) // Index 1 to 8 : from left outboard spoiler to right outboard spoiler
// Spoiler 6 (deg +ve TED) // Index 1 to 8 : from left outboard spoiler to right outboard spoiler
// Spoiler 7 (deg +ve TED) // Index 1 to 8 : from left outboard spoiler to right outboard spoiler
// Spoiler 8 (deg +ve TED) // Index 1 to 8 : from left outboard spoiler to right outboard spoiler
double* l_04_i_aerocomac_spl_f8;
// [0] : engine #1
// [1] : engine #2
double* l_04_i_aerocomac_tnet_f8;
// [0]: outboard left wing
// [1]: inboard left wing
// [2]: root left wing
// [3]: root right wing
// [4]: inboard right wing
// [5]: outboard right wing
// [6]: fuselage icing
// [7]: left horizontal tail
// [8]: right horizontal tail
// [9]: vertical tail
// [10]: engine 1
// [11]: engine 2
double* l_04_i_aerocomac_kice_f8;
double l_04_i_aerocomac_alt_agl_f8;
};
void comacAeroModelPreProcess(ComacDataStructure_S* ComacDataStructure);
void comacAeroModelPostProcess(ComacDataStructure_S* ComacDataStructure);
void comacWeightModelPreProcess(ComacDataStructure_S* ComacDataStructure);
void comacWeightModelPostProcess(ComacDataStructure_S* ComacDataStructure);
void comacGroundModelPreProcess(ComacDataStructure_S* ComacDataStructure);
void comacGroundModelPostProcess(ComacDataStructure_S* ComacDataStructure);
ComacDataStructure_S* allocateComacDataStructure_S(double yitim_, int cnf_numgear_i4, int cnf_numtire_i4);
void init_input_weight_S(input_weight_S* ptr);
void init_output_weight_S(output_weight_S* ptr);
void init_input_ground_S(input_ground_S* ptr, int ngear, int ntiregear);
void init_output_ground_S(output_ground_S* ptr, int ngear, int ntiregear);
void init_input_aero_S(input_aero_S* ptr, int ngear);
void init_output_aero_S(output_aero_S* ptr);
#endif //CMCLIB_H