diff --git a/src/FGComm.cpp b/src/FGComm.cpp index cc1537895863b0a69440d3ee3a8c510a1d1c0438..142d5f87c3b966b6abc0bc4a65e21ce16b2ea131 100644 --- a/src/FGComm.cpp +++ b/src/FGComm.cpp @@ -42,10 +42,14 @@ int main (int argc, char const* argv[]) ss.x.add(new FGStateSpace::Theta); ss.x.add(new FGStateSpace::Q); - if (thruster0->GetType()==FGThruster::ttPropeller) + if (thruster0->GetType()==FGThruster::ttPropeller) { - ss.x.add(new FGStateSpace::Rpm); + ss.x.add(new FGStateSpace::Rpm0); if (variablePropPitch) ss.x.add(new FGStateSpace::PropPitch); + int numEngines = fdm.GetPropulsion()->GetNumEngines(); + if (numEngines>1) ss.x.add(new FGStateSpace::Rpm1); + if (numEngines>2) ss.x.add(new FGStateSpace::Rpm2); + if (numEngines>3) ss.x.add(new FGStateSpace::Rpm3); } ss.x.add(new FGStateSpace::Beta); ss.x.add(new FGStateSpace::Phi); diff --git a/src/Trim.cpp b/src/Trim.cpp index 733987ff6956069cf043d3389e6854da5536b736..8326f119f6da9a0a99a3509b19c7558522c40466 100644 --- a/src/Trim.cpp +++ b/src/Trim.cpp @@ -237,8 +237,12 @@ int main (int argc, char const* argv[]) if (thruster0->GetType()==FGThruster::ttPropeller) { - ss.x.add(new FGStateSpace::Rpm); + ss.x.add(new FGStateSpace::Rpm0); if (variablePropPitch) ss.x.add(new FGStateSpace::PropPitch); + int numEngines = fdm.GetPropulsion()->GetNumEngines(); + if (numEngines>1) ss.x.add(new FGStateSpace::Rpm1); + if (numEngines>2) ss.x.add(new FGStateSpace::Rpm2); + if (numEngines>3) ss.x.add(new FGStateSpace::Rpm3); } ss.x.add(new FGStateSpace::Beta); ss.x.add(new FGStateSpace::Phi); diff --git a/src/math/FGStateSpace.h b/src/math/FGStateSpace.h index 2a5308e20862f808835332bd8edcf4e3c2502f98..aeadac0e46a6f1b2310fb5caf45d5a6e69c29d4d 100644 --- a/src/math/FGStateSpace.h +++ b/src/math/FGStateSpace.h @@ -595,20 +595,59 @@ public: } }; - class Rpm : public Component + class Rpm0 : public Component { public: - Rpm() : Component("Rpm","rev/min") {}; + Rpm0() : Component("Rpm0","rev/min") {}; double get() const { return m_fdm->GetPropulsion()->GetEngine(0)->GetThruster()->GetRPM(); } void set(double val) { - for (int i=0;i<m_fdm->GetPropulsion()->GetNumEngines();i++) - { - m_fdm->GetPropulsion()->GetEngine(i)->GetThruster()->SetRPM(val); - } + m_fdm->GetPropulsion()->GetEngine(0)->GetThruster()->SetRPM(val); + } + }; + + class Rpm1 : public Component + { + public: + Rpm1() : Component("Rpm1","rev/min") {}; + double get() const + { + return m_fdm->GetPropulsion()->GetEngine(1)->GetThruster()->GetRPM(); + } + void set(double val) + { + m_fdm->GetPropulsion()->GetEngine(1)->GetThruster()->SetRPM(val); + } + }; + + class Rpm2 : public Component + { + public: + Rpm2() : Component("Rpmr2","rev/min") {}; + double get() const + { + return m_fdm->GetPropulsion()->GetEngine(2)->GetThruster()->GetRPM(); + } + void set(double val) + { + m_fdm->GetPropulsion()->GetEngine(2)->GetThruster()->SetRPM(val); + } + }; + + class Rpm3 : public Component + { + public: + Rpm3() : Component("Rpm3","rev/min") {}; + double get() const + { + return m_fdm->GetPropulsion()->GetEngine(3)->GetThruster()->GetRPM(); + } + void set(double val) + { + m_fdm->GetPropulsion()->GetEngine(3)->GetThruster()->SetRPM(val); } };