The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Design a Smart Building Elevator Usage Tracker with OOD Principles

Overview

Designing a Smart Building Elevator Usage Tracker using Object-Oriented Design (OOD) principles involves creating a system that effectively monitors and manages the usage patterns of elevators in a building. The goal is to optimize elevator usage, track maintenance needs, and provide data analytics to building managers for efficient building operations.

Key OOD Concepts to Apply:

  1. Encapsulation – Hide the internal workings of the system, exposing only necessary data and behavior.

  2. Inheritance – Use to extend functionality and avoid duplication of code by creating base classes that can be inherited.

  3. Polymorphism – Provide flexibility in how different classes implement certain methods.

  4. Abstraction – Simplify complex systems by focusing on high-level behavior and hiding implementation details.

Components of the System

  1. Elevator: A physical object that performs the primary function of carrying people between floors.

  2. Building: The overarching system that contains multiple elevators.

  3. ElevatorUsage: A data structure that tracks the details of elevator usage such as number of trips, duration of usage, floor requests, and maintenance requirements.

  4. UserInterface: The interface that allows building managers or users to interact with the system.

  5. ElevatorMaintenance: A class dedicated to tracking elevator health, maintenance, and reporting any malfunctions.

Design Breakdown

1. Elevator Class

This class will represent each elevator within the building. It contains properties for tracking the elevator’s state and methods for handling requests.

python
class Elevator: def __init__(self, id, capacity, current_floor=0, status="idle"): self.id = id self.capacity = capacity self.current_floor = current_floor self.status = status # "idle", "moving", "maintenance" self.trips = 0 self.door_status = "closed" # "open" or "closed" def move(self, destination_floor): if self.status != "maintenance": self.status = "moving" self.current_floor = destination_floor self.trips += 1 print(f"Elevator {self.id} is moving to floor {destination_floor}.") else: print(f"Elevator {self.id} is under maintenance and cannot move.") def open_door(self): self.door_status = "open" print(f"Elevator {self.id} door opened.") def close_door(self): self.door_status = "closed" print(f"Elevator {self.id} door closed.") def go_idle(self): self.status = "idle" print(f"Elevator {self.id} is now idle.") def request_maintenance(self): self.status = "maintenance" print(f"Elevator {self.id} is under maintenance.") def get_status(self): return self.status def get_current_floor(self): return self.current_floor

2. ElevatorUsage Class

This class tracks the elevator’s usage data such as number of trips, duration of operation, and any floor requests.

python
class ElevatorUsage: def __init__(self, elevator): self.elevator = elevator self.usage_count = 0 self.total_duration = 0 # in minutes self.floors_visited = set() def record_trip(self, duration, destination_floor): self.usage_count += 1 self.total_duration += duration self.floors_visited.add(destination_floor) def get_usage_report(self): report = { "Total Trips": self.usage_count, "Total Duration": self.total_duration, "Floors Visited": list(self.floors_visited) } return report

3. Building Class

The building class is responsible for managing the collection of elevators within the building. It tracks the building’s elevator fleet and the usage of each elevator.

python
class Building: def __init__(self, name): self.name = name self.elevators = [] def add_elevator(self, elevator): self.elevators.append(elevator) def track_usage(self, elevator_id): for elevator in self.elevators: if elevator.id == elevator_id: return elevator return None def show_all_usage(self): for elevator in self.elevators: print(f"Elevator {elevator.id} usage: {elevator.get_status()}")

4. ElevatorMaintenance Class

This class handles maintenance-related information such as repair status and maintenance schedules.

python
class ElevatorMaintenance: def __init__(self, elevator): self.elevator = elevator self.repair_history = [] def schedule_maintenance(self, issue_description): self.elevator.request_maintenance() repair_data = { "issue": issue_description, "status": "scheduled", "repair_date": "2025-07-20" # Placeholder for actual repair date } self.repair_history.append(repair_data) def complete_maintenance(self): self.elevator.go_idle() print(f"Maintenance for Elevator {self.elevator.id} completed.") def get_repair_history(self): return self.repair_history

5. UserInterface Class

This class provides the user interface for interacting with the system. It allows managers to request elevator maintenance, track usage, and perform other administrative tasks.

python
class UserInterface: def __init__(self, building): self.building = building def display_usage_report(self, elevator_id): elevator = self.building.track_usage(elevator_id) if elevator: usage = elevator.get_usage_report() print(usage) else: print(f"Elevator {elevator_id} not found.") def schedule_maintenance(self, elevator_id, issue_description): elevator = self.building.track_usage(elevator_id) if elevator: maintenance = ElevatorMaintenance(elevator) maintenance.schedule_maintenance(issue_description) else: print(f"Elevator {elevator_id} not found.")

Example Workflow

  1. Create Building & Elevators:

    • A building can have multiple elevators. These elevators are added to the building system.

  2. Track Elevator Usage:

    • The ElevatorUsage class keeps track of how many times each elevator has been used and its performance.

  3. Maintenance Scheduling:

    • If any elevator encounters an issue, it can be scheduled for maintenance using the ElevatorMaintenance class.

  4. Reports & Analytics:

    • The UserInterface class can generate reports on the elevator usage, performance, and maintenance history.

Example Scenario

python
# Initialize building building = Building("Skyline Tower") # Add elevators elevator1 = Elevator(id=1, capacity=10) elevator2 = Elevator(id=2, capacity=8) building.add_elevator(elevator1) building.add_elevator(elevator2) # Track usage for elevator1 elevator_usage1 = ElevatorUsage(elevator1) elevator_usage1.record_trip(5, 3) elevator_usage1.record_trip(3, 5) # Schedule maintenance ui = UserInterface(building) ui.schedule_maintenance(1, "Door malfunction") # Show usage report ui.display_usage_report(1) # Complete maintenance maintenance = ElevatorMaintenance(elevator1) maintenance.complete_maintenance()

Conclusion

This design allows for efficient tracking of elevator usage, maintenance schedules, and building management. By utilizing OOD principles, the system is modular, flexible, and easily scalable, allowing building managers to monitor and optimize elevator operations effectively.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About