mirror of https://codeberg.org/topola/topola.git
specctra: added scraped-examples
This commit is contained in:
parent
c064490724
commit
46e935b9f6
|
|
@ -126,3 +126,6 @@ contracts = { path = "vendored/contracts" }
|
|||
[build-dependencies]
|
||||
clap_mangen = "0.2.23"
|
||||
clap = {version="4.5.8", features = ["derive"] }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use topola::autorouter::history::History;
|
||||
use topola::autorouter::invoker::Command;
|
||||
use topola::autorouter::invoker::Invoker;
|
||||
use topola::autorouter::selection::PinSelection;
|
||||
use topola::autorouter::Autorouter;
|
||||
use topola::specctra::design::SpecctraDesign;
|
||||
|
||||
fn main() -> Result<(), std::io::Error> {
|
||||
let design_file = File::open("example.dsn")?;
|
||||
let mut design_bufread = BufReader::new(design_file);
|
||||
|
||||
let design = SpecctraDesign::load(design_bufread).unwrap();
|
||||
let board = design.make_board();
|
||||
|
||||
let mut invoker = Invoker::new(Autorouter::new(board).unwrap());
|
||||
|
||||
let mut file = File::create("example.ses").unwrap();
|
||||
design.write_ses(invoker.autorouter().board(), &mut file);
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -47,14 +47,6 @@ impl SpecctraDesign {
|
|||
/// # Errors
|
||||
///
|
||||
/// Returns a `LoadingError` if an I/O error occurs or if the file format is invalid.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let design_file = File::open("random_design.dsn").unwrap();
|
||||
/// let design_bufread = BufReader::new(design_file);
|
||||
/// let design = SpecctraDesign::load(design_bufread).unwrap();
|
||||
/// ```
|
||||
pub fn load(reader: impl std::io::BufRead) -> Result<SpecctraDesign, LoadingError> {
|
||||
let mut list_reader = ListTokenizer::new(reader);
|
||||
let dsn = list_reader.read_value::<DsnFile>()?;
|
||||
|
|
@ -63,13 +55,6 @@ impl SpecctraDesign {
|
|||
}
|
||||
|
||||
/// Retrieves the name of the PCB design and return name of the PCB as a string slice.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// FIXME add more detailed info
|
||||
/// ```
|
||||
/// let name = design.get_name();
|
||||
/// ```
|
||||
pub fn get_name(&self) -> &str {
|
||||
&self.pcb.name
|
||||
}
|
||||
|
|
@ -79,14 +64,6 @@ impl SpecctraDesign {
|
|||
/// # Errors
|
||||
///
|
||||
/// Returns an `std::io::Error` if an I/O error occurs while writing the SES file.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let board = invoker.autorouter().board();
|
||||
/// let mut writebuf = vec![];
|
||||
/// design.write_ses(board, &mut writebuf);
|
||||
/// ```
|
||||
pub fn write_ses(
|
||||
&self,
|
||||
board: &Board<SpecctraMesadata>,
|
||||
|
|
@ -195,15 +172,6 @@ impl SpecctraDesign {
|
|||
|
||||
/// This method interprets the PCB design and generates a `Board<SpecctraMesadata>` object
|
||||
/// containing the layout and associated Specctra mesadata .
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let design_file = File::open("random_file.dsn")?;
|
||||
/// let mut design_bufread = BufReader::new(design_file);
|
||||
/// let design = SpecctraDesign::load(design_bufread).unwrap();
|
||||
/// let board = design.make_board();
|
||||
/// ```
|
||||
pub fn make_board(&self) -> Board<SpecctraMesadata> {
|
||||
let mesadata = SpecctraMesadata::from_pcb(&self.pcb);
|
||||
let mut board = Board::new(Layout::new(Drawing::new(
|
||||
|
|
|
|||
Loading…
Reference in New Issue