Refactoring style #398
Replies: 3 comments 1 reply
-
This new abstraction looks like it's going to work like a charm. Testing it on
$ erbb build hardware
Drop.erbui:30:13: error: Unknown style 'rohan'
style rohan, large
^~~~~
<builtin>: note: did you mean 'rogan'?
style rogan, large
^~~~~ Or when an option is not compatible (for example thonk has only unskirted for size 2 and 1, not 3 ie. "large"):
Drop.erbui:30:27: error: Incompatible style 'unskirted'
style rogan, large, unskirted
^~~~~~~~~
<builtin>: note: for selected styles 'size3, 3ps, rogan, skirt, d_shaft, large' From an implementation point of view, we have a new analyser that computes a number of parts from the given style. For one kind of |
Beta Was this translation helpful? Give feedback.
-
There is still a conceptual issue left.
Since it is still unclear if we could have the case that for example a list of parts contains multiple components that would go on the PCB or other usage dictated by the generators, we will assume the generator knows what it is doing with this list of parts. The problem with this approach, is that generators will ignore parts in which they are not interested into, and this could create a problem if a new part is introduced and we forget to add the support code for this part in a specific generator. Until we have more insight about this, we will leave the system as it is. |
Beta Was this translation helpful? Give feedback.
-
After quite some contorsions, semantic style is finally here 🎉 And by contorsions, we mean that quite a lot of successive small improvements have been needed to get there in the end:
One main problem is that generators needed too much semantic information about the components that are used. This is now centralized in a new style analyser. The information itself (for the PCB, BOM, DXF, etc. generators) was coming from too many sources, so we decided to store as much data as possible directly in the Kicad generated files:
The whole system as been made in particular to allow manufacturer for which the definition can't be opened for the public (for IP reasons). Backward compatibility is present, so one might still use for example Finally, the new system will also allow to have 3D previews to check for the general look of the module (as seeing it only from an orthographic front is misleading — eg. Rogan 5PS feels smaller than Rogan 3PS), and maybe even realistic module packshots for marketing early tests. |
Beta Was this translation helpful? Give feedback.
-
Background
We have a current scheme where a user must add a
style
to a control in order to determine what is used.For example:
style rogan.1ps
means use the Alpha 9mm pot with D shaft, and finally the rogan size 1, with pointer and skirtstyle thonk.pj398sm.knurled
means use the thonkiconn with knurled nutstyle led.3mm.red
means use a 3mm red LEDstyle dailywell.2m1
means use 2-position on-on switch, butstyle dailywell.2m3
is 3-position on-off-onWe have all sort of behaviors:
rogan.1ps
)thonk.pj398sm.knurled
)led.3mm.red
)dailywell.2m1
anddailywell.2m3
)Improving problem definition
From a semantic point of view, and to help with the upcoming
manufacturer
feature, we change thestyle
semantic so that it matches the user intent, for example:The user intent is mainly what the end-user will see and haptics, that they can experience in the simulator.
Finally this becomes crucial when bringing the
manufacturer
feature, since the user for example doesn't care if an Alpha or Bourns pot is used, and more importantly, if the manufacturer is going to use a THT or SMT version for a component.Improving current solution
The way styles are done from a language point of view is somehow an ordered list of features, but there are no reason really to order those features:
led.3mm.red
could be alsoled.red.3mm
.For this, instead of having a style describe a constant, we could say that we have a list of constants instead, for which the style doesn't matter:
We can:
led
)on_on
for a 2-position switch)3mm
for aLed
, or using thonkiconn for aCvIn
), so that having no user-definedstyle
at all is still ok.The main problem that arises is probably getting to know the available style options for each control.
This can be done in the documentation, and also through hinting or helping with messages from the
erbb
command.Implementation
Because of the explosion of
style
options, we need to find a way to move them out of the grammar.For this we can just create "constants", that are almost like identifiers, except they can start with a number.
We need also the Xcode syntax highlighter and Pygments lexer to recognise those constants.
Finally on one side we have a set of contants, and a list of set of options on the other side, ordered by more common first.
Matching 2 sets gives:
For each potential final style we have a score:
We do a "lexical" compare:
If 2 sets have the same number of matching options, then select the ones with the less unmatching options, and finally the one earliest in the order.
Beta Was this translation helpful? Give feedback.
All reactions