From a2ba0da5d106761b64b1d8a425b9a751c9ff7f02 Mon Sep 17 00:00:00 2001
From: James Goppert <jgoppert@w7.hsl.dynalias.com>
Date: Sat, 12 Mar 2011 03:20:26 -0500
Subject: [PATCH] Added RPM for each motor.

---
 src/FGComm.cpp          |  8 +++++--
 src/Trim.cpp            |  6 ++++-
 src/math/FGStateSpace.h | 51 ++++++++++++++++++++++++++++++++++++-----
 3 files changed, 56 insertions(+), 9 deletions(-)

diff --git a/src/FGComm.cpp b/src/FGComm.cpp
index cc15378..142d5f8 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 733987f..8326f11 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 2a5308e..aeadac0 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);
         }
     };
 
-- 
GitLab