TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
tmk::advice Namespace Reference

Classes

struct  Region
struct  Advice
struct  Applied
 What the router is given for an advice file, and what each hint became (for the log, the summary and the viewer). More...
struct  AliasMap
 Aliases for net names and part references (a redacted stuck report): the advice an advisor writes uses the aliases, and unalias puts the board's names back before the references are checked. More...
struct  ProcessResult
struct  AdvisorOptions
struct  Consulted
struct  StuckInput
struct  StuckReport

Functions

Advice parse_advice (std::string_view json_text, const std::string &source="advice")
 Parses and validates the text of an advice file. Throws std::runtime_error naming source and the entry ("regions[1].rect").
Advice load_advice_file (const std::string &path)
 Reads a file (size-limited); throws on a missing file or a syntax or content error.
void check_advice_refs (const Advice &a, const model::Board &b, std::vector< std::string > *warnings=nullptr)
 Checks every name against the board: nets, pads (REF.NUM, on one net), copper layers.
Applied apply_advice (const Advice &a, const model::Board &b)
 check_advice_refs, then the RouterOptions::AdviceSet: layer masks and costs, and for each region a rule area plus disallow rules (doc 05 §34) that name its nets.
nlohmann::json advice_to_json (const Advice &a)
 The advice as JSON, with the board's real names: what is saved beside the output so that --advice FILE repeats a run.
nlohmann::json advice_schema ()
 The hint types an advisor may use, as JSON (goes into the stuck report so an advisor adapts to the engine it talks to).
void unalias (Advice &a, const AliasMap &m)
ProcessResult run_process (const std::string &command, const std::string &input, double timeout_s, std::size_t max_out=std::size_t{1}<< 20, std::size_t max_err=std::size_t{1}<< 16)
 Runs command with /bin/sh -c in its own process group, feeds it input on stdin, and collects stdout (at most max_out bytes) and stderr (at most max_err).
Consulted consult_advisor (const AdvisorOptions &opt, const nlohmann::json &report, const AliasMap &aliases, const std::string &advice_name)
 Sends report to the advisor and reads its advice.
StuckReport build_stuck_report (const StuckInput &in)

Variables

constexpr std::size_t kMaxFirstNets = 64
 Upper bounds on what one file may ask for (an advisor is not trusted to be sensible, doc 17 §6).
constexpr std::size_t kMaxPriority = 512
constexpr std::size_t kMaxRegions = 24
constexpr std::size_t kMaxPolygon = 64
constexpr std::size_t kMaxRegionNets = 64
constexpr std::size_t kMaxNote = 2000
constexpr int kMaxVariants = 8
constexpr int kDefaultVariants = 4

Function Documentation

◆ advice_schema()

nlohmann::json tmk::advice::advice_schema ( )

The hint types an advisor may use, as JSON (goes into the stuck report so an advisor adapts to the engine it talks to).

◆ advice_to_json()

nlohmann::json tmk::advice::advice_to_json ( const Advice & a)

The advice as JSON, with the board's real names: what is saved beside the output so that --advice FILE repeats a run.

◆ apply_advice()

Applied tmk::advice::apply_advice ( const Advice & a,
const model::Board & b )

check_advice_refs, then the RouterOptions::AdviceSet: layer masks and costs, and for each region a rule area plus disallow rules (doc 05 §34) that name its nets.

a is not changed.

◆ build_stuck_report()

StuckReport tmk::advice::build_stuck_report ( const StuckInput & in)

◆ check_advice_refs()

void tmk::advice::check_advice_refs ( const Advice & a,
const model::Board & b,
std::vector< std::string > * warnings = nullptr )

Checks every name against the board: nets, pads (REF.NUM, on one net), copper layers.

Throws std::runtime_error listing the unknown ones with a "did you mean" where one is close. Warnings (entries without effect) go to warnings.

◆ consult_advisor()

Consulted tmk::advice::consult_advisor ( const AdvisorOptions & opt,
const nlohmann::json & report,
const AliasMap & aliases,
const std::string & advice_name )

Sends report to the advisor and reads its advice.

The command line itself is not logged or put in the summary (it may carry credentials); only the program name is.

◆ load_advice_file()

Advice tmk::advice::load_advice_file ( const std::string & path)

Reads a file (size-limited); throws on a missing file or a syntax or content error.

◆ parse_advice()

Advice tmk::advice::parse_advice ( std::string_view json_text,
const std::string & source = "advice" )

Parses and validates the text of an advice file. Throws std::runtime_error naming source and the entry ("regions[1].rect").

◆ run_process()

ProcessResult tmk::advice::run_process ( const std::string & command,
const std::string & input,
double timeout_s,
std::size_t max_out = std::size_t{1}<< 20,
std::size_t max_err = std::size_t{1}<< 16 )

Runs command with /bin/sh -c in its own process group, feeds it input on stdin, and collects stdout (at most max_out bytes) and stderr (at most max_err).

After timeout_s seconds the whole group is killed.

◆ unalias()

void tmk::advice::unalias ( Advice & a,
const AliasMap & m )

Variable Documentation

◆ kDefaultVariants

int tmk::advice::kDefaultVariants = 4
inlineconstexpr

Definition at line 54 of file advice.hpp.

◆ kMaxFirstNets

std::size_t tmk::advice::kMaxFirstNets = 64
inlineconstexpr

Upper bounds on what one file may ask for (an advisor is not trusted to be sensible, doc 17 §6).

Definition at line 47 of file advice.hpp.

◆ kMaxNote

std::size_t tmk::advice::kMaxNote = 2000
inlineconstexpr

Definition at line 52 of file advice.hpp.

◆ kMaxPolygon

std::size_t tmk::advice::kMaxPolygon = 64
inlineconstexpr

Definition at line 50 of file advice.hpp.

◆ kMaxPriority

std::size_t tmk::advice::kMaxPriority = 512
inlineconstexpr

Definition at line 48 of file advice.hpp.

◆ kMaxRegionNets

std::size_t tmk::advice::kMaxRegionNets = 64
inlineconstexpr

Definition at line 51 of file advice.hpp.

◆ kMaxRegions

std::size_t tmk::advice::kMaxRegions = 24
inlineconstexpr

Definition at line 49 of file advice.hpp.

◆ kMaxVariants

int tmk::advice::kMaxVariants = 8
inlineconstexpr

Definition at line 53 of file advice.hpp.