Program Listing for File config_trickle.cpp
↰ Return to documentation for file (config/config_trickle.cpp)
#include "config.hpp"
ConfigTrickle::ConfigTrickle() : Config()
{
resource.toflx = true;
}
std::ostream& ConfigTrickle::format(std::ostream& os) const
{
os << "ConfigTrickle" << std::endl;
os << "cmem_buffersize: " << resource.cmem_buffersize << std::endl;
os << "unbuffered: " << unbuffered << std::endl;
os << "bus_dir: " << network.bus_dir << std::endl;
os << "bus_groupname: " << network.bus_groupname << std::endl;
os << "cid: ";
if (resource.cid.empty()) { os << "read from registers"; }
for (const auto& device_cids : resource.cid) {
os << "[";
std::copy(device_cids.begin(), device_cids.end(), std::ostream_iterator<int>(os << std::hex << std::showbase, " "));
os << "] ";
}
os << std::dec << std::endl;
os << "did: ";
if (resource.did) { os << "0x" << std::hex << *resource.did << std::dec; }
else { os << "read from register"; }
os << std::endl;
os << "device: ";
std::copy(resource.device.begin(), resource.device.end(), std::ostream_iterator<int>(os, " "));
os << std::endl;
os << "ip: " << network.ip << std::endl;
os << std::endl;
os << "verbose: " << verbose << std::endl;
os << "verbose_bus: " << network.verbose_bus << std::endl;
os << "vid: 0x" << std::hex << static_cast<uint32_t>(resource.vid) << std::dec << std::endl;
os << std::endl;
return os;
}
std::ostream& operator<<(std::ostream& os, const ConfigTrickle& c) {
return c.format(os);
}
std::string ConfigTrickle::usage()
{
return
R"(felix-trickle - FELIX app for sending trickle configuration to front-end devices
Usage:
felix-trickle [options --device=<device>... --cid=<cid>...]
)";
}
std::string ConfigTrickle::options()
{
return
R"(
General Options:
--bus-dir=DIRECTORY Write felix-bus information to this directory. [default: ./bus]
--bus-groupname=NAME Use this groupname for the bus. [default: FELIX]
--cid=<cid>... CID (Connector Ids) to set in FID (Felix ID). Can be used once per device as a comma
separated connector list e.g. 0x10,0x11. Deprecated, use CONNECTOR_ID registers.
--did=<did> DID (Detector Id) to set in FID (Felix ID). Deprecated, use DETECTOR_ID register.
-d, --device=<device>... Use FLX device DEVICE. [default: 0]
--free-cmem Free previously booked cmem segment by name-<device>-<dma>
-?, --help Give this help list
--iface=<iface> Send data to the interface. [calculated: use --ip value]
-i, --ip=<ip> Publish data on the ip address IP. [default: libfabric:127.0.0.1]
-v, --verbose Produce verbose output
--verbose-bus Produce verbose output for bus
-V, --version Print program version
--vid=N VID (Version Id) to set in FID (Felix ID) [default: 1]
Trickle Options:
-c, --cmem=SIZE CMEM buffer size in MB. [default: 800]
-p, --port=PORT Send data to port PORT. [calculated: 53600 + 10*device + dma]
)";
}
void ConfigTrickle::handle_cmd_line(std::map<std::string, docopt::value> args)
{
auto devices = args["--device"].asStringList();
for(const auto& i : devices){
resource.device.push_back(stoi(i));
}
resource.vid = args["--vid"].asLong();
parse_detector_connector_ids(args);
if (args["--free-cmem"].asBool()) {
ers::warning(felix_log::config_issue("--free-cmem option is deprecated, cmem buffers are reclaimed by default and the option has no effect"));
}
network.bus_dir = args["--bus-dir"].asString();
network.bus_groupname = args["--bus-groupname"].asString();
network.verbose_bus = args["--verbose-bus"].asBool();
verbose = args["--verbose"].asBool();
// derive ip
if (args["--iface"]) {
network.ip = utility::get_value_from_getifaddrs(args["--iface"].asString());
} else {
network.ip = args["--ip"].asString();
}
resource.cmem_buffersize = args["--cmem"].asLong() * 1024 * 1024;
constexpr static uint16_t default_port = 0;
const uint16_t trickle_port = args["--port"] ? args["--port"].asLong() : default_port;
for(auto dev : resource.device){
network.ports.emplace(dev, trickle_port);
}
}