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
|
|
|
#include <vector>
|
2011-10-27 23:24:56 +02:00
|
|
|
#include <list>
|
2012-09-25 00:31:17 +01:00
|
|
|
#include <map>
|
2005-12-29 13:58:21 +00:00
|
|
|
|
2011-10-27 23:24:56 +02:00
|
|
|
class Block;
|
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"
|
2008-07-13 12:51:06 +00:00
|
|
|
#include <ATC/trafficcontrol.hxx>
|
2006-08-26 07:22:20 +00:00
|
|
|
|
2011-04-19 18:01:24 +02:00
|
|
|
|
2005-12-29 13:58:21 +00:00
|
|
|
class FGTaxiSegment; // forward reference
|
2006-08-26 07:22:20 +00:00
|
|
|
class FGAIFlightPlan; // forward reference
|
2006-11-11 10:52:05 +00:00
|
|
|
class FGAirport; // forward reference
|
2005-12-29 13:58:21 +00:00
|
|
|
|
2012-09-24 08:39:30 +01:00
|
|
|
typedef std::vector<FGTaxiSegment*> FGTaxiSegmentVector;
|
2012-09-25 00:31:17 +01:00
|
|
|
typedef FGTaxiSegmentVector::iterator FGTaxiSegmentVectorIterator;
|
2006-10-06 17:36:31 +00:00
|
|
|
|
2012-09-25 00:31:17 +01:00
|
|
|
typedef std::map<int, FGTaxiNode_ptr> IndexTaxiNodeMap;
|
2005-12-29 13:58:21 +00:00
|
|
|
|
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; };
|
|
|
|
};
|
|
|
|
|
2012-09-24 08:39:30 +01:00
|
|
|
typedef std::vector<Block> BlockList;
|
2011-10-27 23:24:56 +02:00
|
|
|
typedef BlockList::iterator BlockListIterator;
|
|
|
|
|
2005-12-29 13:58:21 +00:00
|
|
|
/***************************************************************************************
|
|
|
|
* class FGTaxiSegment
|
|
|
|
**************************************************************************************/
|
|
|
|
class FGTaxiSegment
|
|
|
|
{
|
|
|
|
private:
|
2011-10-03 20:54:58 +02:00
|
|
|
int startNode;
|
|
|
|
int endNode;
|
|
|
|
double length;
|
|
|
|
double heading;
|
|
|
|
bool isActive;
|
|
|
|
bool isPushBackRoute;
|
2011-10-27 23:24:56 +02:00
|
|
|
BlockList blockTimes;
|
2011-10-03 20:54:58 +02:00
|
|
|
FGTaxiNode *start;
|
|
|
|
FGTaxiNode *end;
|
|
|
|
int index;
|
|
|
|
FGTaxiSegment *oppositeDirection;
|
|
|
|
|
2005-12-29 13:58:21 +00:00
|
|
|
public:
|
2012-09-25 00:31:17 +01:00
|
|
|
FGTaxiSegment(int start, int end, bool isPushBack);
|
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
void setIndex (int val) {
|
|
|
|
index = val;
|
|
|
|
};
|
|
|
|
|
|
|
|
void setOpposite(FGTaxiSegment *opp) {
|
|
|
|
oppositeDirection = opp;
|
|
|
|
};
|
|
|
|
|
2012-09-25 00:31:17 +01:00
|
|
|
bool bindToNodes(const IndexTaxiNodeMap& nodes);
|
|
|
|
|
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
|
|
|
|
|
|
|
FGTaxiNode * getEnd() {
|
|
|
|
return end;
|
|
|
|
};
|
|
|
|
FGTaxiNode * getStart() {
|
|
|
|
return start;
|
|
|
|
};
|
|
|
|
double getLength() {
|
|
|
|
return length;
|
|
|
|
};
|
|
|
|
int getIndex() {
|
|
|
|
return index;
|
|
|
|
};
|
2012-09-25 00:31:17 +01:00
|
|
|
|
|
|
|
// compute the center of the arc
|
|
|
|
SGGeod getCenter() const;
|
|
|
|
|
2011-10-03 20:54:58 +02:00
|
|
|
double getHeading() {
|
|
|
|
return heading;
|
|
|
|
};
|
|
|
|
bool isPushBack() {
|
|
|
|
return isPushBackRoute;
|
|
|
|
};
|
|
|
|
|
|
|
|
int getPenalty(int nGates);
|
|
|
|
|
|
|
|
bool operator<(const FGTaxiSegment &other) const {
|
|
|
|
return index < other.index;
|
|
|
|
};
|
|
|
|
//bool hasSmallerHeadingDiff (const FGTaxiSegment &other) const { return headingDiff < other.headingDiff; };
|
|
|
|
FGTaxiSegment *opposite() {
|
|
|
|
return oppositeDirection;
|
|
|
|
};
|
2005-12-29 13:58:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-11-11 10:52:05 +00:00
|
|
|
|
|
|
|
|
2012-09-24 08:39:30 +01:00
|
|
|
typedef std::vector<int> intVec;
|
|
|
|
typedef std::vector<int>::iterator intVecIterator;
|
2005-12-29 13:58:21 +00:00
|
|
|
|
2006-11-11 10:52:05 +00:00
|
|
|
|
|
|
|
|
2006-07-29 18:17:19 +00:00
|
|
|
/***************************************************************************************
|
|
|
|
* class FGTaxiRoute
|
|
|
|
**************************************************************************************/
|
2005-12-29 13:58:21 +00:00
|
|
|
class FGTaxiRoute
|
|
|
|
{
|
|
|
|
private:
|
2011-10-03 20:54:58 +02:00
|
|
|
intVec nodes;
|
|
|
|
intVec routes;
|
|
|
|
double distance;
|
2010-01-02 20:00:06 +00:00
|
|
|
// int depth;
|
2011-10-03 20:54:58 +02:00
|
|
|
intVecIterator currNode;
|
|
|
|
intVecIterator currRoute;
|
2005-12-29 13:58:21 +00:00
|
|
|
|
|
|
|
public:
|
2011-10-03 20:54:58 +02:00
|
|
|
FGTaxiRoute() {
|
|
|
|
distance = 0;
|
|
|
|
currNode = nodes.begin();
|
|
|
|
currRoute = routes.begin();
|
|
|
|
};
|
|
|
|
FGTaxiRoute(intVec nds, intVec rts, double dist, int dpth) {
|
|
|
|
nodes = nds;
|
|
|
|
routes = rts;
|
|
|
|
distance = dist;
|
|
|
|
currNode = nodes.begin();
|
|
|
|
currRoute = routes.begin();
|
2010-01-02 20:00:06 +00:00
|
|
|
// depth = dpth;
|
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;
|
|
|
|
routes = other.routes;
|
|
|
|
distance = other.distance;
|
2010-01-02 20:00:06 +00:00
|
|
|
// depth = other.depth;
|
2011-10-03 20:54:58 +02:00
|
|
|
currNode = nodes.begin();
|
|
|
|
currRoute = routes.begin();
|
|
|
|
return *this;
|
|
|
|
};
|
|
|
|
|
|
|
|
FGTaxiRoute(const FGTaxiRoute& copy) :
|
|
|
|
nodes(copy.nodes),
|
|
|
|
routes(copy.routes),
|
|
|
|
distance(copy.distance),
|
2010-01-02 20:00:06 +00:00
|
|
|
// depth(copy.depth),
|
2011-10-03 20:54:58 +02:00
|
|
|
currNode(nodes.begin()),
|
|
|
|
currRoute(routes.begin())
|
|
|
|
{};
|
|
|
|
|
|
|
|
bool operator< (const FGTaxiRoute &other) const {
|
|
|
|
return distance < other.distance;
|
|
|
|
};
|
|
|
|
bool empty () {
|
|
|
|
return nodes.begin() == nodes.end();
|
|
|
|
};
|
|
|
|
bool next(int *nde);
|
|
|
|
bool next(int *nde, int *rte);
|
|
|
|
void rewind(int legNr);
|
|
|
|
|
|
|
|
void first() {
|
|
|
|
currNode = nodes.begin();
|
|
|
|
currRoute = routes.begin();
|
|
|
|
};
|
|
|
|
int size() {
|
|
|
|
return nodes.size();
|
|
|
|
};
|
|
|
|
int nodesLeft() {
|
|
|
|
return nodes.end() - currNode;
|
|
|
|
};
|
2011-08-07 21:38:50 +02:00
|
|
|
|
2010-01-02 20:00:06 +00:00
|
|
|
// int getDepth() { return depth; };
|
2005-12-29 13:58:21 +00:00
|
|
|
};
|
|
|
|
|
2012-09-24 08:39:30 +01:00
|
|
|
typedef std::vector<FGTaxiRoute> TaxiRouteVector;
|
|
|
|
typedef std::vector<FGTaxiRoute>::iterator TaxiRouteVectorIterator;
|
2005-12-29 13:58:21 +00:00
|
|
|
|
|
|
|
/**************************************************************************************
|
|
|
|
* class FGGroundNetWork
|
|
|
|
*************************************************************************************/
|
2006-08-26 07:22:20 +00:00
|
|
|
class FGGroundNetwork : public FGATCController
|
2005-12-29 13:58:21 +00:00
|
|
|
{
|
|
|
|
private:
|
2011-10-03 20:54:58 +02:00
|
|
|
bool hasNetwork;
|
|
|
|
bool networkInitialized;
|
|
|
|
time_t nextSave;
|
|
|
|
//int maxDepth;
|
|
|
|
int count;
|
2011-10-09 23:44:42 +02:00
|
|
|
int version;
|
2012-09-25 00:31:17 +01:00
|
|
|
|
|
|
|
IndexTaxiNodeMap nodes;
|
|
|
|
FGTaxiNodeVector pushBackNodes;
|
|
|
|
|
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
|
|
|
TaxiRouteVector routes;
|
|
|
|
TrafficVector activeTraffic;
|
|
|
|
TrafficVectorIterator currTraffic;
|
- 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
|
|
|
bool foundRoute;
|
|
|
|
double totalDistance, maxDistance;
|
|
|
|
FGTowerController *towerController;
|
|
|
|
FGAirport *parent;
|
2006-08-16 09:58:26 +00:00
|
|
|
|
- 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
|
|
|
|
2012-09-25 00:31:17 +01:00
|
|
|
void parseCache();
|
2005-12-29 13:58:21 +00:00
|
|
|
public:
|
2011-10-03 20:54:58 +02:00
|
|
|
FGGroundNetwork();
|
|
|
|
~FGGroundNetwork();
|
|
|
|
|
2012-09-25 00:31:17 +01:00
|
|
|
void addNode (FGTaxiNode* node);
|
2011-10-03 20:54:58 +02:00
|
|
|
void addNodes (FGParkingVec *parkings);
|
2012-09-25 00:31:17 +01:00
|
|
|
void addSegment(FGTaxiSegment* seg);
|
2011-10-09 23:44:42 +02:00
|
|
|
void setVersion (int v) { version = v;};
|
|
|
|
|
|
|
|
int getVersion() { return version; };
|
2011-10-03 20:54:58 +02:00
|
|
|
|
|
|
|
void init();
|
|
|
|
bool exists() {
|
|
|
|
return hasNetwork;
|
|
|
|
};
|
|
|
|
void setTowerController(FGTowerController *twrCtrlr) {
|
|
|
|
towerController = twrCtrlr;
|
|
|
|
};
|
|
|
|
|
|
|
|
int findNearestNode(const SGGeod& aGeod);
|
2011-10-09 23:44:42 +02:00
|
|
|
int findNearestNodeOnRunway(const SGGeod& aGeod);
|
2011-10-03 20:54:58 +02:00
|
|
|
|
|
|
|
FGTaxiNode *findNode(unsigned idx);
|
|
|
|
FGTaxiSegment *findSegment(unsigned idx);
|
|
|
|
FGTaxiRoute findShortestRoute(int start, int end, bool fullSearch=true);
|
|
|
|
//void trace(FGTaxiNode *, int, int, double dist);
|
|
|
|
|
|
|
|
int getNrOfNodes() {
|
|
|
|
return nodes.size();
|
|
|
|
};
|
|
|
|
|
|
|
|
void setParent(FGAirport *par) {
|
|
|
|
parent = par;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual void announcePosition(int id, FGAIFlightPlan *intendedRoute, int currentRoute,
|
|
|
|
double lat, double lon, double hdg, double spd, double alt,
|
|
|
|
double radius, int leg, FGAIAircraft *aircraft);
|
|
|
|
virtual void signOff(int id);
|
|
|
|
virtual void updateAircraftInformation(int id, double lat, double lon, double heading, double speed, double alt, double dt);
|
|
|
|
virtual bool hasInstruction(int id);
|
|
|
|
virtual FGATCInstruction getInstruction(int id);
|
|
|
|
|
|
|
|
bool checkTransmissionState(int minState, int MaxState, TrafficVectorIterator i, time_t now, AtcMsgId msgId,
|
|
|
|
AtcMsgDir msgDir);
|
|
|
|
bool checkForCircularWaits(int id);
|
|
|
|
virtual void render(bool);
|
2012-09-24 08:39:30 +01:00
|
|
|
virtual std::string getName();
|
2011-10-03 20:54:58 +02:00
|
|
|
virtual void update(double dt);
|
|
|
|
|
|
|
|
void saveElevationCache();
|
2011-10-09 23:44:42 +02:00
|
|
|
void addVersion(int v) {version = v; };
|
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
|