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

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

#include <recharge_drone.h>

Inheritance diagram for csci3081::RechargeDrone:
Inheritance graph

Public Member Functions

 RechargeDrone (const picojson::object &val)
 
 RechargeDrone (RechargeDrone &)
 Copy Constructor. This creates a new instance of recharing drone that has the same content as the Package argument. More...
 
bool IsCurrentlyCharging ()
 This function will charge the recharging drone at the station when there is no DeadCarrier. More...
 
void ChargeFromStation (float dt)
 This function will charge the recharging drone at the station when there is no DeadCarrier. More...
 
bool IsChargingCarrierFull (float dt)
 This function will charge the DeadCarrier if the DeadCarrier is not charged to full. After the DeadCarrier get charged to full it will set the DeadCarrier Charging Status to false so the simulation will know the DeadCarrier is ready to be schduled. More...
 
bool BatteryDead ()
 This checks if the recharging drone is out of battery. More...
 
float GetBattery ()
 This returns the time in secs left in the carrier's battery.
 
float GetBatteryMaxCharge ()
 This returns the max charge of the recharge drone's battery.
 
bool Charging (float)
 This function is used to charge the battery of the carrier for a certain amount of time in seconds. 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 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 SetDynamic (bool dynamic_)
 This changes the dynamic of the recharge drone. Note that for the recharge drone to move on the simulation, dynamic of the recharge drone must be set to true. More...
 
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 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.
 
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...
 
void SetDeadCarrier (Carrier *carrier)
 This function set the DeadCarrier Pointer to a new carrier. More...
 
CarrierGetDeadCarrier ()
 This function set the DeadCarrier Pointer to a new carrier. More...
 
void SetPositionOfStation (vector< float > station)
 This function set the position of the station(SetPositionOfStation) to a new position. More...
 
vector< float > GetPositionOfStation ()
 This function Get the position of the station(SetPositionOfStation) More...
 
bool IsChargingACarrier ()
 This function should check the DeadCarrier pointer if its null or not and check if the DeadCarrier is getting charged or not. This function should be called in the simulation that to check the status of the recharging_drone. If its charing a DeadCarrier then does not need to Update the recharging drone. More...
 
RouteStrategyGetRouteStrategy ()
 return the Route Strategy that the carrier uses, such as Smart Route, Beeline, or Parabolic Route More...
 
bool BatteryFull ()
 This function checks the battery Capacity to see if it's full or not. This function should be called in IsChargingCarrierFull() to check if the DeadDrone need to be charged more. More...
 
- 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::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

◆ RechargeDrone() [1/2]

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

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

◆ RechargeDrone() [2/2]

csci3081::RechargeDrone::RechargeDrone ( RechargeDrone cpy)

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

Parameters
[in]cpyDrone instance that wants to be copied

Member Function Documentation

◆ BatteryDead()

bool csci3081::RechargeDrone::BatteryDead ( )

This checks if the recharging drone is out of battery.

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

◆ BatteryFull()

bool csci3081::RechargeDrone::BatteryFull ( )

This function checks the battery Capacity to see if it's full or not. This function should be called in IsChargingCarrierFull() to check if the DeadDrone need to be charged more.

Returns
the boolean value that indicates ss the battery full or not

◆ ChargeFromStation()

void csci3081::RechargeDrone::ChargeFromStation ( float  dt)

This function will charge the recharging drone at the station when there is no DeadCarrier.

Parameters
[in]ttime that charge the recharging drone

◆ Charging()

bool csci3081::RechargeDrone::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

◆ GetDeadCarrier()

Carrier * csci3081::RechargeDrone::GetDeadCarrier ( )

This function set the DeadCarrier Pointer to a new carrier.

Returns
return the DeadCarrier NULL for nothing

◆ GetPositionOfStation()

vector< float > csci3081::RechargeDrone::GetPositionOfStation ( )

This function Get the position of the station(SetPositionOfStation)

Returns
return the SetPositionOfStation(NULL for nothing)

◆ GetRouteStrategy()

RouteStrategy * csci3081::RechargeDrone::GetRouteStrategy ( )

return the Route Strategy that the carrier uses, such as Smart Route, Beeline, or Parabolic Route

Returns
RouteStrategy pointer

◆ GetStatus()

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

◆ IsChargingACarrier()

bool csci3081::RechargeDrone::IsChargingACarrier ( )

This function should check the DeadCarrier pointer if its null or not and check if the DeadCarrier is getting charged or not. This function should be called in the simulation that to check the status of the recharging_drone. If its charing a DeadCarrier then does not need to Update the recharging drone.

Returns
the boolean value that indicates reacharging drone is charging a DeadCarrier or not.

◆ IsChargingCarrierFull()

bool csci3081::RechargeDrone::IsChargingCarrierFull ( float  dt)

This function will charge the DeadCarrier if the DeadCarrier is not charged to full. After the DeadCarrier get charged to full it will set the DeadCarrier Charging Status to false so the simulation will know the DeadCarrier is ready to be schduled.

Parameters
[in]ttime that charge the recharging drone
Returns
this function will return true when the DeadCarrier get charged to full

◆ IsCurrentlyCharging()

bool csci3081::RechargeDrone::IsCurrentlyCharging ( )

This function will charge the recharging drone at the station when there is no DeadCarrier.

Parameters
[in]ttime that charge the recharging drone

◆ SetDeadCarrier()

void csci3081::RechargeDrone::SetDeadCarrier ( Carrier carrier)

This function set the DeadCarrier Pointer to a new carrier.

Parameters
[in]carriera carrier pointer that needed to be charged by recharging drone

◆ SetDynamic()

void csci3081::RechargeDrone::SetDynamic ( bool  dynamic_)

This changes the dynamic of the recharge drone. Note that for the recharge drone to move on the simulation, dynamic of the recharge drone must be set to true.

Parameters
[in]nTrue if the recharge drone is actively moving in the simulation False otherwise

◆ SetPosition()

void csci3081::RechargeDrone::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

◆ SetPositionOfStation()

void csci3081::RechargeDrone::SetPositionOfStation ( vector< float >  station)

This function set the position of the station(SetPositionOfStation) to a new position.

Parameters
[in]posthe new position of the Station

◆ SetRoute()

void csci3081::RechargeDrone::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::RechargeDrone::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: