Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
bug fix and demo csv
Browse files Browse the repository at this point in the history
  • Loading branch information
lizlouise1335 committed Dec 14, 2023
1 parent 0977821 commit 43f624e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
13 changes: 11 additions & 2 deletions src/Management.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "../include/manage/Management.hpp"

#include <cmath>

Management::Management() {
this->csv_path_room_ = "";
Expand Down Expand Up @@ -135,6 +135,13 @@ void Management::charge(std::string bot){

void Management::cleaning(Robot& robot, Room& room, int time){
bool fail;
int size;
int roundedUp;
if (robot.get_size() == Robot_Size::Medium){
size = 2;
} else if (robot.get_size() == Robot_Size::Small){
size = 3;
} else{ size = 1; }
for (int i = 0; i < time; i++) {
std::random_device rd; // Obtain a random number from hardware
std::mt19937 gen(rd()); // Seed the generator
Expand All @@ -155,9 +162,11 @@ void Management::cleaning(Robot& robot, Room& room, int time){
return;
}
std::this_thread::sleep_for(std::chrono::seconds(1));
room.set_time_to_clean(time-i);
roundedUp = static_cast<int>(ceil((time-i)/size));
room.set_time_to_clean(roundedUp);
robot.kill_battery();
}
std::cout << "\n [SYSTEM_ALERT] (Room " + room.get_id() + " is clean.)" << std::endl;
room.set_status(Room_Status::clean);
room.set_time_to_clean(0);
robot.go_home();
Expand Down
6 changes: 3 additions & 3 deletions tests/robot_test.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
0,Free,Small,Mop,NA
1,Busy,Small,Vac,2
1,Free,Small,Vac,NA
2,Free,Medium,Scrub,NA
3,Busy,Medium,Mop,5
3,Free,Medium,Mop,NA
4,Free,Large,Vac,NA
5,Busy,Large,Scrub,3
5,Free,Large,Scrub,NA
6,Free,Large,Mop,NA
14 changes: 7 additions & 7 deletions tests/room_test.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
0,Clean,Small,0
1,Dirty,Small,2
2,IP,Medium,4
3,IP,Medium,4
4,Clean,Large,0
5,IP,Large,6
6,Clean,Large,0
0,Dirty,Small,3
1,Dirty,Small,3
2,Dirty,Medium,3
3,Dirty,Medium,3
4,Dirty,Large,3
5,Dirty,Large,3
6,Dirty,Large,3

0 comments on commit 43f624e

Please sign in to comment.