Skyscraper 2.0
controller.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Dispatch Controller Object
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#ifndef _SBS_CONTROLLER_H
25#define _SBS_CONTROLLER_H
26
27namespace SBS {
28
30{
31public:
32
33 int Number;
34 std::string Name; //controller name
35 bool DestinationDispatch; //enable or disable Destination Dispatch
36 bool Hybrid; //if true, allow both standard and destination dispatch modes
37 int Range; //elevator selection range
38 int MaxPassengers; //maximum passengers per route
39 bool Reprocess; //if true, reprocess routes instead of dropping them when an elevator becomes unavailable
40
41 //functions
42 DispatchController(Object *parent, int number);
44 void Loop();
45 bool RequestRoute(CallStation *station, int starting_floor, int destination_floor);
46 bool AddElevator(int elevator);
47 bool RemoveElevator(int elevator);
48 bool ServicesElevator(int elevator);
49 void Report(const std::string &message);
50 bool ReportError(const std::string &message);
51 void ElevatorArrived(int number, int floor, bool direction);
52 void ResetArrival(int number);
53 bool IsElevatorAssigned(int number, int destination_floor, int direction);
54 bool IsElevatorAssignedToOther(int number, int destination_floor, int direction);
55 void AssignElevator(int number, int destination_floor, int direction);
56 void RegisterCallStation(CallStation *station);
57 void UnregisterCallStation(CallStation *station);
58 int GetElevatorArrived(int starting_floor, int destination_floor);
59 int GetElevatorArrivedStandard(int floor, bool direction);
60 bool IsServicedFloor(int floor);
61 bool FireService(int value);
62 bool AtMaxRequests(int elevator, int destination_floor);
63 int GetRecallFloor();
64 bool CallElevator(CallStation *station, bool direction);
65 int GetBottomFloor();
66 int GetTopFloor();
67 bool ServesFloor(int floor);
68 int GetElevator(int index);
69 bool SameElevators(const std::vector<int> &elevators);
70 bool GetCallStatus(int elevator, int floor, bool &up, bool &down);
71 std::vector<CallStation*> GetCallStations(int floor);
72
73private:
74
75 struct Route;
76
77 int FindClosestElevator(bool &busy, bool destination, int starting_floor, int destination_floor, int direction = 0);
78 void DispatchElevator(bool destination, int number, int destination_floor, int direction, bool call);
79 void RemoveRoute(const Route &route);
80 void ProcessRoutes();
81 void GetFloorRange();
82 bool ElevatorUnavailable(int elevator);
83 void CheckArrivals();
84
87
88 struct Call
89 {
90 int floor;
92 };
93
94 struct ElevMap
95 {
96 int number; //elevator number
97 bool arrived; //has elevator arrived at call floor?
98 int arrival_floor; //arrival floor
99 bool arrival_direction; //arrival direction
100 std::vector<int> assigned_destination; //destinations assigned to this elevator (DD mode)
101 std::vector<int> assigned_directions; //directions assigned to this elevator (standard mode)
104 std::vector<Call> calls;
105 };
106
107 std::vector<ElevMap> Elevators;
108
109 struct Route
110 {
112 int destination_floor; //used for destination dispatch mode
113 int direction; //used for standard mode
118 bool destination; //true if a destination dispatch route
119 };
120
121 std::vector<Route> Routes; //destination dispatch requests
122
123 std::vector<CallStation*> CallStations; //call station registrations
124
126};
127
128}
129
130#endif
std::vector< Route > Routes
Definition controller.h:121
std::vector< ElevMap > Elevators
Definition controller.h:107
std::vector< CallStation * > CallStations
Definition controller.h:123
#define SBSIMPEXP
Definition globals.h:53
std::vector< int > assigned_destination
Definition controller.h:100
std::vector< int > assigned_directions
Definition controller.h:101