mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
Modified runDDSCommandUI to accept command line argument.
If no arguments, it behaves like before. Removed runDDSCommand and replaced calls to it in controlDDS.
This commit is contained in:
parent
65ca151620
commit
fd09321fd9
|
@ -61,13 +61,6 @@ Set(LINK_DIRECTORIES
|
||||||
${Boost_LIBRARY_DIRS}
|
${Boost_LIBRARY_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
If(DDS_FOUND)
|
|
||||||
Set(LINK_DIRECTORIES
|
|
||||||
${LINK_DIRECTORIES}
|
|
||||||
DDS_LIBRARY_DIR
|
|
||||||
)
|
|
||||||
EndIf(DDS_FOUND)
|
|
||||||
|
|
||||||
Link_Directories(${LINK_DIRECTORIES})
|
Link_Directories(${LINK_DIRECTORIES})
|
||||||
|
|
||||||
Set(SRCS
|
Set(SRCS
|
||||||
|
@ -176,7 +169,6 @@ If(DDS_FOUND)
|
||||||
Set(Exe_Names
|
Set(Exe_Names
|
||||||
${Exe_Names}
|
${Exe_Names}
|
||||||
fairmq-dds-command-ui
|
fairmq-dds-command-ui
|
||||||
fairmq-dds-command
|
|
||||||
)
|
)
|
||||||
EndIf(DDS_FOUND)
|
EndIf(DDS_FOUND)
|
||||||
|
|
||||||
|
@ -192,7 +184,6 @@ If(DDS_FOUND)
|
||||||
Set(Exe_Source
|
Set(Exe_Source
|
||||||
${Exe_Source}
|
${Exe_Source}
|
||||||
run/runDDSCommandUI.cxx
|
run/runDDSCommandUI.cxx
|
||||||
run/runDDSCommand.cxx
|
|
||||||
)
|
)
|
||||||
EndIf(DDS_FOUND)
|
EndIf(DDS_FOUND)
|
||||||
|
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
#include "dds_intercom.h"
|
|
||||||
|
|
||||||
#include <termios.h> // raw mode console input
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <exception>
|
|
||||||
#include <sstream>
|
|
||||||
#include <thread>
|
|
||||||
#include <atomic>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using namespace dds::intercom_api;
|
|
||||||
|
|
||||||
void PrintControlsHelp()
|
|
||||||
{
|
|
||||||
cout << "To control devices use one of the following arguments:" << 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ( argc != 2 ) {
|
|
||||||
PrintControlsHelp();
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CCustomCmd ddsCustomCmd;
|
|
||||||
|
|
||||||
// subscribe to receive messages from DDS
|
|
||||||
ddsCustomCmd.subscribe([](const string& msg, const string& condition, uint64_t senderId)
|
|
||||||
{
|
|
||||||
cout << "Received: \"" << msg << "\"" << endl;
|
|
||||||
});
|
|
||||||
|
|
||||||
char c = argv[1][0];
|
|
||||||
|
|
||||||
int result = 0; // result of the dds send
|
|
||||||
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case 'c':
|
|
||||||
cout << " > checking state of the devices" << endl;
|
|
||||||
result = ddsCustomCmd.send("check-state", "");
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
cout << " > init devices" << endl;
|
|
||||||
result = ddsCustomCmd.send("INIT_DEVICE", "");
|
|
||||||
break;
|
|
||||||
case 'j':
|
|
||||||
cout << " > init tasks" << endl;
|
|
||||||
result = ddsCustomCmd.send("INIT_TASK", "");
|
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
cout << " > pause devices" << endl;
|
|
||||||
result = ddsCustomCmd.send("PAUSE", "");
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
cout << " > run tasks" << endl;
|
|
||||||
result = ddsCustomCmd.send("RUN", "");
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
cout << " > stop devices" << endl;
|
|
||||||
result = ddsCustomCmd.send("STOP", "");
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
cout << " > reset tasks" << endl;
|
|
||||||
result = ddsCustomCmd.send("RESET_TASK", "");
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
cout << " > reset devices" << endl;
|
|
||||||
result = ddsCustomCmd.send("RESET_DEVICE", "");
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
cout << " > help" << endl;
|
|
||||||
PrintControlsHelp();
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
cout << " > end" << endl;
|
|
||||||
result = ddsCustomCmd.send("END", "");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
cout << "Invalid input: [" << c << "]" << endl;
|
|
||||||
PrintControlsHelp();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == 1)
|
|
||||||
{
|
|
||||||
cout << "Error sending custom command" << endl;
|
|
||||||
}
|
|
||||||
usleep(50000);
|
|
||||||
}
|
|
||||||
catch (exception& e)
|
|
||||||
{
|
|
||||||
cerr << "Error: " << e.what() << endl;
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
|
||||||
}
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace dds::intercom_api;
|
using namespace dds::intercom_api;
|
||||||
|
@ -38,7 +39,10 @@ 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
|
||||||
|
|
||||||
PrintControlsHelp();
|
if ( argc != 2 )
|
||||||
|
PrintControlsHelp();
|
||||||
|
else
|
||||||
|
cin.putback(argv[1][0]);
|
||||||
|
|
||||||
while (cin >> c)
|
while (cin >> c)
|
||||||
{
|
{
|
||||||
|
@ -96,6 +100,10 @@ int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
cerr << "Error sending custom command" << endl;
|
cerr << "Error sending custom command" << endl;
|
||||||
}
|
}
|
||||||
|
if ( argc == 2 ) {
|
||||||
|
usleep(50000);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable raw mode
|
// disable raw mode
|
||||||
|
|
Loading…
Reference in New Issue
Block a user