/** Overriden process groups. */ bool SaveNexus::processGroups() { this->exec(); // We finished successfully. setExecuted(true); notificationCenter().postNotification( new FinishedNotification(this, isExecuted())); return true; }
/** Executes the request. This calles prepareOperation, operation, and * afterOperation. */ void Request::execute() { assert(isBusy()); // Abort as early as possible if abort is requested if(RequestManager::get()->getAbort()) return; prepareOperation(); if(RequestManager::get()->getAbort()) return; operation(); if(RequestManager::get()->getAbort()) return; setExecuted(); if(RequestManager::get()->getAbort()) return; afterOperation(); } // execute
void kore::RenderMesh::execute(void) { const std::vector<kore::ShaderInput>& vAttributes = _shader->getAttributes(); for (unsigned int i = 0; i < vAttributes.size(); ++i) { const kore::ShaderInput& shaderAtt = vAttributes[i]; const kore::MeshAttributeArray* meshAtt = _mesh->getAttributeByName(shaderAtt.name); if (!meshAtt) { Log::getInstance()->write("[ERROR] Mesh %s does not have an" "Attribute %s", _mesh->getName().c_str(), shaderAtt.name.c_str()); return; } glEnableVertexAttribArray(shaderAtt.location); glVertexAttribPointer(shaderAtt.location, meshAtt->numComponents, meshAtt->componentType, GL_FALSE, 0, meshAtt->data); } _shader->applyShader(); // Update uniforms GLint iView = glGetUniformLocation(_shader->getProgramLocation(), "view"); GLint iProj = glGetUniformLocation(_shader->getProgramLocation(), "projection"); GLint iModel = glGetUniformLocation(_shader->getProgramLocation(), "model"); glUniformMatrix4fv(iView, 1, GL_FALSE, glm::value_ptr(_camera->getView())); glUniformMatrix4fv(iProj, 1, GL_FALSE, glm::value_ptr(_camera->getProjection())); glUniformMatrix4fv(iModel, 1, GL_FALSE, glm::value_ptr(glm::mat4(1.0f))); if (_mesh->hasIndices()) { glDrawElements(_mesh->getPrimitiveType(), _mesh->getIndices().size(), GL_UNSIGNED_INT, &_mesh->getIndices()[0]); } else { glDrawArrays(_mesh->getPrimitiveType(), 0, _mesh->getNumVertices()); } setExecuted(true); }
/** * Process two groups and ensure the Result string is set properly on the final * algorithm * * returns True if everything executed correctly */ bool CheckWorkspacesMatch::processGroups() { // Run new algorithm auto result = runCompareWorkspaces(true); // Output as per previous behaviour if (result != successString()) { g_log.notice() << result << "\n"; } setProperty("Result", result); setExecuted(true); notificationCenter().postNotification( new FinishedNotification(this, this->isExecuted())); return true; }
/** * Process two groups and ensure the Result string is set properly on the final * algorithm. * * @return A boolean true if execution was sucessful, false otherwise */ bool CompareWorkspaces::processGroups() { m_Result = true; m_Messages->setRowCount(0); // Clear table // Get workspaces Workspace_const_sptr w1 = getProperty("Workspace1"); Workspace_const_sptr w2 = getProperty("Workspace2"); // Attempt to cast to WorkspaceGroups (will be nullptr on failure) WorkspaceGroup_const_sptr ws1 = boost::dynamic_pointer_cast<const WorkspaceGroup>(w1); WorkspaceGroup_const_sptr ws2 = boost::dynamic_pointer_cast<const WorkspaceGroup>(w2); if (ws1 && ws2) { // Both are groups processGroups(ws1, ws2); } else if (!ws1 && !ws2) { // Neither are groups (shouldn't happen) m_Result = false; throw std::runtime_error("CompareWorkspaces::processGroups - Neither " "input is a WorkspaceGroup. This is a logical " "error in the code."); } else if (!ws1 || !ws2) { recordMismatch( "Type mismatch. One workspace is a group, the other is not."); } if (m_Result && ws1 && ws2) { g_log.notice() << "All workspaces in workspace groups \"" << ws1->name() << "\" and \"" << ws2->name() << "\" matched!" << std::endl; } setProperty("Result", m_Result); setProperty("Messages", m_Messages); // Store output workspace in AnalysisDataService if (!isChild()) this->store(); setExecuted(true); notificationCenter().postNotification( new FinishedNotification(this, this->isExecuted())); return true; }
bool ReflectometryReductionOneAuto::processGroups() { auto group = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( getPropertyValue("InputWorkspace")); const std::string outputIvsQ = this->getPropertyValue("OutputWorkspace"); const std::string outputIvsLam = this->getPropertyValue("OutputWorkspaceWavelength"); // Create a copy of ourselves Algorithm_sptr alg = this->createChildAlgorithm( this->name(), -1, -1, this->isLogging(), this->version()); alg->setChild(false); alg->setRethrows(true); // Copy all the non-workspace properties over std::vector<Property *> props = this->getProperties(); for (auto prop = props.begin(); prop != props.end(); ++prop) { if (*prop) { IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(*prop); if (!wsProp) alg->setPropertyValue((*prop)->name(), (*prop)->value()); } } // Check if the transmission runs are groups or not const std::string firstTrans = this->getPropertyValue("FirstTransmissionRun"); WorkspaceGroup_sptr firstTransG; if (!firstTrans.empty()) { auto firstTransWS = AnalysisDataService::Instance().retrieveWS<Workspace>(firstTrans); firstTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(firstTransWS); if (!firstTransG) alg->setProperty("FirstTransmissionRun", firstTrans); else if (group->size() != firstTransG->size()) throw std::runtime_error("FirstTransmissionRun WorkspaceGroup must be " "the same size as the InputWorkspace " "WorkspaceGroup"); } const std::string secondTrans = this->getPropertyValue("SecondTransmissionRun"); WorkspaceGroup_sptr secondTransG; if (!secondTrans.empty()) { auto secondTransWS = AnalysisDataService::Instance().retrieveWS<Workspace>(secondTrans); secondTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(secondTransWS); if (!secondTransG) alg->setProperty("SecondTransmissionRun", secondTrans); else if (group->size() != secondTransG->size()) throw std::runtime_error("SecondTransmissionRun WorkspaceGroup must be " "the same size as the InputWorkspace " "WorkspaceGroup"); } std::vector<std::string> IvsQGroup, IvsLamGroup; // Execute algorithm over each group member (or period, if this is // multiperiod) size_t numMembers = group->size(); for (size_t i = 0; i < numMembers; ++i) { const std::string IvsQName = outputIvsQ + "_" + boost::lexical_cast<std::string>(i + 1); const std::string IvsLamName = outputIvsLam + "_" + boost::lexical_cast<std::string>(i + 1); alg->setProperty("InputWorkspace", group->getItem(i)->name()); alg->setProperty("OutputWorkspace", IvsQName); alg->setProperty("OutputWorkspaceWavelength", IvsLamName); // Handle transmission runs if (firstTransG) alg->setProperty("FirstTransmissionRun", firstTransG->getItem(i)->name()); if (secondTransG) alg->setProperty("SecondTransmissionRun", secondTransG->getItem(i)->name()); alg->execute(); IvsQGroup.push_back(IvsQName); IvsLamGroup.push_back(IvsLamName); // We use the first group member for our thetaout value if (i == 0) this->setPropertyValue("ThetaOut", alg->getPropertyValue("ThetaOut")); } // Group the IvsQ and IvsLam workspaces Algorithm_sptr groupAlg = this->createChildAlgorithm("GroupWorkspaces"); groupAlg->setChild(false); groupAlg->setRethrows(true); groupAlg->setProperty("InputWorkspaces", IvsLamGroup); groupAlg->setProperty("OutputWorkspace", outputIvsLam); groupAlg->execute(); groupAlg->setProperty("InputWorkspaces", IvsQGroup); groupAlg->setProperty("OutputWorkspace", outputIvsQ); groupAlg->execute(); // If this is a multiperiod workspace and we have polarization corrections // enabled if (this->getPropertyValue("PolarizationAnalysis") != noPolarizationCorrectionMode()) { if (group->isMultiperiod()) { // Perform polarization correction over the IvsLam group Algorithm_sptr polAlg = this->createChildAlgorithm("PolarizationCorrection"); polAlg->setChild(false); polAlg->setRethrows(true); polAlg->setProperty("InputWorkspace", outputIvsLam); polAlg->setProperty("OutputWorkspace", outputIvsLam); polAlg->setProperty("PolarizationAnalysis", this->getPropertyValue("PolarizationAnalysis")); polAlg->setProperty("CPp", this->getPropertyValue(cppLabel())); polAlg->setProperty("CRho", this->getPropertyValue(crhoLabel())); polAlg->setProperty("CAp", this->getPropertyValue(cApLabel())); polAlg->setProperty("CAlpha", this->getPropertyValue(cAlphaLabel())); polAlg->execute(); // Now we've overwritten the IvsLam workspaces, we'll need to recalculate // the IvsQ ones alg->setProperty("FirstTransmissionRun", ""); alg->setProperty("SecondTransmissionRun", ""); for (size_t i = 0; i < numMembers; ++i) { const std::string IvsQName = outputIvsQ + "_" + boost::lexical_cast<std::string>(i + 1); const std::string IvsLamName = outputIvsLam + "_" + boost::lexical_cast<std::string>(i + 1); alg->setProperty("InputWorkspace", IvsLamName); alg->setProperty("OutputWorkspace", IvsQName); alg->setProperty("OutputWorkspaceWavelength", IvsLamName); alg->execute(); } } else { g_log.warning("Polarization corrections can only be performed on " "multiperiod workspaces."); } } // We finished successfully this->setPropertyValue("OutputWorkspace", outputIvsQ); this->setPropertyValue("OutputWorkspaceWavelength", outputIvsLam); setExecuted(true); notificationCenter().postNotification( new FinishedNotification(this, isExecuted())); return true; }
bool ReflectometryReductionOneAuto::processGroups() { // isPolarizationCorrectionOn is used to decide whether // we should process our Transmission WorkspaceGroup members // as individuals (not multiperiod) when PolarizationCorrection is off, // or sum over all of the workspaces in the group // and used that sum as our TransmissionWorkspace when PolarizationCorrection // is on. const bool isPolarizationCorrectionOn = this->getPropertyValue("PolarizationAnalysis") != noPolarizationCorrectionMode(); // Get our input workspace group auto group = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( getPropertyValue("InputWorkspace")); // Get name of IvsQ workspace const std::string outputIvsQ = this->getPropertyValue("OutputWorkspace"); // Get name of IvsLam workspace const std::string outputIvsLam = this->getPropertyValue("OutputWorkspaceWavelength"); // Create a copy of ourselves Algorithm_sptr alg = this->createChildAlgorithm( this->name(), -1, -1, this->isLogging(), this->version()); alg->setChild(false); alg->setRethrows(true); // Copy all the non-workspace properties over std::vector<Property *> props = this->getProperties(); for (auto &prop : props) { if (prop) { IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop); if (!wsProp) alg->setPropertyValue(prop->name(), prop->value()); } } // Check if the transmission runs are groups or not const std::string firstTrans = this->getPropertyValue("FirstTransmissionRun"); WorkspaceGroup_sptr firstTransG; if (!firstTrans.empty()) { auto firstTransWS = AnalysisDataService::Instance().retrieveWS<Workspace>(firstTrans); firstTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(firstTransWS); if (!firstTransG) { // we only have one transmission workspace, so we use it as it is. alg->setProperty("FirstTransmissionRun", firstTrans); } else if (group->size() != firstTransG->size() && !isPolarizationCorrectionOn) { // if they are not the same size then we cannot associate a transmission // group workspace member with every input group workpspace member. throw std::runtime_error("FirstTransmissionRun WorkspaceGroup must be " "the same size as the InputWorkspace " "WorkspaceGroup"); } } const std::string secondTrans = this->getPropertyValue("SecondTransmissionRun"); WorkspaceGroup_sptr secondTransG; if (!secondTrans.empty()) { auto secondTransWS = AnalysisDataService::Instance().retrieveWS<Workspace>(secondTrans); secondTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(secondTransWS); if (!secondTransG) // we only have one transmission workspace, so we use it as it is. alg->setProperty("SecondTransmissionRun", secondTrans); else if (group->size() != secondTransG->size() && !isPolarizationCorrectionOn) { // if they are not the same size then we cannot associate a transmission // group workspace member with every input group workpspace member. throw std::runtime_error("SecondTransmissionRun WorkspaceGroup must be " "the same size as the InputWorkspace " "WorkspaceGroup"); } } std::vector<std::string> IvsQGroup, IvsLamGroup; // Execute algorithm over each group member (or period, if this is // multiperiod) size_t numMembers = group->size(); for (size_t i = 0; i < numMembers; ++i) { const std::string IvsQName = outputIvsQ + "_" + boost::lexical_cast<std::string>(i + 1); const std::string IvsLamName = outputIvsLam + "_" + boost::lexical_cast<std::string>(i + 1); // If our transmission run is a group and PolarizationCorrection is on // then we sum our transmission group members. // // This is done inside of the for loop to avoid the wrong workspace being // used when these arguments are passed through to the exec() method. // If this is not set in the loop, exec() will fetch the first workspace // from the specified Transmission Group workspace that the user entered. if (firstTransG && isPolarizationCorrectionOn) { auto firstTransmissionSum = sumOverTransmissionGroup(firstTransG); alg->setProperty("FirstTransmissionRun", firstTransmissionSum); } if (secondTransG && isPolarizationCorrectionOn) { auto secondTransmissionSum = sumOverTransmissionGroup(secondTransG); alg->setProperty("SecondTransmissionRun", secondTransmissionSum); } // Otherwise, if polarization correction is off, we process them // using one transmission group member at a time. if (firstTransG && !isPolarizationCorrectionOn) // polarization off alg->setProperty("FirstTransmissionRun", firstTransG->getItem(i)->name()); if (secondTransG && !isPolarizationCorrectionOn) // polarization off alg->setProperty("SecondTransmissionRun", secondTransG->getItem(i)->name()); alg->setProperty("InputWorkspace", group->getItem(i)->name()); alg->setProperty("OutputWorkspace", IvsQName); alg->setProperty("OutputWorkspaceWavelength", IvsLamName); alg->execute(); MatrixWorkspace_sptr tempFirstTransWS = alg->getProperty("FirstTransmissionRun"); IvsQGroup.push_back(IvsQName); IvsLamGroup.push_back(IvsLamName); // We use the first group member for our thetaout value if (i == 0) this->setPropertyValue("ThetaOut", alg->getPropertyValue("ThetaOut")); } // Group the IvsQ and IvsLam workspaces Algorithm_sptr groupAlg = this->createChildAlgorithm("GroupWorkspaces"); groupAlg->setChild(false); groupAlg->setRethrows(true); groupAlg->setProperty("InputWorkspaces", IvsLamGroup); groupAlg->setProperty("OutputWorkspace", outputIvsLam); groupAlg->execute(); groupAlg->setProperty("InputWorkspaces", IvsQGroup); groupAlg->setProperty("OutputWorkspace", outputIvsQ); groupAlg->execute(); // If this is a multiperiod workspace and we have polarization corrections // enabled if (isPolarizationCorrectionOn) { if (group->isMultiperiod()) { // Perform polarization correction over the IvsLam group Algorithm_sptr polAlg = this->createChildAlgorithm("PolarizationCorrection"); polAlg->setChild(false); polAlg->setRethrows(true); polAlg->setProperty("InputWorkspace", outputIvsLam); polAlg->setProperty("OutputWorkspace", outputIvsLam); polAlg->setProperty("PolarizationAnalysis", this->getPropertyValue("PolarizationAnalysis")); polAlg->setProperty("CPp", this->getPropertyValue(cppLabel())); polAlg->setProperty("CRho", this->getPropertyValue(crhoLabel())); polAlg->setProperty("CAp", this->getPropertyValue(cApLabel())); polAlg->setProperty("CAlpha", this->getPropertyValue(cAlphaLabel())); polAlg->execute(); // Now we've overwritten the IvsLam workspaces, we'll need to recalculate // the IvsQ ones alg->setProperty("FirstTransmissionRun", ""); alg->setProperty("SecondTransmissionRun", ""); for (size_t i = 0; i < numMembers; ++i) { const std::string IvsQName = outputIvsQ + "_" + boost::lexical_cast<std::string>(i + 1); const std::string IvsLamName = outputIvsLam + "_" + boost::lexical_cast<std::string>(i + 1); alg->setProperty("InputWorkspace", IvsLamName); alg->setProperty("OutputWorkspace", IvsQName); alg->setProperty("CorrectionAlgorithm", "None"); alg->setProperty("OutputWorkspaceWavelength", IvsLamName); alg->execute(); } } else { g_log.warning("Polarization corrections can only be performed on " "multiperiod workspaces."); } } // We finished successfully this->setPropertyValue("OutputWorkspace", outputIvsQ); this->setPropertyValue("OutputWorkspaceWavelength", outputIvsLam); setExecuted(true); notificationCenter().postNotification( new FinishedNotification(this, isExecuted())); return true; }
void kore::RenderMesh::reset(void) { setExecuted(false); }
//============================================================================= // Main execution //============================================================================= StatusCode GaudiSequencer::execute() { if ( m_measureTime ) m_timerTool->start( m_timer ); if (msgLevel(MSG::DEBUG)) debug() << "==> Execute" << endmsg; StatusCode result = StatusCode::SUCCESS; bool seqPass = !m_modeOR; // for OR, result will be false, unless (at least) one is true // for AND, result will be true, unless (at least) one is false // also see comment below .... std::vector<AlgorithmEntry>::const_iterator itE; for ( itE = m_entries.begin(); m_entries.end() != itE; ++itE ) { Algorithm* myAlg = itE->algorithm(); if ( ! myAlg->isEnabled() ) continue; if ( ! myAlg->isExecuted() ) { if ( m_measureTime ) m_timerTool->start( itE->timer() ); result = myAlg->sysExecute(); if ( m_measureTime ) m_timerTool->stop( itE->timer() ); myAlg->setExecuted( true ); if ( ! result.isSuccess() ) break; //== Abort and return bad status } //== Check the returned status if ( !m_ignoreFilter ) { bool passed = myAlg->filterPassed(); if (msgLevel(MSG::VERBOSE)) verbose() << "Algorithm " << myAlg->name() << " returned filter passed " << (passed ? "true" : "false") << endmsg; if ( itE->reverse() ) passed = !passed; //== indicate our own result. For OR, exit as soon as true. // If no more, will exit with false. //== for AND, exit as soon as false. Else, will be true (default) // if not short-circuiting, make sure we latch iPass to 'true' in // OR mode (i.e. it is sufficient for one item to be true in order // to be true at the end, and thus we start out at 'false'), and latch // to 'false' in AND mode (i.e. it is sufficient for one item to // be false to the false in the end, and thus we start out at 'true') // -- i.e. we should not just blindly return the 'last' passed status! // or to put it another way: in OR mode, we don't care about things // which are false, as they leave our current state alone (provided // we stared as 'false'!), and in AND mode, we keep our current // state until someone returns 'false' (provided we started as 'true') if ( m_modeOR ? passed : !passed ) { seqPass = passed; if (msgLevel(MSG::VERBOSE)) verbose() << "SeqPass is now " << (seqPass ? "true" : "false") << endmsg; if (m_shortCircuit) break; } } } if (msgLevel(MSG::VERBOSE)) verbose() << "SeqPass is " << (seqPass ? "true" : "false") << endmsg; if ( !m_ignoreFilter && !m_entries.empty() ) setFilterPassed( seqPass ); setExecuted( true ); if ( m_measureTime ) m_timerTool->stop( m_timer ); return m_returnOK ? StatusCode::SUCCESS : result; }