CSCI3081W Drone Delivery System
Public Member Functions | List of all members
DroneBatteryDecorator Class Reference

Decorator class for adding battery to a drone Responsible for charging, discharging, and finding recharge stations. More...

#include <DroneBatteryDecorator.h>

Inheritance diagram for DroneBatteryDecorator:
Inheritance graph
[legend]
Collaboration diagram for DroneBatteryDecorator:
Collaboration graph
[legend]

Public Member Functions

 DroneBatteryDecorator (Drone *drone, unsigned maxCharge_, unsigned currentCharge_, unsigned lowCharge_, double decreaseTime_)
 Construct a new Drone Battery Decorator object. More...
 
virtual ~DroneBatteryDecorator ()
 Destroy the Drone Battery Decorator object.
 
void decreaseCharge (double dt)
 Decrease the charge of the drone, add 2% charge to the drone. More...
 
void charge (double dt)
 Charge the drone, add 2% charge to the drone if the drone is not at max charge. Charging speed is affected by charging rate. More...
 
Vector3 findNearestRechargeStation ()
 Find the nearest recharge station. More...
 
Vector3 findNearestRechargeStation (Vector3 startPosition)
 Find the nearest recharge station from a given position. More...
 
void update (double dt)
 Update the state of the drone, like position, charge, etc. More...
 
bool isAtRechargeStation ()
 Determine if the drone is at the recharge station. More...
 
void headToRechargeStation (Vector3 station)
 Head to a given recharge station. More...
 
void addToDeadDronesList ()
 If the drone is dead, add it to the dead drones list in the simulation model and wait for recharge drone to charge it. It will be removed from the list by the recharge drone.
 
void addToFunctionalDroneList ()
 If the drone is max charged, add it to the functional drone list. This tells the recharge drone that this drone no longer needs charging.
 
void removeFromFunctionalDroneList ()
 If the drone is dead, remove it from the functional drone list to tell the recharge drone that this drone needs charging.
 
- Public Member Functions inherited from DroneDecorator
 DroneDecorator (Drone *d)
 Constructor for DroneDecorator, calls IEntityDecorator constructor. More...
 
virtual ~DroneDecorator ()
 Destructor.
 
virtual void getNextDelivery () const
 Gets the next delivery in the scheduler.
 
virtual bool getPickedUp () const
 Gets the pickedUp status of the Drone object.
 
virtual PackagegetPackage () const
 Gets pointer to the Drone's package.
 
virtual IStrategygetFinalStrategy () const
 Returns pointer to toFinalDestination.
 
virtual void setToPackage (IStrategy *s) const
 Sets the Drone's toPackage strategy to a new one. More...
 
virtual SimulationModelgetModel () const
 Get the Model object. More...
 
IStrategygetToFinalDestinationStrategy ()
 Get the To Final Destination Strategy object. More...
 
IStrategygetToPackageStrategy ()
 Get the To Package Strategy object. More...
 
- Public Member Functions inherited from IEntityDecorator< Drone >
 IEntityDecorator (T *e)
 Constructor for IEntityDecorator. More...
 
virtual ~IEntityDecorator ()
 Destructor.
 
virtual void linkModel (SimulationModel *model)
 Links this entity to a simulation model, giving it access to the model's public variables and functions. More...
 
virtual int getId () const
 Gets the ID of the entity. More...
 
virtual Vector3 getPosition () const
 Gets the position of the entity. More...
 
virtual Vector3 getDirection () const
 Gets the direction of the entity. More...
 
virtual const JsonObjectgetDetails () const
 Gets the details of the entity. More...
 
virtual std::string getColor () const
 Gets the color of the entity. More...
 
virtual std::string getName () const
 Gets the name of the entity. More...
 
virtual double getSpeed () const
 Gets the speed of the entity. More...
 
virtual void setPosition (Vector3 pos_)
 Sets the position of the entity. More...
 
virtual void setDirection (Vector3 dir_)
 Set the direction of the entity. More...
 
virtual void setColor (std::string col_)
 Sets the color of the entity. More...
 
virtual void rotate (double angle)
 Rotate the entity around y axis. More...
 

Additional Inherited Members

- Protected Attributes inherited from IEntityDecorator< Drone >
T * sub
 

Detailed Description

Decorator class for adding battery to a drone Responsible for charging, discharging, and finding recharge stations.

Constructor & Destructor Documentation

◆ DroneBatteryDecorator()

DroneBatteryDecorator::DroneBatteryDecorator ( Drone drone,
unsigned  maxCharge_,
unsigned  currentCharge_,
unsigned  lowCharge_,
double  decreaseTime_ 
)

Construct a new Drone Battery Decorator object.

Parameters
droneThe drone to be added battery to
maxCharge_Maximum charge the drone can have
currentCharge_Current charge the drone has
decreaseTime_Time it takes for the drone to decrease 2% charge

Member Function Documentation

◆ charge()

void DroneBatteryDecorator::charge ( double  dt)

Charge the drone, add 2% charge to the drone if the drone is not at max charge. Charging speed is affected by charging rate.

Parameters
dtTime elapsed

◆ decreaseCharge()

void DroneBatteryDecorator::decreaseCharge ( double  dt)

Decrease the charge of the drone, add 2% charge to the drone.

Parameters
dtTime elapsed

◆ findNearestRechargeStation() [1/2]

Vector3 DroneBatteryDecorator::findNearestRechargeStation ( )

Find the nearest recharge station.

Returns
Vector3 Position of the nearest recharge station

◆ findNearestRechargeStation() [2/2]

Vector3 DroneBatteryDecorator::findNearestRechargeStation ( Vector3  startPosition)

Find the nearest recharge station from a given position.

Parameters
startPositionThe position to look for the nearest recharge station
Returns
Vector3 Position of the nearest recharge station

◆ headToRechargeStation()

void DroneBatteryDecorator::headToRechargeStation ( Vector3  station)

Head to a given recharge station.

Parameters
stationThe position of the recharge station to head to

◆ isAtRechargeStation()

bool DroneBatteryDecorator::isAtRechargeStation ( )

Determine if the drone is at the recharge station.

Returns
true The drone is at the recharge station
false The drone is not at the recharge station

◆ update()

void DroneBatteryDecorator::update ( double  dt)
virtual

Update the state of the drone, like position, charge, etc.

Parameters
dtTime elapsed

Reimplemented from DroneDecorator.


The documentation for this class was generated from the following file: