To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit f9f3d40e authored by beuchatp's avatar beuchatp
Browse files

The Coordinator refresh button now correctly detects what nodes are in existence

parent d6f7d018
......@@ -5,6 +5,7 @@
#include <QWidget>
#include <QVector>
#include <regex>
namespace Ui {
class Coordinator;
......@@ -21,6 +22,8 @@ public:
private:
QVector<CoordinatorRow*> vector_of_coordinatorRows;
void remove_all_entries_from_vector_of_coordinatorRows();
private slots:
void on_refresh_button_clicked();
......
......@@ -17,9 +17,64 @@ Coordinator::~Coordinator()
void Coordinator::on_refresh_button_clicked()
{
// DELETE ALL EXISTING ROWS
remove_all_entries_from_vector_of_coordinatorRows();
for ( int i_agent = 1 ; i_agent < 11 ; i_agent++ )
#ifdef CATKIN_MAKE
// USE A REGULAR EXPRESSION TO IDENTIFY NODES THAT EXIST
// > The regular expression we use is: \/agent(\d\d\d)\/PPSClient
// with the different that the escaped character is \\ instead of \ only
// GET A "V_string" OF ALL THE NODES CURRENTLY IN EXISTENCE
ros::V_string v_str;
ros::master::getNodes(v_str);
// ITERATE THROUGH THIS "V_string" OF ALL NODE IN EXISTENCE
for(int i = 0; i < v_str.size(); i++)
{
// TEST THE NAME OF THIS NODE AGAINST THE REGULAR EXPRESSION
std::string s = v_str[i];
std::smatch m;
std::regex e ("\\/agent(\\d\\d\\d)\\/PPSClient");
if(std::regex_search(s, m, e))
{
// GET THE MATCHED PART OF THE NODE NAME INTO A LOCAL VARIABLE
// > Note: we use m[1] because we are interested ONLY in the first match
// > Thus "found_string" should the the agentID, as a string with zero padding
std::string found_string = m[1].str();
// LET THE USER KNOW THAT WE FOUND A MATCH
ROS_INFO_STREAM("[Coordinator Row GUI] Found an agent with ID = " << found_string.c_str() );
// CONVERT THE STRING TO AN INTEGER
int this_agentID = stoi(found_string);
// ADD A ROW TO THE COORDINATOR FOR THE AGENT WITH THIS ID FOUND
CoordinatorRow *temp_coordinatorRow = new CoordinatorRow(this,this_agentID);
// Check the box if "coordinate all" is checked
if (ui->coordinate_all_checkBox->isChecked())
{
temp_coordinatorRow->setShouldCoordinate(true);
}
else
{
temp_coordinatorRow->setShouldCoordinate(false);
}
// Add to the vector of coordinator rows
vector_of_coordinatorRows.append(temp_coordinatorRow);
ui->coordinated_agents_scrollAreaWidgetContents->layout()->addWidget(temp_coordinatorRow);
}
}
#else
for ( int i_agent = 1 ; i_agent < 9 ; i_agent++ )
{
//ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout);
......@@ -40,17 +95,23 @@ void Coordinator::on_refresh_button_clicked()
ui->coordinated_agents_scrollAreaWidgetContents->layout()->addWidget(temp_coordinatorRow);
}
#endif
}
void Coordinator::on_delete_button_clicked()
{
// Call the function that performs the task requested
remove_all_entries_from_vector_of_coordinatorRows();
}
void Coordinator::remove_all_entries_from_vector_of_coordinatorRows()
{
// Iterate through and delete all entries
foreach ( CoordinatorRow* temp_coordinatorRow, vector_of_coordinatorRows) {
delete( temp_coordinatorRow );
}
// Clear the vector
vector_of_coordinatorRows.clear();
}
void Coordinator::on_coordinate_all_checkBox_clicked()
......
......@@ -105,8 +105,9 @@ CoordinatorRow::CoordinatorRow(QWidget *parent, int agentID) :
// LET THE USER KNOW WHAT THE BASE NAMESPACE IS
ROS_INFO_STREAM("[Coordinator Row GUI] using base namespace: " << ros_base_namespace.c_str() << ", for agentID = " << my_agentID);
std::string temp_ros_namespace = ros::this_node::getNamespace();
ROS_INFO_STREAM("[Coordinator Row GUI] compared to: ros::this_node::getNamespace() = " << temp_ros_namespace.c_str());
// DEBUGGING FOR NAMESPACES
//std::string temp_ros_namespace = ros::this_node::getNamespace();
//ROS_INFO_STREAM("[Coordinator Row GUI] compared to: ros::this_node::getNamespace() = " << temp_ros_namespace.c_str());
// CREATE A NODE HANDLE TO THE BASE NAMESPACE
ros::NodeHandle base_nodeHandle(ros_base_namespace);
......
......@@ -522,17 +522,17 @@ void MainWindow::setCrazyRadioStatus(int radio_status)
ui->voltage_field->setText(qstr);
voltage_field_mutex.unlock();
// SET THE APPROPRIATE IMAGE FOR THE BATTERY STATUS LABEL
battery_status_label_mutex.lock();
if (m_battery_label_image_current_index != BATTERY_LABEL_IMAGE_INDEX_UNKNOWN)
{
battery_status_label_mutex.lock();
ui->battery_status_label->clear();
QPixmap battery_unknown_pixmap(":/images/battery_unknown.png");
ui->battery_status_label->setPixmap(battery_unknown_pixmap);
ui->battery_status_label->setScaledContents(true);
m_battery_label_image_current_index = BATTERY_LABEL_IMAGE_INDEX_UNKNOWN;
ui->battery_status_label->update();
battery_status_label_mutex.unlock();
}
battery_status_label_mutex.unlock();
// DISABLE THE REMAINDER OF THE GUI
disableGUI();
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment