/*! read server cababilities */ void SortLastWindow::clientInit( void ) { getNetwork()->getAspect()->addFieldFilter(Node::getClassType().getId(), Node::VolumeFieldMask); getNetwork()->getAspect()->addFieldFilter(Node::getClassType().getId(), Node::TravMaskFieldMask); // create default composer if(getComposer() == NULL) { /* FieldContainerPtr fcPtr = FieldContainerFactory::the()->createFieldContainer("BinarySwapComposer"); setComposer(ImageComposerPtr::dcast(fcPtr)); */ } if(getComposer() != NULL) { SortLastWindow *clusterWindow(this); getComposer()->setup(true, getMFServers()->size32(), getClientWindow(), clusterWindow); getComposer()->open(); // build node groups buildGroups(); } }
void Netlink::updateNodeScore(Vertex v) { AdjVertexIterator ut, utEnd; float score = 0.0; unsigned int i = 0; if(flagVerbose) { std::cout << "Checking node " << getNetwork().getVertexName(v) << std::endl; } for(boost::tie(ut, utEnd) = getNetwork().getAdjacentVertexIteratorOfVertex(v); ut != utEnd; ++ut) { if(v != *ut) { // Skip self edges if(flagVerbose) { std::cout << "- Score from neighbor " << getNetwork().getVertexName(*ut) << ": " << getNetwork().getVertexScore(*ut) << std::endl; } score += getNetwork().getVertexScore(*ut); i += 1; } } // Scale by number of neighbors //if(i!=0) score /= i; if(score >= threshold) { score = 1.0; } else { score = 0.0; } if(flagAccumulateToInitialNodeScore) { score += getNetwork().getVertexScore(v); } setVertexScoreUpdated(v, score); return; }
void MultipleNetwork::getEdges(std::set<global_edge_id>& edges) { for (int network = 0; network < getNumNetworks(); network++) { std::set<vertex_id> vertexes; getNetwork(network)->getVertexes(vertexes); for (std::set<vertex_id>::iterator from_iterator = vertexes.begin(); from_iterator != vertexes.end(); from_iterator++) { vertex_id local_from = *from_iterator; std::set<vertex_id> out_neighbors; getNetwork(network)->getOutNeighbors(local_from, out_neighbors); for (std::set<vertex_id>::iterator to_iterator = out_neighbors.begin(); to_iterator != out_neighbors.end(); to_iterator++) { vertex_id local_to = *to_iterator; edges.insert(global_edge_id(getGlobalVertexId(local_from,network),getGlobalVertexId(local_to,network),getNetwork(network)->isDirected(),network)); } } } }
Buffer * DB::getBuffer(const std::string & netName, const std::string & name, const bool create) { for (Buffer & buf : buffers) { if (buf.name == name && getNetwork(buf.networkid)->name == netName) { return &buf; } } if (create) { Buffer buf; buf.networkid = getNetwork(netName, true)->id; buf.name = name; return addBuffer(buf); } return NULL; }
void CParrotControllerApp::createThread() { CParrotControllerThread* thread = new CParrotControllerThread; PARROT_MODE mode; unsigned int beaconTime, turnaroundTime; wxString beaconFileName; bool keepFile; getMode(mode, beaconTime, beaconFileName, turnaroundTime, keepFile); thread->setMode(mode, beaconTime, beaconFileName, turnaroundTime, keepFile); wxLogInfo(wxT("Mode set to %d, beacon time set to %u secs, beacon file name set to %s, turnaround time set to %u secs, keep file set to %d"), mode, beaconTime, beaconFileName.c_str(), turnaroundTime, keepFile); wxString repeaterAddress, localAddress; unsigned int repeaterPort, localPort; getNetwork(repeaterAddress, repeaterPort, localAddress, localPort); wxLogInfo(wxT("Repeater set to %s:%u, local set to %s:%u"), repeaterAddress.c_str(), repeaterPort, localAddress.c_str(), localPort); if (!repeaterAddress.IsEmpty()) { CParrotControllerProtocolHandler* handler = new CParrotControllerProtocolHandler(repeaterAddress, repeaterPort, localAddress, localPort); bool res = handler->open(); if (!res) wxLogError(wxT("Cannot open the protocol handler")); else thread->setNetwork(handler); } // Convert the worker class into a thread m_thread = new CParrotControllerThreadHelper(thread); m_thread->start(); }
long MultipleNetwork::getNumEdges() { long number_of_edges = 0; for (int net=0; net<getNumNetworks(); net++) { number_of_edges += getNetwork(net)->getNumEdges(); } return number_of_edges; }
int ttDiscardUnsentMessages(int networkNbr) { NetworkInterface* nwi = getNetwork(networkNbr); if (nwi == NULL) { char buf[200]; sprintf(buf, "ttDiscardUnsentMessages: Network #%d not present!", networkNbr); TT_MEX_ERROR(buf); return -1; } RTnetwork *nwsys = nwi->nwsys; // get own network node handle NWnode *sender = nwsys->nwnodes[nwi->nodeNbr]; int nbr; // discard all messages from preprocQ nbr = deleteMessages((NWmsg *)sender->preprocQ->getFirst()); // The wireless network does not use the inputQ in the same way as the wired. if ( nwsys->type == CSMACD || nwsys->type == CSMAAMP || nwsys->type == RR || nwsys->type == FDMA || nwsys->type == TDMA || nwsys->type == SFDSE){ NWmsg *msg = (NWmsg *)sender->inputQ->getFirst(); // is the first inputQ message just being sent? if (nwsys->sending == nwi->nodeNbr) { // yes, discard all but the first if (msg != NULL) nbr += deleteMessages((NWmsg *)msg->getNext()); } else // no, discard whole inputQ nbr += deleteMessages(msg); } return nbr; }
void MeshRenderProcessorGLSR::updateDrawers() { auto changed = inport_.getChangedOutports(); DrawerMap temp; std::swap(temp, drawers_); std::map<const Outport*, std::vector<std::shared_ptr<const Mesh>>> data; for (auto& elem : inport_.getSourceVectorData()) { data[elem.first].push_back(elem.second); } for (auto elem : data) { auto ibegin = temp.lower_bound(elem.first); auto iend = temp.upper_bound(elem.first); if (util::contains(changed, elem.first) || ibegin == temp.end() || static_cast<long>(elem.second.size()) != std::distance(ibegin, iend)) { // data is changed or new. for (auto geo : elem.second) { auto factory = getNetwork()->getApplication()->getMeshDrawerFactory(); if (auto renderer = factory->create(geo.get())) { drawers_.emplace(std::make_pair(elem.first, std::move(renderer))); } } } else { // reuse the old data. drawers_.insert(std::make_move_iterator(ibegin), std::make_move_iterator(iend)); } } }
void MultiDisplayWindow::serverSwap(Window *window, UInt32 id) { Connection *connection; // clear command buffers UInt8 pixel[3]; glReadPixels(0,0, 1,1, GL_RGB,GL_UNSIGNED_BYTE, pixel); glFinish(); #if !FAST_SYNC connection=getNetwork()->getMainConnection(); if(!getInterleave()) { // tell client that we are finish connection->signal(); // wait for swap connection->wait(); } #endif Inherited::serverSwap(window,id); }
// For use from Matlab mex function mxArray *ttGetMsgMATLAB(int networkNbr, double* signalPower) { NetworkInterface* nwi = getNetwork(networkNbr); if (nwi == NULL) { // is there no network? char buf[200]; sprintf(buf, "ttGetMsg: Network #%d not present!", networkNbr); TT_MEX_ERROR(buf); return NULL; } NWmsg *nwmsg = nwGetMsg(nwi); if (nwmsg == NULL) { //debugPrintf("ttGetMsgMATLAB: no message to get\n"); *signalPower = 0; return NULL; } *signalPower = nwmsg->signalPower; mxArray *data = mxDuplicateArray(nwmsg->dataMATLAB); //mexMakeArrayPersistent(data); // Delete message delete nwmsg; return data; }
void ttUltrasoundPing(int networkNbr) { NetworkInterface* nwi = getNetwork(networkNbr); if (nwi == NULL) { char buf[200]; sprintf(buf, "ttUltrasoundPing: Network #%d not present!", networkNbr); TT_MEX_ERROR(buf); return; } NWmsg *nwmsg = new NWmsg(); nwmsg->sender = nwi->nodeNbr; nwmsg->receiver = -1; // broadcast nwmsg->length = 0; nwmsg->prio = 0; nwmsg->signalPower = 0.0; nwSendMsg(nwmsg, nwi->nwsys); if (rtsys->oldnwSnd[nwi->portNbr] == 0.0) { rtsys->nwSnd[nwi->portNbr] = 1.0; // trigger output } else { rtsys->nwSnd[nwi->portNbr] = 0.0; // trigger output } }
void *ttGetMsg(int networkNbr, double* signalPower) { void *data; NetworkInterface* nwi = getNetwork(networkNbr); if (nwi == NULL) { // is there no network? char buf[200]; sprintf(buf, "ttGetMsg: Network #%d not present!", networkNbr); TT_MEX_ERROR(buf); return NULL; } NWmsg *nwmsg = nwGetMsg(nwi); if (nwmsg == NULL) { *signalPower = 0; return NULL; } data = nwmsg->data; *signalPower = nwmsg->signalPower; // Delete message delete nwmsg; return data; }
STDMETHODIMP NATNetworkWrap::COMGETTER(Network)(BSTR *aNetwork) { LogRelFlow(("{%p} %s: enter aNetwork=%p\n", this, "NATNetwork::getNetwork", aNetwork)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aNetwork); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getNetwork(BSTROutConverter(aNetwork).str()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aNetwork=%ls hrc=%Rhrc\n", this, "NATNetwork::getNetwork", *aNetwork, hrc)); return hrc; }
void IServerApp::onExit() { for ( auto pp : m_vAllModule ) { pp.second->onExit(); } getNetwork()->RemoveAllDelegate(); }
int ttDiscardUnsentMessages() { NetworkInterface* nwi = getNetwork(1); if (nwi == NULL) { TT_MEX_ERROR("ttDiscardUnsentMessages: Network not present!"); return -1; } return ttDiscardUnsentMessages(1); }
void MultipleNetwork::map(global_vertex_id gvid, vertex_id lvid, int nid) { if (!containsVertex(gvid)) throw ElementNotFoundException("global vertex " + std::to_string(gvid)); if (!containsNetwork(nid)) throw ElementNotFoundException("network " + std::to_string(nid)); if (!getNetwork(nid)->containsVertex(lvid)) throw ElementNotFoundException("local vertex " + std::to_string(lvid)); if (global_to_local_id[gvid].count(nid)>0) throw DuplicateElementException("global vertex " + std::to_string(gvid) + " in network " + std::to_string(nid)); // We update the references between global and local identifiers global_to_local_id[gvid][nid] = lvid; local_to_global_id[nid][lvid] = gvid; }
void dialogCheckHardware::programInit() { connect(pushClose, SIGNAL(clicked()), this, SLOT(slotClose())); // Get the various hardware details getVideo(); getNetwork(); getSound(); }
void ttSetNetworkParameter(int networkNbr, char* parameter, double value) { Network* net = getNetwork(networkNbr); if (net == NULL) { char buf[200]; sprintf(buf, "ttSendMsg: Network #%d not present!", networkNbr); MEX_ERROR(buf); return; } //printf("%d\n",(int)net); nwSetNetworkParameter(net, parameter, value); }
void Netrank::run(unsigned int nIteration, float dFactor) { std::map<Vertex, float>::iterator vt, vtEnd; std::map<Vertex, float> mapRank; //getNetwork().calculatePageRank(mapRank, nIteration, dFactor); //getNetwork().calculatePageRankWithPriors(mapRank, nIteration, dFactor); getNetwork().calculatePageRankWithWeightedPriors(mapRank, nIteration, dFactor); float score = 0.0; for(vt = mapRank.begin(), vtEnd = mapRank.end(); vt != vtEnd; ++vt) { score = 0.0; if(flagAccumulateToInitialNodeScore) { score = getNetwork().getVertexScore(vt->first); } score += vt->second; getNetwork().setVertexScore(vt->first, score); } getNetwork().scaleVertexScores(SCALE_BETWEEN_ZERO_AND_ONE); getNetwork().outputScores(outputFile); return; }
void ttSendMsg(int networkNbr, int receiver, int length, void *data, mxArray *dataMATLAB) { NetworkInterface* nwi = getNetwork(networkNbr); if (nwi == NULL) { char buf[200]; sprintf(buf, "ttSendMsg: Network #%d not present!", networkNbr); TT_MEX_ERROR(buf); return; } int priority = nwi->nodeNbr; ttSendMsg(networkNbr, receiver, length, data, dataMATLAB, priority); }
/*! swap */ void SortLastWindow::clientSwap( void ) { if(getComposer() == NULL) { Connection *connection=getNetwork()->getMainConnection(); // wait for all servers to finish connection->wait(); // initiate swap connection->signal(); } Inherited::clientSwap(); }
void PCHierarchy::addNetwork( PCNetwork* net, string parent, Linkage link ) { // Check if parent exists if( hasNetwork( parent ) ) { // Check if parent's predictions line up with child's hypotheses if( link.checkPredictions( getNetwork( parent ) ) && link.checkHypotheses( net ) ) { links.push_back( link ); } } else { //TODO: error } }
/*! swap */ void SortLastWindow::serverSwap(Window *window, UInt32 id ) { if(getComposer() == NULL) { Connection *connection = getNetwork()->getMainConnection(); // tell client that we are finish connection->signal(); // wait for swap connection->wait(); } Inherited::serverSwap(window,id); }
/*! \fn */ bool Actor::isConnected(Actor* actor) { set<Actor* > *allAttached = getNetwork(NULL); if(allAttached->count(actor) == 0) { delete allAttached; return false; } delete allAttached; return true; }
void ttSendMsg(int networkNbr, int receiver, int length, void *data, mxArray *dataMATLAB, int priority) { NetworkInterface* nwi = getNetwork(networkNbr); if (nwi == NULL) { char buf[200]; sprintf(buf, "ttSendMsg: Network #%d not present!", networkNbr); TT_MEX_ERROR(buf); return; } if (receiver < 0 || receiver > nwi->nwsys->nbrOfNodes) { char buf[200]; sprintf(buf,"ttSendMsg: receiver number (%d) out of bounds!",receiver); TT_MEX_ERROR(buf); return; } if (data != NULL && dataMATLAB != NULL) { char buf[200]; sprintf(buf,"ttSendMsg: data and dataMATLAB cannot both be non-NULL!"); TT_MEX_ERROR(buf); return; } if (length < 0) { char buf[200]; sprintf(buf,"ttSendMsg: length cannot be negative!"); TT_MEX_ERROR(buf); return; } NWmsg *nwmsg = new NWmsg(); nwmsg->sender = nwi->nodeNbr; nwmsg->receiver = receiver-1; nwmsg->data = data; nwmsg->dataMATLAB = dataMATLAB; nwmsg->length = length; nwmsg->prio = priority; nwmsg->timestamp = rtsys->time; nwSendMsg(nwmsg, nwi->nwsys); if (rtsys->oldnwSnd[nwi->portNbr] == 0.0) { rtsys->nwSnd[nwi->portNbr] = 1.0; // trigger output } else { rtsys->nwSnd[nwi->portNbr] = 0.0; // trigger output } }
void CDrawLine::NewOptions() { Display(); if (m_re_edit) { bool changed = false; if ( m_use_default_style != g_EditToolBar.m_LineEdit.m_use_default_style || m_style != m_pDesign->GetOptions()->GetCurrentStyle(GetType()) ) { m_use_default_style = g_EditToolBar.m_LineEdit.m_use_default_style; if (!m_use_default_style) { m_style = m_pDesign->GetOptions()->GetCurrentStyle(GetType()); } // Do we effect the entire net? if (g_EditToolBar.m_LineEdit.m_bEntire_net) { // We must make the latest network.. CNetList n; n.MakeNet( static_cast<CTinyCadMultiDoc*>(m_pDesign->GetParent()) ); // Yep, so better update it... drawingIterator i = m_pDesign->GetDrawingBegin(); while (i != m_pDesign->GetDrawingEnd()) { if ((*i)->GetType() == GetType() && *i != this) { CDrawLine *pLine = static_cast<CDrawLine*>(*i); if (pLine->getNetwork() == getNetwork()) { pLine->m_use_default_style = m_use_default_style; pLine->m_style = m_style; pLine->Display(); } } ++ i; } } } } Display(); }
/*! render client window */ void MultiDisplayWindow::clientSwap( void ) { Connection *connection = getNetwork()->getMainConnection(); #if FAST_SYNC connection->selectChannel(); #else if(!getInterleave()) { // wait for all servers to finish connection->wait(); // initiate swap connection->signal(); } #endif // show client window Inherited::clientSwap(); }
/** * Creates a ImageDisk representation if there isn't an object already defined. **/ void ImageSourceSeries::process() { if (fileList_.empty()) return; std::string basePath{imageFileDirectory_.get()}; long currentIndex = currentImageIndex_.get() - 1; if ((currentIndex < 0) || (currentIndex >= static_cast<long>(fileList_.size()))) { LogError("Invalid image index. Exceeded number of files."); return; } std::string currentFileName{basePath + "/" + fileList_[currentIndex]}; imageFileName_.set(fileList_[currentIndex]); std::string fileExtension = filesystem::getFileExtension(currentFileName); auto factory = getNetwork()->getApplication()->getDataReaderFactory(); if (auto reader = factory->getReaderForTypeAndExtension<Layer>(fileExtension)) { try { auto outLayer = reader->readData(currentFileName); // Call getRepresentation here to force read a ram representation. // Otherwise the default image size, i.e. 256x265, will be reported // until you do the conversion. Since the LayerDisk does not have any metadata. auto ram = outLayer->getRepresentation<LayerRAM>(); // Hack needs to set format here since LayerDisk does not have a format. outLayer->setDataFormat(ram->getDataFormat()); auto outImage = std::make_shared<Image>(outLayer); outImage->getRepresentation<ImageRAM>(); outport_.setData(outImage); } catch (DataReaderException const& e) { util::log(e.getContext(), "Could not load data: " + imageFileName_.get() + ", " + e.getMessage(), LogLevel::Error); } } else { LogWarn("Could not find a data reader for file: " << currentFileName); // remove file from list fileList_.erase(fileList_.begin() + currentIndex); // adjust index property updateProperties(); } }
/*! render client window */ void MultiDisplayWindow::clientSwap( void ) { Connection *connection=getNetwork()->getMainConnection(); if(getFastSync()) { connection->selectChannel(); } else { if(!getInterleave()) { // wait for all servers to finish connection->wait(); // initiate swap connection->signal(); } } // show client window Inherited::clientSwap(); }
void *ttGetMsg(int networkNbr) // returns data (void *) or NULL if no message { void *data; NetworkInterface* nwi = getNetwork(networkNbr); if (nwi == NULL) { // is there no network? char buf[200]; sprintf(buf, "ttGetMsg: Network #%d not present!", networkNbr); TT_MEX_ERROR(buf); return NULL; } NWmsg *nwmsg = nwGetMsg(nwi); if (nwmsg == NULL) { return NULL; } data = nwmsg->data; // Delete message delete nwmsg; return data; }