PwmSummary: Don't show max PWM values
Putting the maximum in PwmSummary has little use - the maximum never changes throughout the runtime of the firmware and can be replaced by documentation elsewhere.
This commit is contained in:
parent
6224486662
commit
5c3b759d0c
|
@ -16,7 +16,7 @@ class Client:
|
|||
pwm_report = self.get_pwm()
|
||||
for pwm_channel in pwm_report:
|
||||
for limit in ["max_i_neg", "max_i_pos", "max_v"]:
|
||||
if pwm_channel[limit]["value"] == 0.0:
|
||||
if pwm_channel[limit] == 0.0:
|
||||
logging.warning("`{}` limit is set to zero on channel {}".format(limit, pwm_channel["channel"]))
|
||||
|
||||
def _read_line(self):
|
||||
|
@ -53,17 +53,17 @@ class Client:
|
|||
Example::
|
||||
[{'channel': 0,
|
||||
'center': 'vref',
|
||||
'i_set': {'max': 2.9802790335151985, 'value': -0.02002179650216762},
|
||||
'max_i_neg': {'max': 3.0, 'value': 3.0},
|
||||
'max_v': {'max': 5.988, 'value': 5.988},
|
||||
'max_i_pos': {'max': 3.0, 'value': 3.0}},
|
||||
'i_set': -0.02002179650216762,
|
||||
'max_i_neg': 2.0,
|
||||
'max_v': 3.988,
|
||||
'max_i_pos': 2.0,
|
||||
'polarity': 'normal',
|
||||
{'channel': 1,
|
||||
'center': 'vref',
|
||||
'i_set': {'max': 2.9802790335151985, 'value': -0.02002179650216762},
|
||||
'max_i_neg': {'max': 3.0, 'value': 3.0},
|
||||
'max_v': {'max': 5.988, 'value': 5.988},
|
||||
'max_i_pos': {'max': 3.0, 'value': 3.0}}
|
||||
'i_set': -0.02002179650216762,
|
||||
'max_i_neg': 2.0,
|
||||
'max_v': 3.988,
|
||||
'max_i_pos': 2.0}
|
||||
'polarity': 'normal',
|
||||
]
|
||||
"""
|
||||
|
|
|
@ -383,26 +383,26 @@ impl Channels {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_max_v(&mut self, channel: usize) -> (ElectricPotential, ElectricPotential) {
|
||||
pub fn get_max_v(&mut self, channel: usize) -> ElectricPotential {
|
||||
let max = 4.0 * ElectricPotential::new::<volt>(3.3);
|
||||
let duty = self.get_pwm(channel, PwmPin::MaxV);
|
||||
(duty * max, MAX_TEC_V)
|
||||
duty * max
|
||||
}
|
||||
|
||||
pub fn get_max_i_pos(&mut self, channel: usize) -> (ElectricCurrent, ElectricCurrent) {
|
||||
pub fn get_max_i_pos(&mut self, channel: usize) -> ElectricCurrent {
|
||||
let duty = match self.channel_state(channel).polarity {
|
||||
Polarity::Normal => self.get_pwm(channel, PwmPin::MaxIPos),
|
||||
Polarity::Reversed => self.get_pwm(channel, PwmPin::MaxINeg),
|
||||
};
|
||||
(duty * MAX_TEC_I_DUTY_TO_CURRENT_RATE, MAX_TEC_I)
|
||||
duty * MAX_TEC_I_DUTY_TO_CURRENT_RATE
|
||||
}
|
||||
|
||||
pub fn get_max_i_neg(&mut self, channel: usize) -> (ElectricCurrent, ElectricCurrent) {
|
||||
pub fn get_max_i_neg(&mut self, channel: usize) -> ElectricCurrent {
|
||||
let duty = match self.channel_state(channel).polarity {
|
||||
Polarity::Normal => self.get_pwm(channel, PwmPin::MaxINeg),
|
||||
Polarity::Reversed => self.get_pwm(channel, PwmPin::MaxIPos),
|
||||
};
|
||||
(duty * MAX_TEC_I_DUTY_TO_CURRENT_RATE, MAX_TEC_I)
|
||||
duty * MAX_TEC_I_DUTY_TO_CURRENT_RATE
|
||||
}
|
||||
|
||||
// Get current passing through TEC
|
||||
|
@ -476,8 +476,8 @@ impl Channels {
|
|||
pub fn set_polarity(&mut self, channel: usize, polarity: Polarity) {
|
||||
if self.channel_state(channel).polarity != polarity {
|
||||
let i_set = self.channel_state(channel).i_set;
|
||||
let max_i_pos = self.get_max_i_pos(channel).0;
|
||||
let max_i_neg = self.get_max_i_neg(channel).0;
|
||||
let max_i_pos = self.get_max_i_pos(channel);
|
||||
let max_i_neg = self.get_max_i_neg(channel);
|
||||
self.channel_state(channel).polarity = polarity;
|
||||
|
||||
self.set_i(channel, i_set);
|
||||
|
@ -541,10 +541,10 @@ impl Channels {
|
|||
PwmSummary {
|
||||
channel,
|
||||
center: CenterPointJson(self.channel_state(channel).center.clone()),
|
||||
i_set: (self.get_i(channel), MAX_TEC_I).into(),
|
||||
max_v: self.get_max_v(channel).into(),
|
||||
max_i_pos: self.get_max_i_pos(channel).into(),
|
||||
max_i_neg: self.get_max_i_neg(channel).into(),
|
||||
i_set: self.get_i(channel),
|
||||
max_v: self.get_max_v(channel),
|
||||
max_i_pos: self.get_max_i_pos(channel),
|
||||
max_i_neg: self.get_max_i_neg(channel),
|
||||
polarity: PolarityJson(self.channel_state(channel).polarity.clone()),
|
||||
}
|
||||
}
|
||||
|
@ -642,26 +642,14 @@ impl Serialize for PolarityJson {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct PwmSummaryField<T: Serialize> {
|
||||
value: T,
|
||||
max: T,
|
||||
}
|
||||
|
||||
impl<T: Serialize> From<(T, T)> for PwmSummaryField<T> {
|
||||
fn from((value, max): (T, T)) -> Self {
|
||||
PwmSummaryField { value, max }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct PwmSummary {
|
||||
channel: usize,
|
||||
center: CenterPointJson,
|
||||
i_set: PwmSummaryField<ElectricCurrent>,
|
||||
max_v: PwmSummaryField<ElectricPotential>,
|
||||
max_i_pos: PwmSummaryField<ElectricCurrent>,
|
||||
max_i_neg: PwmSummaryField<ElectricCurrent>,
|
||||
i_set: ElectricCurrent,
|
||||
max_v: ElectricPotential,
|
||||
max_i_pos: ElectricCurrent,
|
||||
max_i_neg: ElectricCurrent,
|
||||
polarity: PolarityJson,
|
||||
}
|
||||
|
||||
|
|
|
@ -83,9 +83,9 @@ struct PwmLimits {
|
|||
|
||||
impl PwmLimits {
|
||||
pub fn new(channels: &mut Channels, channel: usize) -> Self {
|
||||
let (max_v, _) = channels.get_max_v(channel);
|
||||
let (max_i_pos, _) = channels.get_max_i_pos(channel);
|
||||
let (max_i_neg, _) = channels.get_max_i_neg(channel);
|
||||
let max_v = channels.get_max_v(channel);
|
||||
let max_i_pos = channels.get_max_i_pos(channel);
|
||||
let max_i_neg = channels.get_max_i_neg(channel);
|
||||
PwmLimits {
|
||||
max_v: max_v.get::<volt>(),
|
||||
max_i_pos: max_i_pos.get::<ampere>(),
|
||||
|
|
Loading…
Reference in New Issue