Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature/low voltage #2418

Merged
merged 18 commits into from
Aug 21, 2018
Merged

Feature/low voltage #2418

merged 18 commits into from
Aug 21, 2018

Conversation

AByzhynar
Copy link
Contributor

@AByzhynar AByzhynar commented Jul 25, 2018

Fixes #2233

This PR is ready for review.

Risk

This PR makes no API changes.

Testing Plan

Unit tests are provided
ATF scripts are provided: smartdevicelink/sdl_atf_test_scripts#1953

Breaking Changes
  • None
Enhancements
  • None
Bug Fixes
  • None

Tasks Remaining:

  • None

Summary

Implemented SDL behavior during Low Voltage event including resumption flow.

CLA

void StopComponents() OVERRIDE;

/**
* Makes appropriate actions when Low Voltage signal received:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AByzhynar please avoid Doxygen comments overriden functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LuxoftAKutsan Thank you. Removed in 0f82294

if (is_ign_off_record_missed) {
LOG4CXX_WARN(logger_,
"Some IGN OFF records missed. Possibly due to Low Voltage");
return false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 I will reset global counters after normal IGNITION OFF flow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 We found a betters and more simple solution. We will use only one IGN_ON counter and will reset it in normal IGNITION OFF flow. Code will be provided in separate commit later.

@@ -1203,6 +1229,227 @@ TEST_F(ResumeCtrlTest, GetSavedAppHmiLevel_AskedAppFound_INVALID_ENUM) {
res_ctrl_->GetSavedAppHmiLevel(kTestPolicyAppId_, kMacAddress_));
}

TEST_F(ResumeCtrlTest, ResumptiLowVoltage_AppInFull_Restored) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZhdanovP Check typo here please

Copy link
Contributor

@ZhdanovP ZhdanovP Jul 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 @AByzhynar the names were fixed at 7f61588

return true;
}

void LifeCycleImpl::LowVoltage() {
LOG4CXX_AUTO_TRACE(logger_);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please keep this log, but identify and remove others logs that happens after sdl receives low voltage signal.
we can keep the logs after sdl receives wake up signal.

protocol_handler::ProtocolHandlerImpl* protocol_handler_;
connection_handler::ConnectionHandlerImpl* connection_handler_;
application_manager::ApplicationManagerImpl* app_manager_;
std::unique_ptr<LowVoltageSignalsHandler> low_voltage_signals_handler_;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this one is unique_ptr, but others are normal pointers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 because std::unique_ptr<LowVoltageSignalsHandler> low_voltage_signals_handler_; is the new code and the other pointers are old code. Therefore I don't want to make changes unrelated to feature.

@@ -335,6 +347,37 @@ void ResumeCtrlImpl::OnAwake() {
StartSavePersistentDataTimer();
}

void ResumeCtrlImpl::SaveLowVoltageTime() {
ResetLowVoltageTime();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do this extra reset?
low_voltage_time_ = 0;
low_voltage_time_= new value;

Copy link
Contributor Author

@AByzhynar AByzhynar Jul 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 Right. Removed in bbd93f1

}

void ResumeCtrlImpl::SaveWakeUpTime() {
ResetWakeUpTime();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do this extra reset?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 Right. Removed in bbd93f1

@AByzhynar AByzhynar force-pushed the feature/low_voltage branch from f9a741b to 0f82294 Compare July 28, 2018 17:04
@AByzhynar
Copy link
Contributor Author

AByzhynar commented Jul 28, 2018

@yang1070 Logic for suspending SDL process implemented in cab72dd

@AByzhynar AByzhynar force-pushed the feature/low_voltage branch 2 times, most recently from 79c68f2 to 1c66a5e Compare July 30, 2018 11:10
@AByzhynar
Copy link
Contributor Author

@yang1070 Part of resumption with SQL data base implemented in bf9412e

@@ -313,6 +313,9 @@ extern const char* resume_vr_grammars;

extern const char* ign_off_count;

extern const char* global_ign_on_counter;
extern const char* global_ign_off_counter;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this counter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 Removed in bf125f9

@@ -276,6 +276,8 @@ const char* last_ign_off_time = "last_ign_off_time";
const char* resume_vr_grammars = "resumeVrGrammars";

const char* ign_off_count = "ign_off_count";
const char* global_ign_on_counter = "global_ign_on_counter";
const char* global_ign_off_counter = "global_ign_off_counter";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove global_ign_off_counter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 Agree. Thanks. Will remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 Removed in bf125f9

resumption_storage_->IncrementIgnOffCount();
FinalPersistData();
if (!application_manager_.IsLowVoltage()) {
resumption_storage_->IncrementIgnOffCount();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need IncrementIgnOffCount()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yang1070 This is different counter. Not for low Voltage handling. It existed before and used for different purposes.

Copy link

@yang1070 yang1070 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need ign off counter?

@AByzhynar
Copy link
Contributor Author

@yang1070 We don't need global ignition counter. We have removed it.

Copy link

@yang1070 yang1070 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good.

@yang1070
Copy link

@theresalech Ford has reviewed, tested and approved this change. It is ready for Livio to review.

@theresalech theresalech requested a review from jacobkeeler July 31, 2018 13:06
#ifdef DBUS_HMIADAPTER
, dbus_adapter_(NULL)
, dbus_adapter_thread_(NULL)
#endif // DBUS_HMIADAPTER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove, dbus adapter was removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobkeeler all mentions of DBUS_HMIADAPTER removed

return true;
}
#endif // DBUS_HMIADAPTER

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbus adapter was removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobkeeler 'Removing Dbus' - is the change not related to the feature. I think that it is more correct way - to remove it in separate PR.
Or should we remove it within this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code was removed in a previous PR, but this PR seems to be adding this logic back in where it previously existed. I am just asking that it not be added in again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete dbus_adapter_thread_;
dbus_adapter_thread_ = NULL;
}
#endif // DBUS_HMIADAPTER
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbus adapter was removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -33,6 +33,8 @@
#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_
#define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_RESUMPTION_RESUME_CTRL_IMPL_H_

#include "application_manager/resumption/resume_ctrl.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move the include?

Copy link
Contributor Author

@AByzhynar AByzhynar Aug 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void HandleSignal(const int signo);

/**
* @brief Returns signals mask required for handlning
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, should be handling

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
bool CheckLowVoltageRestrictions(const smart_objects::SmartObject& saved_app);

DEPRECATED bool DisconnectedJustBeforeIgnOff(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can just be removed since this is being included in the 5.0.0 release

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -409,10 +454,37 @@ class ResumeCtrlImpl : public ResumeCtrl,

/**
* @brief CheckDelayAfterIgnOn should check if SDL was started less
* then N seconds ago. N will be readed from profile.
* then N seconds ago. N will be read from profile.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may as well fix the typo with than while you are at it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* @brief CheckDelayBeforeIgnOff checks if app was unregistered less
* then N seconds before Ignition OFF. N will be read from profile.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

than N seconds

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* @brief CheckDelayAfterWakeUp should check if app was registered
* during N seconds after WakeUp signal. N will be read from profile.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

during the first N seconds

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resumption_storage_->GetGlobalIgnOnCounter();
const uint32_t allowed_ign_on_value = 2;
const bool is_emergency_ign_off_occurred =
global_ign_on_count >= allowed_ign_on_value;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be allowed_ign_on_value = 1 and global_ign_on_count > allowed_ign_on_value

Copy link
Contributor

@LuxoftAKutsan LuxoftAKutsan Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobkeeler in that case constant allowed_ign_on_value should be renamed and it is hard for me to imagine the name in that case : maximum_not_allowed_ignition_on_occured ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}
LOG4CXX_ERROR(logger_, "Problem with prepare query");
return global_ign_on_counter;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just return 0 here and reduce scope of global_ign_on_counter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG4CXX_DEBUG(logger_, "Global Ign On Counter = " << global_ign_on_counter);
return global_ign_on_counter;
}
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems default would be 0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobkeeler if SDL is alive, at least one ignition on occurred.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Equivalent change should be made to resumption_data_db.cc then, since the default is 0 there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const mobile_apis::HMILevel::eType restored_test_type = eType::HMI_FULL;
const uint32_t time_offset = 5;
const uint32_t time_stamp =
time(nullptr) - resumption_delay_before_ign_ + time_offset;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this should be - time_offset rather than + time_offset based on the description. Although it does seem that this test would be prone to occasional failures, since Core grabs the timestamp separately from the test (as far as I can see).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobkeeler On the border it means that app was unregistered in the frame of 30 seconds before low voltage and application should restore it's HMI level. So there should be + time_offset.

Here is the example: [----|-----u-----L]

  • | - 30 seconds frame before the low voltage
  • u - unregistering application
  • L - low voltage event

In case if there will be - time_offset there will be the following picture :
[---u---|----L], and Application will not restore it's HMI level.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understood "on the border" as "exactly 30 seconds before LOW_VOLTAGE".
Another thing to note here is that the time_offset is added to the delay in this particular test case, so the window is 35 seconds.

  EXPECT_CALL(app_mngr_settings_, resumption_delay_before_ign())
      .WillOnce(Return(resumption_delay_before_ign_ + time_offset));

If this is just testing when an app unregisters within the time frame, then this case is redundant, as that case is covered by ResumptionLowVoltage_AppInFullUnregisteredWithinTimeFrame_HMILevelRestored

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -532,6 +532,8 @@ int TransportManagerImpl::Reinit() {
LOG4CXX_AUTO_TRACE(logger_);
DisconnectAllDevices();
TerminateAllAdapters();
device_to_adapter_map_.clear();
connection_id_counter_ = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes don't appear relevant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After LowVoltage and Wake Up we should clear old devices from list

const bool is_emergency_ign_off_occurred =
global_ign_on_count >= allowed_ign_on_value;
global_ign_on_count > the_first_ignition;
// In case of resumption it should be minimum second ignition cycle.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not match the functionality. This count is reset on IGNITION_OFF, so a value greater than 1 means that the project was shut down by force. A value of 1 does not meant that it is the first ignition cycle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG4CXX_DEBUG(logger_,
"Global Ign On Counter = " << global_ign_on_counter);
return global_ign_on_counter;
} else {
LOG4CXX_ERROR(logger_,
"Problem with exec query : " << kSelectGlobalIgnOnCounter);
Copy link
Contributor

@jacobkeeler jacobkeeler Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else case is already covered, it will just continue on to the end of the function. This will just result in this log being printed twice

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AByzhynar and others added 15 commits August 21, 2018 12:29
Created Life cycle class interface in order:
  - to make unit-testing available
  - to decrease components coupling
Implemented Low Voltage feature based on POSIX
real-time signals
Implemented resumption logic during Low Voltage
(used app_info.dat file for resumption.Configurable in smartdevicelink.ini
file)
Removed redundant functions
Simplified ingintion cycle data correctness check
Implemented Low Voltage functionality handling in separate process
in order to have possibility to suspend entire SDL process in
case of Low Voltage signal
After receipt of WakeUp signal SDL process is beeing waken up
and resumes all its activities.
LuxoftAKutsan and others added 3 commits August 21, 2018 14:34
ResumptionLowVoltage_AppInFullUnregisteredOnTheBorderOfTimeFrame_HMILevelRestored
unit test

Remove unit test beause of possible sporadic failures
@jacobkeeler jacobkeeler merged commit 7af24ab into develop Aug 21, 2018
@jacobkeeler jacobkeeler deleted the feature/low_voltage branch August 24, 2018 19:38
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants