mirror of https://codeberg.org/topola/topola.git
specctra: change "dsn" to "specctra" where it's about both DSN and SES
This commit is contained in:
parent
96ad809a83
commit
9d00e95457
|
|
@ -34,8 +34,8 @@ bimap = "0.6.3"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
utf8-chars = "3.0.2"
|
utf8-chars = "3.0.2"
|
||||||
|
|
||||||
[dependencies.dsn_derive]
|
[dependencies.specctra_derive]
|
||||||
path = "macro/dsn_derive"
|
path = "macro/specctra_derive"
|
||||||
|
|
||||||
[dependencies.geo]
|
[dependencies.geo]
|
||||||
version = "0.25.1"
|
version = "0.25.1"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "dsn_derive"
|
name = "specctra_derive"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
@ -1,21 +1,17 @@
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use syn::{DeriveInput, Attribute, LitStr};
|
use syn::{Attribute, DeriveInput, LitStr};
|
||||||
|
|
||||||
mod read;
|
mod read;
|
||||||
mod write;
|
mod write;
|
||||||
|
|
||||||
#[proc_macro_derive(ReadDsn, attributes(opt, anon, vec, anon_vec))]
|
#[proc_macro_derive(ReadDsn, attributes(opt, anon, vec, anon_vec))]
|
||||||
pub fn derive_read(input: TokenStream)
|
pub fn derive_read(input: TokenStream) -> TokenStream {
|
||||||
-> TokenStream
|
|
||||||
{
|
|
||||||
let input = syn::parse_macro_input!(input as DeriveInput);
|
let input = syn::parse_macro_input!(input as DeriveInput);
|
||||||
read::impl_read(&input).into()
|
read::impl_read(&input).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[proc_macro_derive(WriteDsn, attributes(anon))]
|
#[proc_macro_derive(WriteSes, attributes(anon))]
|
||||||
pub fn derive_write(input: TokenStream)
|
pub fn derive_write(input: TokenStream) -> TokenStream {
|
||||||
-> TokenStream
|
|
||||||
{
|
|
||||||
let input = syn::parse_macro_input!(input as DeriveInput);
|
let input = syn::parse_macro_input!(input as DeriveInput);
|
||||||
write::impl_write(&input).into()
|
write::impl_write(&input).into()
|
||||||
}
|
}
|
||||||
|
|
@ -31,10 +27,5 @@ fn attr_content(attrs: &Vec<Attribute>, name: &str) -> Option<String> {
|
||||||
attrs
|
attrs
|
||||||
.iter()
|
.iter()
|
||||||
.find(|attr| attr.path().is_ident(name))
|
.find(|attr| attr.path().is_ident(name))
|
||||||
.and_then(|attr| Some(attr
|
.and_then(|attr| Some(attr.parse_args::<LitStr>().expect("string literal").value()))
|
||||||
.parse_args::<LitStr>()
|
|
||||||
.expect("string literal")
|
|
||||||
.value()
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::TokenStream;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::{Data, DeriveInput, Fields, Field};
|
|
||||||
use syn::Type::Path;
|
|
||||||
use syn::ext::IdentExt;
|
use syn::ext::IdentExt;
|
||||||
|
use syn::Type::Path;
|
||||||
|
use syn::{Data, DeriveInput, Field, Fields};
|
||||||
|
|
||||||
use crate::attr_present;
|
|
||||||
use crate::attr_content;
|
use crate::attr_content;
|
||||||
|
use crate::attr_present;
|
||||||
|
|
||||||
pub fn impl_write(input: &DeriveInput) -> TokenStream {
|
pub fn impl_write(input: &DeriveInput) -> TokenStream {
|
||||||
let name = &input.ident;
|
let name = &input.ident;
|
||||||
|
|
@ -13,7 +13,7 @@ pub fn impl_write(input: &DeriveInput) -> TokenStream {
|
||||||
let body = impl_body(&input.data);
|
let body = impl_body(&input.data);
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
impl<W: std::io::Write> WriteDsn<W> for #name {
|
impl<W: std::io::Write> WriteSes<W> for #name {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>)
|
fn write_dsn(&self, writer: &mut ListWriter<W>)
|
||||||
-> std::io::Result<()>
|
-> std::io::Result<()>
|
||||||
{
|
{
|
||||||
|
|
@ -25,12 +25,9 @@ pub fn impl_write(input: &DeriveInput) -> TokenStream {
|
||||||
|
|
||||||
fn impl_body(data: &Data) -> TokenStream {
|
fn impl_body(data: &Data) -> TokenStream {
|
||||||
match data {
|
match data {
|
||||||
Data::Struct(data) => {
|
Data::Struct(data) => match &data.fields {
|
||||||
match &data.fields {
|
|
||||||
Fields::Named(fields) => {
|
Fields::Named(fields) => {
|
||||||
let fields = fields.named.iter().map(|field| {
|
let fields = fields.named.iter().map(|field| impl_field(field));
|
||||||
impl_field(field)
|
|
||||||
});
|
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#(#fields)*
|
#(#fields)*
|
||||||
|
|
@ -38,10 +35,9 @@ fn impl_body(data: &Data) -> TokenStream {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => unimplemented!()
|
_ => unimplemented!(),
|
||||||
}
|
},
|
||||||
}
|
_ => unimplemented!(),
|
||||||
_ => unimplemented!()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +57,6 @@ fn impl_field(field: &Field) -> TokenStream {
|
||||||
quote! {
|
quote! {
|
||||||
writer.write_array(&self.#name)?;
|
writer.write_array(&self.#name)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if let Path(type_path) = &field.ty {
|
if let Path(type_path) = &field.ty {
|
||||||
let segments = &type_path.path.segments;
|
let segments = &type_path.path.segments;
|
||||||
|
|
@ -70,7 +65,7 @@ fn impl_field(field: &Field) -> TokenStream {
|
||||||
if ident == "Option" {
|
if ident == "Option" {
|
||||||
return quote! {
|
return quote! {
|
||||||
writer.write_optional(stringify!(#name_str), &self.#name)?;
|
writer.write_optional(stringify!(#name_str), &self.#name)?;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -80,5 +75,3 @@ fn impl_field(field: &Field) -> TokenStream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -23,7 +23,6 @@ use topola::{
|
||||||
rules::RulesTrait,
|
rules::RulesTrait,
|
||||||
Drawing, Infringement, LayoutException,
|
Drawing, Infringement, LayoutException,
|
||||||
},
|
},
|
||||||
dsn::{design::DsnDesign, mesadata::DsnMesadata},
|
|
||||||
geometry::{
|
geometry::{
|
||||||
compound::CompoundManagerTrait,
|
compound::CompoundManagerTrait,
|
||||||
primitive::{BendShape, DotShape, PrimitiveShape, PrimitiveShapeTrait, SegShape},
|
primitive::{BendShape, DotShape, PrimitiveShape, PrimitiveShapeTrait, SegShape},
|
||||||
|
|
@ -38,6 +37,7 @@ use topola::{
|
||||||
tracer::{Trace, Tracer},
|
tracer::{Trace, Tracer},
|
||||||
EmptyRouterObserver, RouterObserverTrait,
|
EmptyRouterObserver, RouterObserverTrait,
|
||||||
},
|
},
|
||||||
|
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{layers::Layers, overlay::Overlay, painter::Painter, top::Top, viewport::Viewport};
|
use crate::{layers::Layers, overlay::Overlay, painter::Painter, top::Top, viewport::Viewport};
|
||||||
|
|
@ -60,7 +60,7 @@ pub struct App {
|
||||||
overlay: Option<Overlay>,
|
overlay: Option<Overlay>,
|
||||||
|
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
invoker: Option<Arc<Mutex<Invoker<DsnMesadata>>>>,
|
invoker: Option<Arc<Mutex<Invoker<SpecctraMesadata>>>>,
|
||||||
|
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
shared_data: Arc<Mutex<SharedData>>,
|
shared_data: Arc<Mutex<SharedData>>,
|
||||||
|
|
@ -164,7 +164,7 @@ impl eframe::App for App {
|
||||||
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||||
if cfg!(target_arch = "wasm32") {
|
if cfg!(target_arch = "wasm32") {
|
||||||
if let Ok(file_contents) = self.text_channel.1.try_recv() {
|
if let Ok(file_contents) = self.text_channel.1.try_recv() {
|
||||||
let design = DsnDesign::load_from_string(file_contents).unwrap();
|
let design = SpecctraDesign::load_from_string(file_contents).unwrap();
|
||||||
let board = design.make_board();
|
let board = design.make_board();
|
||||||
self.overlay = Some(Overlay::new(&board).unwrap());
|
self.overlay = Some(Overlay::new(&board).unwrap());
|
||||||
self.layers = Some(Layers::new(&board));
|
self.layers = Some(Layers::new(&board));
|
||||||
|
|
@ -174,7 +174,7 @@ impl eframe::App for App {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Ok(path) = self.text_channel.1.try_recv() {
|
if let Ok(path) = self.text_channel.1.try_recv() {
|
||||||
let design = DsnDesign::load_from_file(&path).unwrap();
|
let design = SpecctraDesign::load_from_file(&path).unwrap();
|
||||||
let board = design.make_board();
|
let board = design.make_board();
|
||||||
self.overlay = Some(Overlay::new(&board).unwrap());
|
self.overlay = Some(Overlay::new(&board).unwrap());
|
||||||
self.layers = Some(Layers::new(&board));
|
self.layers = Some(Layers::new(&board));
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::{
|
||||||
|
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::invoker::{Command, Execute, Invoker, InvokerStatus},
|
autorouter::invoker::{Command, Execute, Invoker, InvokerStatus},
|
||||||
dsn::mesadata::DsnMesadata,
|
specctra::mesadata::SpecctraMesadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -31,7 +31,7 @@ impl Top {
|
||||||
ctx: &egui::Context,
|
ctx: &egui::Context,
|
||||||
shared_data: Arc<Mutex<SharedData>>,
|
shared_data: Arc<Mutex<SharedData>>,
|
||||||
sender: Sender<String>,
|
sender: Sender<String>,
|
||||||
maybe_invoker: &Option<Arc<Mutex<Invoker<DsnMesadata>>>>,
|
maybe_invoker: &Option<Arc<Mutex<Invoker<SpecctraMesadata>>>>,
|
||||||
maybe_overlay: &Option<Overlay>,
|
maybe_overlay: &Option<Overlay>,
|
||||||
) {
|
) {
|
||||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ use topola::{
|
||||||
autorouter::invoker::{Command, Invoker},
|
autorouter::invoker::{Command, Invoker},
|
||||||
board::mesadata::MesadataTrait,
|
board::mesadata::MesadataTrait,
|
||||||
drawing::{graph::MakePrimitive, primitive::MakePrimitiveShape},
|
drawing::{graph::MakePrimitive, primitive::MakePrimitiveShape},
|
||||||
dsn::mesadata::DsnMesadata,
|
|
||||||
geometry::{shape::ShapeTrait, GenericNode},
|
geometry::{shape::ShapeTrait, GenericNode},
|
||||||
layout::{via::ViaWeight, zone::MakePolyShape},
|
layout::{via::ViaWeight, zone::MakePolyShape},
|
||||||
math::Circle,
|
math::Circle,
|
||||||
router::EmptyRouterObserver,
|
router::EmptyRouterObserver,
|
||||||
|
specctra::mesadata::SpecctraMesadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -37,7 +37,7 @@ impl Viewport {
|
||||||
ctx: &egui::Context,
|
ctx: &egui::Context,
|
||||||
top: &Top,
|
top: &Top,
|
||||||
shared_data: Arc<Mutex<SharedData>>,
|
shared_data: Arc<Mutex<SharedData>>,
|
||||||
maybe_invoker: &Option<Arc<Mutex<Invoker<DsnMesadata>>>>,
|
maybe_invoker: &Option<Arc<Mutex<Invoker<SpecctraMesadata>>>>,
|
||||||
maybe_overlay: &mut Option<Overlay>,
|
maybe_overlay: &mut Option<Overlay>,
|
||||||
maybe_layers: &Option<Layers>,
|
maybe_layers: &Option<Layers>,
|
||||||
) {
|
) {
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@ use topola::drawing::primitive::MakePrimitiveShape;
|
||||||
use topola::drawing::rules::{Conditions, RulesTrait};
|
use topola::drawing::rules::{Conditions, RulesTrait};
|
||||||
use topola::drawing::seg::FixedSegWeight;
|
use topola::drawing::seg::FixedSegWeight;
|
||||||
use topola::drawing::{Infringement, LayoutException};
|
use topola::drawing::{Infringement, LayoutException};
|
||||||
use topola::dsn::design::DsnDesign;
|
|
||||||
use topola::dsn::mesadata::DsnMesadata;
|
|
||||||
use topola::geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait};
|
use topola::geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait};
|
||||||
use topola::geometry::shape::ShapeTrait;
|
use topola::geometry::shape::ShapeTrait;
|
||||||
use topola::layout::zone::MakePolyShape;
|
use topola::layout::zone::MakePolyShape;
|
||||||
|
|
@ -30,6 +28,8 @@ use topola::router::draw::DrawException;
|
||||||
use topola::router::navmesh::{Navmesh, NavmeshEdgeReference, NavvertexIndex};
|
use topola::router::navmesh::{Navmesh, NavmeshEdgeReference, NavvertexIndex};
|
||||||
use topola::router::tracer::{Trace, Tracer};
|
use topola::router::tracer::{Trace, Tracer};
|
||||||
use topola::router::RouterObserverTrait;
|
use topola::router::RouterObserverTrait;
|
||||||
|
use topola::specctra::design::SpecctraDesign;
|
||||||
|
use topola::specctra::mesadata::SpecctraMesadata;
|
||||||
|
|
||||||
use sdl2::event::Event;
|
use sdl2::event::Event;
|
||||||
use sdl2::keyboard::Keycode;
|
use sdl2::keyboard::Keycode;
|
||||||
|
|
@ -246,7 +246,7 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
]),
|
]),
|
||||||
}));*/
|
}));*/
|
||||||
|
|
||||||
let design = DsnDesign::load_from_file(
|
let design = SpecctraDesign::load_from_file(
|
||||||
"tests/data/de9_tht_female_to_tht_female/de9_tht_female_to_tht_female.dsn",
|
"tests/data/de9_tht_female_to_tht_female/de9_tht_female_to_tht_female.dsn",
|
||||||
)?;
|
)?;
|
||||||
//let design = DsnDesign::load_from_file("tests/data/test/test.dsn")?;
|
//let design = DsnDesign::load_from_file("tests/data/test/test.dsn")?;
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@ pub mod graph;
|
||||||
pub mod drawing;
|
pub mod drawing;
|
||||||
pub mod autorouter;
|
pub mod autorouter;
|
||||||
pub mod board;
|
pub mod board;
|
||||||
pub mod dsn;
|
|
||||||
pub mod geometry;
|
pub mod geometry;
|
||||||
pub mod layout;
|
pub mod layout;
|
||||||
pub mod math;
|
pub mod math;
|
||||||
pub mod router;
|
pub mod router;
|
||||||
|
pub mod specctra;
|
||||||
pub mod triangulation;
|
pub mod triangulation;
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,13 @@ use thiserror::Error;
|
||||||
use crate::{
|
use crate::{
|
||||||
board::{mesadata::MesadataTrait, Board},
|
board::{mesadata::MesadataTrait, Board},
|
||||||
drawing::{dot::FixedDotWeight, seg::FixedSegWeight, Drawing},
|
drawing::{dot::FixedDotWeight, seg::FixedSegWeight, Drawing},
|
||||||
dsn::{
|
|
||||||
de,
|
|
||||||
mesadata::DsnMesadata,
|
|
||||||
structure::{self, DsnFile, Layer, Pcb, Shape},
|
|
||||||
},
|
|
||||||
layout::{zone::SolidZoneWeight, Layout},
|
layout::{zone::SolidZoneWeight, Layout},
|
||||||
math::Circle,
|
math::Circle,
|
||||||
|
specctra::{
|
||||||
|
de,
|
||||||
|
mesadata::SpecctraMesadata,
|
||||||
|
structure::{self, Layer, Pcb, Shape, SpecctraFile},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
|
@ -24,23 +24,18 @@ pub enum LoadingError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DsnDesign {
|
pub struct SpecctraDesign {
|
||||||
pcb: Pcb,
|
pcb: Pcb,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DsnDesign {
|
impl SpecctraDesign {
|
||||||
pub fn load_from_file(filename: &str) -> Result<Self, LoadingError> {
|
pub fn load_from_file(filename: &str) -> Result<Self, LoadingError> {
|
||||||
let file = std::fs::File::open(filename)?;
|
let file = std::fs::File::open(filename)?;
|
||||||
let reader = std::io::BufReader::new(file);
|
let reader = std::io::BufReader::new(file);
|
||||||
let mut list_reader = super::read::ListTokenizer::new(reader);
|
let mut list_reader = super::read::ListTokenizer::new(reader);
|
||||||
|
|
||||||
let dsn = list_reader.read_value::<super::structure::DsnFile>();
|
if let Ok(file) = list_reader.read_value::<super::structure::SpecctraFile>() {
|
||||||
|
//use super::structure::*;
|
||||||
// TODO: make_board() still uses the old version of structure.rs
|
|
||||||
// so we can't pass the data to topola for real
|
|
||||||
|
|
||||||
if let Ok(dsn) = dsn {
|
|
||||||
use super::structure::*;
|
|
||||||
|
|
||||||
// (this entire if let block does not belong here)
|
// (this entire if let block does not belong here)
|
||||||
|
|
||||||
|
|
@ -107,9 +102,8 @@ impl DsnDesign {
|
||||||
|
|
||||||
//println!("{:?}", list_writer.write_value(&ses));
|
//println!("{:?}", list_writer.write_value(&ses));
|
||||||
|
|
||||||
Ok(Self { pcb: dsn.pcb })
|
Ok(Self { pcb: file.pcb })
|
||||||
} else {
|
} else {
|
||||||
dbg!(dsn);
|
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -121,15 +115,15 @@ impl DsnDesign {
|
||||||
|
|
||||||
Ok(Self { pcb })*/
|
Ok(Self { pcb })*/
|
||||||
let mut list_reader = super::read::ListTokenizer::new(contents.as_bytes());
|
let mut list_reader = super::read::ListTokenizer::new(contents.as_bytes());
|
||||||
let dsn = list_reader.read_value::<super::structure::DsnFile>();
|
let dsn = list_reader.read_value::<super::structure::SpecctraFile>();
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
pcb: dsn.unwrap().pcb,
|
pcb: dsn.unwrap().pcb,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn make_board(&self) -> Board<DsnMesadata> {
|
pub fn make_board(&self) -> Board<SpecctraMesadata> {
|
||||||
let mesadata = DsnMesadata::from_pcb(&self.pcb);
|
let mesadata = SpecctraMesadata::from_pcb(&self.pcb);
|
||||||
let mut board = Board::new(Layout::new(Drawing::new(
|
let mut board = Board::new(Layout::new(Drawing::new(
|
||||||
mesadata,
|
mesadata,
|
||||||
self.pcb.structure.layers.len(),
|
self.pcb.structure.layers.len(),
|
||||||
|
|
@ -422,7 +416,7 @@ impl DsnDesign {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layer(
|
fn layer(
|
||||||
board: &Board<DsnMesadata>,
|
board: &Board<SpecctraMesadata>,
|
||||||
layers: &Vec<Layer>,
|
layers: &Vec<Layer>,
|
||||||
layername: &str,
|
layername: &str,
|
||||||
front: bool,
|
front: bool,
|
||||||
|
|
@ -442,7 +436,7 @@ impl DsnDesign {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_circle(
|
fn add_circle(
|
||||||
board: &mut Board<DsnMesadata>,
|
board: &mut Board<SpecctraMesadata>,
|
||||||
place_pos: Point,
|
place_pos: Point,
|
||||||
place_rot: f64,
|
place_rot: f64,
|
||||||
pin_pos: Point,
|
pin_pos: Point,
|
||||||
|
|
@ -468,7 +462,7 @@ impl DsnDesign {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_rect(
|
fn add_rect(
|
||||||
board: &mut Board<DsnMesadata>,
|
board: &mut Board<SpecctraMesadata>,
|
||||||
place_pos: Point,
|
place_pos: Point,
|
||||||
place_rot: f64,
|
place_rot: f64,
|
||||||
pin_pos: Point,
|
pin_pos: Point,
|
||||||
|
|
@ -579,7 +573,7 @@ impl DsnDesign {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_path(
|
fn add_path(
|
||||||
board: &mut Board<DsnMesadata>,
|
board: &mut Board<SpecctraMesadata>,
|
||||||
place_pos: Point,
|
place_pos: Point,
|
||||||
place_rot: f64,
|
place_rot: f64,
|
||||||
pin_pos: Point,
|
pin_pos: Point,
|
||||||
|
|
@ -656,7 +650,7 @@ impl DsnDesign {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_polygon(
|
fn add_polygon(
|
||||||
board: &mut Board<DsnMesadata>,
|
board: &mut Board<SpecctraMesadata>,
|
||||||
place_pos: Point,
|
place_pos: Point,
|
||||||
place_rot: f64,
|
place_rot: f64,
|
||||||
pin_pos: Point,
|
pin_pos: Point,
|
||||||
|
|
@ -5,16 +5,16 @@ use bimap::BiHashMap;
|
||||||
use crate::{
|
use crate::{
|
||||||
board::mesadata::MesadataTrait,
|
board::mesadata::MesadataTrait,
|
||||||
drawing::rules::{Conditions, RulesTrait},
|
drawing::rules::{Conditions, RulesTrait},
|
||||||
dsn::structure::Pcb,
|
specctra::structure::Pcb,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DsnRule {
|
pub struct SpecctraRule {
|
||||||
pub width: f64,
|
pub width: f64,
|
||||||
pub clearance: f64,
|
pub clearance: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DsnRule {
|
impl SpecctraRule {
|
||||||
fn from_dsn(rule: &super::structure::Rule) -> Self {
|
fn from_dsn(rule: &super::structure::Rule) -> Self {
|
||||||
Self {
|
Self {
|
||||||
width: rule.width as f64,
|
width: rule.width as f64,
|
||||||
|
|
@ -24,10 +24,10 @@ impl DsnRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DsnMesadata {
|
pub struct SpecctraMesadata {
|
||||||
structure_rule: DsnRule,
|
structure_rule: SpecctraRule,
|
||||||
// net class name -> rule
|
// net class name -> rule
|
||||||
class_rules: HashMap<String, DsnRule>,
|
class_rules: HashMap<String, SpecctraRule>,
|
||||||
|
|
||||||
// layername <-> layer for Layout
|
// layername <-> layer for Layout
|
||||||
pub layer_layername: BiHashMap<usize, String>,
|
pub layer_layername: BiHashMap<usize, String>,
|
||||||
|
|
@ -39,7 +39,7 @@ pub struct DsnMesadata {
|
||||||
net_netclass: HashMap<usize, String>,
|
net_netclass: HashMap<usize, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DsnMesadata {
|
impl SpecctraMesadata {
|
||||||
pub fn from_pcb(pcb: &Pcb) -> Self {
|
pub fn from_pcb(pcb: &Pcb) -> Self {
|
||||||
let layer_layername = BiHashMap::from_iter(
|
let layer_layername = BiHashMap::from_iter(
|
||||||
pcb.structure
|
pcb.structure
|
||||||
|
|
@ -69,11 +69,11 @@ impl DsnMesadata {
|
||||||
net_netclass.insert(*net, class.name.clone());
|
net_netclass.insert(*net, class.name.clone());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(|class| (class.name.clone(), DsnRule::from_dsn(&class.rule))),
|
.map(|class| (class.name.clone(), SpecctraRule::from_dsn(&class.rule))),
|
||||||
);
|
);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
structure_rule: DsnRule::from_dsn(&pcb.structure.rule),
|
structure_rule: SpecctraRule::from_dsn(&pcb.structure.rule),
|
||||||
class_rules,
|
class_rules,
|
||||||
layer_layername,
|
layer_layername,
|
||||||
net_netname,
|
net_netname,
|
||||||
|
|
@ -81,7 +81,7 @@ impl DsnMesadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_rule(&self, net: usize) -> &DsnRule {
|
pub fn get_rule(&self, net: usize) -> &SpecctraRule {
|
||||||
if let Some(netclass) = self.net_netclass.get(&net) {
|
if let Some(netclass) = self.net_netclass.get(&net) {
|
||||||
self.class_rules
|
self.class_rules
|
||||||
.get(netclass)
|
.get(netclass)
|
||||||
|
|
@ -92,7 +92,7 @@ impl DsnMesadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RulesTrait for DsnMesadata {
|
impl RulesTrait for SpecctraMesadata {
|
||||||
fn clearance(&self, conditions1: &Conditions, conditions2: &Conditions) -> f64 {
|
fn clearance(&self, conditions1: &Conditions, conditions2: &Conditions) -> f64 {
|
||||||
let (Some(net1), Some(net2)) = (conditions1.maybe_net, conditions2.maybe_net) else {
|
let (Some(net1), Some(net2)) = (conditions1.maybe_net, conditions2.maybe_net) else {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
@ -121,7 +121,7 @@ impl RulesTrait for DsnMesadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MesadataTrait for DsnMesadata {
|
impl MesadataTrait for SpecctraMesadata {
|
||||||
fn bename_layer(&mut self, layer: usize, layername: String) {
|
fn bename_layer(&mut self, layer: usize, layername: String) {
|
||||||
self.layer_layername.insert(layer, layername);
|
self.layer_layername.insert(layer, layername);
|
||||||
}
|
}
|
||||||
|
|
@ -2,39 +2,39 @@ use super::common::ListToken;
|
||||||
use super::read::ReadDsn;
|
use super::read::ReadDsn;
|
||||||
use super::read::{ListTokenizer, ParseError};
|
use super::read::{ListTokenizer, ParseError};
|
||||||
use super::write::ListWriter;
|
use super::write::ListWriter;
|
||||||
use super::write::WriteDsn;
|
use super::write::WriteSes;
|
||||||
use dsn_derive::ReadDsn;
|
use specctra_derive::ReadDsn;
|
||||||
use dsn_derive::WriteDsn;
|
use specctra_derive::WriteSes;
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Dummy {}
|
pub struct Dummy {}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct SesFile {
|
pub struct SesFile {
|
||||||
pub session: Session,
|
pub session: Session,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Session {
|
pub struct Session {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub routes: Routes,
|
pub routes: Routes,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Routes {
|
pub struct Routes {
|
||||||
pub resolution: Resolution,
|
pub resolution: Resolution,
|
||||||
pub library_out: Library,
|
pub library_out: Library,
|
||||||
pub network_out: NetworkOut,
|
pub network_out: NetworkOut,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct NetworkOut {
|
pub struct NetworkOut {
|
||||||
#[vec("net")]
|
#[vec("net")]
|
||||||
pub net: Vec<NetOut>,
|
pub net: Vec<NetOut>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct NetOut {
|
pub struct NetOut {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -44,12 +44,12 @@ pub struct NetOut {
|
||||||
pub via: Vec<Via>,
|
pub via: Vec<Via>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct DsnFile {
|
pub struct SpecctraFile {
|
||||||
pub pcb: Pcb,
|
pub pcb: Pcb,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Pcb {
|
pub struct Pcb {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -63,7 +63,7 @@ pub struct Pcb {
|
||||||
pub wiring: Wiring,
|
pub wiring: Wiring,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(WriteDsn, Debug)]
|
#[derive(WriteSes, Debug)]
|
||||||
pub struct Parser {
|
pub struct Parser {
|
||||||
pub string_quote: Option<char>,
|
pub string_quote: Option<char>,
|
||||||
pub space_in_quoted_tokens: Option<bool>,
|
pub space_in_quoted_tokens: Option<bool>,
|
||||||
|
|
@ -71,7 +71,7 @@ pub struct Parser {
|
||||||
pub host_version: Option<String>,
|
pub host_version: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Resolution {
|
pub struct Resolution {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub unit: String,
|
pub unit: String,
|
||||||
|
|
@ -79,7 +79,7 @@ pub struct Resolution {
|
||||||
pub value: f32,
|
pub value: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Structure {
|
pub struct Structure {
|
||||||
#[vec("layer")]
|
#[vec("layer")]
|
||||||
pub layers: Vec<Layer>,
|
pub layers: Vec<Layer>,
|
||||||
|
|
@ -90,7 +90,7 @@ pub struct Structure {
|
||||||
pub rule: Rule,
|
pub rule: Rule,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Layer {
|
pub struct Layer {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -98,36 +98,36 @@ pub struct Layer {
|
||||||
pub property: Property,
|
pub property: Property,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Property {
|
pub struct Property {
|
||||||
pub index: usize,
|
pub index: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Boundary {
|
pub struct Boundary {
|
||||||
pub path: Path,
|
pub path: Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Plane {
|
pub struct Plane {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub net: String,
|
pub net: String,
|
||||||
pub polygon: Polygon,
|
pub polygon: Polygon,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct ViaNames {
|
pub struct ViaNames {
|
||||||
#[anon_vec]
|
#[anon_vec]
|
||||||
pub names: Vec<String>,
|
pub names: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Placement {
|
pub struct Placement {
|
||||||
#[vec("component")]
|
#[vec("component")]
|
||||||
pub components: Vec<Component>,
|
pub components: Vec<Component>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Component {
|
pub struct Component {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -135,7 +135,7 @@ pub struct Component {
|
||||||
pub places: Vec<Place>,
|
pub places: Vec<Place>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub struct Place {
|
pub struct Place {
|
||||||
#[anon]
|
#[anon]
|
||||||
|
|
@ -151,7 +151,7 @@ pub struct Place {
|
||||||
pub PN: Option<String>,
|
pub PN: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Library {
|
pub struct Library {
|
||||||
#[vec("image")]
|
#[vec("image")]
|
||||||
pub images: Vec<Image>,
|
pub images: Vec<Image>,
|
||||||
|
|
@ -159,7 +159,7 @@ pub struct Library {
|
||||||
pub padstacks: Vec<Padstack>,
|
pub padstacks: Vec<Padstack>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Image {
|
pub struct Image {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -171,12 +171,12 @@ pub struct Image {
|
||||||
pub keepouts: Vec<Keepout>,
|
pub keepouts: Vec<Keepout>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Outline {
|
pub struct Outline {
|
||||||
pub path: Path,
|
pub path: Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Pin {
|
pub struct Pin {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -189,12 +189,12 @@ pub struct Pin {
|
||||||
pub y: f32,
|
pub y: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Rotate {
|
pub struct Rotate {
|
||||||
pub angle: f32,
|
pub angle: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Keepout {
|
pub struct Keepout {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub idk: String,
|
pub idk: String,
|
||||||
|
|
@ -202,7 +202,7 @@ pub struct Keepout {
|
||||||
pub shape: Shape,
|
pub shape: Shape,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Padstack {
|
pub struct Padstack {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -235,7 +235,7 @@ impl<R: std::io::BufRead> ReadDsn<R> for Shape {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: std::io::Write> WriteDsn<W> for Shape {
|
impl<W: std::io::Write> WriteSes<W> for Shape {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), std::io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), std::io::Error> {
|
||||||
match self {
|
match self {
|
||||||
Self::Circle(inner) => writer.write_named("circle", inner),
|
Self::Circle(inner) => writer.write_named("circle", inner),
|
||||||
|
|
@ -246,7 +246,7 @@ impl<W: std::io::Write> WriteDsn<W> for Shape {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Circle {
|
pub struct Circle {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub layer: String,
|
pub layer: String,
|
||||||
|
|
@ -256,7 +256,7 @@ pub struct Circle {
|
||||||
pub offset: Option<Point>,
|
pub offset: Option<Point>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Network {
|
pub struct Network {
|
||||||
#[vec("net")]
|
#[vec("net")]
|
||||||
pub nets: Vec<NetPinAssignments>,
|
pub nets: Vec<NetPinAssignments>,
|
||||||
|
|
@ -264,7 +264,7 @@ pub struct Network {
|
||||||
pub classes: Vec<Class>,
|
pub classes: Vec<Class>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
// dsn names this "net", but it's a structure unrelated to "net" in wiring or elsewhere
|
// dsn names this "net", but it's a structure unrelated to "net" in wiring or elsewhere
|
||||||
pub struct NetPinAssignments {
|
pub struct NetPinAssignments {
|
||||||
#[anon]
|
#[anon]
|
||||||
|
|
@ -272,13 +272,13 @@ pub struct NetPinAssignments {
|
||||||
pub pins: Pins,
|
pub pins: Pins,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Pins {
|
pub struct Pins {
|
||||||
#[anon_vec]
|
#[anon_vec]
|
||||||
pub names: Vec<String>,
|
pub names: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Class {
|
pub struct Class {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -288,12 +288,12 @@ pub struct Class {
|
||||||
pub rule: Rule,
|
pub rule: Rule,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Circuit {
|
pub struct Circuit {
|
||||||
pub use_via: String,
|
pub use_via: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Wiring {
|
pub struct Wiring {
|
||||||
#[vec("wire")]
|
#[vec("wire")]
|
||||||
pub wires: Vec<Wire>,
|
pub wires: Vec<Wire>,
|
||||||
|
|
@ -301,7 +301,7 @@ pub struct Wiring {
|
||||||
pub vias: Vec<Via>,
|
pub vias: Vec<Via>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Wire {
|
pub struct Wire {
|
||||||
pub path: Path,
|
pub path: Path,
|
||||||
pub net: String,
|
pub net: String,
|
||||||
|
|
@ -355,7 +355,7 @@ impl<R: std::io::BufRead> ReadDsn<R> for Option<Point> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: std::io::Write> WriteDsn<W> for Vec<Point> {
|
impl<W: std::io::Write> WriteSes<W> for Vec<Point> {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), std::io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), std::io::Error> {
|
||||||
for elem in self {
|
for elem in self {
|
||||||
writer.write_value(&elem.x)?;
|
writer.write_value(&elem.x)?;
|
||||||
|
|
@ -365,7 +365,7 @@ impl<W: std::io::Write> WriteDsn<W> for Vec<Point> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: std::io::Write> WriteDsn<W> for Option<Point> {
|
impl<W: std::io::Write> WriteSes<W> for Option<Point> {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), std::io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), std::io::Error> {
|
||||||
if let Some(value) = self {
|
if let Some(value) = self {
|
||||||
writer.write_value(&value.x)?;
|
writer.write_value(&value.x)?;
|
||||||
|
|
@ -375,7 +375,7 @@ impl<W: std::io::Write> WriteDsn<W> for Option<Point> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Polygon {
|
pub struct Polygon {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub layer: String,
|
pub layer: String,
|
||||||
|
|
@ -385,7 +385,7 @@ pub struct Polygon {
|
||||||
pub coords: Vec<Point>,
|
pub coords: Vec<Point>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Path {
|
pub struct Path {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub layer: String,
|
pub layer: String,
|
||||||
|
|
@ -395,7 +395,7 @@ pub struct Path {
|
||||||
pub coords: Vec<Point>,
|
pub coords: Vec<Point>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Rect {
|
pub struct Rect {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub layer: String,
|
pub layer: String,
|
||||||
|
|
@ -409,7 +409,7 @@ pub struct Rect {
|
||||||
pub y2: f32,
|
pub y2: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Via {
|
pub struct Via {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
@ -421,14 +421,14 @@ pub struct Via {
|
||||||
pub r#type: String,
|
pub r#type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Rule {
|
pub struct Rule {
|
||||||
pub width: f32,
|
pub width: f32,
|
||||||
#[vec("clearance")]
|
#[vec("clearance")]
|
||||||
pub clearances: Vec<Clearance>,
|
pub clearances: Vec<Clearance>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(ReadDsn, WriteDsn, Debug)]
|
#[derive(ReadDsn, WriteSes, Debug)]
|
||||||
pub struct Clearance {
|
pub struct Clearance {
|
||||||
#[anon]
|
#[anon]
|
||||||
pub value: f32,
|
pub value: f32,
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
use super::common::ListToken;
|
use super::common::ListToken;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
pub trait WriteDsn<W: io::Write> {
|
pub trait WriteSes<W: io::Write> {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error>;
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: io::Write> WriteDsn<W> for char {
|
impl<W: io::Write> WriteSes<W> for char {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||||
writer.write_leaf(self.to_string())
|
writer.write_leaf(self.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: io::Write> WriteDsn<W> for String {
|
impl<W: io::Write> WriteSes<W> for String {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||||
let string = if self.len() == 0 {
|
let string = if self.len() == 0 {
|
||||||
"\"\"".to_string()
|
"\"\"".to_string()
|
||||||
|
|
@ -28,7 +28,7 @@ impl<W: io::Write> WriteDsn<W> for String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: io::Write> WriteDsn<W> for bool {
|
impl<W: io::Write> WriteSes<W> for bool {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||||
writer.write_leaf(match self {
|
writer.write_leaf(match self {
|
||||||
true => "on".to_string(),
|
true => "on".to_string(),
|
||||||
|
|
@ -37,25 +37,25 @@ impl<W: io::Write> WriteDsn<W> for bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: io::Write> WriteDsn<W> for i32 {
|
impl<W: io::Write> WriteSes<W> for i32 {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||||
writer.write_leaf(self.to_string())
|
writer.write_leaf(self.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: io::Write> WriteDsn<W> for u32 {
|
impl<W: io::Write> WriteSes<W> for u32 {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||||
writer.write_leaf(self.to_string())
|
writer.write_leaf(self.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: io::Write> WriteDsn<W> for usize {
|
impl<W: io::Write> WriteSes<W> for usize {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||||
writer.write_leaf(self.to_string())
|
writer.write_leaf(self.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: io::Write> WriteDsn<W> for f32 {
|
impl<W: io::Write> WriteSes<W> for f32 {
|
||||||
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
fn write_dsn(&self, writer: &mut ListWriter<W>) -> Result<(), io::Error> {
|
||||||
writer.write_leaf(self.to_string())
|
writer.write_leaf(self.to_string())
|
||||||
}
|
}
|
||||||
|
|
@ -116,11 +116,11 @@ impl<W: io::Write> ListWriter<W> {
|
||||||
self.write_token(ListToken::Leaf { value })
|
self.write_token(ListToken::Leaf { value })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_value<T: WriteDsn<W>>(&mut self, value: &T) -> Result<(), io::Error> {
|
pub fn write_value<T: WriteSes<W>>(&mut self, value: &T) -> Result<(), io::Error> {
|
||||||
value.write_dsn(self)
|
value.write_dsn(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_named<T: WriteDsn<W>>(
|
pub fn write_named<T: WriteSes<W>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
value: &T,
|
value: &T,
|
||||||
|
|
@ -134,7 +134,7 @@ impl<W: io::Write> ListWriter<W> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_optional<T: WriteDsn<W>>(
|
pub fn write_optional<T: WriteSes<W>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
optional: &Option<T>,
|
optional: &Option<T>,
|
||||||
|
|
@ -146,7 +146,7 @@ impl<W: io::Write> ListWriter<W> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_array<T: WriteDsn<W>>(&mut self, array: &Vec<T>) -> Result<(), io::Error> {
|
pub fn write_array<T: WriteSes<W>>(&mut self, array: &Vec<T>) -> Result<(), io::Error> {
|
||||||
for elem in array {
|
for elem in array {
|
||||||
self.write_value(elem)?;
|
self.write_value(elem)?;
|
||||||
}
|
}
|
||||||
|
|
@ -154,7 +154,7 @@ impl<W: io::Write> ListWriter<W> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_named_array<T: WriteDsn<W>>(
|
pub fn write_named_array<T: WriteSes<W>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
array: &Vec<T>,
|
array: &Vec<T>,
|
||||||
|
|
@ -9,12 +9,12 @@ use topola::{
|
||||||
},
|
},
|
||||||
board::{mesadata::MesadataTrait, Board},
|
board::{mesadata::MesadataTrait, Board},
|
||||||
drawing::graph::{GetLayer, GetMaybeNet},
|
drawing::graph::{GetLayer, GetMaybeNet},
|
||||||
dsn::{design::DsnDesign, mesadata::DsnMesadata},
|
|
||||||
graph::GetNodeIndex,
|
graph::GetNodeIndex,
|
||||||
|
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn load_design_and_assert(filename: &str) -> Invoker<DsnMesadata> {
|
pub fn load_design_and_assert(filename: &str) -> Invoker<SpecctraMesadata> {
|
||||||
let design = DsnDesign::load_from_file(filename).unwrap();
|
let design = SpecctraDesign::load_from_file(filename).unwrap();
|
||||||
let mut invoker = Invoker::new(Autorouter::new(design.make_board()).unwrap());
|
let mut invoker = Invoker::new(Autorouter::new(design.make_board()).unwrap());
|
||||||
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
|
|
@ -29,7 +29,7 @@ pub fn load_design_and_assert(filename: &str) -> Invoker<DsnMesadata> {
|
||||||
invoker
|
invoker
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn replay_and_assert(invoker: &mut Invoker<DsnMesadata>, filename: &str) {
|
pub fn replay_and_assert(invoker: &mut Invoker<SpecctraMesadata>, filename: &str) {
|
||||||
let file = File::open(filename).unwrap();
|
let file = File::open(filename).unwrap();
|
||||||
invoker.replay(serde_json::from_reader(file).unwrap());
|
invoker.replay(serde_json::from_reader(file).unwrap());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue