void RobotControl::startEvents() { events = getEventList(); if (events.size() == 0) return; moveIndex = 0; moveTimer.setSingleShot(true); moveTimer.start(events.value(0).StartTime*1000); }
void ZMEvents::dateChanged() { if (m_currentDate == m_dateSelector->GetCurrentPos()) return; m_currentDate = m_dateSelector->GetCurrentPos(); getEventList(); }
void ZMEvents::cameraChanged() { if (m_currentCamera == m_cameraSelector->GetCurrentPos()) return; m_currentCamera = m_cameraSelector->GetCurrentPos(); getEventList(); }
bool ZMEvents::keyPressEvent(QKeyEvent *event) { if (GetFocusWidget()->keyPressEvent(event)) return true; bool handled = false; QStringList actions; handled = GetMythMainWindow()->TranslateKeyPress("TV Playback", event, actions); for (int i = 0; i < actions.size() && !handled; i++) { QString action = actions[i]; handled = true; if (action == "MENU") { showMenu(); } else if (action == "ESCAPE") { if (GetFocusWidget() == m_eventGrid) SetFocusWidget(m_cameraSelector); else handled = false; } else if (action == "DELETE") { if (m_deleteButton) m_deleteButton->Push(); } else if (action == "PAUSE") { if (m_playButton) m_playButton->Push(); } else if (action == "INFO") { m_oldestFirst = !m_oldestFirst; getEventList(); } else if (action == "1") setGridLayout(1); else if (action == "2") setGridLayout(2); else if (action == "3") setGridLayout(3); else handled = false; } if (!handled && MythScreenType::keyPressEvent(event)) handled = true; return handled; }
bool ZMEvents::Create(void) { bool foundtheme = false; // Load the theme for this screen foundtheme = LoadWindowFromXML("zoneminder-ui.xml", "zmevents", this); if (!foundtheme) return false; bool err = false; UIUtilE::Assign(this, m_eventNoText, "eventno_text", &err); UIUtilE::Assign(this, m_playButton, "play_button", &err); UIUtilE::Assign(this, m_deleteButton, "delete_button", &err); UIUtilE::Assign(this, m_cameraSelector, "camera_selector", &err); UIUtilE::Assign(this, m_dateSelector, "date_selector", &err); if (err) { LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'zmevents'"); return false; } BuildFocusList(); getCameraList(); getDateList(); connect(m_cameraSelector, SIGNAL(itemSelected(MythUIButtonListItem*)), this, SLOT(cameraChanged())); connect(m_dateSelector, SIGNAL(itemSelected(MythUIButtonListItem*)), this, SLOT(dateChanged())); // play button if (m_playButton) { m_playButton->SetText(tr("Play")); connect(m_playButton, SIGNAL(Clicked()), this, SLOT(playPressed())); } // delete button if (m_deleteButton) { m_deleteButton->SetText(tr("Delete")); connect(m_deleteButton, SIGNAL(Clicked()), this, SLOT(deletePressed())); } m_oldestFirst = (gCoreContext->GetNumSetting("ZoneMinderOldestFirst", 1) == 1); m_showContinuous = (gCoreContext->GetNumSetting("ZoneMinderShowContinuous", 0) == 1); getEventList(); setGridLayout(gCoreContext->GetNumSetting("ZoneMinderGridLayout", 1)); return true; }
/** Remove low resolution TOF from an EventWorkspace */ void RemoveLowResTOF::execEvent() { // set up the output workspace MatrixWorkspace_sptr matrixOutW = getProperty("OutputWorkspace"); auto outW = boost::dynamic_pointer_cast<EventWorkspace>(matrixOutW); MatrixWorkspace_sptr matrixLowResW = getProperty("LowResTOFWorkspace"); if (m_outputLowResTOF) { matrixLowResW = m_inputWS->clone(); setProperty("LowResTOFWorkspace", matrixLowResW); } auto lowW = boost::dynamic_pointer_cast<EventWorkspace>(matrixLowResW); g_log.debug() << "TOF range was " << m_inputEvWS->getTofMin() << " to " << m_inputEvWS->getTofMax() << " microseconds\n"; std::size_t numEventsOrig = outW->getNumberEvents(); // set up the progress bar m_progress = new Progress(this, 0.0, 1.0, m_numberOfSpectra * 2); // algorithm assumes the data is sorted so it can jump out early outW->sortAll(Mantid::DataObjects::TOF_SORT, m_progress); this->getTminData(true); size_t numClearedEventLists = 0; size_t numClearedEvents = 0; // do the actual work for (size_t workspaceIndex = 0; workspaceIndex < m_numberOfSpectra; workspaceIndex++) { if (outW->getEventList(workspaceIndex).getNumberEvents() > 0) { double tmin = this->calcTofMin(workspaceIndex); if (tmin != tmin) { // Problematic g_log.warning() << "tmin for workspaceIndex " << workspaceIndex << " is nan. Clearing out data. " << "There are " << outW->getEventList(workspaceIndex).getNumberEvents() << " of it. \n"; numClearedEventLists += 1; numClearedEvents += outW->getEventList(workspaceIndex).getNumberEvents(); outW->getEventList(workspaceIndex).clear(false); if (m_outputLowResTOF) lowW->getEventList(workspaceIndex).clear(false); } else if (tmin > 0.) { // there might be events between 0 and tmin (i.e., low resolution) outW->getEventList(workspaceIndex).maskTof(0., tmin); if (outW->getEventList(workspaceIndex).getNumberEvents() == 0) numClearedEventLists += 1; if (m_outputLowResTOF) { double tmax = lowW->getEventList(workspaceIndex).getTofMax(); if (tmax != tmax) { g_log.warning() << "tmax for workspaceIndex " << workspaceIndex << " is nan. Clearing out data. \n"; lowW->getEventList(workspaceIndex).clear(false); } else { // There is possibility that tmin calculated is larger than TOF-MAX // of the spectrum if (tmax + DBL_MIN > tmin) lowW->getEventList(workspaceIndex).maskTof(tmin, tmax + DBL_MIN); } } } else { // do nothing if tmin <= 0. for outW if (m_outputLowResTOF) { // tmin = 0. no event will be in low resolution lowW->getEventList(workspaceIndex).clear(false); } } // } } g_log.information() << "Went from " << numEventsOrig << " events to " << outW->getNumberEvents() << " events (" << (static_cast<double>(numEventsOrig - outW->getNumberEvents()) * 100. / static_cast<double>(numEventsOrig)) << "% removed)\n"; if (numClearedEventLists > 0) g_log.warning() << numClearedEventLists << " spectra of " << m_numberOfSpectra << " had all data removed. The number of removed events is " << numClearedEvents << ".\n"; g_log.debug() << "TOF range is now " << outW->getTofMin() << " to " << outW->getTofMax() << " microseconds\n"; outW->clearMRU(); this->runMaskDetectors(); }
void ModeratorTzero::execEvent(const std::string &emode) { g_log.information("Processing event workspace"); const MatrixWorkspace_const_sptr matrixInputWS = getProperty("InputWorkspace"); // generate the output workspace pointer API::MatrixWorkspace_sptr matrixOutputWS = getProperty("OutputWorkspace"); if (matrixOutputWS != matrixInputWS) { matrixOutputWS = matrixInputWS->clone(); setProperty("OutputWorkspace", matrixOutputWS); } auto outputWS = boost::dynamic_pointer_cast<EventWorkspace>(matrixOutputWS); // Get pointers to sample and source IComponent_const_sptr source = m_instrument->getSource(); IComponent_const_sptr sample = m_instrument->getSample(); double Lss = source->getDistance(*sample); // distance from source to sample // calculate tof shift once for all neutrons if emode==Direct double t0_direct(-1); if (emode == "Direct") { Kernel::Property *eiprop = outputWS->run().getProperty("Ei"); double Ei = boost::lexical_cast<double>(eiprop->value()); mu::Parser parser; parser.DefineVar("incidentEnergy", &Ei); // associate E1 to this parser parser.SetExpr(m_formula); t0_direct = parser.Eval(); } // Loop over the spectra const size_t numHists = static_cast<size_t>(outputWS->getNumberHistograms()); Progress prog(this, 0.0, 1.0, numHists); // report progress of algorithm PARALLEL_FOR1(outputWS) for (int i = 0; i < static_cast<int>(numHists); ++i) { PARALLEL_START_INTERUPT_REGION size_t wsIndex = static_cast<size_t>(i); EventList &evlist = outputWS->getEventList(wsIndex); if (evlist.getNumberEvents() > 0) // don't bother with empty lists { IDetector_const_sptr det; double L1(Lss); // distance from source to sample double L2(-1); // distance from sample to detector try { det = outputWS->getDetector(i); if (det->isMonitor()) { // redefine the sample as the monitor L1 = source->getDistance(*det); L2 = 0; } else { L2 = sample->getDistance(*det); } } catch (Exception::NotFoundError &) { g_log.error() << "Unable to calculate distances to/from detector" << i << std::endl; } if (L2 >= 0) { // One parser for each parallel processor needed (except Edirect mode) double E1; mu::Parser parser; parser.DefineVar("incidentEnergy", &E1); // associate E1 to this parser parser.SetExpr(m_formula); // fast neutrons are shifted by min_t0_next, irrespective of tof double v1_max = L1 / m_t1min; E1 = m_convfactor * v1_max * v1_max; double min_t0_next = parser.Eval(); if (emode == "Indirect") { double t2(-1.0); // time from sample to detector. (-1) signals error if (det->isMonitor()) { t2 = 0.0; } else { static const double convFact = 1.0e-6 * sqrt(2 * PhysicalConstants::meV / PhysicalConstants::NeutronMass); std::vector<double> wsProp = det->getNumberParameter("Efixed"); if (!wsProp.empty()) { double E2 = wsProp.at(0); //[E2]=meV double v2 = convFact * sqrt(E2); //[v2]=meter/microsec t2 = L2 / v2; } else { // t2 is kept to -1 if no Efixed is found g_log.debug() << "Efixed not found for detector " << i << std::endl; } } if (t2 >= 0) // t2 < 0 when no detector info is available { // fix the histogram bins MantidVec &x = evlist.dataX(); for (double &tof : x) { if (tof < m_t1min + t2) tof -= min_t0_next; else tof -= CalculateT0indirect(tof, L1, t2, E1, parser); } MantidVec tofs = evlist.getTofs(); for (double &tof : tofs) { if (tof < m_t1min + t2) tof -= min_t0_next; else tof -= CalculateT0indirect(tof, L1, t2, E1, parser); } evlist.setTofs(tofs); evlist.setSortOrder(Mantid::DataObjects::EventSortType::UNSORTED); } // end of if( t2>= 0) } // end of if(emode=="Indirect") else if (emode == "Elastic") { // Apply t0 correction to histogram bins MantidVec &x = evlist.dataX(); for (double &tof : x) { if (tof < m_t1min * (L1 + L2) / L1) tof -= min_t0_next; else tof -= CalculateT0elastic(tof, L1 + L2, E1, parser); } MantidVec tofs = evlist.getTofs(); for (double &tof : tofs) { // add a [-0.1,0.1] microsecond noise to avoid artifacts // resulting from original tof data if (tof < m_t1min * (L1 + L2) / L1) tof -= min_t0_next; else tof -= CalculateT0elastic(tof, L1 + L2, E1, parser); } evlist.setTofs(tofs); evlist.setSortOrder(Mantid::DataObjects::EventSortType::UNSORTED); MantidVec tofs_b = evlist.getTofs(); MantidVec xarray = evlist.readX(); } // end of else if(emode=="Elastic") else if (emode == "Direct") { // fix the histogram bins MantidVec &x = evlist.dataX(); for (double &tof : x) { tof -= t0_direct; } MantidVec tofs = evlist.getTofs(); for (double &tof : tofs) { tof -= t0_direct; } evlist.setTofs(tofs); evlist.setSortOrder(Mantid::DataObjects::EventSortType::UNSORTED); } // end of else if(emode=="Direct") } // end of if(L2 >= 0) } // end of if (evlist.getNumberEvents() > 0) prog.report(); PARALLEL_END_INTERUPT_REGION } // end of for (int i = 0; i < static_cast<int>(numHists); ++i) PARALLEL_CHECK_INTERUPT_REGION outputWS->clearMRU(); // Clears the Most Recent Used lists */ } // end of void ModeratorTzero::execEvent()