コード例 #1
0
ファイル: sfdaq.c プロジェクト: GumpChan/blackcat
int DAQ_Start ()
{
    int err = daq_start(daq_mod, daq_hand);

    if ( err )
        FatalError("Can't start DAQ (%d) - %s!\n",
            err, daq_get_error(daq_mod, daq_hand));

    else if ( !DAQ_UnprivilegedStart() )
        daq_dlt = daq_get_datalink_type(daq_mod, daq_hand);

    return err;
}
コード例 #2
0
ファイル: engine.cpp プロジェクト: ayuzer/qpx-gamma
ListData* Engine::getList(uint64_t timeout, boost::atomic<bool>& interruptor) {

  boost::unique_lock<boost::mutex> lock(mutex_);

  if (!(aggregate_status_ & DeviceStatus::can_run)) {
    PL_WARN << "<Engine> No devices exist that can perform acquisition";
    return nullptr;
  }

  Spill* one_spill;
  ListData* result = new ListData;

  PL_INFO << "<Engine> Multithreaded list mode acquisition scheduled for " << timeout << " seconds";

  CustomTimer *anouncement_timer = nullptr;
  double secs_between_anouncements = 5;

  get_all_settings();
  save_optimization();
  result->run.state = pull_settings();
  result->run.detectors = get_detectors();
  result->run.time = boost::posix_time::microsec_clock::universal_time();

  SynchronizedQueue<Spill*> parsedQueue;

  if (daq_start(&parsedQueue))
    PL_DBG << "<Engine> Started device daq threads";

  CustomTimer total_timer(timeout, true);
  anouncement_timer = new CustomTimer(true);

  while (daq_running()) {
    wait_ms(1000);
    if (anouncement_timer->s() > secs_between_anouncements) {
      PL_INFO << "  RUNNING Elapsed: " << total_timer.done()
              << "  ETA: " << total_timer.ETA();
      delete anouncement_timer;
      anouncement_timer = new CustomTimer(true);
    }
    if (interruptor.load() || (timeout && total_timer.timeout())) {
      if (daq_stop())
        PL_DBG << "<Engine> Stopped device daq threads successfully";
      else
        PL_ERR << "<Engine> Failed to stop device daq threads";
    }
  }

  delete anouncement_timer;

  result->run.time = boost::posix_time::microsec_clock::universal_time();

  wait_ms(500);

  while (parsedQueue.size() > 0) {
    one_spill = parsedQueue.dequeue();
    for (auto &q : one_spill->hits)
      result->hits.push_back(q);
    delete one_spill;
  }

  parsedQueue.stop();
  return result;
}
コード例 #3
0
ファイル: engine.cpp プロジェクト: ayuzer/qpx-gamma
void Engine::getMca(uint64_t timeout, SpectraSet& spectra, boost::atomic<bool>& interruptor) {

  boost::unique_lock<boost::mutex> lock(mutex_);

  if (!(aggregate_status_ & DeviceStatus::can_run)) {
    PL_WARN << "<Engine> No devices exist that can perform acquisition";
    return;
  }

  PL_INFO << "<Engine> Multithreaded spectra acquisition scheduled for " << timeout << " seconds";

  CustomTimer *anouncement_timer = nullptr;
  double secs_between_anouncements = 5;

  SynchronizedQueue<Spill*> parsedQueue;

  boost::thread builder(boost::bind(&Qpx::Engine::worker_MCA, this, &parsedQueue, &spectra));

  Spill* spill = new Spill;
  get_all_settings();
  save_optimization();
  spill->run.state = pull_settings();
  spill->run.detectors = get_detectors();
  spill->run.time = boost::posix_time::microsec_clock::universal_time();
  parsedQueue.enqueue(spill);

  if (daq_start(&parsedQueue))
    PL_DBG << "<Engine> Started device daq threads";

  CustomTimer total_timer(timeout, true);
  anouncement_timer = new CustomTimer(true);

  while (daq_running()) {
    wait_ms(1000);
    if (anouncement_timer->s() > secs_between_anouncements) {
      if (timeout > 0)
        PL_INFO << "  RUNNING Elapsed: " << total_timer.done()
                << "  ETA: " << total_timer.ETA();
      else
        PL_INFO << "  RUNNING Elapsed: " << total_timer.done();

      delete anouncement_timer;
      anouncement_timer = new CustomTimer(true);
    }
    if (interruptor.load() || (timeout && total_timer.timeout())) {
      if (daq_stop())
        PL_DBG << "<Engine> Stopped device daq threads successfully";
      else
        PL_ERR << "<Engine> Failed to stop device daq threads";
    }
  }

  delete anouncement_timer;

  spill = new Spill;
  get_all_settings();
  save_optimization();
  spill->run.state = pull_settings();
  spill->run.detectors = get_detectors();
  spill->run.time = boost::posix_time::microsec_clock::universal_time();
  parsedQueue.enqueue(spill);

  wait_ms(500);
  while (parsedQueue.size() > 0)
    wait_ms(1000);
  wait_ms(500);
  parsedQueue.stop();
  wait_ms(500);

  builder.join();
}