void SoVtkAssembly::GLRender(SoGLRenderAction *action) { try { SoGroup::GLRender(action); if ( nodeId != getNodeId() ) { nodeId = getNodeId(); updateChildren(); } // Perform setPosition and setOrigin transformations SbVec3f position = Position.getValue(); SbVec3f origin = Origin.getValue(); mAssembly->SetOrigin(origin[0], origin[1], origin[2]); mAssembly->SetPosition(position[0], position[1], position[2]); } catch(...) { SoDebugError::post( __FILE__, "Unknown Exception" ); return ; } }
/*updateNodeProbabilityMatrixs * Update the size of the matrices when a node or and edge is added/removed */ void BNet::updateNodeProbabilityMatrix(int i_nodeNumber, int i_newEdgeFromNodeID){ MatrixXf oldMatrix(listOfNodeConditionalProbabilities[i_nodeNumber]->cols(), listOfNodeConditionalProbabilities[i_nodeNumber]->rows()); oldMatrix = listOfNodeConditionalProbabilities[i_nodeNumber][0]; VectorXd oldVector(listOfNodeInputEdges[i_nodeNumber]->rows()); oldVector = listOfNodeInputEdges[i_nodeNumber][0]; int nbParent = getNumberOfParentsOf(getNodeId(i_nodeNumber)); int nbConditionalProb = 1; for(int c = 0; c < nbParent; c++){ nbConditionalProb *= getParentNb(getNodeId(i_nodeNumber), c)->getNumberOfStates(); } //Create a matrix with cols being the number of states of the node and rows all the possibilities for its parent value listOfNodeConditionalProbabilities[i_nodeNumber] = new MatrixXf(listOfNodes[i_nodeNumber]->getNumberOfStates(), nbConditionalProb); // cout<<getNodeId(i_nodeNumber)->getName()<<" is size "<<listOfNodes[i_nodeNumber]->getNumberOfStates()<<" x "<<nbConditionalProb<<endl; for(int cRows = 0; cRows < listOfNodeConditionalProbabilities[i_nodeNumber]->rows(); cRows++){ for(int cCols = 0; cCols < listOfNodeConditionalProbabilities[i_nodeNumber]->cols(); cCols++){ listOfNodeConditionalProbabilities[i_nodeNumber][0](cRows, cCols) = 1/(listOfNodes[i_nodeNumber]->getNumberOfStates()); } } //Create a matrix with rows being the number of states of the node and rows all the possibilities for its parent value listOfNodeInputEdges[i_nodeNumber] = new VectorXd(getNumberOfParentsOf(listOfNodes[i_nodeNumber])); for(int cRows = 0; cRows < oldVector.rows(); cRows++){ listOfNodeInputEdges[i_nodeNumber][0](cRows) = oldVector(cRows); } listOfNodeInputEdges[i_nodeNumber][0]((listOfNodeInputEdges[i_nodeNumber]->rows())-1) = i_newEdgeFromNodeID; }
bool signerSignMsg(MyMessage &msg) { bool ret; #if defined(MY_SIGNING_FEATURE) // If destination is known to require signed messages and we are the sender, // sign this message unless it is identified as an exception if (DO_SIGN(msg.destination) && msg.sender == getNodeId()) { if (skipSign(msg)) { ret = true; } else { // Send nonce-request _signingNonceStatus=SIGN_WAITING_FOR_NONCE; if (!_sendRoute(build(_msgSign, msg.destination, msg.sensor, C_INTERNAL, I_NONCE_REQUEST).set(""))) { SIGN_DEBUG(PSTR("Failed to transmit nonce request!\n")); ret = false; } else { SIGN_DEBUG(PSTR("Nonce requested from %d. Waiting...\n"), msg.destination); // We have to wait for the nonce to arrive before we can sign our original message // Other messages could come in-between. We trust _process() takes care of them unsigned long enter = hwMillis(); _msgSign = msg; // Copy the message to sign since message buffer might be touched in _process() while (hwMillis() - enter < MY_VERIFICATION_TIMEOUT_MS && _signingNonceStatus==SIGN_WAITING_FOR_NONCE) { _process(); } if (hwMillis() - enter > MY_VERIFICATION_TIMEOUT_MS) { SIGN_DEBUG(PSTR("Timeout waiting for nonce!\n")); ret = false; } else { if (_signingNonceStatus == SIGN_OK) { // process() received a nonce and signerProcessInternal successfully signed the message msg = _msgSign; // Write the signed message back SIGN_DEBUG(PSTR("Message to send has been signed\n")); ret = true; // After this point, only the 'last' member of the message structure is allowed to be altered if the // message has been signed, or signature will become invalid and the message rejected by the receiver } else { SIGN_DEBUG(PSTR("Message to send could not be signed!\n")); ret = false; } } } } } else if (getNodeId() == msg.sender) { mSetSigned(msg, 0); // Message is not supposed to be signed, make sure it is marked unsigned SIGN_DEBUG(PSTR("Will not sign message for destination %d as it does not require it\n"), msg.destination); ret = true; } else { SIGN_DEBUG(PSTR("Will not sign message since it was from %d and we are %d\n"), msg.sender, getNodeId()); ret = true; } #else (void)msg; ret = true; #endif // MY_SIGNING_FEATURE return ret; }
ActionRow RollbackManager::actionRowFromRollbackAction(const RollbackAction & action) { ActionRow row; row.id = 0; row.actor = getActorId(action.actor); row.timestamp = action.unix_time; row.type = action.type; if (row.type == RollbackAction::TYPE_MODIFY_INVENTORY_STACK) { row.location = action.inventory_location; row.list = action.inventory_list; row.index = action.inventory_index; row.add = action.inventory_add; row.stack = action.inventory_stack; row.stack.id = getNodeId(row.stack.name); } else { row.x = action.p.X; row.y = action.p.Y; row.z = action.p.Z; row.oldNode = getNodeId(action.n_old.name); row.oldParam1 = action.n_old.param1; row.oldParam2 = action.n_old.param2; row.oldMeta = action.n_old.meta; row.newNode = getNodeId(action.n_new.name); row.newParam1 = action.n_new.param1; row.newParam2 = action.n_new.param2; row.newMeta = action.n_new.meta; row.guessed = action.actor_is_guess; } return row; }
bool signerVerifyMsg(MyMessage &msg) { bool verificationResult = true; // Before processing message, reject unsigned messages if signing is required and check signature // (if it is signed and addressed to us) // Note that we do not care at all about any signature found if we do not require signing #if defined(MY_SIGNING_FEATURE) && defined(MY_SIGNING_REQUEST_SIGNATURES) // If we are a node, or we are a gateway and the sender require signatures (or just a strict gw) // and we are the destination... #if defined(MY_SIGNING_GW_REQUEST_SIGNATURES_FROM_ALL) if (msg.destination == getNodeId()) { #else if ((!MY_IS_GATEWAY || DO_SIGN(msg.sender)) && msg.destination == getNodeId()) { #endif // Internal messages of certain types are not verified if (skipSign(msg)) { verificationResult = true; } else if (!mGetSigned(msg)) { // Got unsigned message that should have been signed SIGN_DEBUG(PSTR("Message is not signed, but it should have been!\n")); verificationResult = false; } else { if (!signerBackendVerifyMsg(msg)) { SIGN_DEBUG(PSTR("Signature verification failed!\n")); verificationResult = false; } #if defined(MY_NODE_LOCK_FEATURE) if (verificationResult) { // On successful verification, clear lock counters nof_nonce_requests = 0; nof_failed_verifications = 0; } else { nof_failed_verifications++; SIGN_DEBUG(PSTR("Failed verification attempts left until lockdown: %d\n"), MY_NODE_LOCK_COUNTER_MAX-nof_failed_verifications); if (nof_failed_verifications >= MY_NODE_LOCK_COUNTER_MAX) { _nodeLock("TMFV"); //Too many failed verifications } } #endif mSetSigned(msg,0); // Clear the sign-flag now as verification is completed } } #else (void)msg; #endif // MY_SIGNING_REQUEST_SIGNATURES return verificationResult; } static uint8_t sha256_hash[32]; Sha256Class _soft_sha256; void signerSha256Init(void) { memset(sha256_hash, 0, 32); _soft_sha256.init(); }
void GraphCut::setEdgeWeights() { for (int x = 0; x < _image->width(); x++) { for (int y = 0; y < _image->height(); y++) { // adds edges to a node at x, y and assigns weights to those edges int nodeId = getNodeId(x, y); int neighborId; if (y-1 >= 0){ neighborId = getNodeId(x, y-1); if (_warmStart) _graph.edit_edge_wt(nodeId, neighborId, getPairwiseCosts(x, y, x, y-1), getPairwiseCosts(x, y, x, y-1)); else _graph.add_edge(nodeId, neighborId, getPairwiseCosts(x, y, x, y-1), getPairwiseCosts(x, y, x, y-1)); } if (x-1 >= 0){ neighborId = getNodeId(x-1, y); if (_warmStart) _graph.edit_edge_wt(nodeId, neighborId, getPairwiseCosts(x, y, x-1, y), getPairwiseCosts(x, y, x-1, y)); else _graph.add_edge(nodeId, neighborId, getPairwiseCosts(x, y, x-1, y), getPairwiseCosts(x, y, x-1, y)); } if (_parameters->eightNeighborhood) { if ( (x-1 >= 0) && (y-1 >= 0) ) { neighborId = getNodeId(x-1, y-1); if (_warmStart) _graph.edit_edge_wt(nodeId, neighborId, getPairwiseCosts(x, y, x-1, y-1), getPairwiseCosts(x, y, x-1, y-1)); else _graph.add_edge(nodeId, neighborId, getPairwiseCosts(x, y, x-1, y-1), getPairwiseCosts(x, y, x-1, y-1)); } if ( (y+1 < _image->height()) && (x-1 >= 0) ) { neighborId = getNodeId(x-1, y+1); if (_warmStart) _graph.edit_edge_wt(nodeId, neighborId, getPairwiseCosts(x, y, x-1, y+1), getPairwiseCosts(x, y, x-1, y+1)); else _graph.add_edge(nodeId, neighborId, getPairwiseCosts(x, y, x-1, y+1), getPairwiseCosts(x, y, x-1, y+1)); } } } } }
void DeadLockDetector::addPendingInfo(const transaction_id pending, const transaction_id owner) { const DirectedGraph::node_id pending_node_id = getNodeId(pending); const DirectedGraph::node_id owner_node_id = getNodeId(owner); // TODO(Hakan): Check first whether link is already created. Use checked // version for adding an edge. wait_for_graph_->addEdgeUnchecked(pending_node_id, owner_node_id); }
/*! \fn SoXipGLSLUniformGroup::GLRender(SoGLRenderAction * action) * Derived inventor GLRender method, overrides to doAction * \param action - the current state action * \return void */ void SoXipGLSLUniformGroup::GLRender(SoGLRenderAction * action) { if (mNodeId != getNodeId()) { mNodeId = getNodeId(); mNumPrograms = prgTags.getNum(); mNeedsUpdate = true; } groupUpdate(action); }
void BNet::setProbaNode(BNode* i_node){ //If the state is already known (as an evidence) the proability is set //If not, the probability of the parent is looked at // cout<<i_node->getName()<<" has "<<listOfNodeInputEdges[getIdOfNode(i_node)]->rows() <<" parents"<<endl; if(i_node->getState() != -1){ for(int row = 0; row < nodesProbability->rows(); row++){ if(row == i_node->getState()){ nodesProbability[0](row, getIdOfNode(i_node)) = 1; }else{ nodesProbability[0](row, getIdOfNode(i_node)) = 0; } } }else{ for(int i = 0; i < listOfNodeInputEdges[getIdOfNode(i_node)]->rows(); i ++){ //If any of the value in the parents' probability matrice is -1, it means that the probability has't yet been calculated if((listOfNodeInputEdges[getIdOfNode(i_node)][0](i) != getIdOfNode(i_node) ) && nodesProbability[0](0,listOfNodeInputEdges[getIdOfNode(i_node)][0](i)) == -1){ setProbaNode(listOfNodes[listOfNodeInputEdges[getIdOfNode(i_node)][0](i)]); } } //Calculate own proba based on parents' proba for(int j = 0; j < i_node->getNumberOfStates(); j ++){ double proba = 0; for(int k = 0; k < listOfNodeConditionalProbabilities[getIdOfNode(i_node)]->cols(); k++){ double proba2 = 1; double proba1 = (double)listOfNodeConditionalProbabilities[getIdOfNode(i_node)][0](j, k); // cout<<i_node->getName()<<" state: "<<j<<"; conditional prob at "<<k<<": "<<proba1<<endl;; //measure the parent probability int parentStates = 1; for(int i = 0; i < listOfNodeInputEdges[getIdOfNode(i_node)]->rows(); i ++){ if(listOfNodeInputEdges[getIdOfNode(i_node)][0](i) != getIdOfNode(i_node)){ int index = (int)(k/parentStates); // cout<<k<<" :: "<<parentStates<<endl; index = index % getNodeId(listOfNodeInputEdges[getIdOfNode(i_node)][0](i))->getNumberOfStates(); parentStates *= getNodeId(listOfNodeInputEdges[getIdOfNode(i_node)][0](i))->getNumberOfStates(); proba2 *= nodesProbability[0](index, listOfNodeInputEdges[getIdOfNode(i_node)][0](i)); // cout<<"\tParent "<<getNodeId(listOfNodeInputEdges[getIdOfNode(i_node)][0](i))->getName()<<" index "<<index<<"; prob: "<<proba2<<endl; } } // proba += exp(log10(proba1)+log10(proba2)); proba += proba1*proba2; // proba += sqrt(proba1*proba2); //Eventual good solution } nodesProbability[0](j,getIdOfNode(i_node)) = proba; } } }
int Device::getSelectorFBValue(int id) { FunctionBlockCmd fbCmd( get1394Service(), FunctionBlockCmd::eFBT_Selector, id, FunctionBlockCmd::eCA_Current ); fbCmd.setNodeId( getNodeId() ); fbCmd.setSubunitId( 0x00 ); fbCmd.setCommandType( AVCCommand::eCT_Status ); fbCmd.m_pFBSelector->m_inputFbPlugNumber = 0xFF; fbCmd.setVerboseLevel( getDebugLevel() ); if ( !fbCmd.fire() ) { debugError( "cmd failed\n" ); return -1; } // if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL ) { // Util::Cmd::CoutSerializer se; // fbCmd.serialize( se ); // } if((fbCmd.getResponse() != AVCCommand::eR_Implemented)) { debugWarning("fbCmd.getResponse() != AVCCommand::eR_Implemented\n"); } return fbCmd.m_pFBSelector->m_inputFbPlugNumber; }
bool CommunicationLayer::sendToLayer( Directions direction, PacketPtr packet, t_uint recvingLayerIdx) { assert(packet != 0); assert(recvingLayerIdx < numberOfLayers(direction)); CommunicationLayerPtr recvingLayer; switch(direction) { case Directions_Lower: recvingLayer = m_lowerLayers[recvingLayerIdx]; break; case Directions_Upper: removeLayerData(packet); recvingLayer = m_upperLayers[recvingLayerIdx]; break; default: assert(false); } assert(recvingLayer.get() != 0); LogStreamManager::instance()->logPktSendItem(getNodeId(), getLayerType(), *packet); EventPtr recvEvent = LayerRecvEvent::create(direction, packet, recvingLayer, shared_from_this()); if(direction == Directions_Lower) setLowerLayerRecvEventPending(true); assert(m_node != 0); bool wasScheduled = m_node->scheduleEvent(recvEvent, getLayerDelay(direction)); return wasScheduled; }
void GraphCut::getSegmentation(){ LOG_DEBUG(graphcutlog) << "resizing image to " << _image->shape() << std::endl; // adjust the size of the segmentation output to match the input image _segmentationData.reshape(_image->shape()); *_segmentation = _segmentationData; for (int x = 0; x < _image->width(); x++){ for (int y = 0; y < _image->height(); y++){ unsigned int nodeId = getNodeId(x,y); if(_graph.what_segment(nodeId) == graph_type::SOURCE){ (*_segmentation)(x, y) = 0; } else { (*_segmentation)(x, y) = 1; } } } }
bool Device::setActiveClockSource(ClockSource s) { AVC::SignalSourceCmd cmd(get1394Service()); cmd.setCommandType(AVC::AVCCommand::eCT_Control); cmd.setNodeId(getNodeId()); cmd.setSubunitType(AVC::eST_Unit); cmd.setSubunitId(0xff); cmd.setVerbose(getDebugLevel()); AVC::SignalSubunitAddress dst; dst.m_subunitType = AVC::eST_Music; dst.m_subunitId = 0x00; dst.m_plugId = 0x05; cmd.setSignalDestination(dst); if (s.id == 0x00) { AVC::SignalSubunitAddress src; src.m_subunitType = AVC::eST_Music; src.m_subunitId = 0x00; src.m_plugId = 0x06; cmd.setSignalSource( src ); } else { AVC::SignalUnitAddress src; src.m_plugId = 0x83; cmd.setSignalSource(src); } if (!cmd.fire()) { debugError( "Signal source command failed\n" ); return false; } return true; }
uint8_t Device::getConfigurationIdSampleRate() { ExtendedStreamFormatCmd extStreamFormatCmd( get1394Service() ); UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 0 ); extStreamFormatCmd.setPlugAddress( PlugAddress( PlugAddress::ePD_Input, PlugAddress::ePAM_Unit, unitPlugAddress ) ); extStreamFormatCmd.setNodeId( getNodeId() ); extStreamFormatCmd.setCommandType( AVCCommand::eCT_Status ); extStreamFormatCmd.setVerbose( getDebugLevel() ); if ( !extStreamFormatCmd.fire() ) { debugError( "Stream format command failed\n" ); return 0; } FormatInformation* formatInfo = extStreamFormatCmd.getFormatInformation(); FormatInformationStreamsCompound* compoundStream = dynamic_cast< FormatInformationStreamsCompound* > ( formatInfo->m_streams ); if ( compoundStream ) { debugOutput(DEBUG_LEVEL_VERBOSE, "Sample rate 0x%02x\n", compoundStream->m_samplingFrequency ); return compoundStream->m_samplingFrequency; } debugError( "Could not retrieve sample rate\n" ); return 0; }
int Device::getProcessingFBMixerSingleCurrent(int id, int iPlugNum, int iAChNum, int oAChNum) { AVC::FunctionBlockCmd fbCmd(get1394Service(), AVC::FunctionBlockCmd::eFBT_Processing, id, AVC::FunctionBlockCmd::eCA_Current); fbCmd.setNodeId(getNodeId()); fbCmd.setSubunitId(0x00); fbCmd.setCommandType(AVCCommand::eCT_Status); fbCmd.setVerboseLevel( getDebugLevel() ); AVC::FunctionBlockProcessing *fbp = fbCmd.m_pFBProcessing; fbp->m_selectorLength = 0x04; fbp->m_fbInputPlugNumber = iPlugNum; fbp->m_inputAudioChannelNumber = iAChNum; fbp->m_outputAudioChannelNumber = oAChNum; // mixer object is not generated automatically fbp->m_pMixer = new AVC::FunctionBlockProcessingMixer; if ( !fbCmd.fire() ) { debugError( "cmd failed\n" ); return 0; } if( (fbCmd.getResponse() != AVCCommand::eR_Implemented) ) { debugWarning("fbCmd.getResponse() != AVCCommand::eR_Implemented\n"); } int16_t setting = (int16_t)(fbp->m_pMixer->m_mixerSetting); return setting; }
int Device::getFeatureFBLRBalanceValue(int id, int channel, FunctionBlockCmd::EControlAttribute controlAttribute) { FunctionBlockCmd fbCmd( get1394Service(), FunctionBlockCmd::eFBT_Feature, id, controlAttribute); fbCmd.setNodeId( getNodeId() ); fbCmd.setSubunitId( 0x00 ); fbCmd.setCommandType( AVCCommand::eCT_Status ); fbCmd.m_pFBFeature->m_audioChannelNumber = channel; fbCmd.m_pFBFeature->m_controlSelector = FunctionBlockFeature::eCSE_Feature_LRBalance; AVC::FunctionBlockFeatureLRBalance bl; fbCmd.m_pFBFeature->m_pLRBalance = bl.clone(); fbCmd.m_pFBFeature->m_pLRBalance->m_lrBalance = 0; fbCmd.setVerboseLevel( getDebugLevel() ); if ( !fbCmd.fire() ) { debugError( "cmd failed\n" ); return 0; } // if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL ) { // Util::Cmd::CoutSerializer se; // fbCmd.serialize( se ); // } if((fbCmd.getResponse() != AVCCommand::eR_Implemented)) { debugWarning("fbCmd.getResponse() != AVCCommand::eR_Implemented\n"); } int16_t balance=(int16_t)(fbCmd.m_pFBFeature->m_pLRBalance->m_lrBalance); return balance; }
bool Device::writeReg(uint64_t offset, uint32_t data) { int trials; fb_nodeid_t nodeId; fb_nodeaddr_t addr; fb_quadlet_t quad; Util::MutexLockHelper lock(m_DeviceMutex); nodeId = getNodeId() | 0xffc0; addr = MAUDIO_SPECIFIC_ADDRESS + MAUDIO_CONTROL_OFFSET + offset; quad = CondSwapToBus32(data); /* cache because it's 'write-only' */ m_regs[offset / 4] = data; trials = 0; do { if (get1394Service().write_quadlet(nodeId, addr, quad)) break; Util::SystemTimeSource::SleepUsecRelative(100); } while (++trials < 4); return true; }
/** * Frame buffer object allocator. * Allocates and re-allocates FBO's according to user/engine/state variables. */ void SoXipFboAttachColor3D::syncOutput() { bool outputDirty = false; if (!mHandles || mNumAttachments > 16) SoDebugError::post("SoXipFbo", "invalid pointer or more than 16 handles"); else { // Expand list by padding with zeros if to short if (handleOutput.getNum() < static_cast<int>(mNumAttachments)) { for (int i = handleOutput.getNum(); i < mNumAttachments; i++) { //SoDebugError::post("", "num mismatch %d (%d %d)", i, handleOutput.getNum(), mNumAttachments); handleOutput.set1Value(i, 0); outputDirty = true; } } // Update entries if changed for (int i = 0; i < mNumAttachments; i++) { if (handleOutput[i] != static_cast<int>(mHandles[i])) { //SoDebugError::post("", "handle mismatch %d (%d %d)", i, handleOutput[i], mHandles[i]); handleOutput.set1Value(i, static_cast<int>(mHandles[i])); outputDirty = true; } } // Remove absolete entries if (handleOutput.getNum() > static_cast<int>(mNumAttachments)) { //SoDebugError::post("", "length mismatch"); handleOutput.deleteValues(mNumAttachments); outputDirty = true; } } mNodeId = getNodeId(); }
/** * Synchronizing newly bound handles with output unit fields. */ void SoXipBindTextures::syncOutput() { if (mNeedsSync) { if (texture0Output.getValue() != mTexUnits[0]) texture0Output.setValue(mTexUnits[0]); if (texture1Output.getValue() != mTexUnits[1]) texture1Output.setValue(mTexUnits[1]); if (texture2Output.getValue() != mTexUnits[2]) texture2Output.setValue(mTexUnits[2]); if (texture3Output.getValue() != mTexUnits[3]) texture3Output.setValue(mTexUnits[3]); if (texture4Output.getValue() != mTexUnits[4]) texture4Output.setValue(mTexUnits[4]); if (texture5Output.getValue() != mTexUnits[5]) texture5Output.setValue(mTexUnits[5]); if (texture6Output.getValue() != mTexUnits[6]) texture6Output.setValue(mTexUnits[6]); if (texture7Output.getValue() != mTexUnits[7]) texture7Output.setValue(mTexUnits[7]); mNodeId = getNodeId(); mNeedsSync = false; } }
RIFG::NodeId RIFG::getEdgeSink(RIFG::EdgeId eid) const { OA::OA_ptr<OA::DGraph::EdgeInterface> e = getEdge(eid); OA::OA_ptr<OA::DGraph::NodeInterface> n = e->getSink(); return (getNodeId(n)); }
bool Device::writeBlk(uint64_t offset, unsigned int size, uint32_t *data) { fb_nodeid_t nodeId; fb_nodeaddr_t addr; unsigned int i, length, trials; nodeId = getNodeId() | 0xffc0; addr = MAUDIO_SPECIFIC_ADDRESS + MAUDIO_CONTROL_OFFSET + offset; length = size /4; for (i = 0; i < length; i++) { /* the device applies the setting even if the device don't respond */ m_regs[i] = data[i]; data[i] = CondSwapToBus32(data[i]); } trials = 0; do { if (get1394Service().write(nodeId, addr, length, (fb_quadlet_t*)data)) break; Util::SystemTimeSource::SleepUsecRelative(100); } while (++trials < 4); return true; }
bool Device::setFeatureFBLRBalanceCurrent(int id, int channel, int v) { FunctionBlockCmd fbCmd( get1394Service(), FunctionBlockCmd::eFBT_Feature, id, FunctionBlockCmd::eCA_Current ); fbCmd.setNodeId( getNodeId() ); fbCmd.setSubunitId( 0x00 ); fbCmd.setCommandType( AVCCommand::eCT_Control ); fbCmd.m_pFBFeature->m_audioChannelNumber = channel; fbCmd.m_pFBFeature->m_controlSelector = FunctionBlockFeature::eCSE_Feature_LRBalance; AVC::FunctionBlockFeatureLRBalance bl; fbCmd.m_pFBFeature->m_pLRBalance = bl.clone(); fbCmd.m_pFBFeature->m_pLRBalance->m_lrBalance = v; fbCmd.setVerboseLevel( getDebugLevel() ); if ( !fbCmd.fire() ) { debugError( "cmd failed\n" ); return false; } // if ( getDebugLevel() >= DEBUG_LEVEL_NORMAL ) { // Util::Cmd::CoutSerializer se; // fbCmd.serialize( se ); // } if((fbCmd.getResponse() != AVCCommand::eR_Accepted)) { debugWarning("fbCmd.getResponse() != AVCCommand::eR_Accepted\n"); } return (fbCmd.getResponse() == AVCCommand::eR_Accepted); }
uint8_t Device::getConfigurationIdNumberOfChannel( PlugAddress::EPlugDirection ePlugDirection ) { ExtendedPlugInfoCmd extPlugInfoCmd( get1394Service() ); UnitPlugAddress unitPlugAddress( UnitPlugAddress::ePT_PCR, 0 ); extPlugInfoCmd.setPlugAddress( PlugAddress( ePlugDirection, PlugAddress::ePAM_Unit, unitPlugAddress ) ); extPlugInfoCmd.setNodeId( getNodeId() ); extPlugInfoCmd.setCommandType( AVCCommand::eCT_Status ); extPlugInfoCmd.setVerbose( getDebugLevel() ); ExtendedPlugInfoInfoType extendedPlugInfoInfoType( ExtendedPlugInfoInfoType::eIT_NoOfChannels ); extendedPlugInfoInfoType.initialize(); extPlugInfoCmd.setInfoType( extendedPlugInfoInfoType ); if ( !extPlugInfoCmd.fire() ) { debugError( "Number of channels command failed\n" ); return 0; } ExtendedPlugInfoInfoType* infoType = extPlugInfoCmd.getInfoType(); if ( infoType && infoType->m_plugNrOfChns ) { debugOutput(DEBUG_LEVEL_VERBOSE, "Number of channels 0x%02x\n", infoType->m_plugNrOfChns->m_nrOfChannels ); return infoType->m_plugNrOfChns->m_nrOfChannels; } debugError( "Could not retrieve number of channels\n" ); return 0; }
void HttpInterface::evReset(HttpRequest* req, strings& args) { for (NodesMap::iterator descIt = nodes.begin(); descIt != nodes.end(); ++descIt) { bool ok; nodeId = getNodeId(descIt->second.name, 0, &ok); if (!ok) continue; string nodeName = WStringToUTF8(descIt->second.name); Reset(nodeId).serialize(asebaStream); // reset node asebaStream->flush(); Run(nodeId).serialize(asebaStream); // re-run node asebaStream->flush(); if (nodeName.find("thymio-II") == 0) { strings args; args.push_back("motor.left.target"); args.push_back("0"); sendSetVariable(nodeName, args); args[0] = "motor.right.target"; sendSetVariable(nodeName, args); } size_t eventPos; if (commonDefinitions.events.contains(UTF8ToWString("reset"), &eventPos)) { strings data; data.push_back("reset"); sendEvent(nodeName,data); } finishResponse(req, 200, ""); } }
void ReadsLayout::print(size_t index, ostream &out, bool dir, unsigned int start, unsigned int maxD, Pairing *P) { if (getNext(index) != 0) { cerr << "void ReadsLayout::print(size_t index) problem\n"; sendBugReportPlease(cerr); } if (!dir) index = reverseComplement(index); size_t p = getBegin(index); size_t tmp; do { unsigned int position=getPosition(p); if (position > maxD) break; if (position < start) { tmp = p; p = getNext(p); continue; } unsigned int pairedRead=0; unsigned int pairedNode=0; int lib=0; if (P->getNLibrary() != 0) { pairedRead = P->getPairing(p); pairedNode = getNodeId(pairedRead); lib = P->getPeLibraryID(p); } if (getDirection(p)) out << '>'; else out << '<'; for (int i = 0; i < getPosition(p) % 120; i++) out << " "; if (getDirection(p)) out << getDirectRead(p) << " " << p << ' ' << lib << ' ' << pairedNode << '\n'; else out << getReverseRead(p) << " " << p << ' ' << lib << ' ' << pairedNode << '\n'; tmp = p; p = getNext(p); } while (tmp != index); out << flush; if (!dir) //back to initial direction index = reverseComplement(index); }
/** * GLRender, updates and checks handles if necessary. * If node id has changed (ie, if anything in the node has changed) * an update is performed, otherwise it binds the stored handles to units. */ void SoXipBindTextures::GLRender(SoGLRenderAction* action) { if (attachmentHandles.getNum() > 16) { SoDebugError::post("SoXipBindTextures", "cant process more than 16 handles"); return; } bool dbgPrint = false; if (mNodeId != getNodeId()) { mNodeId = getNodeId(); // Check if any handles have changed bool handlesChanged = false; for (int i = 0; i < attachmentHandles.getNum(); i++) { if (mTexHandles[i] != attachmentHandles[i]) { handlesChanged = true; } } // If something has changed we process if (mNumTextures != attachmentHandles.getNum() || handlesChanged) { mNumTextures = attachmentHandles.getNum(); assignTextures(action); dbgPrint = true; } } bindTextures(action); syncOutput(); #ifdef a_DEBUG if (dbgPrint) { dbgPrint = false; // Debug printout FboSetup * fbo = SoXipFboElement::getActive(action->getState(), this); int col = fbo->numColorAttachments; int dep = fbo->numDepthAttachments; SoDebugError::postInfo("SoXipBindTextures", "(fbo %d %d %d) binding %d %d %d on %d %d %d", fbo->fboHandle, col, dep, mTexHandles[0], mTexHandles[1], mTexHandles[2], mTexUnits[0], mTexUnits[1], mTexUnits[2]); } #endif }
static Properties create(unsigned mgmds = 1, unsigned ndbds = 1, unsigned mysqlds = 1, unsigned mgmd_nodeids[] = 0, unsigned ndbd_nodeids[] = 0, unsigned mysqld_nodeids[] = 0) { Uint32 base_port = get_ndbt_base_port() + /* mysqld */ 1; Properties config; require(mgmds >= 1 && ndbds >= 1 && mysqlds >= 1); NodeBitmask mask; mask.set(); mask.clear(Uint32(0)); for (unsigned i = 0; i < mgmds; i++) { Uint32 nodeId = getNodeId(mask, mgmd_nodeids, i); Properties node_settings; node_settings.put("NodeId", nodeId); node_settings.put("HostName", "localhost"); node_settings.put("PortNumber", base_port + i); config.put("ndb_mgmd", nodeId, &node_settings); } for (unsigned i = 0; i < ndbds; i++) { Uint32 nodeId = getNodeId(mask, ndbd_nodeids, i); Properties node_settings; node_settings.put("NodeId", nodeId); if (ndbds == 1) node_settings.put("NoOfReplicas", 1); config.put("ndbd", nodeId, &node_settings); } for (unsigned i = 0; i < mysqlds; i++) { Uint32 nodeId = getNodeId(mask, mysqld_nodeids, i); Properties node_settings; node_settings.put("NodeId", nodeId); config.put("mysqld", nodeId, &node_settings); } return config; }
/** * @brief reallocAll */ void BulkNode::reallocAll(FILE* handle) { int id = getNodeId(); vector<int>::iterator iterId; for (iterId = sVector.begin(); iterId != sVector.end(); iterId++) { //reallocSize(*iterId); int sum = reallocPackets(*iterId); fprintf(handle, "time:%f, NodeId:%d, sId:%d, StoreNum:%d\n", time_, id, *iterId, sum); } }
unsigned int Device::readRegister(fb_nodeaddr_t reg) { quadlet_t quadlet; quadlet = 0; if (get1394Service().read(0xffc0 | getNodeId(), reg, 1, &quadlet) <= 0) { debugError("Error doing RME read from register 0x%06llx\n",reg); } return ByteSwapFromDevice32(quadlet); }
std::vector<transaction_id> DeadLockDetector::getAllVictims() { std::vector<transaction_id> result_victims; wait_for_graph_.reset(new DirectedGraph()); // Critical region on LockTable starts here. lock_table_->latchShared(); for (const auto &lock_control_block : *lock_table_) { const LockTable::lock_own_list &own_list = lock_control_block.second.first; const LockTable::lock_pending_list &pending_list = lock_control_block.second.second; for (const auto &owned_lock_info : own_list) { const transaction_id owned_transaction = owned_lock_info.first; const DirectedGraph::node_id owned_node = getNodeId(owned_transaction); for (const auto &pending_lock_info : pending_list) { const transaction_id pending_transaction = pending_lock_info.first; const DirectedGraph::node_id pending_node = getNodeId(pending_transaction); wait_for_graph_->addEdgeUnchecked(pending_node, owned_node); } } } lock_table_->unlatchShared(); // Critical region on LockTable ends here. const CycleDetector cycle_detector(wait_for_graph_.get()); const std::vector<DirectedGraph::node_id> victim_nodes = cycle_detector.chooseVictimsToBreakCycle(); for (const DirectedGraph::node_id node_id : victim_nodes) { const transaction_id victim_tid = wait_for_graph_->getDataFromNode(node_id); result_victims.push_back(victim_tid); } // Destroy the wait graph. It will be reconstructed kSleepDurationSeconds // seconds later. wait_for_graph_.reset(); return result_victims; }