/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include "SetSimulationStateServiceHandler.h" #include #include #include namespace ROS2SimulationInterfaces { AZStd::unordered_set SetSimulationStateServiceHandler::GetProvidedFeatures() { return AZStd::unordered_set{ SimulationFeatures::SIMULATION_STATE_SETTING, SimulationFeatures::SIMULATION_STATE_PAUSE }; } AZStd::optional SetSimulationStateServiceHandler::HandleServiceRequest( const std::shared_ptr header, const Request& request) { Response response; AZ::Outcome transitionResult; SimulationInterfaces::SimulationManagerRequestBus::BroadcastResult( transitionResult, &SimulationInterfaces::SimulationManagerRequests::SetSimulationState, SimulationInterfaces::SimulationState(request.state.state)); if (transitionResult.IsSuccess()) { response.result.result = simulation_interfaces::msg::Result::RESULT_OK; } else { response.result.result = static_cast(transitionResult.GetError().error_code); response.result.error_message = transitionResult.GetError().error_string.c_str(); } return response; } } // namespace ROS2SimulationInterfaces