chore: perform forgotten rename of `command.rs` to `execution.rs`

This commit is contained in:
Mikolaj Wielgus 2024-10-04 21:55:27 +02:00
parent 5f6045a758
commit 8b9d4074e4
11 changed files with 23 additions and 126 deletions

View File

@ -1,96 +0,0 @@
use enum_dispatch::enum_dispatch;
use serde::{Deserialize, Serialize};
use crate::{board::mesadata::AccessMesadata, layout::via::ViaWeight, stepper::Step};
use super::{
autoroute::{AutorouteExecutionStepper, AutorouteStatus},
compare_detours::{CompareDetoursExecutionStepper, CompareDetoursStatus},
invoker::{Invoker, InvokerError, InvokerStatus},
measure_length::MeasureLengthExecutionStepper,
place_via::PlaceViaExecutionStepper,
remove_bands::RemoveBandsExecutionStepper,
selection::{BandSelection, PinSelection},
AutorouterOptions,
};
type Type = PinSelection;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Command {
Autoroute(PinSelection, AutorouterOptions),
PlaceVia(ViaWeight),
RemoveBands(BandSelection),
CompareDetours(Type, AutorouterOptions),
MeasureLength(BandSelection),
}
#[enum_dispatch(GetMaybeNavmesh, GetMaybeTrace, GetGhosts, GetObstacles)]
pub enum ExecutionStepper {
Autoroute(AutorouteExecutionStepper),
PlaceVia(PlaceViaExecutionStepper),
RemoveBands(RemoveBandsExecutionStepper),
CompareDetours(CompareDetoursExecutionStepper),
MeasureLength(MeasureLengthExecutionStepper),
}
impl ExecutionStepper {
fn step_catch_err<M: AccessMesadata>(
&mut self,
invoker: &mut Invoker<M>,
) -> Result<InvokerStatus, InvokerError> {
Ok(match self {
ExecutionStepper::Autoroute(autoroute) => {
match autoroute.step(&mut invoker.autorouter)? {
AutorouteStatus::Running => InvokerStatus::Running,
AutorouteStatus::Routed(..) => InvokerStatus::Running,
AutorouteStatus::Finished => {
InvokerStatus::Finished("finished autorouting".to_string())
}
}
}
ExecutionStepper::PlaceVia(place_via) => {
place_via.doit(&mut invoker.autorouter)?;
InvokerStatus::Finished("finished placing via".to_string())
}
ExecutionStepper::RemoveBands(remove_bands) => {
remove_bands.doit(&mut invoker.autorouter)?;
InvokerStatus::Finished("finished removing bands".to_string())
}
ExecutionStepper::CompareDetours(compare_detours) => {
match compare_detours.step(&mut invoker.autorouter)? {
CompareDetoursStatus::Running => InvokerStatus::Running,
CompareDetoursStatus::Finished(total_length1, total_length2) => {
InvokerStatus::Finished(format!(
"total detour lengths are {} and {}",
total_length1, total_length2
))
}
}
}
ExecutionStepper::MeasureLength(measure_length) => {
let length = measure_length.doit(&mut invoker.autorouter)?;
InvokerStatus::Finished(format!("Total length of selected bands: {}", length))
}
})
}
}
impl<M: AccessMesadata> Step<Invoker<M>, InvokerStatus, InvokerError, ()> for ExecutionStepper {
fn step(&mut self, invoker: &mut Invoker<M>) -> Result<InvokerStatus, InvokerError> {
match self.step_catch_err(invoker) {
Ok(InvokerStatus::Running) => Ok(InvokerStatus::Running),
Ok(InvokerStatus::Finished(msg)) => {
if let Some(command) = invoker.ongoing_command.take() {
invoker.history.do_(command);
}
Ok(InvokerStatus::Finished(msg))
}
Err(err) => {
invoker.ongoing_command = None;
Err(err)
}
}
}
}

View File

