This took much longer than expected, but the KiCad evaluator is finally here, fully functional and ready to roll. What a Rust adventure and learning experience this has been :sweat_smile: This initial implementation of the evaluator supports the following features (out of all currently planned features):
[x] Evaluation of all default and custom-defined expressions defined in component attributes.
[x] Full namespace support, attributes of components defined in child schematics in the KiCad hierarchical schematic model can be accessed via <schematic>.<component>.<attribute>, e.g. DCDC.R3.Tolerance. (Parent schematics cannot be accessed by design to preserve the capability of evaluating every schematic independently.)
[x] Order-independent evaluation using a recursive dependency resolver.
[x] Self-dependency and circular dependency detection.
[x] Automatic appending of the unit for an attribute if provided.
[x] Automatic parsing of numeric types for the value field (if no string-based unit is given).
[x] Support for global overrides (using text field parsing or a custom KiCad component).
[x] Support for support functions such as voltage_divider(...) (either baked-in or loaded externally).
[x] Applying the updates from the internal Schematic format back into the kicad_parse_gen::schematic::Schematic (#18).
As evidenced by the rather large commits, this has gone through many revisions until I finally figured out how to implement this properly in Rust. Thus, I suggest squashing the commits when merging. I'm also aware that the code is a bit lightly commented right now due to lack of time, but I will improve that front with upcoming PRs. I can however also add the comments to this PR if that's preferred.
This took much longer than expected, but the KiCad
evaluator
is finally here, fully functional and ready to roll. What a Rust adventure and learning experience this has been :sweat_smile: This initial implementation of theevaluator
supports the following features (out of all currently planned features):<schematic>.<component>.<attribute>
, e.g.DCDC.R3.Tolerance
. (Parent schematics cannot be accessed by design to preserve the capability of evaluating every schematic independently.)voltage_divider(...)
(either baked-in or loaded externally).Schematic
format back into thekicad_parse_gen::schematic::Schematic
(#18).As evidenced by the rather large commits, this has gone through many revisions until I finally figured out how to implement this properly in Rust. Thus, I suggest squashing the commits when merging. I'm also aware that the code is a bit lightly commented right now due to lack of time, but I will improve that front with upcoming PRs. I can however also add the comments to this PR if that's preferred.
cc @luxas @chiplet