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/measure_length",
|
||||
"autorouter/multilayer_autoroute",
|
||||
"autorouter/planar_permutator",
|
||||
"autorouter/planar_permuter",
|
||||
"autorouter/planar_reconfigurator",
|
||||
"autorouter/planar_reconfigurer",
|
||||
"autorouter/place_via",
|
||||
"autorouter/planar_autoroute",
|
||||
"autorouter/planner",
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use crate::{
|
|||
drawing::graph::PrimitiveIndex,
|
||||
geometry::{edit::Edit, primitive::PrimitiveShape},
|
||||
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
||||
stepper::{Abort, EstimateProgress, Step},
|
||||
stepper::{Abort, EstimateProgress, ReconfiguratorStatus, Step},
|
||||
};
|
||||
|
||||
#[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
|
||||
{
|
||||
type Error = AutorouterError;
|
||||
|
|
@ -64,8 +65,10 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteCo
|
|||
fn step(
|
||||
&mut self,
|
||||
autorouter: &mut Autorouter<M>,
|
||||
) -> Result<ControlFlow<Option<BoardEdit>, PlanarAutorouteContinueStatus>, AutorouterError>
|
||||
{
|
||||
) -> Result<
|
||||
ControlFlow<Option<BoardEdit>, ReconfiguratorStatus<(), PlanarAutorouteContinueStatus>>,
|
||||
AutorouterError,
|
||||
> {
|
||||
match self.planar.step(autorouter) {
|
||||
Ok(ControlFlow::Break(Some(edit))) => {
|
||||
self.anteroute_edit.merge(edit);
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ use super::{
|
|||
pub enum PlanarAutorouteContinueStatus {
|
||||
/// The autoroute is currently running and in progress.
|
||||
Running,
|
||||
/// A specific segment has been successfully routed.
|
||||
/// A band has been successfully routed.
|
||||
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),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use crate::{
|
|||
drawing::graph::PrimitiveIndex,
|
||||
geometry::primitive::PrimitiveShape,
|
||||
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
||||
stepper::{Abort, EstimateProgress, Reconfigure, Step},
|
||||
stepper::{Abort, EstimateProgress, ReconfiguratorStatus, Reconfigure, Step},
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
type Error = AutorouterError;
|
||||
|
|
@ -70,10 +71,15 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteCo
|
|||
fn step(
|
||||
&mut self,
|
||||
autorouter: &mut Autorouter<M>,
|
||||
) -> Result<ControlFlow<Option<BoardEdit>, PlanarAutorouteContinueStatus>, AutorouterError>
|
||||
{
|
||||
) -> Result<
|
||||
ControlFlow<Option<BoardEdit>, ReconfiguratorStatus<(), PlanarAutorouteContinueStatus>>,
|
||||
AutorouterError,
|
||||
> {
|
||||
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) => {
|
||||
if !self.options.permutate {
|
||||
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;
|
||||
}
|
||||
|
||||
pub enum ReconfiguratorStatus<Re, Ru> {
|
||||
Running(Ru),
|
||||
Reconfigured(Re),
|
||||
}
|
||||
|
||||
/// Steppers that can receive discrete events and act on them implement this
|
||||
/// trait.
|
||||
// XXX: Doesn't this violate the rule that stepper's future states are
|
||||
|
|
|
|||
Loading…
Reference in New Issue