Implementing VNAV support in FlightGear: Difference between revisions

Jump to navigation Jump to search
m
Line 178: Line 178:
* waypoint_distance
* waypoint_distance


The '''FGWaypoint''' class would need to be extended to help with the calculation of other types of waypoints.
The '''FGWaypoint''' class would need to be extended to help with the calculation of other types of waypoints. To add a stub for a new waypoint named '''waypoint_custom''', these would be the required changes:
 
<syntaxhighlight lang="diff">
diff --git a/src/models/FGFCS.cpp b/src/models/FGFCS.cpp
index 5457632..fc921cb 100644
--- a/src/models/FGFCS.cpp
+++ b/src/models/FGFCS.cpp
@@ -636,7 +636,8 @@ bool FGFCS::Load(Element* el, SystemType systype)
        } else if (component_element->GetName() == string("gyro")) {
          newChannel->Add(new FGGyro(this, component_element));
        } else if ((component_element->GetName() == string("waypoint_heading")) ||
-                  (component_element->GetName() == string("waypoint_distance")))
+                  (component_element->GetName() == string("waypoint_distance")) ||
+       (component_element->GetName() == string("waypoint_custom")) )
        {
          newChannel->Add(new FGWaypoint(this, component_element));
        } else if (component_element->GetName() == string("angle")) {
diff --git a/src/models/flight_control/FGFCSComponent.cpp b/src/models/flight_control/FGFCSComponent.cpp
index 630f5cb..29ebbdc 100644
--- a/src/models/flight_control/FGFCSComponent.cpp
+++ b/src/models/flight_control/FGFCSComponent.cpp
@@ -110,6 +110,8 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs)
    Type = "WAYPOINT_HEADING";
  } else if (element->GetName() == string("waypoint_distance")) {
    Type = "WAYPOINT_DISTANCE";
+  } else if (element->GetName() == string("waypoint_custom")) {
+    Type = "WAYPOINT_CUSTOM";
  } else if (element->GetName() == string("angle")) {
    Type = "ANGLE";
  } else if (element->GetName() == string("distributor")) {
diff --git a/src/models/flight_control/FGWaypoint.cpp b/src/models/flight_control/FGWaypoint.cpp
index 0df8d07..4c5b707 100644
--- a/src/models/flight_control/FGWaypoint.cpp
+++ b/src/models/flight_control/FGWaypoint.cpp
@@ -58,6 +58,9 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
{
  if      (Type == "WAYPOINT_HEADING")  WaypointType = eHeading;
  else if (Type == "WAYPOINT_DISTANCE") WaypointType = eDistance;
+  else if (Type == "WAYPOINT_CUSTOM") WaypointType = eCustom;
+
+
  target_latitude_unit = 1.0;
  target_longitude_unit = 1.0;
@@ -123,7 +126,7 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
  } else {
      eUnit = eRad; // Default is radians if unspecified
    }
-  } else {
+  } else if (WaypointType == eDistance) {
    if (!unit.empty()) {
    if      (unit == "FT") eUnit = eFeet;
    else if (unit == "M")  eUnit = eMeters;
@@ -131,7 +134,10 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, eleme
    } else {
      eUnit = eFeet; // Default is feet if unspecified
    }
-  }
+  }
+    else if (WaypointType ==eCustom) {
+    }
+
  FGFCSComponent::bind();
  Debug(0);
diff --git a/src/models/flight_control/FGWaypoint.h b/src/models/flight_control/FGWaypoint.h
index 4444671..0aac0db 100644
--- a/src/models/flight_control/FGWaypoint.h
+++ b/src/models/flight_control/FGWaypoint.h
@@ -123,7 +123,7 @@ private:
  double radius;
  std::string unit;
  enum {eNone=0, eDeg, eRad, eFeet, eMeters} eUnit;
-  enum {eNoType=0, eHeading, eDistance} WaypointType;
+  enum {eNoType=0, eHeading, eDistance, eCustom} WaypointType;
  void Debug(int from);
};
 
</syntaxhighlight>


=== Adding new Control System Components ===
=== Adding new Control System Components ===

Navigation menu