Skip to content

cheikhwade07/Firefighting-Drone-Swarm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

243 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Firefighting Drone Real-Time System

Project Iteration 5 builds on Iteration 4 by implementing code to log and generate analytics on key simulation events.

Changes from Iteration 4

  • Config.java added for increased customization and simulation stability
  • SystemLauncher.java added for the convenient starting of simulation
  • EventLogger.java added to record simulation events
  • 3 different analytics are generated based on logged data: average drone response time and total simulation time
  • individual drone metrics (total flight time, total idle time, drone id) are recorded and displayed

Project Files

File Description
Scheduler.java Monitor/server that queues fire events, applies a priority algorithm, delegates tasks to drones, and relays extinguishment confirmations back to FireIncidentSubSystem.
FireIncidentSubSystem.java Reads fire events from the event CSV, maintains the active-fires list, and confirms extinguishment or partial updates received from the Scheduler.
DroneSubsystem.java Models a single drone: dispatches to a zone, drops 15 L of agent, returns to base, and refills. Reports task results and fault messages back to the Scheduler.
FireEvent.java Data class describing one fire event (time, zone ID, event type, severity, water remaining).
ZoneMap.java Aggregates all Zone objects loaded from the zone CSV.
Zone.java Rectangular fire zone with coordinates, centre calculation, and zone ID.
ZoneFileReader.java Parses the zone CSV into Zone objects.
FireEventFileReader.java Parses the event CSV into FireEvent objects.
TimeSimulation.java Replays fire events in real-time (scaled by a clock factor) by calling FireIncidentSubSystem.processEvent.
FireFightingGUI.java Swing GUI displaying the zone map, active fires, drone positions, and a status bar. Receives UDP updates.
FireInfo.java Storage for certain FireEvent data required by the GUI.
DroneInfo.java Storage for certain Drone data required by the GUI.
Config.java Storage for certain simulation data. Allows simulation to run in case of missing or misconfigured input file.
EventLogger.java Generates log file of metadata for important simulation events.
SystemLauncher.java Starts simulation; runs key files in the correct order.
DroneStatus.java Enum for drone states: IDLE, EN_ROUTE, DROPPING_AGENT, RETURNING. Each state has an associated display colour.
EventType.java Enum for fire event types: FireDetected, DroneRequested.
Severity.java Enum for fire severity (LOW = 10 L, MODERATE = 20 L, HIGH = 30 L).
FaultType.java Enum for fault types: NONE, FLIGHT_TIMEOUT, NOZZLE_STUCK_CLOSED, MESSAGE_CORRUPTED.
FireStatus.java Enum for fire status: Active, BeingServiced, Extinguished.
EventCode.java Enum for simulation occurrences: DRONE_STATE_CHANGE, FIRE_ENTER_QUEUE, FIRE_EXIT_QUEUE, FIRE_REQUEUD, FIRE_RESERVED, and more.
SchedulerState.java Enum for scheduler states: WAITING, ASSIGNING, MONITORING, HANDLING_FAULT.
DroneSubsystemTest.java JUnit 5 tests for DroneSubsystem.
SchedulerTest.java JUnit 5 tests for Scheduler.
FireIncidentSubSystemTest.java JUnit 5 tests for FireIncidentSubSystem.

Input File Formats

Event file (Sample_event_file.csv)

Time = hh:mm:ss, zoneID = int, Event type = FIRE_DETECTED|DRONE_REQUEST, Severity = High|Moderate|Low, Fault type = NONE|FLIGHT_TIMEOUT|MESSAGE_CORRUPTED|NOZZLE_STUCK_CLOSED
14:03:15,3,FIRE_DETECTED,High,NONE
14:10:00,7,DRONE_REQUEST,Moderate,FLIGHT_TIMEOUT

Zone file (sample_zone_file.csv)

zoneID,(x1,y1),(x2,y2)
1,(0,0),(700,600)
2,(0,600),(650,1500)

Setup Instructions

  1. Download and unzip L4G8_Iteration_5.zip into an IntelliJ IDEA project folder.
  2. Ensure the following are in the src/ folder:
    • All .java source files listed above.
    • sample_zone_file.csv and Sample_event_file.csv (place in the project root, not src/).
  3. Add JUnit 5 as a dependency (via Maven or by adding the JUnit Jupiter JARs to the module classpath).
  4. Run the file SystemLauncher.java to start the simulation.
  5. (Optional) Alternatively, the program may be manually started by running the following files in the correct order: Scheduler.java -> FireFightingGUI.java -> DroneSubsystem.java -> FireIncidentSubSystem.java

Running the Tests

Each test class can be run individually inside IntelliJ IDEA:

  1. Right-click DroneSubsystemTest.javaRun 'DroneSubsystemTest'
  2. Right-click SchedulerTest.javaRun 'SchedulerTest'
  3. Right-click FireIncidentSubSystemTest.javaRun 'FireIncidentSubSystemTest'

Note: DroneSubsystemTest.tankIsFullAfterHandleTask and droneStatusIsIdleAfterHandleTask involve real Thread.sleep calls (drone travel + agent drop times). These tests take approximately 20–30 seconds each to complete. This is expected behaviour.


Generating Analytics

EventLogger.java records numerous key statistics as the simulator progresses that aim to analyze the overall performance of each drone and their scheduling algorithm. Utilizing these figures, the following analytics are generated:

  1. Average Drone Response Time: Calculates the average time it takes for any drone to reach their designated FireEvents once a fireEvent has been detected. This figure is calculated by collecting the time of initialization for FireEvents and subtracting the time of arrival of each applicable drone, then taking the average of all calculated figures.
  2. Total Simulation Time: The total time required for the simulation to conclude. Therefore, this figure determines the overall efficiency of the scheduler by tracking the total time to extinguish all fires. This figure is calculated by subtracting the time in which the final FireEvent is extinguished from the time in which the first FireEvent is detected.

Additionally, the following data for each individual drone is logged by the simulation:

  1. Total Flight Time: The total time a given drone has spent away from the Base. Determined by calculating the time between IDLE DroneStatus events.
  2. Total Idle Time: The total time a given drone has spent in the Base. Determined by calculating the time between IDLE DroneStatus events.

Scheduler Priority Algorithm

The scheduler orders the fire queue using the following rules (see Scheduler.determineFirePriority()):

  1. Full-tank trips first – events whose amountOfWaterNeeded is a multiple of 15 (i.e. exactly 15 L or 30 L remaining) are placed at the front of the queue. This maximises agent delivery efficiency by ensuring drones always fly with a full load.
  2. Furthest zone wins – within the same priority tier, the zone furthest from the base is chosen first to avoid sending a heavily-loaded drone on a short trip while a distant fire waits.
  3. Route optimisation (pairing) – if two fires each need less than a full tank, the algorithm pairs them so a drone can top up both in a single round trip when the detour is shorter than returning to base.

Practical severity ordering under this algorithm:

  • HIGH (30 L) – dispatched first (30 % 15 == 0).
  • LOW (10 L) / MODERATE (20 L) – dispatched afterwards (neither is divisible by 15).

About

SYSC 3303A - RealTime Concurrent Systems - Winter 2026

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages