CSCI 3081 - Drone Delivery System
Public Member Functions | List of all members
csci3081::Drone Class Reference

A representation of a drone It stores the drone's name, ID, version, position, direction, speed, and dynamic mode. More...

#include <drone.h>

Inheritance diagram for csci3081::Drone:
Inheritance graph

Public Member Functions

 Drone (const picojson::object &val)
 
 Drone (Drone &)
 Copy Constructor. This creates a new instance of Package that has the same content as the Package argument. More...
 
- Public Member Functions inherited from csci3081::Carrier
bool BatteryDead ()
 This checks if the carrier is out of battery. More...
 
bool BatteryFull ()
 This function checks if the battery is full. More...
 
float GetBattery ()
 This returns the time in secs left in the carrier's battery.
 
float GetMaxBattery ()
 This returns the battery maximum capacity.
 
bool Charging (float)
 This function is used to charge the battery of the carrier for a certain amount of time in seconds. More...
 
bool HavePackage ()
 This checks if the carrier is already linked to a package. More...
 
PackageGetPackage ()
 This returns a Package pointer to the package that the carrier is linking to, and returns NULL if the carrier is not linking to any package.
 
bool AddPackage (Package *arg)
 This links a package object to the carrier if the carrier is not already linking to another package (carrier can only carry one package at a time) More...
 
PackageDropPackage ()
 This releases the link of the package from the carrier, making the package pointer of the carrier NULL, and return a pointer to the just dropped/delivered package. More...
 
void SetPosition (std::vector< float > v)
 This function uses to set the new position of the carrier. However, carrier only moves in simulation if its dynamic attribute is set to true. More...
 
void SetSpeed (float)
 This sets the speed of the carrier. Change the speed of the carrier if the argument is a non-negative float number. More...
 
float GetSpeed ()
 return the current speed of the carrier
 
void SetRoute (std::vector< vector< float >>)
 This function adds a full route to route attribute of the carrier This is useful when use for the GetPath() function from IGraph class. More...
 
std::vector< float > NextPosition ()
 This function returns the next position in std::vector<float> in the queue that the carrier needs to move to.
 
void PopPosition ()
 This function pops the first element/position in the position queue of the carrier.
 
void GetStatus ()
 Overwritten GetStatus from ASubject. This function creates the arguments required by Notify function and makes call to Notify function. This function should be called when path is added to the carrier and when the carrier becomes idle. More...
 
RouteStrategyGetRouteStrategy ()
 return the Route Strategy that the carrier uses, such as Smart Route, Beeline, or Parabolic Route
 
bool IsCurrentlyCharging ()
 This function checks if the carrier battery is currently charging. More...
 
BatteryGetBatteryObj ()
 This function will return the Battery object. More...
 
void SetChargingStatus (bool b)
 This function sets the carrier battery status. More...
 
void SetDroneStatusWhenBatteryDies (std::string status)
 This function sets the battery status when the battery dies (alive, dead on ground, or dead in the air) More...
 
std::string GetDroneStatusWhenBatteryDies ()
 This function gets the battery status (alive, dead on ground, or dead in the air) More...
 
void GoDownToGround ()
 This function sends the carrier down (if on the air) to the ground when the battery is dead. If the carrier is currently delivering a package, it will drop its package for other available carriers to come and pick it up.
 
void Update (float dt)
 This is an inherited method from EntityBase to use for DeliverySimulation. This updates the position of the carrier on the simulation if the position changes and its dynamic is set to true. In addition, this function also checks if the carrier is in within distance with the package to pick it up, or within distance with the customer to drop off the package.
 
- Public Member Functions inherited from csci3081::EntityBase
const picojson::object & GetDetails ()
 
int GetId () const
 
const std::string & GetName ()
 
const std::vector< float > & GetPosition () const
 
const std::vector< float > & GetDirection () const
 
float GetRadius () const
 
int GetVersion () const
 
bool IsDynamic () const
 
float DistanceBetween (IEntity *another)
 
bool IsWithin (IEntity *another)
 
std::string GetType ()
 
- Public Member Functions inherited from entity_project::IEntity
virtual ~IEntity ()
 The destructor.
 
- Public Member Functions inherited from csci3081::ASubject
void Attach (entity_project::IEntityObserver *observer)
 Adds an observer to the list of observers for this subject. More...
 
void Detach (entity_project::IEntityObserver *observer)
 Deletes an observer from the list of observers for this subject. More...
 
std::vector< entity_project::IEntityObserver * > GetList ()
 Getter function for the list of observers (mostly used in testing) More...
 
void Notify (picojson::value &event, const entity_project::IEntity &entity)
 Sends out Notification to the observer watching this subject. More...
 

Additional Inherited Members

- Protected Attributes inherited from csci3081::Carrier
Battery battery
 
Packagepackage
 
float speed
 
std::vector< std::vector< float > > route
 
std::string droneStatusWhenBatteryDies = "not dead yet"
 
bool ChargingStatus = false
 
RouteStrategyrouteStrategy = NULL
 
- Protected Attributes inherited from csci3081::EntityBase
std::string name
 
int ID
 
std::vector< float > position
 
std::vector< float > direction
 
bool dynamic
 
int version
 
float radius
 
std::string type
 
picojson::object details
 
- Protected Attributes inherited from csci3081::ASubject
std::vector< entity_project::IEntityObserver * > list
 List of pointers to the observers for this subject.
 

Detailed Description

A representation of a drone It stores the drone's name, ID, version, position, direction, speed, and dynamic mode.

Constructor & Destructor Documentation

◆ Drone() [1/2]

csci3081::Drone::Drone ( const picojson::object &  val)

Constructor, creates a Package object param[in] val a picojson::object object that has the detail of the package including name, position, direction, radius, and speed

◆ Drone() [2/2]

csci3081::Drone::Drone ( Drone cpy)

Copy Constructor. This creates a new instance of Package that has the same content as the Package argument.

Parameters
[in]cpyDrone instance that wants to be copied

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