diff --git a/src/api/class/src/class_core.cpp b/src/api/class/src/class_core.cpp index c4b0aae5c251a72bddd19577638591b878868422..5cba6bb9f84522a9586e9120c15b8c2d528ca553 100644 --- a/src/api/class/src/class_core.cpp +++ b/src/api/class/src/class_core.cpp @@ -644,11 +644,11 @@ ClassError::Error ClassCore::velecSelected(const int &id, const bool &selected) if(selected) { - return sendMsg(commands::ClassCommands::CMD_CONFIGVELEC + std::to_string(id) + commands::ClassCommands::CMD_VELEC_SELECTED + commands::ClassCommands::CMD_AUX); + return sendMsg(commands::ClassCommands::CMD_CONFIGVELEC + std::to_string(id) + commands::ClassCommands::CMD_CONFIGVELEC_PARAM4 + commands::ClassCommands::CMD_VELEC_SELECTED + commands::ClassCommands::CMD_AUX); } else { - return sendMsg(commands::ClassCommands::CMD_CONFIGVELEC + std::to_string(id) + commands::ClassCommands::CMD_VELEC_NOTSELECTED + commands::ClassCommands::CMD_AUX); + return sendMsg(commands::ClassCommands::CMD_CONFIGVELEC + std::to_string(id) + commands::ClassCommands::CMD_CONFIGVELEC_PARAM4 + commands::ClassCommands::CMD_VELEC_NOTSELECTED + commands::ClassCommands::CMD_AUX); } } @@ -679,22 +679,14 @@ ClassError::Error ClassCore::velecsSelected(const std::vector<int> &id, const st log_warn_stream_("[velecsSelected] No virtual electrode with id: " << id[velecIndex] << "configured from this client."); } - std::stringstream ss; - ss << "velec " << id[velecIndex]; - ss << " *selected "; if (selected[velecIndex]) { - //commands::ClassCommands::CMD_CONFIGVELEC + id + commands::ClassCommands::CMD_VELEC_SELECTED + commands::ClassCommands::CMD_AUX - ss << "1"; + msg_list.push_back(commands::ClassCommands::CMD_CONFIGVELEC + std::to_string(id[velecIndex]) + commands::ClassCommands::CMD_CONFIGVELEC_PARAM4 + commands::ClassCommands::CMD_VELEC_SELECTED + commands::ClassCommands::CMD_AUX); } else { - //commands::ClassCommands::CMD_CONFIGVELEC + id + commands::ClassCommands::CMD_VELEC_NOTSELECTED + commands::ClassCommands::CMD_AUX - ss << "0"; + msg_list.push_back(commands::ClassCommands::CMD_CONFIGVELEC + std::to_string(id[velecIndex]) + commands::ClassCommands::CMD_CONFIGVELEC_PARAM4 + commands::ClassCommands::CMD_VELEC_NOTSELECTED + commands::ClassCommands::CMD_AUX); //ss << "0"; } - ss << "\r\n"; - std::string msg = ss.str(); - msg_list.push_back(msg); } return sendMsgs(msg_list); } @@ -716,12 +708,9 @@ ClassError::Error ClassCore::stimVelec(const std::string &name) { log_warn_stream_("[velecSelected] No virtual electrode with name: " << name << " condifgured from this client."); } + + return sendMsg(commands::ClassCommands::CMD_VELECSTIM + name + commands::ClassCommands::CMD_AUX); - std::stringstream ss; - ss << "stim " << name << "\r\n"; - std::string msg = ss.str(); - - return sendMsg(msg); } ClassError::Error ClassCore::acqImpedanceConfig(const bool &positive) @@ -932,7 +921,7 @@ void ClassCore::udpMsgReceived(std::string msg, std::string ip) } } } - else if (msg.find("velec ") != std::string::npos) + else if (msg.find("velec ") != std::string::npos && (msg.find("*name ") == std::string::npos)) { double is_waiting_velecstatus = false; if (velecstatus_mutex_.try_lock()) @@ -1419,12 +1408,9 @@ ClassError::Error ClassCore::logeventsStatus() ClassError::Error ClassCore::velecStatus(const int &number) { - std::stringstream ss; - ss << "velec " << number << " ?\r\n"; - std::string msg = ss.str(); - - ClassError::Error response = sendMsg(msg); + ClassError::Error response = sendMsg(commands::ClassCommands::CMD_CONFIGVELEC + std::to_string(number) + commands::ClassCommands::CMD_AUX); + if (velecstatus_mutex_.try_lock()) { is_waiting_velecstatus_ = true; @@ -1436,12 +1422,7 @@ ClassError::Error ClassCore::velecStatus(const int &number) ClassError::Error ClassCore::patternStatus(const int &number) { - std::stringstream ss; - ss << "pattern " << number << " ?\r\n"; - std::string msg = ss.str(); - - ClassError::Error response = sendMsg(msg); - + ClassError::Error response = sendMsg(commands::ClassCommands::CMD_CONFIGPATTERN + std::to_string(number) + commands::ClassCommands::CMD_AUX2 + commands::ClassCommands::CMD_AUX); if (patternstatus_mutex_.try_lock()) { is_waiting_patternstatus_ = true; diff --git a/src/commands.h b/src/commands.h index 4be2337ca0f165523061120e444eb8884c4a826a..3e1373bc34693d50a6477715e7deac7c833a537d 100644 --- a/src/commands.h +++ b/src/commands.h @@ -21,6 +21,7 @@ namespace commands static std::string ClassCommands::CMD_CONFIGACQ_PARAM1; static std::string ClassCommands::CMD_CONFIGACQ_PARAM2; static std::string ClassCommands::CMD_CONFIGACQ_PARAM3; + static std::string ClassCommands::CMD_CONFIGVELEC_PARAM4; static std::string ClassCommands::CMD_VELEC_SELECTED; static std::string ClassCommands::CMD_VELEC_NOTSELECTED; @@ -28,6 +29,7 @@ namespace commands static std::string ClassCommands::CMD_ONSTIM; static std::string ClassCommands::CMD_OFFSTIM; + static std::string ClassCommands::CMD_VELECSTIM; static std::string ClassCommands::CMD_CONFIGELEC; @@ -77,7 +79,7 @@ namespace commands static std::string ClassCommands::CMD_GETDEVICENAME; static std::string ClassCommands::CMD_GETLOGEVENTS; //velec - //pattern + static std::string ClassCommands::CMD_GETPATTERN; static std::string ClassCommands::CMD_GETHV; static std::string ClassCommands::CMD_GETINTERVAL; static std::string ClassCommands::CMD_GETRTC; @@ -91,7 +93,7 @@ namespace commands static std::string ClassCommands::CMD_BUFFERFLUSH; static std::string ClassCommands::CMD_AUX; - + static std::string ClassCommands::CMD_AUX2; diff --git a/src/commands.lib b/src/commands.lib index 7d1f2e090cd325b4b83bccd9daae96df7f147ce8..2c6c5c1789c267362d537d5567966680fba04819 100644 Binary files a/src/commands.lib and b/src/commands.lib differ