// Use async tasks because adding/removing HubInfos require calls to ClientListener (which is likely // to cause deadlocks if done inside ClientManagerListener) void HubApi::on(ClientManagerListener::ClientCreated, const ClientPtr& aClient) noexcept { addAsyncTask([=] { addHub(aClient); if (!subscriptionActive("hub_created")) { return; } send("hub_created", serializeClient(aClient)); }); }
void LedManager::loadSettings(ofxXmlSettings settings) { settings.pushTag("leds"); int loadedHubs = settings.getNumTags("hub"); printf("Loaded hubs %i\n",loadedHubs); for(int i=0;i<loadedHubs;i++) { addHub(settings,i); //hubs[i]->loadSettings(settings,i); } settings.popTag(); updateLedCount(); updatePositions(); updateLedMap(); }
/******************************************************************** * Main SCAN algorithm ********************************************************************/ void Scan::run(const double epsilon, const int mi) { // All vertices begin unclassified // So let's begin. We will iterate the labels list. In no moment // can a label became "unclassified" again, so this loop will // do the trick. hmap::iterator node; uint cnt = 0; for (node = g.graph_map.begin(); node != g.graph_map.end(); ++node) { // Making sure this node was not yet evaluated if (getClusterLabel(node->first) == -1) { // Is it a core? if (isCore(node->first, epsilon, mi)) { //std::cout << node->first << " is a core!\n"; // Will begin a new cluster int cid = getNewClusterID(); // Put all the e-neighborhood of the node in a queue std::set<Edge> x; x = neighborhood(node->first, epsilon); std::queue<uint> q; std::set<Edge>::iterator it; //std::cout << node->first << " nhood is:"; for (it = x.begin(); it != x.end(); ++it) { //std::cout << " " << it->getNode() << std::endl; q.push(it->getNode()); } while (!q.empty()) { uint y = q.front(); q.pop(); std::set<Edge> r; r = dirReach(y, epsilon, mi); std::set<Edge>::iterator setIt; for (setIt = r.begin(); setIt != r.end(); ++setIt) { // If the node is unclassified if (getClusterLabel(setIt->getNode()) == -1) { addToCluster(setIt->getNode(), cid); q.push(setIt->getNode()); } // If the node is a non-member of the cluster if (getClusterLabel(setIt->getNode()) == 0) { addToCluster(setIt->getNode(), cid); } } } } else { // Not a Core, so it will be labeled as non-member (0) setClusterLabel(node->first, 0); } } else { // Node already evaluated. Move along. continue; } } // Further classifies non-members hmap_ii::iterator nmnode; for (nmnode = cluster_label.begin(); nmnode != cluster_label.end(); ++nmnode) { if (nmnode->second == 0) { std::set<uint> tmp; tmp = getNeighborClusters(nmnode->first); if (tmp.size() > 1) { addHub(nmnode->first, tmp); } else { std::pair<uint, uint> o(nmnode->first,*tmp.begin()); outliers.push_back(o); } } } std::cout << "SCAN finished."; std::cout << std::endl; }