mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-06 14:28:54 +08:00
Hysteresis: enable initializing arrays with default constructor initial state false
This commit is contained in:
@@ -42,8 +42,12 @@
|
||||
namespace systemlib
|
||||
{
|
||||
|
||||
void
|
||||
Hysteresis::set_hysteresis_time_from(const bool from_state, const hrt_abstime new_hysteresis_time_us)
|
||||
Hysteresis::Hysteresis(bool initial_state)
|
||||
{
|
||||
_state = _requested_state = initial_state;
|
||||
}
|
||||
|
||||
void Hysteresis::set_hysteresis_time_from(const bool from_state, const hrt_abstime new_hysteresis_time_us)
|
||||
{
|
||||
if (from_state) {
|
||||
_time_from_true_us = new_hysteresis_time_us;
|
||||
@@ -53,8 +57,7 @@ Hysteresis::set_hysteresis_time_from(const bool from_state, const hrt_abstime ne
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Hysteresis::set_state_and_update(const bool new_state, const hrt_abstime &now_us)
|
||||
void Hysteresis::set_state_and_update(const bool new_state, const hrt_abstime &now_us)
|
||||
{
|
||||
if (new_state != _state) {
|
||||
if (new_state != _requested_state) {
|
||||
@@ -69,8 +72,7 @@ Hysteresis::set_state_and_update(const bool new_state, const hrt_abstime &now_us
|
||||
update(now_us);
|
||||
}
|
||||
|
||||
void
|
||||
Hysteresis::update(const hrt_abstime &now_us)
|
||||
void Hysteresis::update(const hrt_abstime &now_us)
|
||||
{
|
||||
if (_requested_state != _state) {
|
||||
|
||||
|
||||
@@ -49,12 +49,8 @@ namespace systemlib
|
||||
class Hysteresis
|
||||
{
|
||||
public:
|
||||
explicit Hysteresis(bool init_state) :
|
||||
_state(init_state),
|
||||
_requested_state(init_state)
|
||||
{}
|
||||
Hysteresis() = delete; // no default constructor
|
||||
|
||||
Hysteresis() = default;
|
||||
explicit Hysteresis(bool initial_state);
|
||||
~Hysteresis() = default;
|
||||
|
||||
bool get_state() const { return _state; }
|
||||
@@ -67,13 +63,13 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
hrt_abstime _last_time_to_change_state{0};
|
||||
hrt_abstime _last_time_to_change_state = 0;
|
||||
|
||||
hrt_abstime _time_from_true_us{0};
|
||||
hrt_abstime _time_from_false_us{0};
|
||||
hrt_abstime _time_from_true_us = 0;
|
||||
hrt_abstime _time_from_false_us = 0;
|
||||
|
||||
bool _state;
|
||||
bool _requested_state;
|
||||
bool _state = false;
|
||||
bool _requested_state = false;
|
||||
};
|
||||
|
||||
} // namespace systemlib
|
||||
|
||||
Reference in New Issue
Block a user