Skip to content

Commit

Permalink
Add 'no control' controller
Browse files Browse the repository at this point in the history
  • Loading branch information
rbx committed Feb 19, 2024
1 parent 36b48f5 commit 39cb021
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions fairmq/plugins/control/Control.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@ Control::Control(const string& name, Plugin::Version version, const string& main
});

try {
TakeDeviceControl();

auto control = GetProperty<string>("control");

if (control != "none") {
TakeDeviceControl();
}

if (control == "static") {
LOG(debug) << "Running builtin controller: static";
fControllerThread = thread(&Control::StaticMode, this);
} else if (control == "none") {
LOG(debug) << "Builtin controller: disabled";
} else if (control == "gui") {
LOG(debug) << "Running builtin controller: gui";
fControllerThread = thread(&Control::GUIMode, this);
Expand Down Expand Up @@ -142,7 +146,7 @@ auto ControlPluginProgramOptions() -> Plugin::ProgOptions
namespace po = boost::program_options;
auto pluginOptions = po::options_description{"Control (builtin) Plugin"};
pluginOptions.add_options()
("control", po::value<string>()->default_value("dynamic"), "Control mode, 'static' or 'dynamic' (aliases for dynamic are external and interactive)")
("control", po::value<string>()->default_value("dynamic"), "Control mode, 'static' or 'dynamic' (aliases for dynamic are external and interactive), 'none', 'gui'")
("catch-signals", po::value<int >()->default_value(1), "Enable signal handling (1/0).");
return pluginOptions;
}
Expand Down Expand Up @@ -271,11 +275,11 @@ auto Control::InteractiveMode() -> void
try {
RunStartupSequence();

if(!fDeviceShutdownRequested) {
if (!fDeviceShutdownRequested) {
RunREPL();
}

if(!fDeviceShutdownRequested) {
if (!fDeviceShutdownRequested) {
RunShutdownSequence();
}
} catch (PluginServices::DeviceControlError& e) {
Expand Down Expand Up @@ -404,7 +408,7 @@ try {
// or for device shutdown request (Ctrl-C)
fStateQueue.WaitForNextOrCustom([this]{ return fDeviceShutdownRequested.load(); });

if(!fDeviceShutdownRequested) {
if (!fDeviceShutdownRequested) {
RunShutdownSequence();
}
} catch (PluginServices::DeviceControlError& e) {
Expand All @@ -421,7 +425,7 @@ try {
// Wait for device shutdown request (Ctrl-C)
fStateQueue.WaitForCustom([this]{ return fDeviceShutdownRequested.load(); });

if(!fDeviceShutdownRequested) {
if (!fDeviceShutdownRequested) {
RunShutdownSequence();
}
} catch (PluginServices::DeviceControlError& e) {
Expand Down
2 changes: 1 addition & 1 deletion test/device/_config.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TestDevice : public Device
{
public:
TestDevice(const string& transport)
: fDeviceThread(&Device::RunStateMachine, this)
: fDeviceThread(&Device::RunStateMachine, this)
{
SetTransport(transport);
test::Control(*this, test::Cycle::ToRun);
Expand Down

0 comments on commit 39cb021

Please sign in to comment.