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

A representation of a carrier An abstract base class for delivery transportation clases like Drone or Robot. Robot and Drone inherited from Carrier. More...

#include <carrier.h>

Inheritance diagram for csci3081::Carrier:
Inheritance graph

Public Member Functions

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...
 

Protected Attributes

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 carrier An abstract base class for delivery transportation clases like Drone or Robot. Robot and Drone inherited from Carrier.

Member Function Documentation

◆ AddPackage()

bool csci3081::Carrier::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)

Parameters
[in]arga Package pointer
Returns
True upon succeeding linking the package to the carrier False otherwise (e.g. carrier is already linked to another package)

◆ BatteryDead()

bool csci3081::Carrier::BatteryDead ( )

This checks if the carrier is out of battery.

Returns
TRUE if the battery of the carrier is out FALSE otherwise

◆ BatteryFull()

bool csci3081::Carrier::BatteryFull ( )

This function checks if the battery is full.

Returns
bool True if battery is full. False otherwise.

◆ Charging()

bool csci3081::Carrier::Charging ( float  sec)

This function is used to charge the battery of the carrier for a certain amount of time in seconds.

Parameters
[in]secamount of time in secs to charge the battery
Returns
TRUE if the battery can be charged FALSE otherwise

◆ DropPackage()

Package * csci3081::Carrier::DropPackage ( )

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.

Returns
a Package pointer to the just dropped/delivered package

◆ GetBatteryObj()

Battery * csci3081::Carrier::GetBatteryObj ( )

This function will return the Battery object.

Returns
Battery Battery in the drone

◆ GetDroneStatusWhenBatteryDies()

std::string csci3081::Carrier::GetDroneStatusWhenBatteryDies ( )

This function gets the battery status (alive, dead on ground, or dead in the air)

Returns
string battery status

◆ GetStatus()

void csci3081::Carrier::GetStatus ( )
virtual

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.

Parameters
picojson::value&event
constentity_project::IEntity& entity

Implements csci3081::ASubject.

◆ HavePackage()

bool csci3081::Carrier::HavePackage ( )

This checks if the carrier is already linked to a package.

Returns
True if the carrier is already linked to a package (package pointer of the carrier is not NULL) False otherwise

◆ IsCurrentlyCharging()

bool csci3081::Carrier::IsCurrentlyCharging ( )

This function checks if the carrier battery is currently charging.

Returns
bool True if battery is currently charging. False otherwise.

◆ SetChargingStatus()

void csci3081::Carrier::SetChargingStatus ( bool  b)

This function sets the carrier battery status.

Parameters
[in]bTRUE if battery is charging. False otherwise.

◆ SetDroneStatusWhenBatteryDies()

void csci3081::Carrier::SetDroneStatusWhenBatteryDies ( std::string  status)

This function sets the battery status when the battery dies (alive, dead on ground, or dead in the air)

Parameters
[in]statusStatus of the battery.

◆ SetPosition()

void csci3081::Carrier::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.

Parameters
agra std::vector<float> that has the new position of the carrier

◆ SetRoute()

void csci3081::Carrier::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.

Parameters
agra std::vector<std::vector<float>> that has the positions need to be added

◆ SetSpeed()

void csci3081::Carrier::SetSpeed ( float  s)

This sets the speed of the carrier. Change the speed of the carrier if the argument is a non-negative float number.

Parameters
[in]sa non-negative float value for the carrier's speed

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