mirror of https://codeberg.org/topola/topola.git
terminology: distinguish between "command" and its "execution"
This commit is contained in:
parent
cc0bf1845a
commit
5448474857
|
|
@ -30,14 +30,14 @@ impl TryInto<()> for AutorouteStatus {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct AutorouteCommandStepper {
|
||||
pub struct AutorouteExecutionStepper {
|
||||
ratlines_iter: Box<dyn Iterator<Item = EdgeIndex<usize>>>,
|
||||
options: AutorouterOptions,
|
||||
route: Option<RouteStepper>,
|
||||
curr_ratline: Option<EdgeIndex<usize>>,
|
||||
}
|
||||
|
||||
impl AutorouteCommandStepper {
|
||||
impl AutorouteExecutionStepper {
|
||||
pub fn new(
|
||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||
ratlines: impl IntoIterator<Item = EdgeIndex<usize>> + 'static,
|
||||
|
|
@ -64,7 +64,7 @@ impl AutorouteCommandStepper {
|
|||
}
|
||||
|
||||
impl<M: AccessMesadata> Step<Autorouter<M>, AutorouteStatus, AutorouterError, ()>
|
||||
for AutorouteCommandStepper
|
||||
for AutorouteExecutionStepper
|
||||
{
|
||||
fn step(&mut self, autorouter: &mut Autorouter<M>) -> Result<AutorouteStatus, AutorouterError> {
|
||||
let Some(curr_ratline) = self.curr_ratline else {
|
||||
|
|
@ -119,25 +119,25 @@ impl<M: AccessMesadata> Step<Autorouter<M>, AutorouteStatus, AutorouterError, ()
|
|||
}
|
||||
}
|
||||
|
||||
impl GetMaybeNavmesh for AutorouteCommandStepper {
|
||||
impl GetMaybeNavmesh for AutorouteExecutionStepper {
|
||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||
self.route.as_ref().map(|route| route.navmesh())
|
||||
}
|
||||
}
|
||||
|
||||
impl GetMaybeTrace for AutorouteCommandStepper {
|
||||
impl GetMaybeTrace for AutorouteExecutionStepper {
|
||||
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||
self.route.as_ref().map(|route| route.trace())
|
||||
}
|
||||
}
|
||||
|
||||
impl GetGhosts for AutorouteCommandStepper {
|
||||
impl GetGhosts for AutorouteExecutionStepper {
|
||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||
self.route.as_ref().map_or(&[], |route| route.ghosts())
|
||||
}
|
||||
}
|
||||
|
||||
impl GetObstacles for AutorouteCommandStepper {
|
||||
impl GetObstacles for AutorouteExecutionStepper {
|
||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||
self.route.as_ref().map_or(&[], |route| route.obstacles())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ use crate::{
|
|||
};
|
||||
|
||||
use super::{
|
||||
autoroute::AutorouteCommandStepper,
|
||||
compare_detours::CompareDetoursCommandStepper,
|
||||
measure_length::MeasureLengthCommandStepper,
|
||||
place_via::PlaceViaCommandStepper,
|
||||
autoroute::AutorouteExecutionStepper,
|
||||
compare_detours::CompareDetoursExecutionStepper,
|
||||
measure_length::MeasureLengthExecutionStepper,
|
||||
place_via::PlaceViaExecutionStepper,
|
||||
ratsnest::{Ratsnest, RatvertexIndex},
|
||||
remove_bands::RemoveBandsCommandStepper,
|
||||
remove_bands::RemoveBandsExecutionStepper,
|
||||
selection::{BandSelection, PinSelection},
|
||||
};
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ impl<M: AccessMesadata> Autorouter<M> {
|
|||
&mut self,
|
||||
selection: &PinSelection,
|
||||
options: AutorouterOptions,
|
||||
) -> Result<AutorouteCommandStepper, AutorouterError> {
|
||||
) -> Result<AutorouteExecutionStepper, AutorouterError> {
|
||||
self.autoroute_ratlines(self.selected_ratlines(selection), options)
|
||||
}
|
||||
|
||||
|
|
@ -70,8 +70,8 @@ impl<M: AccessMesadata> Autorouter<M> {
|
|||
&mut self,
|
||||
ratlines: Vec<EdgeIndex<usize>>,
|
||||
options: AutorouterOptions,
|
||||
) -> Result<AutorouteCommandStepper, AutorouterError> {
|
||||
AutorouteCommandStepper::new(self, ratlines, options)
|
||||
) -> Result<AutorouteExecutionStepper, AutorouterError> {
|
||||
AutorouteExecutionStepper::new(self, ratlines, options)
|
||||
}
|
||||
|
||||
pub fn undo_autoroute(&mut self, selection: &PinSelection) -> Result<(), AutorouterError> {
|
||||
|
|
@ -99,8 +99,8 @@ impl<M: AccessMesadata> Autorouter<M> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn place_via(&self, weight: ViaWeight) -> Result<PlaceViaCommandStepper, AutorouterError> {
|
||||
PlaceViaCommandStepper::new(weight)
|
||||
pub fn place_via(&self, weight: ViaWeight) -> Result<PlaceViaExecutionStepper, AutorouterError> {
|
||||
PlaceViaExecutionStepper::new(weight)
|
||||
}
|
||||
|
||||
pub fn undo_place_via(&mut self, _weight: ViaWeight) {
|
||||
|
|
@ -110,8 +110,8 @@ impl<M: AccessMesadata> Autorouter<M> {
|
|||
pub fn remove_bands(
|
||||
&self,
|
||||
selection: &BandSelection,
|
||||
) -> Result<RemoveBandsCommandStepper, AutorouterError> {
|
||||
RemoveBandsCommandStepper::new(selection)
|
||||
) -> Result<RemoveBandsExecutionStepper, AutorouterError> {
|
||||
RemoveBandsExecutionStepper::new(selection)
|
||||
}
|
||||
|
||||
pub fn undo_remove_bands(&mut self, _selection: &BandSelection) {
|
||||
|
|
@ -122,7 +122,7 @@ impl<M: AccessMesadata> Autorouter<M> {
|
|||
&mut self,
|
||||
selection: &PinSelection,
|
||||
options: AutorouterOptions,
|
||||
) -> Result<CompareDetoursCommandStepper, AutorouterError> {
|
||||
) -> Result<CompareDetoursExecutionStepper, AutorouterError> {
|
||||
let ratlines = self.selected_ratlines(selection);
|
||||
let ratline1 = *ratlines
|
||||
.get(0)
|
||||
|
|
@ -138,15 +138,15 @@ impl<M: AccessMesadata> Autorouter<M> {
|
|||
ratline1: EdgeIndex<usize>,
|
||||
ratline2: EdgeIndex<usize>,
|
||||
options: AutorouterOptions,
|
||||
) -> Result<CompareDetoursCommandStepper, AutorouterError> {
|
||||
CompareDetoursCommandStepper::new(self, ratline1, ratline2, options)
|
||||
) -> Result<CompareDetoursExecutionStepper, AutorouterError> {
|
||||
CompareDetoursExecutionStepper::new(self, ratline1, ratline2, options)
|
||||
}
|
||||
|
||||
pub fn measure_length(
|
||||
&mut self,
|
||||
selection: &BandSelection,
|
||||
) -> Result<MeasureLengthCommandStepper, AutorouterError> {
|
||||
MeasureLengthCommandStepper::new(selection)
|
||||
) -> Result<MeasureLengthExecutionStepper, AutorouterError> {
|
||||
MeasureLengthExecutionStepper::new(selection)
|
||||
}
|
||||
|
||||
pub fn ratline_endpoints(
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ use serde::{Deserialize, Serialize};
|
|||
use crate::{board::mesadata::AccessMesadata, layout::via::ViaWeight, step::Step};
|
||||
|
||||
use super::{
|
||||
autoroute::{AutorouteCommandStepper, AutorouteStatus},
|
||||
compare_detours::{CompareDetoursCommandStepper, CompareDetoursStatus},
|
||||
autoroute::{AutorouteExecutionStepper, AutorouteStatus},
|
||||
compare_detours::{CompareDetoursExecutionStepper, CompareDetoursStatus},
|
||||
invoker::{Invoker, InvokerError, InvokerStatus},
|
||||
measure_length::MeasureLengthCommandStepper,
|
||||
place_via::PlaceViaCommandStepper,
|
||||
remove_bands::RemoveBandsCommandStepper,
|
||||
measure_length::MeasureLengthExecutionStepper,
|
||||
place_via::PlaceViaExecutionStepper,
|
||||
remove_bands::RemoveBandsExecutionStepper,
|
||||
selection::{BandSelection, PinSelection},
|
||||
AutorouterOptions,
|
||||
};
|
||||
|
|
@ -26,21 +26,21 @@ pub enum Command {
|
|||
}
|
||||
|
||||
#[enum_dispatch(GetMaybeNavmesh, GetMaybeTrace, GetGhosts, GetObstacles)]
|
||||
pub enum CommandStepper {
|
||||
Autoroute(AutorouteCommandStepper),
|
||||
PlaceVia(PlaceViaCommandStepper),
|
||||
RemoveBands(RemoveBandsCommandStepper),
|
||||
CompareDetours(CompareDetoursCommandStepper),
|
||||
MeasureLength(MeasureLengthCommandStepper),
|
||||
pub enum ExecutionStepper {
|
||||
Autoroute(AutorouteExecutionStepper),
|
||||
PlaceVia(PlaceViaExecutionStepper),
|
||||
RemoveBands(RemoveBandsExecutionStepper),
|
||||
CompareDetours(CompareDetoursExecutionStepper),
|
||||
MeasureLength(MeasureLengthExecutionStepper),
|
||||
}
|
||||
|
||||
impl CommandStepper {
|
||||
impl ExecutionStepper {
|
||||
fn step_catch_err<M: AccessMesadata>(
|
||||
&mut self,
|
||||
invoker: &mut Invoker<M>,
|
||||
) -> Result<InvokerStatus, InvokerError> {
|
||||
match self {
|
||||
CommandStepper::Autoroute(autoroute) => {
|
||||
ExecutionStepper::Autoroute(autoroute) => {
|
||||
match autoroute.step(&mut invoker.autorouter)? {
|
||||
AutorouteStatus::Running => Ok(InvokerStatus::Running),
|
||||
AutorouteStatus::Routed(..) => Ok(InvokerStatus::Running),
|
||||
|
|
@ -49,19 +49,19 @@ impl CommandStepper {
|
|||
))),
|
||||
}
|
||||
}
|
||||
CommandStepper::PlaceVia(place_via) => {
|
||||
ExecutionStepper::PlaceVia(place_via) => {
|
||||
place_via.doit(&mut invoker.autorouter)?;
|
||||
Ok(InvokerStatus::Finished(String::from(
|
||||
"finished placing via",
|
||||
)))
|
||||
}
|
||||
CommandStepper::RemoveBands(remove_bands) => {
|
||||
ExecutionStepper::RemoveBands(remove_bands) => {
|
||||
remove_bands.doit(&mut invoker.autorouter)?;
|
||||
Ok(InvokerStatus::Finished(String::from(
|
||||
"finished removing bands",
|
||||
)))
|
||||
}
|
||||
CommandStepper::CompareDetours(compare_detours) => {
|
||||
ExecutionStepper::CompareDetours(compare_detours) => {
|
||||
match compare_detours.step(&mut invoker.autorouter)? {
|
||||
CompareDetoursStatus::Running => Ok(InvokerStatus::Running),
|
||||
CompareDetoursStatus::Finished(total_length1, total_length2) => {
|
||||
|
|
@ -72,7 +72,7 @@ impl CommandStepper {
|
|||
}
|
||||
}
|
||||
}
|
||||
CommandStepper::MeasureLength(measure_length) => {
|
||||
ExecutionStepper::MeasureLength(measure_length) => {
|
||||
let length = measure_length.doit(&mut invoker.autorouter)?;
|
||||
Ok(InvokerStatus::Finished(format!(
|
||||
"Total length of selected bands: {}",
|
||||
|
|
@ -83,7 +83,7 @@ impl CommandStepper {
|
|||
}
|
||||
}
|
||||
|
||||
impl<M: AccessMesadata> Step<Invoker<M>, InvokerStatus, InvokerError, ()> for CommandStepper {
|
||||
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),
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use crate::{
|
|||
};
|
||||
|
||||
use super::{
|
||||
autoroute::{AutorouteCommandStepper, AutorouteStatus},
|
||||
autoroute::{AutorouteExecutionStepper, AutorouteStatus},
|
||||
invoker::{GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles},
|
||||
Autorouter, AutorouterError, AutorouterOptions,
|
||||
};
|
||||
|
|
@ -32,9 +32,9 @@ impl TryInto<(f64, f64)> for CompareDetoursStatus {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct CompareDetoursCommandStepper {
|
||||
autoroute: AutorouteCommandStepper,
|
||||
next_autoroute: Option<AutorouteCommandStepper>,
|
||||
pub struct CompareDetoursExecutionStepper {
|
||||
autoroute: AutorouteExecutionStepper,
|
||||
next_autoroute: Option<AutorouteExecutionStepper>,
|
||||
ratline1: EdgeIndex<usize>,
|
||||
ratline2: EdgeIndex<usize>,
|
||||
total_length1: f64,
|
||||
|
|
@ -42,7 +42,7 @@ pub struct CompareDetoursCommandStepper {
|
|||
done: bool,
|
||||
}
|
||||
|
||||
impl CompareDetoursCommandStepper {
|
||||
impl CompareDetoursExecutionStepper {
|
||||
pub fn new(
|
||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||
ratline1: EdgeIndex<usize>,
|
||||
|
|
@ -64,7 +64,7 @@ impl CompareDetoursCommandStepper {
|
|||
// XXX: Do we really need this to be a stepper? We don't use at the moment, as sorting functions
|
||||
// aren't steppable either. It may be useful for debugging later on tho.
|
||||
impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterError, (f64, f64)>
|
||||
for CompareDetoursCommandStepper
|
||||
for CompareDetoursExecutionStepper
|
||||
{
|
||||
fn step(
|
||||
&mut self,
|
||||
|
|
@ -112,25 +112,25 @@ impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterErro
|
|||
}
|
||||
}
|
||||
|
||||
impl GetMaybeNavmesh for CompareDetoursCommandStepper {
|
||||
impl GetMaybeNavmesh for CompareDetoursExecutionStepper {
|
||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||
self.autoroute.maybe_navmesh()
|
||||
}
|
||||
}
|
||||
|
||||
impl GetMaybeTrace for CompareDetoursCommandStepper {
|
||||
impl GetMaybeTrace for CompareDetoursExecutionStepper {
|
||||
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||
self.autoroute.maybe_trace()
|
||||
}
|
||||
}
|
||||
|
||||
impl GetGhosts for CompareDetoursCommandStepper {
|
||||
impl GetGhosts for CompareDetoursExecutionStepper {
|
||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||
self.autoroute.ghosts()
|
||||
}
|
||||
}
|
||||
|
||||
impl GetObstacles for CompareDetoursCommandStepper {
|
||||
impl GetObstacles for CompareDetoursExecutionStepper {
|
||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||
self.autoroute.obstacles()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,103 @@
|
|||
use enum_dispatch::enum_dispatch;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{board::mesadata::AccessMesadata, layout::via::ViaWeight, step::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> {
|
||||
match self {
|
||||
ExecutionStepper::Autoroute(autoroute) => {
|
||||
match autoroute.step(&mut invoker.autorouter)? {
|
||||
AutorouteStatus::Running => Ok(InvokerStatus::Running),
|
||||
AutorouteStatus::Routed(..) => Ok(InvokerStatus::Running),
|
||||
AutorouteStatus::Finished => Ok(InvokerStatus::Finished(String::from(
|
||||
"finished autorouting",
|
||||
))),
|
||||
}
|
||||
}
|
||||
ExecutionStepper::PlaceVia(place_via) => {
|
||||
place_via.doit(&mut invoker.autorouter)?;
|
||||
Ok(InvokerStatus::Finished(String::from(
|
||||
"finished placing via",
|
||||
)))
|
||||
}
|
||||
ExecutionStepper::RemoveBands(remove_bands) => {
|
||||
remove_bands.doit(&mut invoker.autorouter)?;
|
||||
Ok(InvokerStatus::Finished(String::from(
|
||||
"finished removing bands",
|
||||
)))
|
||||
}
|
||||
ExecutionStepper::CompareDetours(compare_detours) => {
|
||||
match compare_detours.step(&mut invoker.autorouter)? {
|
||||
CompareDetoursStatus::Running => Ok(InvokerStatus::Running),
|
||||
CompareDetoursStatus::Finished(total_length1, total_length2) => {
|
||||
Ok(InvokerStatus::Finished(String::from(format!(
|
||||
"total detour lengths are {} and {}",
|
||||
total_length1, total_length2
|
||||
))))
|
||||
}
|
||||
}
|
||||
}
|
||||
ExecutionStepper::MeasureLength(measure_length) => {
|
||||
let length = measure_length.doit(&mut invoker.autorouter)?;
|
||||
Ok(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,13 +13,13 @@ use crate::{
|
|||
};
|
||||
|
||||
use super::{
|
||||
autoroute::AutorouteCommandStepper,
|
||||
command::{Command, CommandStepper},
|
||||
compare_detours::CompareDetoursCommandStepper,
|
||||
autoroute::AutorouteExecutionStepper,
|
||||
command::{Command, ExecutionStepper},
|
||||
compare_detours::CompareDetoursExecutionStepper,
|
||||
history::{History, HistoryError},
|
||||
measure_length::MeasureLengthCommandStepper,
|
||||
place_via::PlaceViaCommandStepper,
|
||||
remove_bands::RemoveBandsCommandStepper,
|
||||
measure_length::MeasureLengthExecutionStepper,
|
||||
place_via::PlaceViaExecutionStepper,
|
||||
remove_bands::RemoveBandsExecutionStepper,
|
||||
Autorouter, AutorouterError,
|
||||
};
|
||||
|
||||
|
|
@ -108,14 +108,14 @@ impl<M: AccessMesadata> Invoker<M> {
|
|||
}
|
||||
|
||||
#[debug_requires(self.ongoing_command.is_none())]
|
||||
pub fn execute_stepper(&mut self, command: Command) -> Result<CommandStepper, InvokerError> {
|
||||
pub fn execute_stepper(&mut self, command: Command) -> Result<ExecutionStepper, InvokerError> {
|
||||
let execute = self.dispatch_command(&command);
|
||||
self.ongoing_command = Some(command);
|
||||
execute
|
||||
}
|
||||
|
||||
#[debug_requires(self.ongoing_command.is_none())]
|
||||
fn dispatch_command(&mut self, command: &Command) -> Result<CommandStepper, InvokerError> {
|
||||
fn dispatch_command(&mut self, command: &Command) -> Result<ExecutionStepper, InvokerError> {
|
||||
Ok(match command {
|
||||
Command::Autoroute(selection, options) => {
|
||||
let mut ratlines = self.autorouter.selected_ratlines(selection);
|
||||
|
|
@ -134,19 +134,19 @@ impl<M: AccessMesadata> Invoker<M> {
|
|||
});
|
||||
}
|
||||
|
||||
CommandStepper::Autoroute(self.autorouter.autoroute_ratlines(ratlines, *options)?)
|
||||
ExecutionStepper::Autoroute(self.autorouter.autoroute_ratlines(ratlines, *options)?)
|
||||
}
|
||||
Command::PlaceVia(weight) => {
|
||||
CommandStepper::PlaceVia(self.autorouter.place_via(*weight)?)
|
||||
ExecutionStepper::PlaceVia(self.autorouter.place_via(*weight)?)
|
||||
}
|
||||
Command::RemoveBands(selection) => {
|
||||
CommandStepper::RemoveBands(self.autorouter.remove_bands(selection)?)
|
||||
ExecutionStepper::RemoveBands(self.autorouter.remove_bands(selection)?)
|
||||
}
|
||||
Command::CompareDetours(selection, options) => CommandStepper::CompareDetours(
|
||||
Command::CompareDetours(selection, options) => ExecutionStepper::CompareDetours(
|
||||
self.autorouter.compare_detours(selection, *options)?,
|
||||
),
|
||||
Command::MeasureLength(selection) => {
|
||||
CommandStepper::MeasureLength(self.autorouter.measure_length(selection)?)
|
||||
ExecutionStepper::MeasureLength(self.autorouter.measure_length(selection)?)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ use super::{
|
|||
Autorouter, AutorouterError,
|
||||
};
|
||||
|
||||
pub struct MeasureLengthCommandStepper {
|
||||
pub struct MeasureLengthExecutionStepper {
|
||||
selection: BandSelection,
|
||||
maybe_length: Option<f64>,
|
||||
}
|
||||
|
||||
impl MeasureLengthCommandStepper {
|
||||
impl MeasureLengthExecutionStepper {
|
||||
pub fn new(selection: &BandSelection) -> Result<Self, AutorouterError> {
|
||||
Ok(Self {
|
||||
selection: selection.clone(),
|
||||
|
|
@ -51,25 +51,25 @@ impl MeasureLengthCommandStepper {
|
|||
}
|
||||
}
|
||||
|
||||
impl GetMaybeNavmesh for MeasureLengthCommandStepper {
|
||||
impl GetMaybeNavmesh for MeasureLengthExecutionStepper {
|
||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl GetMaybeTrace for MeasureLengthCommandStepper {
|
||||
impl GetMaybeTrace for MeasureLengthExecutionStepper {
|
||||
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl GetGhosts for MeasureLengthCommandStepper {
|
||||
impl GetGhosts for MeasureLengthExecutionStepper {
|
||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||
&[]
|
||||
}
|
||||
}
|
||||
|
||||
impl GetObstacles for MeasureLengthCommandStepper {
|
||||
impl GetObstacles for MeasureLengthExecutionStepper {
|
||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||
&[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ use super::{
|
|||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PlaceViaCommandStepper {
|
||||
pub struct PlaceViaExecutionStepper {
|
||||
weight: ViaWeight,
|
||||
done: bool,
|
||||
}
|
||||
|
||||
impl PlaceViaCommandStepper {
|
||||
impl PlaceViaExecutionStepper {
|
||||
pub fn new(weight: ViaWeight) -> Result<Self, AutorouterError> {
|
||||
Ok(Self {
|
||||
weight,
|
||||
|
|
@ -39,25 +39,25 @@ impl PlaceViaCommandStepper {
|
|||
}
|
||||
}
|
||||
|
||||
impl GetMaybeNavmesh for PlaceViaCommandStepper {
|
||||
impl GetMaybeNavmesh for PlaceViaExecutionStepper {
|
||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl GetMaybeTrace for PlaceViaCommandStepper {
|
||||
impl GetMaybeTrace for PlaceViaExecutionStepper {
|
||||
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl GetGhosts for PlaceViaCommandStepper {
|
||||
impl GetGhosts for PlaceViaExecutionStepper {
|
||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||
&[]
|
||||
}
|
||||
}
|
||||
|
||||
impl GetObstacles for PlaceViaCommandStepper {
|
||||
impl GetObstacles for PlaceViaExecutionStepper {
|
||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||
&[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ use super::{
|
|||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RemoveBandsCommandStepper {
|
||||
pub struct RemoveBandsExecutionStepper {
|
||||
selection: BandSelection,
|
||||
done: bool,
|
||||
}
|
||||
|
||||
impl RemoveBandsCommandStepper {
|
||||
impl RemoveBandsExecutionStepper {
|
||||
pub fn new(selection: &BandSelection) -> Result<Self, AutorouterError> {
|
||||
Ok(Self {
|
||||
selection: selection.clone(),
|
||||
|
|
@ -47,25 +47,25 @@ impl RemoveBandsCommandStepper {
|
|||
}
|
||||
}
|
||||
|
||||
impl GetMaybeNavmesh for RemoveBandsCommandStepper {
|
||||
impl GetMaybeNavmesh for RemoveBandsExecutionStepper {
|
||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl GetMaybeTrace for RemoveBandsCommandStepper {
|
||||
impl GetMaybeTrace for RemoveBandsExecutionStepper {
|
||||
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl GetGhosts for RemoveBandsCommandStepper {
|
||||
impl GetGhosts for RemoveBandsExecutionStepper {
|
||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||
&[]
|
||||
}
|
||||
}
|
||||
|
||||
impl GetObstacles for RemoveBandsCommandStepper {
|
||||
impl GetObstacles for RemoveBandsExecutionStepper {
|
||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||
&[]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use thiserror::Error;
|
||||
use topola::{
|
||||
autorouter::{
|
||||
command::CommandStepper,
|
||||
command::ExecutionStepper,
|
||||
invoker::{
|
||||
GetGhosts, GetMaybeNavmesh, GetMaybeTrace, GetObstacles, Invoker, InvokerError,
|
||||
InvokerStatus,
|
||||
|
|
@ -15,18 +15,18 @@ use topola::{
|
|||
step::Step,
|
||||
};
|
||||
|
||||
#[derive(Error, Debug, Clone)]
|
||||
pub enum ActivityError {
|
||||
#[error(transparent)]
|
||||
Invoker(#[from] InvokerError),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ActivityStatus {
|
||||
Running,
|
||||
Finished(String),
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, Clone)]
|
||||
pub enum ActivityError {
|
||||
#[error(transparent)]
|
||||
Invoker(#[from] InvokerError),
|
||||
}
|
||||
|
||||
impl From<InvokerStatus> for ActivityStatus {
|
||||
fn from(status: InvokerStatus) -> Self {
|
||||
match status {
|
||||
|
|
@ -48,7 +48,7 @@ impl TryInto<()> for ActivityStatus {
|
|||
|
||||
pub enum ActivityStepper {
|
||||
// There will be another variant for interactive activities here soon. (TODO)
|
||||
Command(CommandStepper),
|
||||
Execution(ExecutionStepper),
|
||||
}
|
||||
|
||||
impl Step<Invoker<SpecctraMesadata>, ActivityStatus, ActivityError, ()> for ActivityStepper {
|
||||
|
|
@ -57,7 +57,7 @@ impl Step<Invoker<SpecctraMesadata>, ActivityStatus, ActivityError, ()> for Acti
|
|||
invoker: &mut Invoker<SpecctraMesadata>,
|
||||
) -> Result<ActivityStatus, ActivityError> {
|
||||
match self {
|
||||
ActivityStepper::Command(execute) => Ok(execute.step(invoker)?.into()),
|
||||
ActivityStepper::Execution(execute) => Ok(execute.step(invoker)?.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ impl GetMaybeNavmesh for ActivityStepper {
|
|||
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
||||
fn maybe_navmesh(&self) -> Option<&Navmesh> {
|
||||
match self {
|
||||
ActivityStepper::Command(execute) => execute.maybe_navmesh(),
|
||||
ActivityStepper::Execution(execute) => execute.maybe_navmesh(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ impl GetMaybeTrace for ActivityStepper {
|
|||
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
||||
fn maybe_trace(&self) -> Option<&TraceStepper> {
|
||||
match self {
|
||||
ActivityStepper::Command(execute) => execute.maybe_trace(),
|
||||
ActivityStepper::Execution(execute) => execute.maybe_trace(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ impl GetGhosts for ActivityStepper {
|
|||
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
||||
fn ghosts(&self) -> &[PrimitiveShape] {
|
||||
match self {
|
||||
ActivityStepper::Command(execute) => execute.ghosts(),
|
||||
ActivityStepper::Execution(execute) => execute.ghosts(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ impl GetObstacles for ActivityStepper {
|
|||
/// Implemented manually instead of with `enum_dispatch` because it doesn't work across crates.
|
||||
fn obstacles(&self) -> &[PrimitiveIndex] {
|
||||
match self {
|
||||
ActivityStepper::Command(execute) => execute.obstacles(),
|
||||
ActivityStepper::Execution(execute) => execute.obstacles(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -104,9 +104,9 @@ pub struct ActivityWithStatus {
|
|||
}
|
||||
|
||||
impl ActivityWithStatus {
|
||||
pub fn new_execute(execute: CommandStepper) -> ActivityWithStatus {
|
||||
pub fn new_execute(execute: ExecutionStepper) -> ActivityWithStatus {
|
||||
Self {
|
||||
activity: ActivityStepper::Command(execute),
|
||||
activity: ActivityStepper::Execution(execute),
|
||||
maybe_status: None,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
pub struct RouteInteractionStepper {
|
||||
route: RouteStepper,
|
||||
options: RouterOptions,
|
||||
}
|
||||
Loading…
Reference in New Issue