Skip to content
Browse files

Added payload and fuel settings.

  • Loading branch information...
1 parent 100a148 commit 86dab386bad0517a7a50426dd0dde41652e2917d Ser Keong Lim committed Jan 31, 2012
Showing with 75 additions and 14 deletions.
  1. +19 −1 gui/MainWindow.cpp
  2. +42 −8 gui/MainWindow.ui
  3. +14 −5 src/initialization/FGTrimmer.cpp
View
20 gui/MainWindow.cpp
@@ -24,6 +24,8 @@
#include <cstdlib>
#include <fstream>
#include <models/FGAircraft.h>
+#include <models/FGMassBalance.h>
+#include <models/propulsion/FGTank.h>
#include <models/propulsion/FGEngine.h>
#include <models/propulsion/FGTurbine.h>
#include <models/propulsion/FGTurboProp.h>
@@ -90,6 +92,8 @@ void MainWindow::writeSettings()
settings->setValue("yawRate",lineEdit_yawRate->text());
settings->setValue("altitude",lineEdit_altitude->text());
settings->setValue("gamma",lineEdit_gamma->text());
+ settings->setValue("payload",lineEdit_payload->text());
+ settings->setValue("fuel",lineEdit_fuel->text());
settings->setValue("flapPos",lineEdit_flapPos->text());
settings->setValue("variablePropPitch",checkBox_variablePropPitch->checkState());
settings->setValue("stabAxisRoll",checkBox_stabAxisRoll->checkState());
@@ -171,6 +175,8 @@ void MainWindow::readSettings()
lineEdit_yawRate->setText(settings->value("yawRate",0).toString());
lineEdit_altitude->setText(settings->value("altitude",100).toString());
lineEdit_gamma->setText(settings->value("gamma",0).toString());
+ lineEdit_payload->setText(settings->value("payload",0).toString());
+ lineEdit_fuel->setText(settings->value("fuel",0).toString());
lineEdit_flapPos->setText(settings->value("flapPos",0).toString());
checkBox_variablePropPitch->setCheckState((Qt::CheckState)settings->value("variablePropPitch",Qt::Unchecked).toInt());
checkBox_stabAxisRoll->setCheckState((Qt::CheckState)settings->value("stabAxisRoll",Qt::Checked).toInt());
@@ -473,11 +479,23 @@ bool MainWindow::setupFdm() {
std::string aircraftName = fdm->GetAircraft()->GetAircraftName();
std::cout << "\tsuccessfully loaded: " << aircraftName << std::endl;
+ // Set fuel level
+ for (int i=0;i<fdm->GetPropulsion()->GetNumTanks();i++) {
+ fdm->GetPropulsion()->GetTank(i)->SetContents(
+ atof(lineEdit_fuel->text().toAscii())/100.0*
+ fdm->GetPropulsion()->GetTank(i)->GetCapacity());
+ }
+
// Turn on propulsion system
fdm->GetPropulsion()->InitRunning(-1);
fdm->GetFCS()->SetDfCmd(atof(lineEdit_flapPos->text().toAscii()));
- // get propulsion pointer to determine type/ etc.
+ // Set payload, assuming payload is a point mass at c.g. so can just
+ // increase the empty weight of the aircraft
+ fdm->GetMassBalance()->SetEmptyWeight(fdm->GetMassBalance()->GetEmptyWeight() +
+ atof(lineEdit_payload->text().toAscii()));
+
+ // get propulsion pointer to determine type/ etc.
FGEngine * engine0 = fdm->GetPropulsion()->GetEngine(0);
FGThruster * thruster0 = engine0->GetThruster();
View
50 gui/MainWindow.ui
@@ -111,7 +111,7 @@
</size>
</property>
<property name="currentIndex">
- <number>5</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
@@ -313,13 +313,6 @@
</property>
</widget>
</item>
- <item row="5" column="9">
- <widget class="QCheckBox" name="checkBox_variablePropPitch">
- <property name="text">
- <string>variable prop pitch</string>
- </property>
- </widget>
- </item>
<item row="1" column="9">
<widget class="QLabel" name="label_42">
<property name="sizePolicy">
@@ -541,7 +534,48 @@
</property>
</widget>
</item>
+ <item row="6" column="10">
+ <widget class="QLineEdit" name="lineEdit_fuel"/>
+ </item>
+ <item row="6" column="11">
+ <widget class="QLabel" name="label_51">
+ <property name="text">
+ <string>%</string>
+ </property>
+ </widget>
+ </item>
<item row="5" column="10">
+ <widget class="QLineEdit" name="lineEdit_payload"/>
+ </item>
+ <item row="5" column="9">
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>payload</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="9">
+ <widget class="QLabel" name="label_49">
+ <property name="text">
+ <string>fuel</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="11">
+ <widget class="QLabel" name="label_50">
+ <property name="text">
+ <string>lbs</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QCheckBox" name="checkBox_variablePropPitch">
+ <property name="text">
+ <string>variable prop pitch</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="4">
<widget class="QCheckBox" name="checkBox_stabAxisRoll">
<property name="text">
<string>stability axis roll</string>
View
19 src/initialization/FGTrimmer.cpp
@@ -22,6 +22,8 @@
#include "models/FGAccelerations.h"
#include "models/propulsion/FGEngine.h"
#include "models/propulsion/FGThruster.h"
+#include "models/propulsion/FGTank.h"
+#include "models/FGMassBalance.h"
#include "models/FGAuxiliary.h"
#include "models/FGAircraft.h"
#include <iomanip>
@@ -244,8 +246,8 @@ void FGTrimmer::printSolution(std::ostream & stream, const std::vector<double> &
<< "\n\nd/dt actuator state"
<< "\n\td/dt throttle, %/s\t:\t" << dthrottle
<< "\n\td/dt elevator, %/s\t:\t" << delevator
- << "\n\td/dt aileron, %/s\t\t:\t" << daileron
- << "\n\td/dt rudder, %/s\t\t:\t" << drudder
+ << "\n\td/dt aileron, %/s\t:\t" << daileron
+ << "\n\td/dt rudder, %/s\t:\t" << drudder
// nav state
<< "\n\nd/dt nav state"
@@ -255,11 +257,18 @@ void FGTrimmer::printSolution(std::ostream & stream, const std::vector<double> &
<< "\n\td/dt lon, deg/s\t\t:\t" << dlon
<< std::fixed
- << "\n\npropulsion system"
+ << "\n\npropulsion system state"
<< std::scientific << std::setw(10)
- << "\n\tfuel flow rate (lbm/s)\t:\t" << m_fdm->GetPropulsion()->GetEngine(0)->GetFuelFlowRate()
+ << "\n\ttotal mass (lbm)\t:\t" << m_fdm->GetMassBalance()->GetWeight()
+ << std::endl;
- << "\n" << std::endl;
+ for (int i=0;i<m_fdm->GetPropulsion()->GetNumTanks();i++) {
+ std::cout << "\n\ttank " << i << ":\n\tfuel (lbm)\t\t:\t"
+ << m_fdm->GetPropulsion()->GetTank(i)->GetContents()
+ << "\n\tfuel flow rate (lbm/s)\t:\t"
+ << m_fdm->GetPropulsion()->GetEngine(i)->GetFuelFlowRate()
+ << std::endl;
+ }
}
void FGTrimmer::printState(std::ostream & stream)

0 comments on commit 86dab38

Please sign in to comment.
Something went wrong with that request. Please try again.