Schema component and stock component matching - HendriXML/KiCad-BOM-reporter GitHub Wiki

Schema component and stock component matching

This is a detailed and technical description of how the matching of schema and stock components are done.

Schema components and stock components both are handled in a similar way. For each component it’s specification class is determined by reading the data into a specification object of such a class and the asking the object if it’s valid or not. (In this way available data can be treated differently in each class, without outside knowledge on how.) More special specification classes are tried before the more generic. The first valid specification object of the schema or stock component is added to the list belonging to it’s specification class (so resistors are seperated from capacitors). Components don’t have specification data, only “instance data” such as a designator or a stock location, instead specification objects manage a list of components, starting with a single one.

The next step is bundle identical specifications, this is done by first sorting the list and then walking trough it. If a specification object is identical to the previous one, the components are moved and the identical specification object is removed. So resistors with the same value, power rating etc. are grouped in the component list of the same specification object.

At this point schema specifications and stock specifications are still in seperate but very similar lists. This is required because when matching schema specifications with stock specifications they don’t need to be identical. For some specification requirements better values are allowed. (Better tolerances, poweratings etc.).

The next step is to match each schema specification with each stock specification of the same specification class. If they match than add (but not move) the stock component to the schema specification in a stock component list. (Stock components might match multiple times with schema specifications).

Requirements that must match exactly can be indexed to speed up the matching process.

After these steps we end up with categorized and bundled specifications which contain schema components and their matching stock components.