TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
engine.hpp File Reference

From detected instances to effective rules and engine inputs (design doc 15 §3.5, §5.5, §7): evaluate -> every catalogue rule of every instance, tagged applied / satisfied-by-board / not-applied(reason) / advisory, with a measured value where TraceMaker can measure it; compile -> placement pseudo-nets (pad pairs), keep-out rule areas for the router and DRC, and a sidecar .kicad_dru with the generated custom rules; report -> the text and JSON the user sees. More...

#include <optional>
#include <string>
#include <string_view>
#include <vector>
#include <nlohmann/json.hpp>
#include "crules/catalogue.hpp"
#include "crules/detect.hpp"
#include "crules/impedance_rules.hpp"
#include "model/board.hpp"
#include "model/rules.hpp"

Go to the source code of this file.

Classes

struct  tmk::crules::Measure
struct  tmk::crules::EffectiveRule
struct  tmk::crules::Evaluation
struct  tmk::crules::ProximityPairs
 A proximity rule bound to pads (doc 15 §4 proximity): each pair is (pad of the part that should move close, pad it should be close to). More...
struct  tmk::crules::PlacementAffinity
 Placement pseudo-nets for every applicable proximity rule (mode soft or on; confidence >= suggest). More...
struct  tmk::crules::EdgeAttraction
 Connector edge pull for the placer (doc 15 §5.2 edge; CONN-01, USB2-11, DISP-02), opt-in (tracemaker-place –edge-attraction): the anchor of every instance with a connector edge rule (mode soft/on, not advisory, not disabled by the user), once per footprint, never a locked part and never a pin header or socket (board-to-board and jumper headers, CONN-01 note). More...
struct  tmk::crules::GeneratedKeepout
 Keep-out rule areas (doc 15 §5.5, P2) for instances at confidence >= apply: crystal + load caps (XTAL-04), switching-regulator inductor (BUCK-06/BOOST-04), discrete Ethernet magnetics (ETH-05: tracks, vias and zones on the magnetics' side and the adjacent layer only). More...
struct  tmk::crules::SyntheticClass
 Net classes from rules (doc 15 §5.3-5.4 and §16, P5): impedance rules with a computed width/gap, and width rules with a current or a minimum width, become synthetic net classes for the nets bound to the rule's roles. More...

Namespaces

namespace  tmk
namespace  tmk::crules

Enumerations

enum class  tmk::crules::Mode : std::uint8_t { tmk::crules::Off , tmk::crules::Report , tmk::crules::Soft , tmk::crules::On }
 –component-rules (doc 15 §3.5): off = nothing; report = detect and check only; soft = rules as costs, no hard constraints; on = catalogue severities (generated keep-outs become router/DRC rule areas). More...
enum class  tmk::crules::Status : std::uint8_t { tmk::crules::Applied , tmk::crules::SatisfiedByBoard , tmk::crules::NotApplied , tmk::crules::Advisory }

Functions

Mode tmk::crules::parse_mode (std::string_view s)
 throws std::invalid_argument
const char * tmk::crules::mode_name (Mode m)
const char * tmk::crules::status_name (Status s)
std::vector< ProximityPairs > tmk::crules::proximity_pairs (const model::Board &b, const Catalogue &cat, const Detection &det)
Evaluation tmk::crules::evaluate (const model::Board &b, const model::DesignRules *rules, const Catalogue &cat, const Detection &det, Mode mode)
std::vector< PlacementAffinity > tmk::crules::placement_affinities (const model::Board &b, const Catalogue &cat, const Detection &det, Mode mode)
std::vector< EdgeAttraction > tmk::crules::edge_attractions (const model::Board &b, const Catalogue &cat, const Detection &det, Mode mode)
std::vector< GeneratedKeepout > tmk::crules::generate_keepouts (const model::Board &b, const Catalogue &cat, const Detection &det, std::vector< std::string > *not_generated=nullptr)
std::string tmk::crules::dru_sidecar (const model::Board &b, const Catalogue &cat, const Detection &det)
 The same intent as KiCad custom rules with net exemptions (which rule areas cannot express), for the user to review or merge: "\<output\>.tracemaker.kicad_dru".
std::vector< std::pair< model::NetId, model::NetId > > tmk::crules::usb_pairs (const model::Board &b, const Catalogue &cat, const Detection &det)
 USB 2.0 D+/D- pairs to route coupled first (USB2-02, doc 15 P3): one (dp, dm) per usb2 instance whose dp and dm roles each bind exactly one net, in instance order, without duplicates.
std::vector< SyntheticClass > tmk::crules::synthetic_net_classes (const model::Board &b, const model::DesignRules &rules, const Catalogue &cat, const Detection &det, const Evaluation &ev)
model::DesignRules tmk::crules::with_synthetic_classes (const model::Board &b, model::DesignRules rules, const std::vector< SyntheticClass > &sc)
 rules with the synthetic classes added and their nets assigned to them (in memory only, rule 8).
std::string tmk::crules::report_text (const model::Board &b, const Catalogue &cat, const Detection &det, const Evaluation &ev)
 Report (doc 15 §7).
nlohmann::json tmk::crules::report_json (const model::Board &b, const Catalogue &cat, const Detection &det, const Evaluation &ev)

Detailed Description

From detected instances to effective rules and engine inputs (design doc 15 §3.5, §5.5, §7): evaluate -> every catalogue rule of every instance, tagged applied / satisfied-by-board / not-applied(reason) / advisory, with a measured value where TraceMaker can measure it; compile -> placement pseudo-nets (pad pairs), keep-out rule areas for the router and DRC, and a sidecar .kicad_dru with the generated custom rules; report -> the text and JSON the user sees.

Everything is deterministic: instances in catalogue/reference order, rules in catalogue order.

Definition in file engine.hpp.