fix: 修复 UPS 输出管脚状态未更新的问题。
This commit is contained in:
parent
2f52f142b8
commit
9b40b5dfdd
@ -47,7 +47,6 @@ impl DcOutControllerState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_adapter_down(&mut self) {
|
fn handle_adapter_down(&mut self) {
|
||||||
info!("status: {:?}", self);
|
|
||||||
match self.status {
|
match self.status {
|
||||||
DcOutStatus::On => {
|
DcOutStatus::On => {
|
||||||
self.status = DcOutStatus::WaitingOff;
|
self.status = DcOutStatus::WaitingOff;
|
||||||
@ -208,7 +207,7 @@ impl DcOutController {
|
|||||||
|
|
||||||
match pin.lock() {
|
match pin.lock() {
|
||||||
Ok(pin) => {
|
Ok(pin) => {
|
||||||
if let Err(err) = Self::output_ctl(state, pin) {
|
if let Err(err) = Self::output_ctl(&mut state, pin) {
|
||||||
warn!("Put Control Pin State Failed. {}", err);
|
warn!("Put Control Pin State Failed. {}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,7 +221,6 @@ impl DcOutController {
|
|||||||
} else {
|
} else {
|
||||||
warn!("DC_OUT_STATE_EVENT_LOOP is None");
|
warn!("DC_OUT_STATE_EVENT_LOOP is None");
|
||||||
}
|
}
|
||||||
debug!("status: {:?}", state);
|
|
||||||
})
|
})
|
||||||
.map_err(|err| anyhow::anyhow!("Subscribe Voltage Failed. {}", err))?;
|
.map_err(|err| anyhow::anyhow!("Subscribe Voltage Failed. {}", err))?;
|
||||||
self.voltage_subscription = Some(voltage_subscription);
|
self.voltage_subscription = Some(voltage_subscription);
|
||||||
@ -232,14 +230,14 @@ impl DcOutController {
|
|||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
}
|
}
|
||||||
fn output_ctl(
|
fn output_ctl(
|
||||||
mut state: DcOutControllerState,
|
state: &mut DcOutControllerState,
|
||||||
mut pin: MutexGuard<DcOutPin>,
|
mut pin: MutexGuard<DcOutPin>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
if DcOutStatus::Off == state.status && state.pin_state == PinState::Low {
|
if DcOutStatus::Off == state.status {
|
||||||
pin.set_high()
|
pin.set_high()
|
||||||
.map_err(|err| anyhow::anyhow!("Set DC Output Control Pin High Failed. {}", err))?;
|
.map_err(|err| anyhow::anyhow!("Set DC Output Control Pin High Failed. {}", err))?;
|
||||||
state.pin_state = PinState::High;
|
state.pin_state = PinState::High;
|
||||||
} else if DcOutStatus::On == state.status && state.pin_state == PinState::High {
|
} else if DcOutStatus::On == state.status {
|
||||||
pin.set_low()
|
pin.set_low()
|
||||||
.map_err(|err| anyhow::anyhow!("Set DC Output Control Pin Low Failed. {}", err))?;
|
.map_err(|err| anyhow::anyhow!("Set DC Output Control Pin Low Failed. {}", err))?;
|
||||||
state.pin_state = PinState::Low;
|
state.pin_state = PinState::Low;
|
||||||
|
Loading…
Reference in New Issue
Block a user