Implement Specctra SES session-file writer
Ports the write path of io/specctra/SesWriter.java to emit a valid session from a parsed DsnBoard plus a RoutingResult. Each _write_* function mirrors a write* method upstream: - session scope with base_design, placement (resolution + components echoed from the DSN), an empty was_is, and routes - routes carries resolution, a reduced parser scope, library_out with the via padstacks, and network_out - network_out emits (net (wire (path layer width x1 y1 ...)) (via padstack x y)) for each routed net; integer coordinates via round- half-up to match Java Math.round write_ses(board) with no result produces a valid no-op session, proving the DSN-in / SES-out round trip. Only routes > network_out is required by SesReader and kicad-cli; the rest is echoed for a well-formed file. 18 tests: indent/quoting rules, no-op session structure, placement and library_out echo, routed wire/via serialization, integer rounding, and round-trips re-parsed through the project's own DSN tokenizer/sexp (64 tests total across the suite, all green; ruff clean).
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
"""Specctra SES (session) writing for freeroute.
|
||||
|
||||
Public API::
|
||||
|
||||
from freeroute.dsn import parse_dsn
|
||||
from freeroute.ses import write_ses, RoutingResult, RoutedWire, RoutedVia
|
||||
|
||||
board = parse_dsn(dsn_text)
|
||||
ses_text = write_ses(board) # valid no-op session
|
||||
# ... or with routed geometry:
|
||||
result = RoutingResult()
|
||||
result.add_wire("NET_A", RoutedWire("Top", 200, [0, 0, 1000, 0]))
|
||||
ses_text = write_ses(board, result)
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .indent import Identifier, IndentWriter
|
||||
from .model import RoutedNet, RoutedVia, RoutedWire, RoutingResult
|
||||
from .writer import write_ses, write_ses_file
|
||||
|
||||
__all__ = [
|
||||
"write_ses",
|
||||
"write_ses_file",
|
||||
"RoutingResult",
|
||||
"RoutedNet",
|
||||
"RoutedWire",
|
||||
"RoutedVia",
|
||||
"Identifier",
|
||||
"IndentWriter",
|
||||
]
|
||||
Reference in New Issue
Block a user