|
| 1 | +// Copyright CERN and copyright holders of ALICE O2. This software is |
| 2 | +// distributed under the terms of the GNU General Public License v3 (GPL |
| 3 | +// Version 3), copied verbatim in the file "COPYING". |
| 4 | +// |
| 5 | +// See http://alice-o2.web.cern.ch/license for full licensing information. |
| 6 | +// |
| 7 | +// In applying this license CERN does not waive the privileges and immunities |
| 8 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 9 | +// or submit itself to any jurisdiction. |
| 10 | + |
| 11 | +/// \file ProgramUserLogic.cxx |
| 12 | +/// \brief Tool to control and report on the dummy(!) User Logic |
| 13 | +/// |
| 14 | +/// \author Kostas Alexopoulos ([email protected]) |
| 15 | + |
| 16 | +#include <iostream> |
| 17 | +#include "Cru/CruBar.h" |
| 18 | +#include "ReadoutCard/ChannelFactory.h" |
| 19 | +#include "CommandLineUtilities/Options.h" |
| 20 | +#include "CommandLineUtilities/Program.h" |
| 21 | + |
| 22 | +using namespace AliceO2::roc::CommandLineUtilities; |
| 23 | +using namespace AliceO2::roc; |
| 24 | +namespace po = boost::program_options; |
| 25 | + |
| 26 | +class ProgramUserLogic : public Program |
| 27 | +{ |
| 28 | + public: |
| 29 | + virtual Description getDescription() |
| 30 | + { |
| 31 | + return { "User Logic", "Control the dummy User Logic", |
| 32 | + "roc-ul --id 0042:0 --event-size=128 \n" |
| 33 | + "roc-ul --id 0042:0 --random-event-size \n" |
| 34 | + "roc-ul --id 0042:0 --status \n" }; |
| 35 | + } |
| 36 | + |
| 37 | + virtual void addOptions(boost::program_options::options_description& options) |
| 38 | + { |
| 39 | + Options::addOptionCardId(options); |
| 40 | + options.add_options()("random-event-size", |
| 41 | + po::bool_switch(&mOptions.randomEventSize), |
| 42 | + "Toggle random event size"); |
| 43 | + options.add_options()("event-size", |
| 44 | + po::value<uint32_t>(&mOptions.eventSize)->default_value(100), |
| 45 | + "Set the event size (in GBT words = 128bits)"); |
| 46 | + options.add_options()("status", |
| 47 | + po::bool_switch(&mOptions.status), |
| 48 | + "Print UL status only"); |
| 49 | + } |
| 50 | + |
| 51 | + virtual void run(const boost::program_options::variables_map& map) |
| 52 | + { |
| 53 | + |
| 54 | + auto cardId = Options::getOptionCardId(map); |
| 55 | + auto card = RocPciDevice(cardId).getCardDescriptor(); |
| 56 | + auto cardType = card.cardType; |
| 57 | + if (cardType != CardType::type::Cru) { |
| 58 | + std::cerr << "Unsupported card type, only CRU supported." << std::endl; |
| 59 | + return; |
| 60 | + } |
| 61 | + |
| 62 | + Parameters params = Parameters::makeParameters(cardId, 2); |
| 63 | + auto bar = ChannelFactory().getBar(params); |
| 64 | + auto cruBar2 = std::dynamic_pointer_cast<CruBar>(bar); |
| 65 | + if (mOptions.status) { |
| 66 | + Cru::UserLogicInfo ulInfo = cruBar2->reportUserLogic(); |
| 67 | + std::cout << "==========================" << std::endl; |
| 68 | + std::cout << "Event size: " << ulInfo.eventSize << " GBT words" << std::endl; |
| 69 | + std::cout << "Event size: " << (ulInfo.eventSize * 128) / 1024.0 << "Kb" << std::endl; |
| 70 | + std::cout << "Event size: " << (ulInfo.eventSize * 128) / (1024.0 * 8) << "KB" << std::endl; |
| 71 | + std::cout << "Randomized: " << std::boolalpha << ulInfo.random << std::endl; |
| 72 | + std::cout << "==========================" << std::endl; |
| 73 | + } else { |
| 74 | + cruBar2->controlUserLogic(mOptions.eventSize, mOptions.randomEventSize); |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + private: |
| 79 | + struct OptionsStruct { |
| 80 | + uint32_t eventSize; |
| 81 | + bool randomEventSize; |
| 82 | + bool status; |
| 83 | + } mOptions; |
| 84 | +}; |
| 85 | + |
| 86 | +int main(int argc, char** argv) |
| 87 | +{ |
| 88 | + return ProgramUserLogic().execute(argc, argv); |
| 89 | +} |
0 commit comments