CSCI3081W Drone Delivery System
DroneBatteryDecorator.h
1 #pragma once
2 
3 #include "DroneDecorator.h"
4 #include "SimulationModel.h"
5 
13  public:
22  DroneBatteryDecorator(Drone* drone, unsigned maxCharge_,
23  unsigned currentCharge_, unsigned lowCharge_,
24  double decreaseTime_);
25 
31 
38  void decreaseCharge(double dt);
39 
47  void charge(double dt);
48 
55 
63 
69  void update(double dt);
70 
78 
85 
93 
100 
107 
108  private:
116  void arriveAtRechargeStation();
117 
124  void lookAheadForRechargeStation();
125 
132  double batteryNeededForDistance(double distance);
133  unsigned maxCharge;
134  unsigned currentCharge;
135  unsigned lowCharge;
136  double movingDecreaseTime;
137  double timeElapsed = 0;
138  bool ismoving = false;
139  bool notCharging = false;
140  bool droneReady = false;
141  double chargingRate = 2;
142  IStrategy* toRechargeStation = nullptr;
143  int idleFrames = 0;
144  bool goingToPackage = false;
145  bool goingToFinalDestination = false;
146  double malfunctionedStationTime = 0;
147 };
Decorator class for adding battery to a drone Responsible for charging, discharging,...
Definition: DroneBatteryDecorator.h:12
DroneBatteryDecorator(Drone *drone, unsigned maxCharge_, unsigned currentCharge_, unsigned lowCharge_, double decreaseTime_)
Construct a new Drone Battery Decorator object.
Vector3 findNearestRechargeStation()
Find the nearest recharge station.
void headToRechargeStation(Vector3 station)
Head to a given recharge station.
void charge(double dt)
Charge the drone, add 2% charge to the drone if the drone is not at max charge. Charging speed is aff...
bool isAtRechargeStation()
Determine if the drone is at the recharge station.
void decreaseCharge(double dt)
Decrease the charge of the drone, add 2% charge to the drone.
void addToFunctionalDroneList()
If the drone is max charged, add it to the functional drone list. This tells the recharge drone that ...
virtual ~DroneBatteryDecorator()
Destroy the Drone Battery Decorator object.
void removeFromFunctionalDroneList()
If the drone is dead, remove it from the functional drone list to tell the recharge drone that this d...
void update(double dt)
Update the state of the drone, like position, charge, etc.
Vector3 findNearestRechargeStation(Vector3 startPosition)
Find the nearest recharge station from a given position.
void addToDeadDronesList()
If the drone is dead, add it to the dead drones list in the simulation model and wait for recharge dr...
Base class decorator for Drone that implements IEntityDecorator Drone template, delegates all work to...
Definition: DroneDecorator.h:13
Represents a drone in a physical system. Drones move using euler integration based on a specified vel...
Definition: Drone.h:19
Strategy interface.
Definition: IStrategy.h:11
a simple class used for vector math, most function are self explanatory
Definition: vector3.h:12