diff --git a/fairmq/plugins/DDS/DDS.cxx b/fairmq/plugins/DDS/DDS.cxx index c6e82321..fb8c4398 100644 --- a/fairmq/plugins/DDS/DDS.cxx +++ b/fairmq/plugins/DDS/DDS.cxx @@ -10,6 +10,8 @@ #include // for the interactive mode #include // for the interactive mode +#include +#include using namespace std; @@ -89,7 +91,7 @@ auto DDS::HandleControl() -> void } // subscribe for state changes from DDS (subscriptions start firing after fService.start() is called) - SubscribeForStateChanges(); + SubscribeForCustomCommands(); // start DDS service - subscriptions will only start firing after this step fService.start(); @@ -201,7 +203,7 @@ auto DDS::PublishBoundChannels() -> void } } -auto DDS::SubscribeForStateChanges() -> void +auto DDS::SubscribeForCustomCommands() -> void { string id = GetProperty("id"); string pid(to_string(getpid())); @@ -230,6 +232,15 @@ auto DDS::SubscribeForStateChanges() -> void fStopCondition.notify_one(); } } + else if (cmd == "dump-config") + { + stringstream ss; + for (const auto pKey: GetPropertyKeys()) + { + ss << id << ": " << pKey << " -> " << GetPropertyAsString(pKey) << endl; + } + fDDSCustomCmd.send(ss.str(), to_string(senderId)); + } else { LOG(WARN) << "Unknown command: " << cmd; diff --git a/fairmq/plugins/DDS/DDS.h b/fairmq/plugins/DDS/DDS.h index 88a757bc..01acf999 100644 --- a/fairmq/plugins/DDS/DDS.h +++ b/fairmq/plugins/DDS/DDS.h @@ -56,7 +56,7 @@ class DDS : public Plugin auto FillChannelContainers() -> void; auto SubscribeForConnectingChannels() -> void; auto PublishBoundChannels() -> void; - auto SubscribeForStateChanges() -> void; + auto SubscribeForCustomCommands() -> void; dds::intercom_api::CIntercomService fService; dds::intercom_api::CCustomCmd fDDSCustomCmd; diff --git a/fairmq/plugins/DDS/runDDSCommandUI.cxx b/fairmq/plugins/DDS/runDDSCommandUI.cxx index c7ffe6e9..0bcdb23b 100644 --- a/fairmq/plugins/DDS/runDDSCommandUI.cxx +++ b/fairmq/plugins/DDS/runDDSCommandUI.cxx @@ -23,7 +23,7 @@ using namespace dds::intercom_api; void PrintControlsHelp() { cout << "Use keys to control the devices:" << endl; - cout << "[c] check states, [h] help, [p] pause, [r] run, [s] stop, [t] reset task, [d] reset device, [q] end, [j] init task, [i] init device" << endl; + cout << "[c] check states, [o] dump config, [h] help, [p] pause, [r] run, [s] stop, [t] reset task, [d] reset device, [q] end, [j] init task, [i] init device" << endl; cout << "To quit press Ctrl+C" << endl; } @@ -42,7 +42,7 @@ int main(int argc, char* argv[]) // subscribe to receive messages from DDS ddsCustomCmd.subscribe([](const string& msg, const string& /*condition*/, uint64_t /*senderId*/) { - cout << "Received: \"" << msg << "\"" << endl; + cout << "Received: " << msg << endl; }); service.start(); @@ -72,6 +72,10 @@ int main(int argc, char* argv[]) cout << " > checking state of the devices" << endl; ddsCustomCmd.send("check-state", ""); break; + case 'o': + cout << " > dumping config of the devices" << endl; + ddsCustomCmd.send("dump-config", ""); + break; case 'i': cout << " > init devices" << endl; ddsCustomCmd.send("INIT DEVICE", "");