mirror of https://codeberg.org/topola/topola.git
chore(autorouter): let ExecutionStepper::step_catch_err take Autorouter as context
This commit is contained in:
parent
4171443c45
commit
24c7f66b04
|
|
@ -16,7 +16,7 @@ use super::{
|
|||
place_via::PlaceViaExecutionStepper,
|
||||
remove_bands::RemoveBandsExecutionStepper,
|
||||
selection::{BandSelection, PinSelection},
|
||||
AutorouterOptions,
|
||||
Autorouter, AutorouterOptions,
|
||||
};
|
||||
|
||||
type Type = PinSelection;
|
||||
|
|
@ -42,26 +42,24 @@ pub enum ExecutionStepper {
|
|||
impl ExecutionStepper {
|
||||
fn step_catch_err<M: AccessMesadata>(
|
||||
&mut self,
|
||||
invoker: &mut Invoker<M>,
|
||||
autorouter: &mut Autorouter<M>,
|
||||
) -> Poll<Result<String, InvokerError>> {
|
||||
match self {
|
||||
ExecutionStepper::Autoroute(autoroute) => {
|
||||
match autoroute.step(&mut invoker.autorouter)? {
|
||||
AutorouteStatus::Running => Poll::Pending,
|
||||
AutorouteStatus::Routed(..) => Poll::Pending,
|
||||
AutorouteStatus::Finished => Poll::Ready("finished autorouting".to_string()),
|
||||
}
|
||||
}
|
||||
ExecutionStepper::Autoroute(autoroute) => match autoroute.step(autorouter)? {
|
||||
AutorouteStatus::Running => Poll::Pending,
|
||||
AutorouteStatus::Routed(..) => Poll::Pending,
|
||||
AutorouteStatus::Finished => Poll::Ready("finished autorouting".to_string()),
|
||||
},
|
||||
ExecutionStepper::PlaceVia(place_via) => {
|
||||
place_via.doit(&mut invoker.autorouter)?;
|
||||
place_via.doit(autorouter)?;
|
||||
Poll::Ready("finished placing via".to_string())
|
||||
}
|
||||
ExecutionStepper::RemoveBands(remove_bands) => {
|
||||
remove_bands.doit(&mut invoker.autorouter)?;
|
||||
remove_bands.doit(autorouter)?;
|
||||
Poll::Ready("finished removing bands".to_string())
|
||||
}
|
||||
ExecutionStepper::CompareDetours(compare_detours) => {
|
||||
match compare_detours.step(&mut invoker.autorouter)? {
|
||||
match compare_detours.step(autorouter)? {
|
||||
CompareDetoursStatus::Running => Poll::Pending,
|
||||
CompareDetoursStatus::Finished(total_length1, total_length2) => {
|
||||
Poll::Ready(format!(
|
||||
|
|
@ -72,7 +70,7 @@ impl ExecutionStepper {
|
|||
}
|
||||
}
|
||||
ExecutionStepper::MeasureLength(measure_length) => {
|
||||
let length = measure_length.doit(&mut invoker.autorouter)?;
|
||||
let length = measure_length.doit(autorouter)?;
|
||||
Poll::Ready(format!("Total length of selected bands: {}", length))
|
||||
}
|
||||
}
|
||||
|
|
@ -86,17 +84,18 @@ impl StepError for ExecutionStepper {
|
|||
|
||||
impl<M: AccessMesadata> PollStep<Invoker<M>, String> for ExecutionStepper {
|
||||
fn poll_step(&mut self, invoker: &mut Invoker<M>) -> Poll<Result<String, InvokerError>> {
|
||||
self.step_catch_err(invoker).map(|x| match x {
|
||||
Ok(msg) => {
|
||||
if let Some(command) = invoker.ongoing_command.take() {
|
||||
invoker.history.do_(command);
|
||||
self.step_catch_err(&mut invoker.autorouter)
|
||||
.map(|x| match x {
|
||||
Ok(msg) => {
|
||||
if let Some(command) = invoker.ongoing_command.take() {
|
||||
invoker.history.do_(command);
|
||||
}
|
||||
Ok(msg)
|
||||
}
|
||||
Ok(msg)
|
||||
}
|
||||
Err(err) => {
|
||||
invoker.ongoing_command = None;
|
||||
Err(err)
|
||||
}
|
||||
})
|
||||
Err(err) => {
|
||||
invoker.ongoing_command = None;
|
||||
Err(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue