Skip to content

Instantly share code, notes, and snippets.

@LuxoftAKutsan
Created August 15, 2016 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuxoftAKutsan/100e236f269e119ae3b3d62158dcd482 to your computer and use it in GitHub Desktop.
Save LuxoftAKutsan/100e236f269e119ae3b3d62158dcd482 to your computer and use it in GitHub Desktop.
mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM;
const bool is_vr_invalid_unsupported =
Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
vr_result_,
hmi_apis::Common_Result::INVALID_ENUM,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
const bool is_ui_invalid_unsupported =
Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
ui_result_,
hmi_apis::Common_Result::INVALID_ENUM,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
const bool is_no_ui_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
ui_result_,
hmi_apis::Common_Result::SUCCESS,
hmi_apis::Common_Result::WARNINGS,
hmi_apis::Common_Result::WRONG_LANGUAGE,
hmi_apis::Common_Result::RETRY,
hmi_apis::Common_Result::SAVED,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
const bool is_no_vr_error = Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
vr_result_,
hmi_apis::Common_Result::SUCCESS,
hmi_apis::Common_Result::WARNINGS,
hmi_apis::Common_Result::WRONG_LANGUAGE,
hmi_apis::Common_Result::RETRY,
hmi_apis::Common_Result::SAVED,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
bool result = (is_no_ui_error && is_no_vr_error) ||
(is_no_ui_error && is_vr_invalid_unsupported) ||
(is_no_vr_error && is_ui_invalid_unsupported);
LOG4CXX_DEBUG(logger_, "calculated result " << ui_result_<< " " << is_no_ui_error << " " << is_no_vr_error);
const bool is_vr_or_ui_warning =
Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
hmi_apis::Common_Result::WARNINGS, ui_result_, vr_result_);
const bool is_vr_or_ui_unsupported =
Compare<hmi_apis::Common_Result::eType, EQ, ONE>(
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, ui_result_, vr_result_);
const bool is_vr_and_ui_unsupported =
Compare<hmi_apis::Common_Result::eType, EQ, ALL>(
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE, ui_result_, vr_result_);
if (!result && hmi_apis::Common_Result::REJECTED == ui_result_) {
result_code = MessageHelper::HMIToMobileResult(ui_result_);
} else if (result && is_vr_or_ui_unsupported) {
result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE;
} else if (is_vr_or_ui_warning ) {
result_code = mobile_apis::Result::WARNINGS;
} else {
result_code =
MessageHelper::HMIToMobileResult(std::max(ui_result_, vr_result_));
if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) {
result_code =
MessageHelper::HMIToMobileResult(vr_result_);
}
if (hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == vr_result_) {
result_code = MessageHelper::HMIToMobileResult(ui_result_);
}
LOG4CXX_DEBUG(logger_, "HMIToMobileResult " << result_code);
}
if (BothSend() && hmi_apis::Common_Result::SUCCESS == vr_result_) {
const bool is_ui_not_ok = Compare<hmi_apis::Common_Result::eType, NEQ, ALL>(
ui_result_,
hmi_apis::Common_Result::SUCCESS,
hmi_apis::Common_Result::WARNINGS,
hmi_apis::Common_Result::UNSUPPORTED_RESOURCE);
if (is_ui_not_ok) {
result_code = ui_result_ == hmi_apis::Common_Result::REJECTED
? mobile_apis::Result::REJECTED
: mobile_apis::Result::GENERIC_ERROR;
msg_params[strings::grammar_id] = application->get_grammar_id();
msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
SendHMIRequest(hmi_apis::FunctionID::VR_DeleteCommand, &msg_params);
application->RemoveCommand(
(*message_)[strings::msg_params][strings::cmd_id].asUInt());
result = false;
LOG4CXX_DEBUG(logger_, "Result " <<result );
}
}
if (BothSend() && hmi_apis::Common_Result::SUCCESS == ui_result_ &&
!is_no_vr_error && hmi_apis::Common_Result::UNSUPPORTED_RESOURCE != vr_result_) {
result_code = vr_result_ == hmi_apis::Common_Result::REJECTED
? mobile_apis::Result::REJECTED
: mobile_apis::Result::GENERIC_ERROR ;
SendHMIRequest(hmi_apis::FunctionID::UI_DeleteCommand, &msg_params);
application->RemoveCommand(
(*message_)[strings::msg_params][strings::cmd_id].asUInt());
result = false;
LOG4CXX_DEBUG(logger_, "Result " <<result );
}
if (!BothSend() && is_vr_or_ui_unsupported) {
LOG4CXX_DEBUG(logger_, "!BothSend() && is_vr_or_ui_unsupported");
result = false;
}
if (is_vr_and_ui_unsupported) {
LOG4CXX_DEBUG(logger_, "is_vr_and_ui_unsupported");
result = false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment