diff --git a/CMakeLists.txt b/CMakeLists.txt index 68582384994d738c58685586d1653da4b1f53056..346b106c53e59daa7ed5d6dd552abb0c073f9c48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,9 @@ endif() find_package(coda_et REQUIRED) get_target_property(CODA_ET_INCLUDE_DIR coda_et::coda_et INTERFACE_INCLUDE_DIRECTORIES) +find_package(EVIO REQUIRED) +get_target_property(EVIO_INCLUDE_DIR EVIO::EVIO INTERFACE_INCLUDE_DIRECTORIES) + #---------------------------------------------------------------------------- # Set up Podd and ROOT dependencies if(HCANA_BUILTIN_PODD) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 74815add0127f8aad04c09b75a6d80c36669208c..5913b619cf79375dbab3c0c2e0b40dc1071ad82c 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -16,6 +16,7 @@ foreach(exe_src ${APP_SOURCES}) $<INSTALL_INTERFACE:${SPDLOG_INCLUDE_DIR}> $<BUILD_INTERFACE:${FMT_INCLUDE_DIR}> $<BUILD_INTERFACE:${CODA_ET_INCLUDE_DIR}> + $<BUILD_INTERFACE:${EVIO_INCLUDE_DIR}> ) target_link_libraries(${exe} @@ -24,6 +25,7 @@ foreach(exe_src ${APP_SOURCES}) Podd::Podd Podd::Decode coda_et::coda_et + EVIO::evioxx ) install(TARGETS ${exe} DESTINATION ${CMAKE_INSTALL_BINDIR}) endforeach(exe_src ${APP_SOURCES}) diff --git a/tools/et_feeder.cpp b/tools/et_feeder.cpp index ce11688f588254cce9a9e3af51bb0ba9c73b0b61..cb14f23c484baaba83bb14f463f1fcc6711a67ea 100644 --- a/tools/et_feeder.cpp +++ b/tools/et_feeder.cpp @@ -1,12 +1,14 @@ #include "ConfigOption.h" #include "PRadETChannel.h" #include "et.h" -#include "evio.h" +#include "evio/evioUtil.hxx" +#include "evio/evioFileChannel.hxx" #include <csignal> #include <thread> #include <chrono> #include <iostream> +#define PROGRESS_COUNT 100 using namespace std::chrono; @@ -19,7 +21,7 @@ void signal_handler(int signal) { } -int main(int argc, char* argv[]) +int main(int argc, char* argv[]) try { // setup input arguments ConfigOption conf_opt; @@ -65,19 +67,20 @@ int main(int argc, char* argv[]) } } + // attach to ET system auto ch = new PRadETChannel(); - try { - ch->Open(host.c_str(), port, etf.c_str()); - ch->NewStation("Data Feeder"); - ch->AttachStation(); - } catch (PRadException e) { - std::cerr << e.FailureType() << ": " << e.FailureDesc() << std::endl; - return -1; - } + ch->Open(host.c_str(), port, etf.c_str()); + ch->NewStation("Data Feeder"); + ch->AttachStation(); + + // evio file reader + evio::evioFileChannel *chan = new evio::evioFileChannel(conf_opt.GetArgument(0).c_str(), "r"); + chan->open(); // install signal handler std::signal(SIGINT, signal_handler); - while (true) { + int count = 0; + while (chan->read()) { if (gSignalStatus == SIGINT) { std::cout << "Received control-C, exiting..." << std::endl; ch->ForceClose(); @@ -86,9 +89,26 @@ int main(int argc, char* argv[]) system_clock::time_point start(system_clock::now()); system_clock::time_point next(start + std::chrono::milliseconds(interval)); + if (++count % PROGRESS_COUNT == 0) { + std::cout << "Read and feed " << count << " events to ET, rate is 1 event per " + << interval << " ms.\r" << std::flush; + } + ch->Write((void*) chan->getBuffer(), chan->getBufSize() * sizeof(uint32_t)); + std::this_thread::sleep_until(next); } + std::cout << "Read and feed " << count << " events to ET, rate is 1 event per " + << interval << " ms." << std::endl; + chan->close(); return 0; + +} catch (PRadException e) { + std::cerr << e.FailureType() << ": " << e.FailureDesc() << std::endl; + return -1; +} catch (evio::evioException e) { + std::cerr << e.toString() << endl; +} catch (...) { + std::cerr << "?unknown exception" << endl; }