mirror of https://codeberg.org/topola/topola.git
refactor(autorouter/planar_reconfigurator): Return different status upon reconfiguration
This commit is contained in:
parent
4306aa33c4
commit
260aca064d
|
|
@ -28,8 +28,8 @@ allowed_scopes = [
|
||||||
"autorouter/invoker",
|
"autorouter/invoker",
|
||||||
"autorouter/measure_length",
|
"autorouter/measure_length",
|
||||||
"autorouter/multilayer_autoroute",
|
"autorouter/multilayer_autoroute",
|
||||||
"autorouter/planar_permutator",
|
"autorouter/planar_reconfigurator",
|
||||||
"autorouter/planar_permuter",
|
"autorouter/planar_reconfigurer",
|
||||||
"autorouter/place_via",
|
"autorouter/place_via",
|
||||||
"autorouter/planar_autoroute",
|
"autorouter/planar_autoroute",
|
||||||
"autorouter/planner",
|
"autorouter/planner",
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use crate::{
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::{edit::Edit, primitive::PrimitiveShape},
|
geometry::{edit::Edit, primitive::PrimitiveShape},
|
||||||
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
||||||
stepper::{Abort, EstimateProgress, Step},
|
stepper::{Abort, EstimateProgress, ReconfiguratorStatus, Step},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||||
|
|
@ -56,7 +56,8 @@ impl MultilayerAutorouteExecutionStepper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteContinueStatus>
|
impl<M: AccessMesadata>
|
||||||
|
Step<Autorouter<M>, Option<BoardEdit>, ReconfiguratorStatus<(), PlanarAutorouteContinueStatus>>
|
||||||
for MultilayerAutorouteExecutionStepper
|
for MultilayerAutorouteExecutionStepper
|
||||||
{
|
{
|
||||||
type Error = AutorouterError;
|
type Error = AutorouterError;
|
||||||
|
|
@ -64,8 +65,10 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteCo
|
||||||
fn step(
|
fn step(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<M>,
|
autorouter: &mut Autorouter<M>,
|
||||||
) -> Result<ControlFlow<Option<BoardEdit>, PlanarAutorouteContinueStatus>, AutorouterError>
|
) -> Result<
|
||||||
{
|
ControlFlow<Option<BoardEdit>, ReconfiguratorStatus<(), PlanarAutorouteContinueStatus>>,
|
||||||
|
AutorouterError,
|
||||||
|
> {
|
||||||
match self.planar.step(autorouter) {
|
match self.planar.step(autorouter) {
|
||||||
Ok(ControlFlow::Break(Some(edit))) => {
|
Ok(ControlFlow::Break(Some(edit))) => {
|
||||||
self.anteroute_edit.merge(edit);
|
self.anteroute_edit.merge(edit);
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ use super::{
|
||||||
pub enum PlanarAutorouteContinueStatus {
|
pub enum PlanarAutorouteContinueStatus {
|
||||||
/// The autoroute is currently running and in progress.
|
/// The autoroute is currently running and in progress.
|
||||||
Running,
|
Running,
|
||||||
/// A specific segment has been successfully routed.
|
/// A band has been successfully routed.
|
||||||
Routed(BandTermsegIndex),
|
Routed(BandTermsegIndex),
|
||||||
/// A specific segment had been already routed and has been skipped.
|
/// A band had been already routed and has been skipped.
|
||||||
Skipped(BandTermsegIndex),
|
Skipped(BandTermsegIndex),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ use crate::{
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::primitive::PrimitiveShape,
|
geometry::primitive::PrimitiveShape,
|
||||||
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
||||||
stepper::{Abort, EstimateProgress, Reconfigure, Step},
|
stepper::{Abort, EstimateProgress, ReconfiguratorStatus, Reconfigure, Step},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PlanarAutorouteExecutionReconfigurator {
|
pub struct PlanarAutorouteExecutionReconfigurator {
|
||||||
|
|
@ -62,7 +62,8 @@ impl PlanarAutorouteExecutionReconfigurator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteContinueStatus>
|
impl<M: AccessMesadata>
|
||||||
|
Step<Autorouter<M>, Option<BoardEdit>, ReconfiguratorStatus<(), PlanarAutorouteContinueStatus>>
|
||||||
for PlanarAutorouteExecutionReconfigurator
|
for PlanarAutorouteExecutionReconfigurator
|
||||||
{
|
{
|
||||||
type Error = AutorouterError;
|
type Error = AutorouterError;
|
||||||
|
|
@ -70,10 +71,15 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteCo
|
||||||
fn step(
|
fn step(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<M>,
|
autorouter: &mut Autorouter<M>,
|
||||||
) -> Result<ControlFlow<Option<BoardEdit>, PlanarAutorouteContinueStatus>, AutorouterError>
|
) -> Result<
|
||||||
{
|
ControlFlow<Option<BoardEdit>, ReconfiguratorStatus<(), PlanarAutorouteContinueStatus>>,
|
||||||
|
AutorouterError,
|
||||||
|
> {
|
||||||
match self.stepper.step(autorouter) {
|
match self.stepper.step(autorouter) {
|
||||||
Ok(ok) => Ok(ok),
|
Ok(ControlFlow::Break(maybe_edit)) => Ok(ControlFlow::Break(maybe_edit)),
|
||||||
|
Ok(ControlFlow::Continue(status)) => {
|
||||||
|
Ok(ControlFlow::Continue(ReconfiguratorStatus::Running(status)))
|
||||||
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if !self.options.permutate {
|
if !self.options.permutate {
|
||||||
return Err(err);
|
return Err(err);
|
||||||
|
|
@ -94,7 +100,9 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.stepper.step(autorouter)
|
Ok(ControlFlow::Continue(
|
||||||
|
ReconfiguratorStatus::Reconfigured(()),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,11 @@ pub trait Reconfigure<Ctx> {
|
||||||
) -> Self::Output;
|
) -> Self::Output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum ReconfiguratorStatus<Re, Ru> {
|
||||||
|
Running(Ru),
|
||||||
|
Reconfigured(Re),
|
||||||
|
}
|
||||||
|
|
||||||
/// Steppers that can receive discrete events and act on them implement this
|
/// Steppers that can receive discrete events and act on them implement this
|
||||||
/// trait.
|
/// trait.
|
||||||
// XXX: Doesn't this violate the rule that stepper's future states are
|
// XXX: Doesn't this violate the rule that stepper's future states are
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue