Line data Source code
1 : /**
2 : * @file dal_methods.cpp
3 : *
4 : * This is part of the DUNE DAQ Software Suite, copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 :
9 : #include "pybind11/operators.h"
10 : #include "pybind11/pybind11.h"
11 : #include "pybind11/stl.h"
12 :
13 : #include "confmodel/DaqModule.hpp"
14 : #include "confmodel/Session.hpp"
15 :
16 : #include "appmodel/SmartDaqApplication.hpp"
17 :
18 : #include <sstream>
19 :
20 : namespace py = pybind11;
21 :
22 : namespace dunedaq::appmodel::python {
23 :
24 : struct ObjectLocator {
25 0 : ObjectLocator(const std::string& id_arg, const std::string& class_name_arg) :
26 0 : id(id_arg), class_name(class_name_arg)
27 0 : {}
28 : const std::string id;
29 : const std::string class_name;
30 : };
31 :
32 : std::vector<ObjectLocator>
33 0 : smart_daq_application_generate_modules(const conffwk::Configuration& confdb, const std::string& app_id, const std::string& session_id)
34 : {
35 0 : auto app =
36 0 : const_cast<conffwk::Configuration&>(confdb).get<appmodel::SmartDaqApplication>(app_id);
37 0 : auto session =
38 0 : const_cast<conffwk::Configuration&>(confdb).get<confmodel::Session>(session_id);
39 :
40 0 : auto helper = std::make_shared<ConfigurationHelper>(session);
41 0 : app->generate_modules(helper);
42 0 : std::vector<ObjectLocator> mods;
43 0 : for (auto mod : app->get_modules()) {
44 0 : mods.push_back({mod->UID(),mod->class_name()});
45 : }
46 0 : return mods;
47 0 : }
48 :
49 0 : std::vector<std::string> smart_daq_application_construct_commandline_parameters(const conffwk::Configuration& db,
50 : const std::string& session_id,
51 : const std::string& app_id) {
52 0 : const auto* app = const_cast<conffwk::Configuration&>(db).get<dunedaq::appmodel::SmartDaqApplication>(app_id);
53 0 : const auto* session = const_cast<conffwk::Configuration&>(db).get<dunedaq::confmodel::Session>(session_id);
54 0 : return app->construct_commandline_parameters(db, session);
55 : }
56 :
57 : void
58 0 : register_dal_methods(py::module& m)
59 : {
60 0 : py::class_<ObjectLocator>(m, "ObjectLocator")
61 0 : .def(py::init<const std::string&, const std::string&>())
62 0 : .def_readonly("id", &ObjectLocator::id)
63 0 : .def_readonly("class_name", &ObjectLocator::class_name)
64 : ;
65 :
66 0 : m.def("smart_daq_application_generate_modules", &smart_daq_application_generate_modules, "Generate DaqModules");
67 0 : m.def("smart_daq_application_construct_commandline_parameters", &smart_daq_application_construct_commandline_parameters, "Get a version of the command line agruments parsed");
68 0 : }
69 :
70 : } // namespace dunedaq::appmodel::python
|