@ -1,7 +1,7 @@
use enum_dispatch::enum_dispatch; use enum_dispatch::enum_dispatch;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{board::mesadata::AccessMesadata, layout::via::ViaWeight, step::Step}; use crate::{board::mesadata::AccessMesadata, layout::via::ViaWeight, stepper::Step};
use super::{ use super::{
autoroute::{AutorouteExecutionStepper, AutorouteStatus}, autoroute::{AutorouteExecutionStepper, AutorouteStatus},
@ -39,47 +39,40 @@ impl ExecutionStepper {
&mut self, &mut self,
invoker: &mut Invoker<M>, invoker: &mut Invoker<M>,
) -> Result<InvokerStatus, InvokerError> { ) -> Result<InvokerStatus, InvokerError> {
match self { Ok(match self {
ExecutionStepper::Autoroute(autoroute) => { ExecutionStepper::Autoroute(autoroute) => {
match autoroute.step(&mut invoker.autorouter)? { match autoroute.step(&mut invoker.autorouter)? {
AutorouteStatus::Running => Ok(InvokerStatus::Running), AutorouteStatus::Running => InvokerStatus::Running,
AutorouteStatus::Routed(..) => Ok(InvokerStatus::Running), AutorouteStatus::Routed(..) => InvokerStatus::Running,
AutorouteStatus::Finished => Ok(InvokerStatus::Finished(String::from( AutorouteStatus::Finished => {
"finished autorouting", InvokerStatus::Finished("finished autorouting".to_string())
))), }
} }
} }
ExecutionStepper::PlaceVia(place_via) => { ExecutionStepper::PlaceVia(place_via) => {
place_via.doit(&mut invoker.autorouter)?; place_via.doit(&mut invoker.autorouter)?;
Ok(InvokerStatus::Finished(String::from( InvokerStatus::Finished("finished placing via".to_string())
"finished placing via",
)))
} }
ExecutionStepper::RemoveBands(remove_bands) => { ExecutionStepper::RemoveBands(remove_bands) => {
remove_bands.doit(&mut invoker.autorouter)?; remove_bands.doit(&mut invoker.autorouter)?;
Ok(InvokerStatus::Finished(String::from( InvokerStatus::Finished("finished removing bands".to_string())
"finished removing bands",
)))
} }
ExecutionStepper::CompareDetours(compare_detours) => { ExecutionStepper::CompareDetours(compare_detours) => {
match compare_detours.step(&mut invoker.autorouter)? { match compare_detours.step(&mut invoker.autorouter)? {
CompareDetoursStatus::Running => Ok(InvokerStatus::Running), CompareDetoursStatus::Running => InvokerStatus::Running,
CompareDetoursStatus::Finished(total_length1, total_length2) => { CompareDetoursStatus::Finished(total_length1, total_length2) => {
Ok(InvokerStatus::Finished(String::from(format!( InvokerStatus::Finished(format!(
"total detour lengths are {} and {}", "total detour lengths are {} and {}",
total_length1, total_length2 total_length1, total_length2
)))) ))
} }
} }
} }
ExecutionStepper::MeasureLength(measure_length) => { ExecutionStepper::MeasureLength(measure_length) => {
let length = measure_length.doit(&mut invoker.autorouter)?; let length = measure_length.doit(&mut invoker.autorouter)?;
Ok(InvokerStatus::Finished(format!( InvokerStatus::Finished(format!("Total length of selected bands: {}", length))
"Total length of selected bands: {}",
length
)))
} }
} })
} }
} }

View File

@ -5,7 +5,7 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use thiserror::Error; use thiserror::Error;
use crate::autorouter::command::Command; use crate::autorouter::execution::Command;
#[derive(Error, Debug, Clone)] #[derive(Error, Debug, Clone)]
pub enum HistoryError { pub enum HistoryError {

View File

@ -16,8 +16,8 @@ use crate::{
use super::{ use super::{
autoroute::AutorouteExecutionStepper, autoroute::AutorouteExecutionStepper,
command::{Command, ExecutionStepper},
compare_detours::CompareDetoursExecutionStepper, compare_detours::CompareDetoursExecutionStepper,
execution::{Command, ExecutionStepper},
history::{History, HistoryError}, history::{History, HistoryError},
measure_length::MeasureLengthExecutionStepper, measure_length::MeasureLengthExecutionStepper,
place_via::PlaceViaExecutionStepper, place_via::PlaceViaExecutionStepper,

View File

@ -2,8 +2,8 @@
pub mod autoroute; pub mod autoroute;
mod autorouter; mod autorouter;
pub mod command;
pub mod compare_detours; pub mod compare_detours;
pub mod execution;
pub mod history; pub mod history;
pub mod invoker; pub mod invoker;
pub mod measure_length; pub mod measure_length;

View File

@ -1,7 +1,7 @@
use thiserror::Error; use thiserror::Error;
use topola::{ use topola::{
autorouter::{ autorouter::{
command::ExecutionStepper, execution::ExecutionStepper,
invoker::{ invoker::{
GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker, InvokerError, GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker, InvokerError,
InvokerStatus, InvokerStatus,

View File

@ -5,7 +5,7 @@ use std::{
use topola::{ use topola::{
autorouter::{ autorouter::{
command::Command, execution::Command,
history::History, history::History,
invoker::{Invoker, InvokerError}, invoker::{Invoker, InvokerError},
AutorouterOptions, AutorouterOptions,

View File

@ -6,7 +6,7 @@ use petgraph::{
use rstar::{Envelope, AABB}; use rstar::{Envelope, AABB};
use topola::{ use topola::{
autorouter::{ autorouter::{
command::Command, execution::Command,
invoker::{GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker}, invoker::{GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker},
}, },
drawing::{ drawing::{

View File

@ -1,7 +1,7 @@
use clap::Parser; use clap::Parser;
use std::fs::File; use std::fs::File;
use std::io::BufReader; use std::io::BufReader;
use topola::autorouter::command::Command; use topola::autorouter::execution::Command;
use topola::autorouter::history::History; use topola::autorouter::history::History;
use topola::autorouter::invoker::Invoker; use topola::autorouter::invoker::Invoker;
use topola::autorouter::selection::PinSelection; use topola::autorouter::selection::PinSelection;

View File

@ -1,5 +1,5 @@
use topola::{ use topola::{
autorouter::{command::Command, invoker::InvokerError, AutorouterError}, autorouter::{execution::Command, invoker::InvokerError, AutorouterError},
board::mesadata::AccessMesadata, board::mesadata::AccessMesadata,
layout::via::ViaWeight, layout::via::ViaWeight,
math::Circle, math::Circle,

View File

@ -1,6 +1,6 @@
use topola::{ use topola::{
autorouter::{ autorouter::{
command::Command, execution::Command,
invoker::{Invoker, InvokerError}, invoker::{Invoker, InvokerError},
AutorouterError, AutorouterError,
}, },