Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialisation of running engines confusing #101

Closed
seanmcleod opened this issue Jul 22, 2018 · 3 comments
Closed

Initialisation of running engines confusing #101

seanmcleod opened this issue Jul 22, 2018 · 3 comments
Labels

Comments

@seanmcleod
Copy link
Member

seanmcleod commented Jul 22, 2018

I have an aircraft with 2 engines and I wanted both engines to be started by the initialization file. Looking at FGInitialCondition.h I saw the following comment:

// - running (-1 for all engines, 0 for no engines, 1 ... n for specific engines)

So I added a running element to my initialization file.

<running> -1 </running>

However neither of the engines are started.

I then also noticed that the code in FGInitialCondition.cpp looks for multiple running elements, and based on the comment above - 1 … n for specific engines I tried the following based on the comment regarding 0 and 1.

<running> 1 </running>
<running> 2 </running>

However that only results in engine 1 being started and engine 0 isn't started. Engines are 0 based, from FGFDMExec.cpp

  for (unsigned int n=0; n < propulsion->GetNumEngines(); ++n) {
    if (IC->IsEngineRunning(n)) {
      try {
        propulsion->InitRunning(n);
      } catch (const string& str) {

So looking at the code in FGInitialCondition.cpp.

  // Check to see if any engines are specified to be initialized in a running state
  Element* running_elements = document->FindElement("running");
  while (running_elements) {
    enginesRunning |= 1 << int(running_elements->GetDataAsNumber());
    running_elements = document->FindNextElement("running");
  }

I then tried the following which now does start both engines (0 and 1).

<running> 0 </running>
<running> 1 </running>

So assuming that the engine indices to the running elements should be 0 based then the comment in FGInitialCondition.h needs to be updated.

// 0 for no engines, 1 ... n for specific engines)

And the code needs to be fixed to properly handle the -1 option.

I'm happy to make the fixes, but before I do I just wanted to double-check whether the engine indices in the running elements should be 0 or 1 based.

@bcoconni
Copy link
Member

It is very likely that I am the culprit of this (due to the commit 66ceba9 that does not handle the case where -1 is specified).

Not sure that the case 0 ever worked however. After all, if one does not want the engine started then he/she would not specify any <running> element ?

So yes please fix this and sorry about that.

@bcoconni bcoconni added the bug label Jul 22, 2018
@seanmcleod
Copy link
Member Author

Doesn't look like the code before your commit handled the -1 case either. I'll submit a pull request to fix the handling of the -1 option and update the comment that engine values go from 0 to n-1.

@bcoconni
Copy link
Member

I just pushed the PR #103.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants