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 : app->generate_modules(session);
41 0 : std::vector<ObjectLocator> mods;
42 0 : for (auto mod : app->get_modules()) {
43 0 : mods.push_back({mod->UID(),mod->class_name()});
44 : }
45 0 : return mods;
46 0 : }
47 :
48 0 : std::vector<std::string> smart_daq_application_construct_commandline_parameters(const conffwk::Configuration& db,
49 : const std::string& session_id,
50 : const std::string& app_id) {
51 0 : const auto* app = const_cast<conffwk::Configuration&>(db).get<dunedaq::appmodel::SmartDaqApplication>(app_id);
52 0 : const auto* session = const_cast<conffwk::Configuration&>(db).get<dunedaq::confmodel::Session>(session_id);
53 0 : return app->construct_commandline_parameters(db, session);
54 : }
55 :
56 : void
57 0 : register_dal_methods(py::module& m)
58 : {
59 0 : py::class_<ObjectLocator>(m, "ObjectLocator")
60 0 : .def(py::init<const std::string&, const std::string&>())
61 0 : .def_readonly("id", &ObjectLocator::id)
62 0 : .def_readonly("class_name", &ObjectLocator::class_name)
63 : ;
64 :
65 0 : m.def("smart_daq_application_generate_modules", &smart_daq_application_generate_modules, "Generate DaqModules");
66 0 : m.def("smart_daq_application_construct_commandline_parameters", &smart_daq_application_construct_commandline_parameters, "Get a version of the command line agruments parsed");
67 0 : }
68 :
69 : } // namespace dunedaq::appmodel::python
|