2005-12-29 13:58:21 +00:00
|
|
|
// groundnet.hxx - A number of classes to handle taxiway
|
|
|
|
// assignments by the AI code
|
|
|
|
//
|
|
|
|
// Written by Durk Talsma, started June 2005.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2004 Durk Talsma.
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2006-02-21 01:16:04 +00:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2005-12-29 13:58:21 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
#ifndef _GROUNDNETWORK_HXX_
|
|
|
|
#define _GROUNDNETWORK_HXX_
|
|
|
|
|
2006-04-17 12:59:35 +00:00
|
|
|
#include <simgear/compiler.h>
|
|
|
|
|
2008-07-25 18:38:29 +00:00
|
|
|
#include <string>
|
2005-12-29 13:58:21 +00:00
|
|
|
|
2007-07-05 19:00:59 +00:00
|
|
|
#include "gnnode.hxx"
|
2005-12-29 13:58:21 +00:00
|
|
|
#include "parking.hxx"
|
2006-08-26 07:22:20 +00:00
|
|
|
|
2015-12-01 00:01:27 +00:00
|
|
|
class FGAirportDynamicsXMLLoader;
|
|
|
|
|
2015-12-09 14:01:24 +01:00
|
|
|
typedef std::vector<int> intVec;
|
|
|
|
typedef std::vector<int>::iterator intVecIterator;
|
|
|
|
|
2011-10-27 23:24:56 +02:00
|
|
|
class Block
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
int id;
|
|
|
|
time_t blocktime;
|
|
|
|
time_t touch;
|
|
|
|
public:
|
|
|
|
Block(int i, time_t bt, time_t curr) { id = i; blocktime= bt; touch = curr; };
|
|
|
|
~Block() {};
|
|
|
|
int getId() { return id; };
|
|
|
|
void updateTimeStamps(time_t bt, time_t now) { blocktime = (bt < blocktime) ? bt : blocktime; touch = now; };
|
|
|
|
const time_t getBlockTime() const { return blocktime; };
|
|
|
|
time_t getTimeStamp() { return touch; };
|
|
|
|
bool operator< (const Block &other) const { return blocktime < other.blocktime; };
|
|
|
|
};
|
|
|
|
|
2005-12-29 13:58:21 +00:00
|
|
|
/***************************************************************************************
|
|
|
|
* class FGTaxiSegment
|
|
|
|
**************************************************************************************/
|
|
|
|
class FGTaxiSegment
|
|
|
|
{
|
|
|
|
private:
|
2015-12-01 00:01:27 +00:00
|
|
|
// weak (non-owning) pointers deliberately here:
|
|
|
|
// the ground-network owns the nodes
|
|
|
|
const FGTaxiNode* startNode;
|
|
|
|
const FGTaxiNode* endNode;
|
2012-10-01 17:18:36 +01:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
bool isActive;
|
2011-10-27 23:24:56 +02:00
|
|
|
BlockList blockTimes;
|
2012-10-01 17:18:36 +01:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
int index;
|
2015-12-01 00:01:27 +00:00
|
|
|
FGTaxiSegment *oppositeDirection; // also deliberatley weak
|
2011-10-03 20:54:58 +02:00
|
|
|
|
2012-10-01 17:18:36 +01:00
|
|
|
friend class FGGroundNetwork;
|
2005-12-29 13:58:21 +00:00
|
|
|
public:
|
2015-12-01 00:01:27 +00:00
|
|
|
FGTaxiSegment(FGTaxiNode* start, FGTaxiNode* end);
|
2012-09-25 00:31:17 +01:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
void setIndex (int val) {
|
|
|
|
index = val;
|
|
|
|
};
|
2012-09-25 00:31:17 +01:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
void setDimensions(double elevation);
|
2011-10-27 23:24:56 +02:00
|
|
|
void block(int id, time_t blockTime, time_t now);
|
|
|
|
void unblock(time_t now);
|
|
|
|
bool hasBlock(time_t now);
|
2011-10-03 20:54:58 +02:00
|
|
|
|
2013-03-06 23:21:29 +01:00
|
|
|
FGTaxiNodeRef getEnd() const;
|
|
|
|
FGTaxiNodeRef getStart() const;
|
2012-10-01 17:18:36 +01:00
|
|
|
|
|
|
|
double getLength() const;
|
2012-09-25 00:31:17 +01:00
|
|
|
|
|
|
|
// compute the center of the arc
|
|
|
|
SGGeod getCenter() const;
|
|
|
|
|
2012-10-01 17:18:36 +01:00
|
|
|
double getHeading() const;
|
|
|
|
|
|
|
|
int getIndex() {
|
|
|
|
return index;
|
2011-10-03 20:54:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
int getPenalty(int nGates);
|
|
|
|
|
|
|
|
bool operator<(const FGTaxiSegment &other) const {
|
|
|
|
return index < other.index;
|
|
|
|
};
|
2012-10-01 17:18:36 +01:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
FGTaxiSegment *opposite() {
|
|
|
|
return oppositeDirection;
|
|
|
|
};
|
2005-12-29 13:58:21 +00:00
|
|
|
};
|
|
|
|
|
2006-07-29 18:17:19 +00:00
|
|
|
/***************************************************************************************
|
|
|
|
* class FGTaxiRoute
|
|
|
|
**************************************************************************************/
|
2005-12-29 13:58:21 +00:00
|
|
|
class FGTaxiRoute
|
|
|
|
{
|
|
|
|
private:
|
2015-12-01 00:01:27 +00:00
|
|
|
FGTaxiNodeVector nodes;
|
2015-05-15 13:30:16 +02:00
|
|
|
intVec routes;
|
2011-10-03 20:54:58 +02:00
|
|
|
double distance;
|
2015-12-01 00:01:27 +00:00
|
|
|
FGTaxiNodeVector::iterator currNode;
|
2015-05-15 13:30:16 +02:00
|
|
|
intVec::iterator currRoute;
|
2005-12-29 13:58:21 +00:00
|
|
|
|
|
|
|
public:
|
2011-10-03 20:54:58 +02:00
|
|
|
FGTaxiRoute() {
|
|
|
|
distance = 0;
|
|
|
|
currNode = nodes.begin();
|
2015-05-15 13:30:16 +02:00
|
|
|
currRoute = routes.begin();
|
2011-10-03 20:54:58 +02:00
|
|
|
};
|
2012-10-01 17:18:36 +01:00
|
|
|
|
2015-12-01 00:01:27 +00:00
|
|
|
FGTaxiRoute(const FGTaxiNodeVector& nds, intVec rts, double dist, int dpth) {
|
2011-10-03 20:54:58 +02:00
|
|
|
nodes = nds;
|
2015-05-15 13:30:16 +02:00
|
|
|
routes = rts;
|
2011-10-03 20:54:58 +02:00
|
|
|
distance = dist;
|
|
|
|
currNode = nodes.begin();
|
2015-05-15 13:30:16 +02:00
|
|
|
currRoute = routes.begin();
|
2011-10-03 20:54:58 +02:00
|
|
|
};
|
2007-07-15 14:08:31 +00:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
FGTaxiRoute& operator= (const FGTaxiRoute &other) {
|
|
|
|
nodes = other.nodes;
|
2015-05-15 13:30:16 +02:00
|
|
|
routes = other.routes;
|
2011-10-03 20:54:58 +02:00
|
|
|
distance = other.distance;
|
|
|
|
currNode = nodes.begin();
|
2015-05-15 13:30:16 +02:00
|
|
|
currRoute = routes.begin();
|
2011-10-03 20:54:58 +02:00
|
|
|
return *this;
|
|
|
|
};
|
|
|
|
|
|
|
|
FGTaxiRoute(const FGTaxiRoute& copy) :
|
|
|
|
nodes(copy.nodes),
|
2015-05-15 13:30:16 +02:00
|
|
|
routes(copy.routes),
|
2011-10-03 20:54:58 +02:00
|
|
|
distance(copy.distance),
|
2015-05-15 13:30:16 +02:00
|
|
|
currNode(nodes.begin()),
|
|
|
|
currRoute(routes.begin())
|
2011-10-03 20:54:58 +02:00
|
|
|
{};
|
|
|
|
|
|
|
|
bool operator< (const FGTaxiRoute &other) const {
|
|
|
|
return distance < other.distance;
|
|
|
|
};
|
|
|
|
bool empty () {
|
2012-10-01 17:18:36 +01:00
|
|
|
return nodes.empty();
|
2011-10-03 20:54:58 +02:00
|
|
|
};
|
2015-12-01 00:01:27 +00:00
|
|
|
bool next(FGTaxiNodeRef& nde, int *rte);
|
2012-10-01 17:18:36 +01:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
void first() {
|
|
|
|
currNode = nodes.begin();
|
2015-05-15 13:30:16 +02:00
|
|
|
currRoute = routes.begin();
|
2011-10-03 20:54:58 +02:00
|
|
|
};
|
|
|
|
int size() {
|
|
|
|
return nodes.size();
|
|
|
|
};
|
|
|
|
int nodesLeft() {
|
|
|
|
return nodes.end() - currNode;
|
|
|
|
};
|
2005-12-29 13:58:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************************
|
|
|
|
* class FGGroundNetWork
|
|
|
|
*************************************************************************************/
|
2015-12-09 14:01:24 +01:00
|
|
|
class FGGroundNetwork
|
2005-12-29 13:58:21 +00:00
|
|
|
{
|
|
|
|
private:
|
2016-01-10 16:38:01 -06:00
|
|
|
friend class FGGroundNetXMLLoader;
|
2015-12-01 00:01:27 +00:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
bool hasNetwork;
|
|
|
|
bool networkInitialized;
|
2015-12-09 14:01:24 +01:00
|
|
|
|
2011-10-09 23:44:42 +02:00
|
|
|
int version;
|
2012-09-25 00:31:17 +01:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
FGTaxiSegmentVector segments;
|
2012-09-25 00:31:17 +01:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
FGAirport *parent;
|
2006-08-16 09:58:26 +00:00
|
|
|
|
2015-12-01 00:01:27 +00:00
|
|
|
FGParkingList m_parkings;
|
|
|
|
FGTaxiNodeVector m_nodes;
|
|
|
|
|
|
|
|
FGTaxiNodeRef findNodeByIndex(int index) const;
|
- Ground network XML parsing code reads the new attributes "holdPointType"
and "isOnRunway".
- Added initial support for AI controlled pushback operations, making use of the
current editing capabilities of TaxiDraw CVS / New_GUI_CODE. The current
implementation is slightly more computationally intensive than strictly
required, due to the currently inability of taxidraw to link one specific
pushBack point to to a particular startup location. FlightGear now determines
this dynamically, and once we have that functionality in TaxiDraw, the
initialization part of createPushBack() can be further simplified.
- Smoother transition from pushback to taxi. No more skipping of waypoints, and
aircraft wait for two minutes at pushback point.
- The classes FGTaxiNode, FGTaxiSegment, and FGParking, now have copy
constructors, and assignment operators.
- Removed declaration of undefined constructor FGTaxiNode(double, double, int)
- Array boundry checks and cleanup.
- Modified Dijkstra path search algoritm to solve partial problems. Currently
limited to include pushback points and routes only, but can probably be
extended to a more general approach.
- Added initial support for giving certain routes in the network a penalty, in
order to discourage the use of certain routes over others.
2007-08-08 06:09:58 +00:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
//void printRoutingError(string);
|
2006-09-19 17:04:22 +00:00
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
void checkSpeedAdjustment(int id, double lat, double lon,
|
|
|
|
double heading, double speed, double alt);
|
|
|
|
void checkHoldPosition(int id, double lat, double lon,
|
|
|
|
double heading, double speed, double alt);
|
- Ground network XML parsing code reads the new attributes "holdPointType"
and "isOnRunway".
- Added initial support for AI controlled pushback operations, making use of the
current editing capabilities of TaxiDraw CVS / New_GUI_CODE. The current
implementation is slightly more computationally intensive than strictly
required, due to the currently inability of taxidraw to link one specific
pushBack point to to a particular startup location. FlightGear now determines
this dynamically, and once we have that functionality in TaxiDraw, the
initialization part of createPushBack() can be further simplified.
- Smoother transition from pushback to taxi. No more skipping of waypoints, and
aircraft wait for two minutes at pushback point.
- The classes FGTaxiNode, FGTaxiSegment, and FGParking, now have copy
constructors, and assignment operators.
- Removed declaration of undefined constructor FGTaxiNode(double, double, int)
- Array boundry checks and cleanup.
- Modified Dijkstra path search algoritm to solve partial problems. Currently
limited to include pushback points and routes only, but can probably be
extended to a more general approach.
- Added initial support for giving certain routes in the network a penalty, in
order to discourage the use of certain routes over others.
2007-08-08 06:09:58 +00:00
|
|
|
|
2011-04-26 19:18:28 +02:00
|
|
|
|
2015-12-01 00:01:27 +00:00
|
|
|
void addSegment(const FGTaxiNodeRef& from, const FGTaxiNodeRef& to);
|
|
|
|
void addParking(const FGParkingRef& park);
|
|
|
|
|
|
|
|
FGTaxiNodeVector segmentsFrom(const FGTaxiNodeRef& from) const;
|
|
|
|
|
2016-01-10 16:38:01 -06:00
|
|
|
void addAwosFreq (int val) {
|
|
|
|
freqAwos.push_back(val);
|
|
|
|
};
|
|
|
|
void addUnicomFreq (int val) {
|
|
|
|
freqUnicom.push_back(val);
|
|
|
|
};
|
|
|
|
void addClearanceFreq(int val) {
|
|
|
|
freqClearance.push_back(val);
|
|
|
|
};
|
|
|
|
void addGroundFreq (int val) {
|
|
|
|
freqGround.push_back(val);
|
|
|
|
};
|
|
|
|
void addTowerFreq (int val) {
|
|
|
|
freqTower.push_back(val);
|
|
|
|
};
|
|
|
|
void addApproachFreq (int val) {
|
|
|
|
freqApproach.push_back(val);
|
|
|
|
};
|
|
|
|
|
|
|
|
intVec freqAwos; // </AWOS>
|
|
|
|
intVec freqUnicom; // </UNICOM>
|
|
|
|
intVec freqClearance;// </CLEARANCE>
|
|
|
|
intVec freqGround; // </GROUND>
|
|
|
|
intVec freqTower; // </TOWER>
|
|
|
|
intVec freqApproach; // </APPROACH>
|
2005-12-29 13:58:21 +00:00
|
|
|
public:
|
2016-01-10 16:38:01 -06:00
|
|
|
FGGroundNetwork(FGAirport* pr);
|
2011-10-03 20:54:58 +02:00
|
|
|
~FGGroundNetwork();
|
2011-10-09 23:44:42 +02:00
|
|
|
|
2012-10-01 17:18:36 +01:00
|
|
|
void setVersion (int v) { version = v;};
|
2011-10-09 23:44:42 +02:00
|
|
|
int getVersion() { return version; };
|
2011-10-03 20:54:58 +02:00
|
|
|
|
2016-01-10 16:38:01 -06:00
|
|
|
void init();
|
2011-10-03 20:54:58 +02:00
|
|
|
bool exists() {
|
|
|
|
return hasNetwork;
|
|
|
|
};
|
|
|
|
|
2016-01-10 16:38:01 -06:00
|
|
|
FGAirport* airport() const
|
|
|
|
{ return parent; }
|
|
|
|
|
2015-12-01 00:01:27 +00:00
|
|
|
FGTaxiNodeRef findNearestNode(const SGGeod& aGeod) const;
|
|
|
|
FGTaxiNodeRef findNearestNodeOnRunway(const SGGeod& aGeod, FGRunway* aRunway = NULL) const;
|
|
|
|
|
|
|
|
FGTaxiSegment *findSegment(unsigned int idx) const;
|
|
|
|
|
2015-12-09 14:01:24 +01:00
|
|
|
FGTaxiSegment* findOppositeSegment(unsigned int index) const;
|
|
|
|
|
2015-12-01 00:01:27 +00:00
|
|
|
const FGParkingList& allParkings() const;
|
2011-10-03 20:54:58 +02:00
|
|
|
|
2016-07-16 18:23:48 +01:00
|
|
|
FGParkingRef getParkingByIndex(unsigned int index) const;
|
|
|
|
|
2012-10-01 17:18:36 +01:00
|
|
|
/**
|
|
|
|
* Find the taxiway segment joining two (ground-net) nodes. Returns
|
|
|
|
* NULL if no such segment exists.
|
2015-12-01 00:01:27 +00:00
|
|
|
* It is permitted to pass HULL for the 'to' indicating that any
|
2012-10-01 17:18:36 +01:00
|
|
|
* segment originating at 'from' is acceptable.
|
|
|
|
*/
|
2015-12-01 00:01:27 +00:00
|
|
|
FGTaxiSegment *findSegment(const FGTaxiNode* from, const FGTaxiNode* to) const;
|
2012-10-01 17:18:36 +01:00
|
|
|
|
2015-12-01 00:01:27 +00:00
|
|
|
FGTaxiRoute findShortestRoute(FGTaxiNode* start, FGTaxiNode* end, bool fullSearch=true);
|
2011-10-03 20:54:58 +02:00
|
|
|
|
2015-12-09 14:01:24 +01:00
|
|
|
|
|
|
|
void blockSegmentsEndingAt(FGTaxiSegment* seg, int blockId,
|
|
|
|
time_t blockTime, time_t now);
|
2011-10-03 20:54:58 +02:00
|
|
|
|
2011-10-09 23:44:42 +02:00
|
|
|
void addVersion(int v) {version = v; };
|
2015-12-09 14:01:24 +01:00
|
|
|
void unblockAllSegments(time_t now);
|
2016-01-10 16:38:01 -06:00
|
|
|
|
|
|
|
const intVec& getTowerFrequencies() const;
|
|
|
|
const intVec& getGroundFrequencies() const;
|
|
|
|
|
2005-12-29 13:58:21 +00:00
|
|
|
};
|
|
|
|
|
2006-08-26 07:22:20 +00:00
|
|
|
|
2005-12-29 13:58:21 +00:00
|
|
|
#endif
|