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/resumption during low voltage #2412

Conversation

AByzhynar
Copy link
Contributor

@AByzhynar AByzhynar commented Jul 24, 2018

Fixes #2233

This PR is [ready] for review.

Risk

This PR makes [no] API changes.

Testing Plan

Unit tests will be provided
ATF tests will be provided

Summary

Added resumption logic during Low Voltage event

CLA

* @return Low Voltage event timestamp if event LOV VOLTAGE event occures
* otherwise 0
*/
time_t LowVoltageTime() const OVERRIDE;
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 duplication of comments in implementation and interface

Copy link
Contributor Author

@AByzhynar AByzhynar Jul 24, 2018

Choose a reason for hiding this comment

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

/**
* @brief Resets Low Voltage signal timestamp to zero
*/
virtual void ResetLowVoltageTime() = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar check if this functions should be public in interface

Copy link
Contributor Author

@AByzhynar AByzhynar Jul 24, 2018

Choose a reason for hiding this comment

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

* @brief Checks if saved HMI level is allowed for resumption
* by Ignition Cycle restrictions
* @param saved_app application specific section from backup file
* @return True is allowed , othrwise - False
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar typo
true if allowed

Copy link
Contributor Author

@AByzhynar AByzhynar Jul 24, 2018

Choose a reason for hiding this comment

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

resume_controller().SaveApplication(app_to_remove);
} else {
resume_controller().RemoveApplicationFromSaved(app_to_remove);
if (!IsLowVoltage()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar move low voltage check to ResumeCtrl

Copy link
Contributor Author

@AByzhynar AByzhynar Jul 24, 2018

Choose a reason for hiding this comment

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

LOG4CXX_INFO(logger_, "Application was dissconnected long before ign off");
result = false;
if (!CheckDelayBeforeIgnOff(saved_app)) {
LOG4CXX_INFO(logger_, "Application was disconnected long before ign off");
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar rename to debug

Copy link
Contributor Author

@AByzhynar AByzhynar Jul 24, 2018

Choose a reason for hiding this comment

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

@AByzhynar AByzhynar force-pushed the feature/resumption_during_low_voltage branch 2 times, most recently from 3c9dd5c to 94730fa Compare July 24, 2018 11:03
static_cast<time_t>(resumption_storage_->GetIgnOffTime());

if (0 == ign_off_time) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar in case if function has multiple returns please log information about return reason

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sync_primitives::AutoLock autolock(resumption_lock_);
Json::Value& resumption = GetResumptionData();
if (!resumption.isMember(strings::global_ign_on_counter)) {
resumption[strings::global_ign_on_counter] = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar it is not expected that getter will change data.

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 Absolutely agree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sync_primitives::AutoLock autolock(resumption_lock_);
Json::Value& resumption = GetResumptionData();
if (!resumption.isMember(strings::global_ign_off_counter)) {
resumption[strings::global_ign_off_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.

@AByzhynar it is not expected that getter will change data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -124,6 +124,40 @@ class ResumeCtrl {
*/
virtual void OnAwake() = 0;

/**
* @brief Returns Low Voltage signal timestamp
* @return Low Voltage event timestamp if event LOV VOLTAGE event occures
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar Low Voltage event timestamp if LOV VOLTAGE event occures

Copy link
Contributor Author

Choose a reason for hiding this comment

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

* @return Wake Up timestamp if Wake Up signal occures
* otherwise 0
*/
time_t WakeUpTime() const;
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar I would suggest to create enum like TimestampType{LOW_VOLTAGE, WAKE_UP}
And then you could reduce count of functions:

  • GetTime(TimestampType)
  • SaveTime(TimestampType)
  • ResetTime(TimestampType)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AKalinich-Luxoft Disagree. it is the same type for all events. I don't see any reason to complicate the code.

* Ignition Off,
* otherwise return false
*/
bool CheckDelayBeforeIgnOff(const smart_objects::SmartObject& saved_app);
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar could these check functions be const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


/**
* @brief Returns Low Voltage signal timestamp
* @return Low Voltage event timestamp if event LOV VOLTAGE event occures
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar redundant event word

@return Low Voltage event timestamp if LOV VOLTAGE event occures

const uint32_t global_ign_on_count =
resumption_storage_->GetGlobalIgnOnCounter();
const uint32_t diff = global_ign_on_count - global_ign_off_count;
if (diff >= 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar could be moved to a separate const with a meaningful name

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 ZhdanovP force-pushed the feature/resumption_during_low_voltage branch from 2be4522 to e8c27a3 Compare July 24, 2018 16:48
@AByzhynar AByzhynar force-pushed the feature/resumption_during_low_voltage branch from e8c27a3 to c073062 Compare July 24, 2018 17:10
@ZhdanovP ZhdanovP force-pushed the feature/resumption_during_low_voltage branch from c073062 to 7ec0f18 Compare July 24, 2018 17:19
@AByzhynar AByzhynar force-pushed the feature/low_voltage branch from 65c39a3 to 4506e6d Compare July 24, 2018 18:02
@AByzhynar AByzhynar force-pushed the feature/resumption_during_low_voltage branch 2 times, most recently from fc1c822 to 93ff02d Compare July 24, 2018 18:39

void ResumeCtrlImpl::ResetLowVoltageTime() {
low_voltage_time_ = 0;
LOG4CXX_DEBUG(logger_, "Resetting Low Voltage timestamp :");
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar redundant semicolon

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 Done and squashed.


void ResumeCtrlImpl::ResetWakeUpTime() {
wake_up_time_ = 0;
LOG4CXX_DEBUG(logger_, "Resetting Wake Up timestamp :");
Copy link
Contributor

Choose a reason for hiding this comment

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

@AByzhynar redundant semicolon

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 Done and squashed.

@AByzhynar AByzhynar force-pushed the feature/resumption_during_low_voltage branch 2 times, most recently from 5328fdc to 36d137b Compare July 25, 2018 11:18
AByzhynar and others added 2 commits July 25, 2018 14:20
Implemented resumption logic during Low Voltage
(used app_info.dat file for resumption.Configurable in smartdevicelink.ini
file)
@AByzhynar AByzhynar force-pushed the feature/resumption_during_low_voltage branch from 36d137b to 24b20e8 Compare July 25, 2018 12:07
@AByzhynar AByzhynar merged commit ad32f74 into smartdevicelink:feature/low_voltage Jul 25, 2018
# 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.

3 participants