mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
FairMQ: Add dump-config functionality to DDS plugin
This commit is contained in:
parent
511141c851
commit
7429f7a326
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
#include <termios.h> // for the interactive mode
|
#include <termios.h> // for the interactive mode
|
||||||
#include <poll.h> // for the interactive mode
|
#include <poll.h> // for the interactive mode
|
||||||
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
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)
|
// 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
|
// start DDS service - subscriptions will only start firing after this step
|
||||||
fService.start();
|
fService.start();
|
||||||
|
@ -201,7 +203,7 @@ auto DDS::PublishBoundChannels() -> void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DDS::SubscribeForStateChanges() -> void
|
auto DDS::SubscribeForCustomCommands() -> void
|
||||||
{
|
{
|
||||||
string id = GetProperty<string>("id");
|
string id = GetProperty<string>("id");
|
||||||
string pid(to_string(getpid()));
|
string pid(to_string(getpid()));
|
||||||
|
@ -230,6 +232,15 @@ auto DDS::SubscribeForStateChanges() -> void
|
||||||
fStopCondition.notify_one();
|
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
|
else
|
||||||
{
|
{
|
||||||
LOG(WARN) << "Unknown command: " << cmd;
|
LOG(WARN) << "Unknown command: " << cmd;
|
||||||
|
|
|
@ -56,7 +56,7 @@ class DDS : public Plugin
|
||||||
auto FillChannelContainers() -> void;
|
auto FillChannelContainers() -> void;
|
||||||
auto SubscribeForConnectingChannels() -> void;
|
auto SubscribeForConnectingChannels() -> void;
|
||||||
auto PublishBoundChannels() -> void;
|
auto PublishBoundChannels() -> void;
|
||||||
auto SubscribeForStateChanges() -> void;
|
auto SubscribeForCustomCommands() -> void;
|
||||||
|
|
||||||
dds::intercom_api::CIntercomService fService;
|
dds::intercom_api::CIntercomService fService;
|
||||||
dds::intercom_api::CCustomCmd fDDSCustomCmd;
|
dds::intercom_api::CCustomCmd fDDSCustomCmd;
|
||||||
|
|
|
@ -23,7 +23,7 @@ using namespace dds::intercom_api;
|
||||||
void PrintControlsHelp()
|
void PrintControlsHelp()
|
||||||
{
|
{
|
||||||
cout << "Use keys to control the devices:" << endl;
|
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;
|
cout << "To quit press Ctrl+C" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ int main(int argc, char* argv[])
|
||||||
// subscribe to receive messages from DDS
|
// subscribe to receive messages from DDS
|
||||||
ddsCustomCmd.subscribe([](const string& msg, const string& /*condition*/, uint64_t /*senderId*/)
|
ddsCustomCmd.subscribe([](const string& msg, const string& /*condition*/, uint64_t /*senderId*/)
|
||||||
{
|
{
|
||||||
cout << "Received: \"" << msg << "\"" << endl;
|
cout << "Received: " << msg << endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
service.start();
|
service.start();
|
||||||
|
@ -72,6 +72,10 @@ int main(int argc, char* argv[])
|
||||||
cout << " > checking state of the devices" << endl;
|
cout << " > checking state of the devices" << endl;
|
||||||
ddsCustomCmd.send("check-state", "");
|
ddsCustomCmd.send("check-state", "");
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
cout << " > dumping config of the devices" << endl;
|
||||||
|
ddsCustomCmd.send("dump-config", "");
|
||||||
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
cout << " > init devices" << endl;
|
cout << " > init devices" << endl;
|
||||||
ddsCustomCmd.send("INIT DEVICE", "");
|
ddsCustomCmd.send("INIT DEVICE", "");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user