From 2817df42311de6ac70ef2af45244f515961e29d3 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Fri, 27 Feb 2026 11:07:38 -0600 Subject: [PATCH 1/3] JCF: for a study, remove moo dependency --- CMakeLists.txt | 2 +- include/cmdlib/cmd/Nljs.hpp | 50 +++++++++++++++++++++++++++ include/cmdlib/cmd/Structs.hpp | 62 ++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 include/cmdlib/cmd/Nljs.hpp create mode 100644 include/cmdlib/cmd/Structs.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4eb1fb3..6262fd0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ find_package(ers REQUIRED) set(CMDLIB_DEPENDENCIES ${CETLIB} ${CETLIB_EXCEPT} TBB::tbb logging::logging ers::ers nlohmann_json::nlohmann_json) -daq_codegen(*.jsonnet TEMPLATES Structs.hpp.j2 Nljs.hpp.j2 ) +#daq_codegen(*.jsonnet TEMPLATES Structs.hpp.j2 Nljs.hpp.j2 ) ############################################################################## # Main library diff --git a/include/cmdlib/cmd/Nljs.hpp b/include/cmdlib/cmd/Nljs.hpp new file mode 100644 index 0000000..20921f1 --- /dev/null +++ b/include/cmdlib/cmd/Nljs.hpp @@ -0,0 +1,50 @@ +/* + * This file is 100% generated. Any manual edits will likely be lost. + * + * This contains functions struct and other type definitions for shema in + * namespace dunedaq::cmdlib::cmd to be serialized via nlohmann::json. + */ +#ifndef DUNEDAQ_CMDLIB_CMD_NLJS_HPP +#define DUNEDAQ_CMDLIB_CMD_NLJS_HPP + +// My structs +#include "cmdlib/cmd/Structs.hpp" + + +#include + +namespace dunedaq::cmdlib::cmd { + + using data_t = nlohmann::json; + + inline void to_json(data_t& j, const Command& obj) { + j["id"] = obj.id; + j["data"] = obj.data; + } + + inline void from_json(const data_t& j, Command& obj) { + if (j.contains("id")) + j.at("id").get_to(obj.id); + obj.data = j.at("data"); + } + + inline void to_json(data_t& j, const CommandReply& obj) { + j["success"] = obj.success; + j["result"] = obj.result; + j["appname"] = obj.appname; + j["data"] = obj.data; + } + + inline void from_json(const data_t& j, CommandReply& obj) { + if (j.contains("success")) + j.at("success").get_to(obj.success); + if (j.contains("result")) + j.at("result").get_to(obj.result); + if (j.contains("appname")) + j.at("appname").get_to(obj.appname); + obj.data = j.at("data"); + } + +} // namespace dunedaq::cmdlib::cmd + +#endif // DUNEDAQ_CMDLIB_CMD_NLJS_HPP \ No newline at end of file diff --git a/include/cmdlib/cmd/Structs.hpp b/include/cmdlib/cmd/Structs.hpp new file mode 100644 index 0000000..c04b0a5 --- /dev/null +++ b/include/cmdlib/cmd/Structs.hpp @@ -0,0 +1,62 @@ +/* + * This file is 100% generated. Any manual edits will likely be lost. + * + * This contains struct and other type definitions for shema in + * namespace dunedaq::cmdlib::cmd. + */ +#ifndef DUNEDAQ_CMDLIB_CMD_STRUCTS_HPP +#define DUNEDAQ_CMDLIB_CMD_STRUCTS_HPP + +#include + +#include +#include + +namespace dunedaq::cmdlib::cmd { + + // @brief The aplication name. + using AppId = std::string; + + // @brief The command name. FIXME: this should be an enum! + using CmdId = std::string; + + // @brief An opaque object holding lower layer substructure + using Data = nlohmann::json; + + // @brief Top-level command object structure + struct Command + { + + // @brief Identify the type of command + CmdId id = ""; + + // @brief Command data object with type-specific structure + Data data = {}; + }; + + // @brief Outcome of the command: OK=true, NotOK=false + using IsOk = bool; + + // @brief The command name. + using Result = std::string; + + // @brief Top-level command reply object structure + struct CommandReply + { + + // @brief Outcome of the command: OK=true, NotOK=false + IsOk success = true; + + // @brief Textual result of the command + Result result = ""; + + // @brief Application name + AppId appname = ""; + + // @brief Command reply data object with type-specific structure + Data data = {}; + }; + +} // namespace dunedaq::cmdlib::cmd + +#endif // DUNEDAQ_CMDLIB_CMD_STRUCTS_HPP \ No newline at end of file From 333b1293c3be2c49ced500705290315e71a9833d Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 20 Apr 2026 11:08:07 -0500 Subject: [PATCH 2/3] JCF: DUNE-DAQ/daq-deliverables#214: remove commented-out call to obsolete daq_codegen function --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6262fd0..ead789b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,6 @@ find_package(ers REQUIRED) set(CMDLIB_DEPENDENCIES ${CETLIB} ${CETLIB_EXCEPT} TBB::tbb logging::logging ers::ers nlohmann_json::nlohmann_json) -#daq_codegen(*.jsonnet TEMPLATES Structs.hpp.j2 Nljs.hpp.j2 ) - ############################################################################## # Main library From 120a46bd4b775ad5bb1f480e991bd059bfc23e33 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 21 Apr 2026 11:52:23 -0500 Subject: [PATCH 3/3] JCF: DUNE-DAQ/daq-deliverables#214: remove obsolete jsonnet files --- schema/cmdlib/cmd.jsonnet | 46 --------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 schema/cmdlib/cmd.jsonnet diff --git a/schema/cmdlib/cmd.jsonnet b/schema/cmdlib/cmd.jsonnet deleted file mode 100644 index c423f67..0000000 --- a/schema/cmdlib/cmd.jsonnet +++ /dev/null @@ -1,46 +0,0 @@ -// This is the "command" schema ("cmd") used by appfwk applications. -// -// It governs the expected top-level structure of command objects. -// -// Its objects hold substructure as an "any" type which is expected to -// be interpreted by the next lower layer. - -local moo = import "moo.jsonnet"; -local s = moo.oschema.schema("dunedaq.cmdlib.cmd"); - -// A temporary schema construction context. -local cs = { - data: s.any("Data", - doc="An opaque object holding lower layer substructure"), - - // fixme: this should be an enum but I'm not allowed to make it so yet. - cmdid: s.string("CmdId", pattern=moo.re.ident_only, - doc="The command name. FIXME: this should be an enum!"), - // cmdid: s.enum("CmdId", ["unknown","init","conf","start","stop","scrap","fini"], - // "unknown", doc="The known command types"), - - isok: s.boolean("IsOk", doc="Outcome of the command: OK=true, NotOK=false"), - - descr: s.string("Result", - doc="The command name."), - appid: s.string("AppId", - doc="The aplication name."), - - command: s.record("Command", [ - s.field("id", self.cmdid, - doc="Identify the type of command"), - s.field("data", self.data, optional=true, - doc="Command data object with type-specific structure"), - ], doc="Top-level command object structure"), - - cmdreply: s.record("CommandReply", [ - s.field("success", self.isok, 1, doc="Outcome of the command: OK=true, NotOK=false"), - s.field("result", self.descr, doc="Textual result of the command"), - s.field("appname", self.appid, doc="Application name"), - s.field("data", self.data, optional=true, - doc="Command reply data object with type-specific structure"), - ], doc="Top-level command reply object structure"), -}; - -// Output a topologically sorted array. -moo.oschema.sort_select(cs)