The entire application Urls is within the app elevator
.
api
folder within app elevator
contains the views.py
and serializers.py
files.
views.py
contains the whole logic of the APIs .
serializers.py
contains the logic to convert complex data types like queryset to json
Documentation below.
In settings.py
in DATABASES please input your own Id and password for the database and create a database in your pgAdmin panel.
Recommended python version -----> 3.9.X (The LATEST STABLE RELEASE)
python -m venv myvenv
myvenv\Scripts\activate.bat
pip install -r requirements.txt
python manage.py runserver
The REST API to the app is described below.
Please note the id's as they are used to send the requests
POST /initialise
{
"elevators":5
}
{
"message": [
{
"id": 16,
"doorStatus": "Closed",
"currentFloor": 0,
"motion": "Stopped",
"operational": true,
"listofRequest": null
},
{
"id": 17,
"doorStatus": "Closed",
"currentFloor": 0,
"motion": "Stopped",
"operational": true,
"listofRequest": null
},
{
"id": 18,
"doorStatus": "Closed",
"currentFloor": 0,
"motion": "Stopped",
"operational": true,
"listofRequest": null
},
{
"id": 19,
"doorStatus": "Closed",
"currentFloor": 0,
"motion": "Stopped",
"operational": true,
"listofRequest": null
},
{
"id": 20,
"doorStatus": "Closed",
"currentFloor": 0,
"motion": "Stopped",
"operational": true,
"listofRequest": null
}
Request a floor for a particular elevetor to travel to.
POST /listofrequests/:id
{
"listofRequest":4
}
{ "message": "Request added"}
GET /listofrequests/:id
[5, 8, 4]
GET /nextfloor/:id
5
According to the current Floor of the elevator this api will show direction
GET /direction/:id
"Up"
POST /status/:id
{ "operational":true }
{
"id": 16,
"doorStatus": "Closed",
"currentFloor": 0,
"motion": "Stopped",
"operational": false,
"listofRequest": [
5,
8
]
}
GET /status/:id
"Elevator is operational" / "Elevator is not operational"
POST /door/:id
{
"doorStatus":"Open"
}
{
"id": 16,
"doorStatus": "Open",
"currentFloor": 0,
"motion": "Stopped",
"operational": false,
"listofRequest": [
5,
8
]
}
GET /door/:id
"Open" / "Closed"
Request of floor number is listed. The nearest elevator is selected for each request. Both these data sets i.e request and nearest elevator are assigned in two different arrays in which each element has one 1-1 relationship
POST /liftAsssigner
{
"person":[5,2,6,1,8]
}
Returns the Id's of the elevator with respect to floor from which request originated
[
17,
18,
19,
20,
16
]
GET /active/:id
"active"
POST /listofrequests/:id
{
"motion":"Moving"
}
{
"id": 16,
"doorStatus": "Open",
"currentFloor": 0,
"motion": "Moving",
"operational": false,
"listofRequest": [
5,
8
]
}
GET /motion/:id
"Moving"/ "Stopped"
Runs the elevator with respect to the list of Requests that specific elevator has and updates currentFloor
GET /runLift/:id
Terminal shows the motion of the elevator and after stopping we get a response "Elevator has stopped"
GET /deinitialise/
{ "message": "All Elevators Deleted Please enter new number of elevators with initialise api"}