Skip to content

Commit

Permalink
Added logic to remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
tmldeponti committed Apr 16, 2024
1 parent 387be50 commit db4080b
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions sw/simulator/nps/nps_fdm_jsbsim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@
#define JSBSIM_PATH(_x) _x
#endif

/* Actuator naming*/
#ifdef NPS_USE_COMMANDS
#define NPS_AUTOMATIC_JSBSIM_ACTUATOR_NAMES TRUE
#endif

#ifdef NPS_ACTUATOR_NAMES
#define NPS_AUTOMATIC_JSBSIM_ACTUATOR_NAMES TRUE
#endif

#ifndef NPS_AUTOMATIC_JSBSIM_ACTUATOR_NAMES
#define NPS_AUTOMATIC_JSBSIM_ACTUATOR_NAMES FALSE
#endif

/** Name of the JSBSim model.
* Defaults to the AIRFRAME_NAME
*/
Expand Down Expand Up @@ -304,23 +317,14 @@ void nps_fdm_set_temperature(double temp, double h)
*/
static void feed_jsbsim(double *commands, int commands_nb __attribute__((unused)))
{
#ifdef NPS_ACTUATOR_NAMES
#if NPS_AUTOMATIC_JSBSIM_ACTUATOR_NAMES
char buf[64];
#if defined(NPS_USE_COMMANDS)
const char *names[] = COMMAND_NAMES;
#elif defined(NPS_ACTUATOR_NAMES)
const char *names[] = NPS_ACTUATOR_NAMES;
#endif
string property;

int i;
for (i = 0; i < commands_nb; i++) {
sprintf(buf, "fcs/%s", names[i]);
property = string(buf);
FDMExec->GetPropertyManager()->GetNode(property)->SetDouble("", commands[i]);
}
#else /* use COMMAND names */
#ifdef NPS_USE_COMMANDS /*Use generated command names*/
char buf[64];
const char *names[] = COMMAND_NAMES;
string property;

int i;
for (i = 0; i < commands_nb; i++) {
sprintf(buf, "fcs/%s", names[i]);
Expand Down Expand Up @@ -366,8 +370,7 @@ static void feed_jsbsim(double *commands, int commands_nb __attribute__((unused)
FCS->SetDfCmd(commands[COMMAND_FLAP]);
#endif /* COMMAND_FLAP */

#endif /* NPS_USE_COMMANDS */
#endif /* NPS_ACTUATOR_NAMES */
#endif /* NPS_AUTOMATIC_JSBSIM_ACTUATOR_NAMES */
}

/**
Expand Down

0 comments on commit db4080b

Please sign in to comment.