logger mode

This commit is contained in:
ackimixs
2024-04-29 16:15:23 +02:00
parent 0effa0ca57
commit d03d28aa8e

View File

@@ -1,4 +1,5 @@
#include <TCPSocket/TCPClient.hpp>
#include <unistd.h>
int main(int argc, char* argv[]) {
@@ -7,40 +8,50 @@ int main(int argc, char* argv[]) {
port = std::stoi(argv[1]);
}
bool loggerMode = false;
if (argc >= 3) {
loggerMode = std::stoi(argv[2]);
}
TCPClient client("127.0.0.1", port); // Replace "127.0.0.1" with the IP address of your server and 8080 with the port number
client.start();
while (!client.shouldStop()) {
std::string message;
std::cin >> message;
if (message == "quit") {
client.stop();
break;
}
if (message == "ready") {
client.sendMessage("lidar;strat;ready;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("aruco;strat;ready;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("arduino;strat;ready;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("tirette;strat;ready;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("servo_moteur;strat;ready;1");
} else if (message == "pong") {
client.sendMessage("lidar;ihm;pong;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("aruco;ihm;pong;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("arduino;ihm;pong;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("tirette;ihm;pong;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("servo_moteur;ihm;pong;1");
if (loggerMode) {
usleep(500'000);
} else {
client.sendMessage(message);
std::string message;
std::cin >> message;
if (message == "quit") {
client.stop();
break;
}
if (message == "ready") {
client.sendMessage("lidar;strat;ready;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("aruco;strat;ready;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("arduino;strat;ready;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("tirette;strat;ready;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("servo_moteur;strat;ready;1");
} else if (message == "pong") {
client.sendMessage("lidar;ihm;pong;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("aruco;ihm;pong;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("arduino;ihm;pong;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("tirette;ihm;pong;1");
std::this_thread::sleep_for(std::chrono::milliseconds(100));
client.sendMessage("servo_moteur;ihm;pong;1");
} else {
client.sendMessage(message);
}
}
}