Skip to content

Commit

Permalink
added some documentation to network proximity service
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantanaka committed Feb 21, 2018
1 parent a0d4253 commit 7751260
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace wrench{

std::map<std::string, std::complex<double>> coordinate_lookup_table;

std::shared_ptr<NetworkProximityDaemon> getCommunicationPeer(NetworkProximityDaemon *daemon);
std::shared_ptr<NetworkProximityDaemon> getCommunicationPeer(const NetworkProximityDaemon * sender_daemon);

void vivaldiUpdate(double proximityValue, std::string sender_hostname, std::string peer_hostname);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ namespace wrench {
* @param sender_daemon: the network daemon requesting a peer to communicate with next
* @return a shared_ptr to the network daemon that is the selected communication peer
*/
std::shared_ptr<NetworkProximityDaemon>
NetworkProximityService::getCommunicationPeer(NetworkProximityDaemon *sender_daemon) {
std::shared_ptr<NetworkProximityDaemon> // TODO:
NetworkProximityService::getCommunicationPeer(const NetworkProximityDaemon * sender_daemon) {

WRENCH_INFO("Obtaining communication peer for %s", sender_daemon->mailbox_name.c_str());

Expand Down Expand Up @@ -428,7 +428,6 @@ namespace wrench {
std::complex<double> error_direction, scaled_direction;

// if both coordinates are at the origin, we need a random direction vector
// TODO: is this comparison okay?
if (estimated_distance == 0.0) {
// TODO: maybe use time(0) from <ctime> as seed
static std::default_random_engine direction_rng(0);
Expand All @@ -440,6 +439,7 @@ namespace wrench {
error_direction = sender_coordinates - peer_coordinates;
}

// scaled_direction will get start to approach 0 when error_direction gets small
scaled_direction = error_direction * error;

// compute the updated sender coordinates
Expand All @@ -455,7 +455,7 @@ namespace wrench {
sender_coordinates.real(), sender_coordinates.imag(), updated_sender_coordinates.real(),
updated_sender_coordinates.imag());

// TESTING VIVALDI RESULTS
// WRITING VIVALDI RESULTS FOR DEBUGGING
std::ofstream output("/home/ryan/Dropbox/Spring18/GRAD_PROJECT/vivaldi_visual/coordinate_table.txt", std::ofstream::app);

std::map<std::string, std::complex<double>>::iterator it;
Expand All @@ -465,6 +465,7 @@ namespace wrench {
}
output << "*" << std::endl;
output.close();
// END WRITING VIVALDI RESULTS

}

Expand Down

0 comments on commit 7751260

Please sign in to comment.