LCOV - code coverage report
Current view: top level - src/config - config_file_to_host.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 25 33 75.8 %
Date: 2025-09-09 12:09:29 Functions: 6 10 60.0 %

          Line data    Source code
       1             : #include "config.hpp"
       2             : 
       3             : 
       4          22 : ConfigFileToHost::ConfigFileToHost() : ConfigToHost(), ConfigFile() {
       5          22 :     resource.toflx = false;
       6          22 :     use_file = true;
       7          22 : }
       8             : 
       9          44 : ConfigFileToHost::~ConfigFileToHost() {
      10          44 : }
      11             : 
      12           0 : std::ostream& ConfigFileToHost::format(std::ostream& os) const {
      13           0 :     os << "ConfigFileToHost" << std::endl;
      14           0 :     os << "block_rate: " << block_rate << std::endl;
      15           0 :     os << "repeat: " << repeat << std::endl;
      16           0 :     os << std::endl;
      17           0 :     return ConfigToHost::format(ConfigFile::format(os));
      18             : }
      19             : 
      20           0 : std::ostream& operator<<(std::ostream& os, const ConfigFileToHost& c) {
      21           0 :     return c.format(os);
      22             : }
      23             : 
      24          22 : std::string ConfigFileToHost::usage() {
      25          22 :     return
      26          22 : R"(felix-file2host - FELIX central data acquisition application
      27             : 
      28             :     Usage:
      29             :       felix-file2host [options --device=<device>... --cid=<cid>... --dma=<id>... --elink=DMAID:LID... --stream=DMAID:LID...] FILE
      30             : )";
      31             : }
      32             : 
      33          22 : std::string ConfigFileToHost::options() {
      34          44 :     return ConfigToHost::options() + ConfigFile::options() +
      35          44 : R"(
      36             :     FileToHost Options:
      37             :         --block-rate=RATE           Use to define the reading rate. [default: 0] (max.speed)
      38             :         --data-format=FMT           ToHost data format, 0(1) for subchunk trailer(headers). [default: 0]
      39             :         --no-repeat                 Do not repeat reading the file
      40             :     -u, --stream=ELINK ...          Enable elinks with streams, syntax DMAid:elink e.g. 0:0x08.
      41             : )" ;
      42             : }
      43             : 
      44          22 : void ConfigFileToHost::handle_cmd_line(std::map<std::string, docopt::value> args) {
      45          22 :     ConfigToHost::handle_cmd_line(args);
      46          22 :     ConfigFile::handle_cmd_line(args);
      47             : 
      48          22 :     block_rate = args["--block-rate"].asLong();
      49          22 :     toHostDataFormat = args["--data-format"].asLong();
      50          22 :     repeat = !args["--no-repeat"].asBool();
      51             : 
      52          26 :     for(auto entry : args["--stream"].asStringList() ){
      53           4 :         std::string::size_type n = entry.find(":");
      54           8 :         int dmaid = stoi(entry.substr(0, n));
      55           8 :         uint16_t elink = std::stoul(entry.substr(n+1), nullptr, 16);
      56           4 :         elinks_with_streams[dmaid].push_back(elink);
      57           4 :     }
      58          22 : }

Generated by: LCOV version 1.0