mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
MQ/example9 Adapted to the new running scheme with DDS.
- removed the executables that are running only in DDS (ddsEx9Sampler.cxx, ddsEx9TaskProcessor.cxx, ddsEx9FileSink.cxx, ddsParameterMQServer.cxx); - adapted the executables to allow running within the DDS (setting channel names); - changed the topology file to run the correct executables (ex9-dds-topology.xml); - ex9-dds.json - changed the parameter channel name back to "data" (to be compatible with other examples); - added a shell script to controlDDS.sh; - added fairmq/fairmq-dds-command executable to send single commands to DDS; - adapted parmq/parmq-server to run within DDS.
This commit is contained in:
parent
253604344f
commit
65ca151620
|
@ -176,6 +176,7 @@ 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)
|
||||||
|
|
||||||
|
@ -191,6 +192,7 @@ 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)
|
||||||
|
|
||||||
|
|
103
fairmq/run/runDDSCommand.cxx
Normal file
103
fairmq/run/runDDSCommand.cxx
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
#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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user