mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
DDS plugin: remove static mode
This commit is contained in:
parent
073f5e5c0e
commit
b0b271d1f4
|
@ -37,16 +37,6 @@ DDS::DDS(const string& name,
|
||||||
const string& homepage,
|
const string& homepage,
|
||||||
PluginServices* pluginServices)
|
PluginServices* pluginServices)
|
||||||
: Plugin(name, version, maintainer, homepage, pluginServices)
|
: Plugin(name, version, maintainer, homepage, pluginServices)
|
||||||
, fTransitions({"INIT DEVICE",
|
|
||||||
"COMPLETE INIT",
|
|
||||||
"BIND",
|
|
||||||
"CONNECT",
|
|
||||||
"INIT TASK",
|
|
||||||
"RUN",
|
|
||||||
"STOP",
|
|
||||||
"RESET TASK",
|
|
||||||
"RESET DEVICE",
|
|
||||||
"END"})
|
|
||||||
, fCurrentState(DeviceState::Idle)
|
, fCurrentState(DeviceState::Idle)
|
||||||
, fLastState(DeviceState::Idle)
|
, fLastState(DeviceState::Idle)
|
||||||
, fDeviceTerminationRequested(false)
|
, fDeviceTerminationRequested(false)
|
||||||
|
@ -71,15 +61,13 @@ DDS::DDS(const string& name,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto control = GetProperty<string>("control");
|
auto control = GetProperty<string>("control");
|
||||||
bool staticMode(false);
|
|
||||||
if (control == "static") {
|
if (control == "static") {
|
||||||
LOG(debug) << "Running DDS controller: static";
|
LOG(error) << "DDS Plugin: static mode is not supported";
|
||||||
staticMode = true;
|
throw invalid_argument("DDS Plugin: static mode is not supported");
|
||||||
} else if (control == "dynamic" || control == "external" || control == "interactive") {
|
} else if (control == "dynamic" || control == "external" || control == "interactive") {
|
||||||
LOG(debug) << "Running DDS controller: external";
|
LOG(debug) << "Running DDS controller: external";
|
||||||
} else {
|
} else {
|
||||||
LOG(error) << "Unrecognized control mode '" << control << "' requested. " << "Ignoring and falling back to static control mode.";
|
LOG(error) << "Unrecognized control mode '" << control << "' requested. " << "Ignoring and starting in external control mode.";
|
||||||
staticMode = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SubscribeForCustomCommands();
|
SubscribeForCustomCommands();
|
||||||
|
@ -108,11 +96,7 @@ DDS::DDS(const string& name,
|
||||||
}
|
}
|
||||||
case DeviceState::Exiting:
|
case DeviceState::Exiting:
|
||||||
fWorkGuard.reset();
|
fWorkGuard.reset();
|
||||||
{
|
fDeviceTerminationRequested = true;
|
||||||
unique_lock<mutex> lock(fStopMutex);
|
|
||||||
fDeviceTerminationRequested = true;
|
|
||||||
}
|
|
||||||
fStopCondition.notify_one();
|
|
||||||
UnsubscribeFromDeviceStateChange();
|
UnsubscribeFromDeviceStateChange();
|
||||||
ReleaseDeviceControl();
|
ReleaseDeviceControl();
|
||||||
break;
|
break;
|
||||||
|
@ -133,11 +117,7 @@ DDS::DDS(const string& name,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (staticMode) {
|
StartWorkerThread();
|
||||||
fControllerThread = thread(&DDS::StaticControl, this);
|
|
||||||
} else {
|
|
||||||
StartWorkerThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
fDDS.Start();
|
fDDS.Start();
|
||||||
} catch (PluginServices::DeviceControlError& e) {
|
} catch (PluginServices::DeviceControlError& e) {
|
||||||
|
@ -169,26 +149,6 @@ auto DDS::WaitForExitingAck() -> void
|
||||||
[this]() { return fExitingAckedByLastExternalController; });
|
[this]() { return fExitingAckedByLastExternalController; });
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DDS::StaticControl() -> void
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
TransitionDeviceStateTo(DeviceState::Running);
|
|
||||||
|
|
||||||
// wait until stop signal
|
|
||||||
unique_lock<mutex> lock(fStopMutex);
|
|
||||||
while (!fDeviceTerminationRequested) {
|
|
||||||
fStopCondition.wait_for(lock, chrono::seconds(1));
|
|
||||||
}
|
|
||||||
LOG(debug) << "Stopping DDS plugin static controller";
|
|
||||||
} catch (DeviceErrorState&) {
|
|
||||||
ReleaseDeviceControl();
|
|
||||||
} catch (exception& e) {
|
|
||||||
ReleaseDeviceControl();
|
|
||||||
LOG(error) << "Error: " << e.what() << "\n";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto DDS::FillChannelContainers() -> void
|
auto DDS::FillChannelContainers() -> void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -133,7 +133,6 @@ class DDS : public Plugin
|
||||||
~DDS();
|
~DDS();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
auto StaticControl() -> void;
|
|
||||||
auto WaitForExitingAck() -> void;
|
auto WaitForExitingAck() -> void;
|
||||||
auto StartWorkerThread() -> void;
|
auto StartWorkerThread() -> void;
|
||||||
|
|
||||||
|
@ -154,11 +153,6 @@ class DDS : public Plugin
|
||||||
std::unordered_map<std::string, int> fI;
|
std::unordered_map<std::string, int> fI;
|
||||||
std::unordered_map<std::string, IofN> fIofN;
|
std::unordered_map<std::string, IofN> fIofN;
|
||||||
|
|
||||||
std::mutex fStopMutex;
|
|
||||||
std::condition_variable fStopCondition;
|
|
||||||
|
|
||||||
const std::set<std::string> fTransitions;
|
|
||||||
|
|
||||||
std::thread fControllerThread;
|
std::thread fControllerThread;
|
||||||
DeviceState fCurrentState, fLastState;
|
DeviceState fCurrentState, fLastState;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user