mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Allow DDS command UI to target parts of the topology
This commit is contained in:
parent
b89c309768
commit
4aae1ad8d4
|
@ -12,7 +12,6 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <sstream>
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -34,24 +33,27 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
string sessionID;
|
string sessionID;
|
||||||
char commandChar;
|
char command;
|
||||||
|
string topologyPath;
|
||||||
|
|
||||||
bpo::options_description options("fairmq-dds-command-ui options");
|
bpo::options_description options("fairmq-dds-command-ui options");
|
||||||
options.add_options()
|
options.add_options()
|
||||||
("session,s", bpo::value<string>(&sessionID)->required(), "DDS Session ID")
|
("session,s", bpo::value<string> (&sessionID)->required(), "DDS Session ID")
|
||||||
("command,c", bpo::value<char> (&commandChar)->default_value(' '), "Command character")
|
("command,c", bpo::value<char> (&command)->default_value(' '), "Command character")
|
||||||
|
("path,p", bpo::value<string> (&topologyPath)->default_value(""), "DDS Topology path to send command to")
|
||||||
("help,h", "Produce help message");
|
("help,h", "Produce help message");
|
||||||
|
|
||||||
bpo::variables_map vm;
|
bpo::variables_map vm;
|
||||||
bpo::store(bpo::command_line_parser(argc, argv).options(options).run(), vm);
|
bpo::store(bpo::command_line_parser(argc, argv).options(options).run(), vm);
|
||||||
bpo::notify(vm);
|
|
||||||
|
|
||||||
if (vm.count("help")) {
|
if (vm.count("help")) {
|
||||||
cout << "FairMQ DDS Command UI" << endl << options << endl;
|
cout << "FairMQ DDS Command UI" << endl << options << endl;
|
||||||
cout << "possible command characters: [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 << "Commands: [c] check state, [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;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bpo::notify(vm);
|
||||||
|
|
||||||
CIntercomService service;
|
CIntercomService service;
|
||||||
CCustomCmd ddsCustomCmd(service);
|
CCustomCmd ddsCustomCmd(service);
|
||||||
|
|
||||||
|
@ -61,7 +63,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: " << endl << msg << endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
service.start(sessionID);
|
service.start(sessionID);
|
||||||
|
@ -74,8 +76,8 @@ int main(int argc, char* argv[])
|
||||||
t.c_lflag &= ~ICANON; // disable canonical input
|
t.c_lflag &= ~ICANON; // disable canonical input
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &t); // apply the new settings
|
tcsetattr(STDIN_FILENO, TCSANOW, &t); // apply the new settings
|
||||||
|
|
||||||
if (commandChar != ' ') {
|
if (command != ' ') {
|
||||||
cin.putback(commandChar);
|
cin.putback(command);
|
||||||
} else {
|
} else {
|
||||||
PrintControlsHelp();
|
PrintControlsHelp();
|
||||||
}
|
}
|
||||||
|
@ -84,39 +86,39 @@ int main(int argc, char* argv[])
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
cout << " > checking state of the devices" << endl;
|
cout << " > checking state of the devices" << endl;
|
||||||
ddsCustomCmd.send("check-state", "");
|
ddsCustomCmd.send("check-state", topologyPath);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
cout << " > dumping config of the devices" << endl;
|
cout << " > dumping config of the devices" << endl;
|
||||||
ddsCustomCmd.send("dump-config", "");
|
ddsCustomCmd.send("dump-config", topologyPath);
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
cout << " > init devices" << endl;
|
cout << " > init devices" << endl;
|
||||||
ddsCustomCmd.send("INIT DEVICE", "");
|
ddsCustomCmd.send("INIT DEVICE", topologyPath);
|
||||||
break;
|
break;
|
||||||
case 'j':
|
case 'j':
|
||||||
cout << " > init tasks" << endl;
|
cout << " > init tasks" << endl;
|
||||||
ddsCustomCmd.send("INIT TASK", "");
|
ddsCustomCmd.send("INIT TASK", topologyPath);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
cout << " > pause devices" << endl;
|
cout << " > pause devices" << endl;
|
||||||
ddsCustomCmd.send("PAUSE", "");
|
ddsCustomCmd.send("PAUSE", topologyPath);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
cout << " > run tasks" << endl;
|
cout << " > run tasks" << endl;
|
||||||
ddsCustomCmd.send("RUN", "");
|
ddsCustomCmd.send("RUN", topologyPath);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
cout << " > stop devices" << endl;
|
cout << " > stop devices" << endl;
|
||||||
ddsCustomCmd.send("STOP", "");
|
ddsCustomCmd.send("STOP", topologyPath);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
cout << " > reset tasks" << endl;
|
cout << " > reset tasks" << endl;
|
||||||
ddsCustomCmd.send("RESET TASK", "");
|
ddsCustomCmd.send("RESET TASK", topologyPath);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
cout << " > reset devices" << endl;
|
cout << " > reset devices" << endl;
|
||||||
ddsCustomCmd.send("RESET DEVICE", "");
|
ddsCustomCmd.send("RESET DEVICE", topologyPath);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
cout << " > help" << endl;
|
cout << " > help" << endl;
|
||||||
|
@ -124,7 +126,7 @@ int main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
cout << " > end" << endl;
|
cout << " > end" << endl;
|
||||||
ddsCustomCmd.send("END", "");
|
ddsCustomCmd.send("END", topologyPath);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cout << "Invalid input: [" << c << "]" << endl;
|
cout << "Invalid input: [" << c << "]" << endl;
|
||||||
|
@ -132,8 +134,8 @@ int main(int argc, char* argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commandChar != ' ') {
|
if (command != ' ') {
|
||||||
usleep(50000);
|
this_thread::sleep_for(chrono::milliseconds(100)); // give dds a chance to complete request
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user