From 2f503154635dcaa4ad854da57abfb71d6e5c8483 Mon Sep 17 00:00:00 2001 From: Georges Labreche Date: Wed, 23 Oct 2019 19:09:54 +0200 Subject: [PATCH 1/6] [ADE-73]: Connectors Plugin: setting properties from config, interpreting 'mating: automatic' property, and loading plugin by default. --- app/manifest.xml | 1 + app/src/MARS.cpp | 1 + plugins/connectors/README.md | 66 +++++++++++++++++++++++++++ plugins/connectors/build.sh | 16 +++++++ plugins/connectors/src/Connectors.cpp | 66 ++++++++++++++++++++++----- plugins/connectors/src/Connectors.h | 13 +++++- 6 files changed, 150 insertions(+), 13 deletions(-) create mode 100644 plugins/connectors/README.md create mode 100644 plugins/connectors/build.sh diff --git a/app/manifest.xml b/app/manifest.xml index 305563900..a69570faf 100644 --- a/app/manifest.xml +++ b/app/manifest.xml @@ -25,6 +25,7 @@ + needs_opt diff --git a/app/src/MARS.cpp b/app/src/MARS.cpp index 8e588a0e2..264e35654 100644 --- a/app/src/MARS.cpp +++ b/app/src/MARS.cpp @@ -212,6 +212,7 @@ namespace mars { libManager->loadLibrary("CameraGUI", NULL, true); libManager->loadLibrary("PythonMars", NULL, true); libManager->loadLibrary("data_broker_plotter2", NULL, true); + libManager->loadLibrary("connectors", NULL, true); } } } diff --git a/plugins/connectors/README.md b/plugins/connectors/README.md new file mode 100644 index 000000000..9b70e0506 --- /dev/null +++ b/plugins/connectors/README.md @@ -0,0 +1,66 @@ +# Connectors Plugin + +## What is this? +This plugin mates male and female connectors that are close to each other. Parameters for proximity thresholds are set for distance and angle in a connectors YAML of a model's smurf export. + +## Sample configuration YAML: + +```yaml + connectors: + autoconnect: true + types: + - name: transterra + distance: 0.15 + angle: 3.1415 + maxforce: 100 + + connectors: + - gender: male + link: male_connector + mating: automatic + name: payload_male_connector + type: transterra + - gender: female + link: female_connector + mating: automatic + name: payload_female_connector + type: transterra +``` + +## GUI + +### Control +Connector connections can be manually enabled or disabled from the plugin's interface: + - Control > Connect available connectors. + - Control > Disconnect all connectors. + + +### Properties +Global autoconnect can be set from the Plugin properties interface. + +## Mating requirements + +There are 2 cases that will trigger checking for connections: + 1. When it is forced from the Control GUI: Control > Connect available connectors + 2. During plugin update(): **If** autoconnect is globally set to true **or if** male **and** female connectors' mating properties are both set to `automatic`. + +## Truth table + + | case | autoconnect | male mating | female mating | connected | + |------|-------------|-------------|---------------|-----------| + | 1 | F | automatic | - | F | + | 2 | F | - | automatic | F | + | 3 | F | - | - | F | + | 4 | F | automatic | automatic | T | + | 5 | T | automatic | - | T | + | 6 | T | - | automatic | T | + | 7 | T | - | - | T | + | 8 | T | automatic | automatic | T | + +## Known issues +Known issues with the sample YAML showcased in this README, + - Female mating is always set as 'automatic' no matter the actual value set in the YAML. This results in a failure of truth table case 1. + - Manual disconnect does not work for truth table cases 1, 4, 5, 6, 7, and 8. + - Issues with cases 1 and 5 are due to the previously mentioned female mating issue. + - Cases 6 and 7 will work after setting autoconnect to false. This issue already existed in the previous version of this plugin. + - Cases 4 and 8 never work due to the update() method always checking for connections. diff --git a/plugins/connectors/build.sh b/plugins/connectors/build.sh new file mode 100644 index 000000000..2f92955d6 --- /dev/null +++ b/plugins/connectors/build.sh @@ -0,0 +1,16 @@ +#! /bin/bash + +echo -e "\033[32;1m" +echo "********** build MARS plugin **********" +echo -e "\033[0m" + +rm -rf build +mkdir build +cd build +cmake_debug +make -j4 +cd .. + +echo -e "\033[32;1m" +echo "********** done building MARS plugin **********" +echo -e "\033[0m" diff --git a/plugins/connectors/src/Connectors.cpp b/plugins/connectors/src/Connectors.cpp index 599325636..7e296f067 100644 --- a/plugins/connectors/src/Connectors.cpp +++ b/plugins/connectors/src/Connectors.cpp @@ -49,13 +49,16 @@ namespace mars { } void Connectors::init() { + const std::map* entities = control->entities->subscribeToEntityCreation(this); for (std::map::const_iterator it = entities->begin(); it != entities->end(); ++it) { + // Regsiter the entity. registerEntity(it->second); } + if(control->cfg) { - cfgautoconnect = control->cfg->getOrCreateProperty("Connectors", "autoconnect", false, this); - cfgbreakable = control->cfg->getOrCreateProperty("Connectors", "breakable", false, this); + cfgautoconnect = control->cfg->getOrCreateProperty("Connectors", "autoconnect", autoconnect, this); + cfgbreakable = control->cfg->getOrCreateProperty("Connectors", "breakable", breakable, this); } else { cfgautoconnect.bValue = false; @@ -66,6 +69,9 @@ namespace mars { gui->addGenericMenuAction("../Control/Disconnect all connectors", 2, this); //maleconnectors.clear(); //femaleconnectors.clear(); + + LOG_INFO("Connectors Plugin: init was successful."); + } void Connectors::connect(std::string male, std::string female) { @@ -125,6 +131,17 @@ namespace mars { void Connectors::registerEntity(sim::SimEntity* entity) { configmaps::ConfigMap entitymap = entity->getConfig(); if (entitymap.hasKey("connectors")) { + + if(entitymap["connectors"].hasKey("autoconnect")){ + // Set configured value for autoconnect. + autoconnect = (((std::string)entitymap["connectors"]["autoconnect"]).compare("true") == 0); + } + + // Set configured value for breakable. + if(entitymap["connectors"].hasKey("breakable")){ + breakable = (((std::string)entitymap["connectors"]["breakable"]).compare("true") == 0); + } + configmaps::ConfigMap tmpmap; // gather types configmaps::ConfigVector typevec = entitymap["connectors"]["types"]; @@ -171,29 +188,54 @@ namespace mars { } - void Connectors::checkForPossibleConnections() { - std::string malename, femalename, maletype, femaletype; + void Connectors::checkForPossibleConnections(bool isforced) { + // Connector properties. + std::string malename, femalename, maletype, femaletype, maleautoconnect, femaleautoconnect; + + // Merge type to check against. + std::string automatic ("automatic"); + + // Nested for loop to check for every male-female connector mating combination. for (std::map::iterator mit= maleconnectors.begin(); mit!=maleconnectors.end(); ++mit) { + + // Get male connector properties. malename = (std::string)mit->second["name"]; maletype = (std::string)mit->second["type"]; + maleautoconnect = (std::string)mit->second["mating"]; + for (std::map::iterator fit= femaleconnectors.begin(); fit!=femaleconnectors.end(); ++fit) { + + // Get female connector properties. femalename = (std::string)fit->second["name"]; femaletype = (std::string)fit->second["type"]; - if (maletype.compare(femaletype) == 0 && mated(malename, femalename) - && ((std::string)mit->second["partner"]).empty() && ((std::string)fit->second["partner"]).empty()) { - connect(malename, femalename); + femaleautoconnect = (std::string)fit->second["mating"]; + + // There are 2 cases that will trigger checking for connections: + // 1. When it is forced from the Control GUI: Control > Connect available connectors + // 2. During plugin update(): IF autoconnect is globally set to true OR IF male and female's mating properties are both set to automatic. + if(isforced || (cfgautoconnect.bValue || (maleautoconnect.compare(automatic) == 0 && femaleautoconnect.compare(automatic) == 0))){ + + // Check if connectors meet the mating requirements: + // 1. They are of the same type. + // 2. They are close enough to each other (distance and angle) as per the set thresholds in the model's YML config file. + // 3. They are not already connected to each other. + if (maletype.compare(femaletype) == 0 && mated(malename, femalename) + && ((std::string)mit->second["partner"]).empty() && ((std::string)fit->second["partner"]).empty()) { + + // All mating requirements have been met. Mate the connectors. + connect(malename, femalename); } } + } } } - void Connectors::update(sReal time_ms) { - if (cfgautoconnect.bValue) { - checkForPossibleConnections(); - } + + checkForPossibleConnections(false); + // the following is experimental and not working yet if (cfgbreakable.bValue) { for (std::map::iterator it = connections.begin(); it!=connections.end(); ++it) { @@ -222,7 +264,7 @@ namespace mars { void Connectors::menuAction(int action, bool checked) { if(action == 1) { - checkForPossibleConnections(); + checkForPossibleConnections(true); } else if (action == 2) { for (std::map::iterator it = connections.begin(); it!=connections.end(); ++it) { disconnect(it->first); diff --git a/plugins/connectors/src/Connectors.h b/plugins/connectors/src/Connectors.h index 424f20a7b..1d68c544a 100644 --- a/plugins/connectors/src/Connectors.h +++ b/plugins/connectors/src/Connectors.h @@ -87,14 +87,25 @@ namespace mars { void registerEntity(sim::SimEntity* entity); private: + // By default, the plugins's autoconnect and breakable properties are false. + bool autoconnect = false; + bool breakable = false; + cfg_manager::cfgPropertyStruct cfgautoconnect, cfgbreakable; std::map maleconnectors; std::map femaleconnectors; std::map connectortypes; std::map connections; bool mated(std::string malename, std::string femalename); - void checkForPossibleConnections(); + /** + * Checks every male-female connector mating combination and mates all + * the pairs that meet the mating requirements. + * + * @param isforced Connection check is triggered from the Control GUI. + */ + void checkForPossibleConnections(bool isforced); + //void checkForPossibleConnections(); }; // end of class definition Connectors From 9b7fb6ec4839673950715bb91e0a54ca5efc76ab Mon Sep 17 00:00:00 2001 From: Georges Labreche Date: Thu, 24 Oct 2019 05:44:36 +0200 Subject: [PATCH 2/6] [ADE-73] Used thread to fix manual disconnection when autoconnect is set to true. --- plugins/connectors/README.md | 10 ++-- plugins/connectors/src/Connectors.cpp | 74 ++++++++++++++++++++++----- plugins/connectors/src/Connectors.h | 14 ++++- 3 files changed, 76 insertions(+), 22 deletions(-) diff --git a/plugins/connectors/README.md b/plugins/connectors/README.md index 9b70e0506..f32214012 100644 --- a/plugins/connectors/README.md +++ b/plugins/connectors/README.md @@ -57,10 +57,6 @@ There are 2 cases that will trigger checking for connections: | 7 | T | - | - | T | | 8 | T | automatic | automatic | T | -## Known issues -Known issues with the sample YAML showcased in this README, - - Female mating is always set as 'automatic' no matter the actual value set in the YAML. This results in a failure of truth table case 1. - - Manual disconnect does not work for truth table cases 1, 4, 5, 6, 7, and 8. - - Issues with cases 1 and 5 are due to the previously mentioned female mating issue. - - Cases 6 and 7 will work after setting autoconnect to false. This issue already existed in the previous version of this plugin. - - Cases 4 and 8 never work due to the update() method always checking for connections. +## Known issue +Female mating is always set as 'automatic' no matter the actual value set in the YAML. This results in a failure of truth table case 1. +This can be replicated with the sample YAML featured in this README. diff --git a/plugins/connectors/src/Connectors.cpp b/plugins/connectors/src/Connectors.cpp index 7e296f067..098734730 100644 --- a/plugins/connectors/src/Connectors.cpp +++ b/plugins/connectors/src/Connectors.cpp @@ -44,8 +44,12 @@ namespace mars { using namespace mars::utils; using namespace mars::interfaces; - Connectors::Connectors(lib_manager::LibManager *theManager) - : MarsPluginTemplateGUI(theManager, "Connectors") { + // To manage thread shared resources. + std::atomic isDisconnectionTriggered(false); + + Connectors::Connectors(lib_manager::LibManager *theManager) : + MarsPluginTemplateGUI(theManager, "Connectors"), + mars::utils::Thread() { } void Connectors::init() { @@ -70,10 +74,45 @@ namespace mars { //maleconnectors.clear(); //femaleconnectors.clear(); + // Start thread loop. + // This tread will diconnect connections when they are triggered by the user from the Control GUI. + // At the same time, it prevents the plugin' update() method from invoking checkForPossibleConnections(). + start(); + LOG_INFO("Connectors Plugin: init was successful."); } + void Connectors::run() { + // This thread is an infinite loop that checks if connections need to be disconnected and proceesds in + // disconnecting them if they do. + // This logic essentially prevents the update() method from invoking checkForPossibleConnections().' + while(true){ + + // Has disconnection been triggered by the user via the Control GUI? + if(isDisconnectionTriggered.load()){ + + // If so, then disconnect all connections. + for (std::map::iterator it = connections.begin(); it!=connections.end(); ++it) { + disconnect(it->first); + } + + // Sleep for a bit to allow time for disconnects to physically detach by falling far enough so that a + // reconnection is not just retriggered automatically if autoconnect is set to true. + msleep(100); + + // Set atomic boolean to indicate that we are done with the disconnection. + // The plugin's update() call can continue invoking checkForPossibleConnections(). + isDisconnectionTriggered = false; + + }else{ + + // Sleep for a bit before checking again if a disconnection was triggered by the user. + msleep(100); + } + } + } + void Connectors::connect(std::string male, std::string female) { fprintf(stderr, "Create connection: %s, %s\n", male.c_str(), female.c_str()); interfaces::JointData jointdata; @@ -92,6 +131,10 @@ namespace mars { } } + // This ia a shared resources. + // When invokating, make sure to wrap with !isDisconnectionTriggered.load(). + // The method itself is not wrapped because more often than not it is contained in a for loop + // so it is best to wrap the for loop rather than every invokation of this method within the for loop. void Connectors::disconnect(std::string connector) { configmaps::ConfigMap* conmap = NULL; unsigned long jointid = 0; @@ -128,6 +171,7 @@ namespace mars { (it->second)["partner"] = ""; } } + void Connectors::registerEntity(sim::SimEntity* entity) { configmaps::ConfigMap entitymap = entity->getConfig(); if (entitymap.hasKey("connectors")) { @@ -156,8 +200,7 @@ namespace mars { tmpmap["nodeid"] = control->nodes->getID((*it)["link"]); if (((std::string)((*it)["gender"])).compare("male") == 0) { // male maleconnectors[(std::string)(tmpmap["name"])] = tmpmap; - fprintf(stderr, "Adding male connector: %s\n", ((std::string)(tmpmap["name"])).c_str(), - (unsigned long)(tmpmap["nodeid"])); + fprintf(stderr, "Adding male connector: %s\n", ((std::string)(tmpmap["name"])).c_str(), (unsigned long)(tmpmap["nodeid"])); } else { // female femaleconnectors[(std::string)(tmpmap["name"])] = tmpmap; fprintf(stderr, "Adding female connector: %s\n", ((std::string)(tmpmap["name"])).c_str()); @@ -234,15 +277,19 @@ namespace mars { void Connectors::update(sReal time_ms) { - checkForPossibleConnections(false); + if(!isDisconnectionTriggered.load()){ + checkForPossibleConnections(false); + } // the following is experimental and not working yet if (cfgbreakable.bValue) { - for (std::map::iterator it = connections.begin(); it!=connections.end(); ++it) { - utils::Vector forcevec = control->joints->getSimJoint(maleconnectors[it->first]["jointid"])->getJointLoad(); - //fprintf(stderr, "JointLoad: %g\n", forcevec.norm()); - if (forcevec.norm() > (double)(connectortypes[maleconnectors[it->first]["type"]]["maxforce"])) { - disconnect(it->first); + if(!isDisconnectionTriggered.load()){ + for (std::map::iterator it = connections.begin(); it!=connections.end(); ++it) { + utils::Vector forcevec = control->joints->getSimJoint(maleconnectors[it->first]["jointid"])->getJointLoad(); + //fprintf(stderr, "JointLoad: %g\n", forcevec.norm()); + if (forcevec.norm() > (double)(connectortypes[maleconnectors[it->first]["type"]]["maxforce"])) { + disconnect(it->first); + } } } } @@ -265,10 +312,11 @@ namespace mars { void Connectors::menuAction(int action, bool checked) { if(action == 1) { checkForPossibleConnections(true); + } else if (action == 2) { - for (std::map::iterator it = connections.begin(); it!=connections.end(); ++it) { - disconnect(it->first); - } + // Use atomic boolean to flag the thread that it should disconnect connections. + // Setting this atomic boolean to true will also prevent the plugin's update method from invoking checkForPossibleConnections(). + isDisconnectionTriggered = true; } } diff --git a/plugins/connectors/src/Connectors.h b/plugins/connectors/src/Connectors.h index 1d68c544a..78bc93b1b 100644 --- a/plugins/connectors/src/Connectors.h +++ b/plugins/connectors/src/Connectors.h @@ -42,6 +42,10 @@ #include #include +// Threads. +#include +#include + #include namespace mars { @@ -53,7 +57,8 @@ namespace mars { public mars::data_broker::ReceiverInterface, public mars::main_gui::MenuInterface, public mars::cfg_manager::CFGClient, - public mars::interfaces::EntitySubscriberInterface { + public mars::interfaces::EntitySubscriberInterface, + public mars::utils::Thread { public: Connectors(lib_manager::LibManager *theManager); @@ -86,6 +91,12 @@ namespace mars { // Connectors methods void registerEntity(sim::SimEntity* entity); + /** + * This tread will diconnect connections when they are triggered by the user from the Control GUI. + * At the same time, it prevents the plugin' update() method from invoking checkForPossibleConnections(). + */ + void run(void); + private: // By default, the plugins's autoconnect and breakable properties are false. bool autoconnect = false; @@ -105,7 +116,6 @@ namespace mars { * @param isforced Connection check is triggered from the Control GUI. */ void checkForPossibleConnections(bool isforced); - //void checkForPossibleConnections(); }; // end of class definition Connectors From a6855a15164722bf493a8a821c90f1693546ef48 Mon Sep 17 00:00:00 2001 From: Georges Labreche Date: Fri, 25 Oct 2019 22:06:45 +0200 Subject: [PATCH 3/6] [ADE-73] Removed loading of connectors plugin by default. --- app/src/MARS.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/MARS.cpp b/app/src/MARS.cpp index 264e35654..8e588a0e2 100644 --- a/app/src/MARS.cpp +++ b/app/src/MARS.cpp @@ -212,7 +212,6 @@ namespace mars { libManager->loadLibrary("CameraGUI", NULL, true); libManager->loadLibrary("PythonMars", NULL, true); libManager->loadLibrary("data_broker_plotter2", NULL, true); - libManager->loadLibrary("connectors", NULL, true); } } } From 7a74f36c5f4a76331298fb154089e3e320344cf8 Mon Sep 17 00:00:00 2001 From: Georges Labreche Date: Fri, 25 Oct 2019 22:19:19 +0200 Subject: [PATCH 4/6] [ADE-73] Removed externalization of autoconnect. Increase sleep time after disconnect is triggered. --- plugins/connectors/src/Connectors.cpp | 21 ++++++++------------- plugins/connectors/src/Connectors.h | 4 ---- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/plugins/connectors/src/Connectors.cpp b/plugins/connectors/src/Connectors.cpp index 098734730..62f639ed5 100644 --- a/plugins/connectors/src/Connectors.cpp +++ b/plugins/connectors/src/Connectors.cpp @@ -61,13 +61,14 @@ namespace mars { } if(control->cfg) { - cfgautoconnect = control->cfg->getOrCreateProperty("Connectors", "autoconnect", autoconnect, this); - cfgbreakable = control->cfg->getOrCreateProperty("Connectors", "breakable", breakable, this); + cfgautoconnect = control->cfg->getOrCreateProperty("Connectors", "autoconnect", false, this); + cfgbreakable = control->cfg->getOrCreateProperty("Connectors", "breakable", false, this); } else { cfgautoconnect.bValue = false; cfgbreakable.bValue = false; } + gui->addGenericMenuAction("../Control/", 0, NULL, 0, "", 0, -1); // separator gui->addGenericMenuAction("../Control/Connect available connectors", 1, this); gui->addGenericMenuAction("../Control/Disconnect all connectors", 2, this); @@ -99,7 +100,7 @@ namespace mars { // Sleep for a bit to allow time for disconnects to physically detach by falling far enough so that a // reconnection is not just retriggered automatically if autoconnect is set to true. - msleep(100); + msleep(300); // Set atomic boolean to indicate that we are done with the disconnection. // The plugin's update() call can continue invoking checkForPossibleConnections(). @@ -173,26 +174,20 @@ namespace mars { } void Connectors::registerEntity(sim::SimEntity* entity) { + configmaps::ConfigMap entitymap = entity->getConfig(); if (entitymap.hasKey("connectors")) { - if(entitymap["connectors"].hasKey("autoconnect")){ - // Set configured value for autoconnect. - autoconnect = (((std::string)entitymap["connectors"]["autoconnect"]).compare("true") == 0); - } - - // Set configured value for breakable. - if(entitymap["connectors"].hasKey("breakable")){ - breakable = (((std::string)entitymap["connectors"]["breakable"]).compare("true") == 0); - } - configmaps::ConfigMap tmpmap; + // gather types configmaps::ConfigVector typevec = entitymap["connectors"]["types"]; + for (configmaps::ConfigVector::iterator it = typevec.begin(); it!= typevec.end(); ++it) { tmpmap = (*it); connectortypes[(*it)["name"]] = tmpmap; // the one last read in determines the type } + // gather connectors configmaps::ConfigVector convec = entitymap["connectors"]["connectors"]; for (configmaps::ConfigVector::iterator it = convec.begin(); it!= convec.end(); ++it) { diff --git a/plugins/connectors/src/Connectors.h b/plugins/connectors/src/Connectors.h index 78bc93b1b..9057d03a6 100644 --- a/plugins/connectors/src/Connectors.h +++ b/plugins/connectors/src/Connectors.h @@ -98,10 +98,6 @@ namespace mars { void run(void); private: - // By default, the plugins's autoconnect and breakable properties are false. - bool autoconnect = false; - bool breakable = false; - cfg_manager::cfgPropertyStruct cfgautoconnect, cfgbreakable; std::map maleconnectors; std::map femaleconnectors; From 14e5668966f0828971ad8fef3996b4cd5fc73edd Mon Sep 17 00:00:00 2001 From: Raul Dominguez Date: Tue, 29 Oct 2019 12:36:38 +0100 Subject: [PATCH 5/6] [ADE 73] Rename method mated to closeEnough because it describes better the functionality --- plugins/connectors/src/Connectors.cpp | 4 ++-- plugins/connectors/src/Connectors.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/connectors/src/Connectors.cpp b/plugins/connectors/src/Connectors.cpp index 62f639ed5..66f3047bf 100644 --- a/plugins/connectors/src/Connectors.cpp +++ b/plugins/connectors/src/Connectors.cpp @@ -210,7 +210,7 @@ namespace mars { Connectors::~Connectors() { } - bool Connectors::mated(std::string malename, std::string femalename) { + bool Connectors::closeEnough(std::string malename, std::string femalename) { unsigned long maleid = maleconnectors[malename]["nodeid"]; unsigned long femaleid = femaleconnectors[femalename]["nodeid"]; utils::Vector malerot = control->nodes->getRotation(maleid)*Vector(1.0, 0.0, 0.0); @@ -259,7 +259,7 @@ namespace mars { // 1. They are of the same type. // 2. They are close enough to each other (distance and angle) as per the set thresholds in the model's YML config file. // 3. They are not already connected to each other. - if (maletype.compare(femaletype) == 0 && mated(malename, femalename) + if (maletype.compare(femaletype) == 0 && closeEnough(malename, femalename) && ((std::string)mit->second["partner"]).empty() && ((std::string)fit->second["partner"]).empty()) { // All mating requirements have been met. Mate the connectors. diff --git a/plugins/connectors/src/Connectors.h b/plugins/connectors/src/Connectors.h index 9057d03a6..1af2812e5 100644 --- a/plugins/connectors/src/Connectors.h +++ b/plugins/connectors/src/Connectors.h @@ -103,7 +103,7 @@ namespace mars { std::map femaleconnectors; std::map connectortypes; std::map connections; - bool mated(std::string malename, std::string femalename); + bool closeEnough(std::string malename, std::string femalename); /** * Checks every male-female connector mating combination and mates all From 3f751ab992bf068359b37d2178c4fb471d530a1e Mon Sep 17 00:00:00 2001 From: Georges Labreche Date: Tue, 29 Oct 2019 13:18:51 +0100 Subject: [PATCH 6/6] [ADE-73] Renamed maleautoconnect and femaleautoconnect to malemating and femalemating. --- plugins/connectors/src/Connectors.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/connectors/src/Connectors.cpp b/plugins/connectors/src/Connectors.cpp index 66f3047bf..1a85a7272 100644 --- a/plugins/connectors/src/Connectors.cpp +++ b/plugins/connectors/src/Connectors.cpp @@ -228,7 +228,7 @@ namespace mars { void Connectors::checkForPossibleConnections(bool isforced) { // Connector properties. - std::string malename, femalename, maletype, femaletype, maleautoconnect, femaleautoconnect; + std::string malename, femalename, maletype, femaletype, malemating, femalemating; // Merge type to check against. std::string automatic ("automatic"); @@ -240,7 +240,7 @@ namespace mars { // Get male connector properties. malename = (std::string)mit->second["name"]; maletype = (std::string)mit->second["type"]; - maleautoconnect = (std::string)mit->second["mating"]; + malemating = (std::string)mit->second["mating"]; for (std::map::iterator fit= femaleconnectors.begin(); fit!=femaleconnectors.end(); ++fit) { @@ -248,12 +248,12 @@ namespace mars { // Get female connector properties. femalename = (std::string)fit->second["name"]; femaletype = (std::string)fit->second["type"]; - femaleautoconnect = (std::string)fit->second["mating"]; + femalemating = (std::string)fit->second["mating"]; // There are 2 cases that will trigger checking for connections: // 1. When it is forced from the Control GUI: Control > Connect available connectors // 2. During plugin update(): IF autoconnect is globally set to true OR IF male and female's mating properties are both set to automatic. - if(isforced || (cfgautoconnect.bValue || (maleautoconnect.compare(automatic) == 0 && femaleautoconnect.compare(automatic) == 0))){ + if(isforced || (cfgautoconnect.bValue || (malemating.compare(automatic) == 0 && femalemating.compare(automatic) == 0))){ // Check if connectors meet the mating requirements: // 1. They are of the same type.