diff options
author | Alexander Kutsan <AKutsan@luxoft.com> | 2015-04-07 16:46:45 +0300 |
---|---|---|
committer | Alexander Kutsan <AKutsan@luxoft.com> | 2015-04-08 12:32:15 +0300 |
commit | d40880bbcc668e73a53ef47abb0143f020a00706 (patch) | |
tree | 134fb51c22f0e14f5549ef72aa65d00532dddb88 | |
parent | 48e08bc7408e7371b34042670087fbcb9ea0d915 (diff) | |
download | sdl_core-d40880bbcc668e73a53ef47abb0143f020a00706.tar.gz |
APPLINK-11916 Fix bugs. Teke test workable
In Request controller request_info timeout value is changeble now
5 files changed, 27 insertions, 21 deletions
diff --git a/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h b/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h index 9e1de14e2e..53cbe5fdc1 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/create_interaction_choice_set_request.h @@ -116,13 +116,15 @@ class CreateInteractionChoiceSetRequest : public CommandRequestImpl { int32_t choice_set_id_; size_t expected_chs_count_; + size_t recived_chs_count_; + /** * @brief Flag for stop sending VR commands to HMI, in case one of responses * failed */ volatile bool error_from_hmi_; - sync_primitives::Lock cmd_ids_lock; + sync_primitives::Lock vr_commands_lock_; /* * @brief Sends VR AddCommand request to HMI * diff --git a/src/components/application_manager/include/application_manager/request_info.h b/src/components/application_manager/include/application_manager/request_info.h index b0d1f836d8..3f8611fa49 100644 --- a/src/components/application_manager/include/application_manager/request_info.h +++ b/src/components/application_manager/include/application_manager/request_info.h @@ -84,7 +84,7 @@ namespace request_controller { } uint64_t timeout_sec() { - return timeout_sec_; + return request()->default_timeout() / date_time::DateTime::MILLISECONDS_IN_SECOND; } TimevalStruct end_time() { diff --git a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc index 28ad8a3d53..843ec1fcd8 100644 --- a/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/src/commands/mobile/create_interaction_choice_set_request.cc @@ -48,6 +48,7 @@ CreateInteractionChoiceSetRequest::CreateInteractionChoiceSetRequest( const MessageSharedPtr& message) : CommandRequestImpl(message), expected_chs_count_(0), + recived_chs_count_(0), error_from_hmi_(false) { } @@ -314,7 +315,15 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( msg_params[strings::app_id] = app->app_id(); msg_params[strings::grammar_id] = choice_set[strings::grammar_id]; const uint32_t choice_count = choice_set[strings::choice_set].length(); - for (size_t chs_num = 0; chs_num < choice_count; ++chs_num) { + SetAllowedToTerminate(false); + + expected_chs_count_ = choice_count; + size_t chs_num = 0; + for ( ;chs_num < choice_count; ++chs_num) { + if (error_from_hmi_) { + LOG4CXX_WARN(logger_, "Error from HMI received. Stop sending VRCommands"); + break; + } msg_params[strings::cmd_id] = choice_set[strings::choice_set][chs_num][strings::choice_id]; msg_params[strings::vr_commands] = smart_objects::SmartObject( @@ -322,22 +331,18 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( msg_params[strings::vr_commands] = choice_set[strings::choice_set][chs_num][strings::vr_commands]; - sync_primitives::AutoLock lock(cmd_ids_lock); - if (error_from_hmi_) { - LOG4CXX_WARN(logger_, "Error from HMI received. Stop sending VRCommands"); - return; - } const uint32_t vr_cmd_id = msg_params[strings::cmd_id].asUInt(); + sync_primitives::AutoLock lock(vr_commands_lock_); const uint32_t vr_corr_id = SendHMIRequest(hmi_apis::FunctionID::VR_AddCommand, &msg_params, true); VRCommandInfo vr_command(vr_cmd_id); sent_commands_map_[vr_corr_id] = vr_command; LOG4CXX_DEBUG(logger_, "VR_command sent corr_id " << vr_corr_id << " cmd_id " << vr_corr_id); - expected_chs_count_++; } + expected_chs_count_ = chs_num; LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_); // All Responses from HMI can came after TimeOut - SetAllowedToTerminate(false); + } void @@ -348,7 +353,7 @@ CreateInteractionChoiceSetRequest::on_event(const event_engine::Event& event) { if (event.id() == hmi_apis::FunctionID::VR_AddCommand) { Common_Result::eType vr_result_ = static_cast<Common_Result::eType>( message[strings::params][hmi_response::code].asInt()); - expected_chs_count_--; + recived_chs_count_++; LOG4CXX_DEBUG(logger_, "Got VR.AddCommand response, there are " << expected_chs_count_ << " more to wait."); if (Common_Result::SUCCESS == vr_result_) { @@ -365,7 +370,7 @@ CreateInteractionChoiceSetRequest::on_event(const event_engine::Event& event) { } } LOG4CXX_DEBUG(logger_, "expected_chs_count_ = " << expected_chs_count_); - if (0 == expected_chs_count_) { + if (recived_chs_count_ >= expected_chs_count_) { OnAllHMIResponsesReceived(); } } @@ -377,14 +382,13 @@ void CreateInteractionChoiceSetRequest::onTimeOut() { error_from_hmi_ = true; SendResponse(false, mobile_apis::Result::GENERIC_ERROR); } - if (0 == expected_chs_count_) { - OnAllHMIResponsesReceived(); - } + OnAllHMIResponsesReceived(); + default_timeout_ = 0; } void CreateInteractionChoiceSetRequest::DeleteChoices() { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock lock(cmd_ids_lock); + sync_primitives::AutoLock lock(vr_commands_lock_); ApplicationSharedPtr application = ApplicationManagerImpl::instance()->application(connection_key()); @@ -402,6 +406,8 @@ void CreateInteractionChoiceSetRequest::DeleteChoices() { if (vr_command_info.succesful_response_received_) { msg_param[strings::cmd_id] = vr_command_info.cmd_id_; SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_param); + } else { + LOG4CXX_WARN(logger_, "succesfull response did no received cmd_id = " << vr_command_info.cmd_id_); } } sent_commands_map_.clear(); diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index 57d48680be..16df90363a 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -193,7 +193,7 @@ RequestInfoPtr RequestInfoSet::FrontWithNotNullTimeout() { TimeSortedRequestInfoSet::iterator it = time_sorted_pending_requests_.begin(); while (it != time_sorted_pending_requests_.end()) { RequestInfoPtr tmp = *it; - if ( tmp ->timeout_sec() || !tmp->request()->AllowedToTerminate()) { + if (0 == tmp ->timeout_sec()) { ++it; } else { result = tmp; @@ -357,10 +357,6 @@ bool RequestInfoTimeComparator::operator()(const RequestInfoPtr lhs, } // compare_result == date_time::EQUAL // If time is equal, sort by hash - LOG4CXX_DEBUG(logger_, "EQUAL " << lhs->end_time().tv_sec << ":" << lhs->end_time().tv_usec - << " and " << rhs->end_time().tv_sec << ":" << rhs->end_time().tv_usec - << "; compare hash: " << lhs->hash() << " < " << rhs->hash() - << " = " << (lhs->hash() < rhs->hash())); return lhs->hash() < rhs->hash(); } diff --git a/src/components/application_manager/test/request_info_test.cc b/src/components/application_manager/test/request_info_test.cc index be54ff3127..86103e7998 100644 --- a/src/components/application_manager/test/request_info_test.cc +++ b/src/components/application_manager/test/request_info_test.cc @@ -21,6 +21,8 @@ class MockRequest: public application_manager::commands::Command { MOCK_CONST_METHOD0(default_timeout, uint32_t ()); MOCK_CONST_METHOD0(function_id, int32_t ()); MOCK_METHOD0(onTimeOut, void ()); + MOCK_METHOD0(AllowedToTerminate, bool ()); + MOCK_METHOD1(SetAllowedToTerminate, void (bool)); uint32_t connection_key_; uint32_t correlation_id_; |