PluginServices: Do not throw if device control cannot be released

This commit is contained in:
Dennis Klein 2019-07-28 11:56:02 +02:00 committed by Dennis Klein
parent 93eb599df7
commit 008be36125
4 changed files with 7 additions and 6 deletions

View File

@ -74,7 +74,8 @@ auto PluginServices::ReleaseDeviceControl(const string& controller) -> void
if (fDeviceController == controller) { if (fDeviceController == controller) {
fDeviceController = boost::none; fDeviceController = boost::none;
} else { } else {
throw DeviceControlError{tools::ToString("Plugin '", controller, "' cannot release control because it has not taken over control.")}; LOG(debug) << "Plugin '" << controller << "' cannot release control "
<< "because it has no control.";
} }
} }

View File

@ -63,6 +63,9 @@ struct DDSSubscription
LOG(error) << "DDS Error received: error code: " << errorCode << ", error message: " << errorMsg; LOG(error) << "DDS Error received: error code: " << errorCode << ", error message: " << errorMsg;
}); });
// fDDSCustomCmd.subscribe([](const std::string& cmd, const std::string& cond, uint64_t senderId) {
// LOG(debug) << "cmd: " << cmd << ", cond: " << cond << ", senderId: " << senderId;
// });
assert(!dds_session_id.empty()); assert(!dds_session_id.empty());
} }

View File

@ -273,7 +273,7 @@ int main(int argc, char* argv[])
cerr << "state-changes-unsubscription failed with return code: " << parts[2]; cerr << "state-changes-unsubscription failed with return code: " << parts[2];
} }
} else { } else {
// cout << "Received: " << msg << endl; cout << "Received: " << msg << endl;
} }
}); });

View File

@ -26,10 +26,7 @@ TEST_F(PluginServices, OnlySingleController)
mServices.ChangeDeviceState("bar", DeviceStateTransition::InitDevice), mServices.ChangeDeviceState("bar", DeviceStateTransition::InitDevice),
fair::mq::PluginServices::DeviceControlError fair::mq::PluginServices::DeviceControlError
); );
ASSERT_THROW( // no control for bar ASSERT_NO_THROW(mServices.ReleaseDeviceControl("bar"));
mServices.ReleaseDeviceControl("bar"),
fair::mq::PluginServices::DeviceControlError
);
ASSERT_NO_THROW(mServices.ReleaseDeviceControl("foo")); ASSERT_NO_THROW(mServices.ReleaseDeviceControl("foo"));
ASSERT_FALSE(mServices.GetDeviceController()); ASSERT_FALSE(mServices.GetDeviceController());