forked from M-Labs/kirdy
temp_mon: fix limits not effective at stable temp
- previously, temp is stable, temp limits are not checked
This commit is contained in:
parent
fb69ae3306
commit
c214e4182d
@ -32,6 +32,7 @@ pub struct TempMon {
|
||||
state: State,
|
||||
count: u32,
|
||||
is_set_point_changed: bool,
|
||||
is_limit_changed: bool,
|
||||
}
|
||||
|
||||
impl Default for TempMon {
|
||||
@ -48,6 +49,7 @@ impl Default for TempMon {
|
||||
count: 0,
|
||||
// stable_temp_count: 0,
|
||||
is_set_point_changed: false,
|
||||
is_limit_changed: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -68,6 +70,7 @@ impl TempMon {
|
||||
|
||||
pub fn set_upper_limit(&mut self, upper_limit: ThermodynamicTemperature) {
|
||||
self.upper_limit = upper_limit;
|
||||
self.is_limit_changed = true;
|
||||
}
|
||||
|
||||
pub fn get_upper_limit(&mut self) -> ThermodynamicTemperature {
|
||||
@ -76,6 +79,7 @@ impl TempMon {
|
||||
|
||||
pub fn set_lower_limit(&mut self, lower_limit: ThermodynamicTemperature) {
|
||||
self.lower_limit = lower_limit;
|
||||
self.is_limit_changed = true;
|
||||
}
|
||||
|
||||
pub fn get_lower_limit(&mut self) -> ThermodynamicTemperature {
|
||||
@ -129,11 +133,9 @@ impl TempMon {
|
||||
}
|
||||
}
|
||||
State::PidStartUp | State::PidStable => {
|
||||
let is_over_temp: bool;
|
||||
if self.state == State::PidStartUp {
|
||||
is_over_temp = temp > self.upper_limit || temp < self.lower_limit;
|
||||
} else {
|
||||
is_over_temp = (temp.value - self.set_point.value).abs() > 0.5;
|
||||
let mut is_over_temp = temp > self.upper_limit || temp < self.lower_limit;
|
||||
if self.state != State::PidStartUp {
|
||||
is_over_temp = is_over_temp || (temp.value - self.set_point.value).abs() > 0.5;
|
||||
}
|
||||
|
||||
let is_within_spec: bool = (temp.value - self.set_point.value).abs() < 0.001;
|
||||
@ -163,6 +165,12 @@ impl TempMon {
|
||||
} else if self.is_set_point_changed {
|
||||
self.is_set_point_changed = false;
|
||||
self.state = State::PidStartUp;
|
||||
} else if self.is_limit_changed {
|
||||
self.is_limit_changed = false;
|
||||
if is_over_temp {
|
||||
self.state = State::PidStartUp;
|
||||
self.count = 0;
|
||||
}
|
||||
} else if self.status.status == TempStatusEnum::Stable {
|
||||
self.state = State::PidStable;
|
||||
} else if !pid_engaged {
|
||||
|
Loading…
Reference in New Issue
Block a user