Added stackup support to the report

This commit is contained in:
Salvador E. Tropea 2022-01-18 15:51:55 -03:00
parent b6b42cc9bf
commit b73a2e51d4
7 changed files with 97 additions and 10 deletions

View File

@ -125,10 +125,10 @@ class Globals(FiltersOptions):
elif ly.type == 'copper' and ly.thickness:
if not len(thicknesses):
thicknesses.add(ly.thickness)
self.copper_thickness = str(int(ly.thickness*1000))
self.copper_thickness = str(int(ly.thickness))
elif ly.thickness not in thicknesses:
thicknesses.add(ly.thickness)
self.copper_thickness += ' / '+str(int(ly.thickness*1000))
self.copper_thickness += ' / '+str(int(ly.thickness))
def get_stack_up(self):
logger.debug("Looking for stack-up information in the PCB")

View File

@ -1411,7 +1411,7 @@ class PCBLayer(object):
elif i_type == 'color':
layer.color = _check_str(i, 1, tname)
elif i_type == 'thickness':
layer.thickness = _check_float(i, 1, tname)
layer.thickness = _check_float(i, 1, tname)*1000
elif i_type == 'material':
layer.material = _check_str(i, 1, tname)
elif i_type == 'epsilon_r':

View File

@ -136,6 +136,11 @@ class ReportOptions(BaseOptions):
continue
units = None
var_ori = var
m = re.match(r'^(%[^,]+),(.*)$', var)
pattern = None
if m:
pattern = m.group(1)
var = m.group(2)
if var.endswith('_mm'):
units = to_mm
digits = self._mm_digits
@ -154,7 +159,22 @@ class ReportOptions(BaseOptions):
val = 'N/A'
elif units is not None and isinstance(val, (int, float)):
val = units(val, digits)
line = line.replace('${'+var_ori+'}', str(val))
if pattern is not None:
clear = False
if 's' in pattern:
val = str(val)
else:
try:
val = float(val)
except ValueError:
val = 0
clear = True
rep = pattern % val
if clear:
rep = ' '*len(rep)
else:
rep = str(val)
line = line.replace('${'+var_ori+'}', rep)
else:
print('Error: Unable to expand `{}`'.format(var))
return line
@ -212,6 +232,18 @@ class ReportOptions(BaseOptions):
text += self.do_replacements(line, {'drill': d, 'count': self._drills[d]})
return text
def context_stackup(self, line):
""" Replace iterator for the `stackup` context """
text = ''
for s in self._stackup:
context = {}
for k in dir(s):
val = getattr(s, k)
if k[0] != '_' and not callable(val):
context[k] = val if val is not None else ''
text += self.do_replacements(line, context)
return text
@staticmethod
def is_pure_smd_5(m):
return m.GetAttributes() == UI_SMD
@ -433,7 +465,7 @@ class ReportOptions(BaseOptions):
self._tracks_defined = set(self._track_sizes)
def eval_conditional(self, line):
context = {k: getattr(self, k) for k in dir(self) if k[0] != '_'}
context = {k: getattr(self, k) for k in dir(self) if k[0] != '_' and not callable(getattr(self, k))}
res = None
text = line[2:].strip()
logger.debug('- Evaluating `{}`'.format(text))
@ -462,13 +494,12 @@ class ReportOptions(BaseOptions):
elif ':' in line:
context = line[1:].split(':')[0]
logger.debug("- Report context: `{}`".format(context))
try:
name = 'context_'+context
if hasattr(self, name):
# Contexts are members called context_*
line = getattr(self, 'context_'+context)(line[len(context)+2:])
line = getattr(self, name)(line[len(context)+2:])
done = True
except AttributeError:
pass
if not done:
else:
raise KiPlotConfigurationError("Unknown context: `{}`".format(context))
if not done:
# Just replace using any data member (_* excluded)
@ -496,6 +527,8 @@ class ReportOptions(BaseOptions):
self.castellated_pads = GS.global_castellated_pads
self.edge_plating = GS.global_edge_plating
self.copper_thickness = GS.global_copper_thickness
self.stackup = 'yes' if GS.stackup else ''
self._stackup = GS.stackup if GS.stackup else []
self.collect_data(GS.board)
self.do_template(self.template, fname)

View File

@ -21,6 +21,16 @@ Special features:
#?edge_plating
- Edge plating
#?stackup
Stackup:
#?stackup
| Name | Type | Color | Thickness | Material | Epsilon_r | Loss tangent |
#?stackup
|----------------------|----------------------|----------|-----------|----------|-----------|--------------|
#?stackup
#stackup:| ${%-20s,name} | ${%-20s,type} | ${%-8s,color} | ${%9d,thickness} | ${%-8s,material} | ${%9.1f,epsilon_r} | ${%12.2f,loss_tangent} |
#?stackup
# Important sizes
Clearance: ${clearance_mm} mm (${clearance_mils} mils)

View File

@ -18,6 +18,16 @@ Special features:
#?edge_plating
- Edge plating
#?stackup
Stackup:
#?stackup
| Name | Type | Color | Thickness | Material | Epsilon_r | Loss tangent |
#?stackup
|----------------------|----------------------|----------|-----------|----------|-----------|--------------|
#?stackup
#stackup:| ${%-20s,name} | ${%-20s,type} | ${%-8s,color} | ${%9d,thickness} | ${%-8s,material} | ${%9.1f,epsilon_r} | ${%12.2f,loss_tangent} |
#?stackup
Materials:
- ${pcb_material}, ${thickness_mm} mm
- ${pcb_finish}

View File

@ -17,6 +17,23 @@ Special features:
- Castellated pads
- Edge plating
Stackup:
| Name | Type | Color | Thickness | Material | Epsilon_r | Loss tangent |
|----------------------|----------------------|----------|-----------|----------|-----------|--------------|
| F.SilkS | Top Silk Screen | White | | | | |
| F.Paste | Top Solder Paste | | | | | |
| F.Mask | Top Solder Mask | Blue | 10 | | | |
| F.Cu | copper | | 35 | | | |
| dielectric 1 | core | | 480 | FR4 | 4.5 | 0.02 |
| In1.Cu | copper | | 35 | | | |
| dielectric 2 | prepreg | | 480 | FR4 | 4.5 | 0.02 |
| In2.Cu | copper | | 35 | | | |
| dielectric 3 | core | | 480 | FR4 | 4.5 | 0.02 |
| B.Cu | copper | | 35 | | | |
| B.Mask | Bottom Solder Mask | Red | 10 | | | |
| B.Paste | Bottom Solder Paste | | | | | |
| B.SilkS | Bottom Silk Screen | Black | | | | |
# Important sizes
Clearance: 0.15 mm (6 mils)

View File

@ -14,6 +14,23 @@ Special features:
- Castellated pads
- Edge plating
Stackup:
| Name | Type | Color | Thickness | Material | Epsilon_r | Loss tangent |
|----------------------|----------------------|----------|-----------|----------|-----------|--------------|
| F.SilkS | Top Silk Screen | White | | | | |
| F.Paste | Top Solder Paste | | | | | |
| F.Mask | Top Solder Mask | Blue | 10 | | | |
| F.Cu | copper | | 35 | | | |
| dielectric 1 | core | | 480 | FR4 | 4.5 | 0.02 |
| In1.Cu | copper | | 35 | | | |
| dielectric 2 | prepreg | | 480 | FR4 | 4.5 | 0.02 |
| In2.Cu | copper | | 35 | | | |
| dielectric 3 | core | | 480 | FR4 | 4.5 | 0.02 |
| B.Cu | copper | | 35 | | | |
| B.Mask | Bottom Solder Mask | Red | 10 | | | |
| B.Paste | Bottom Solder Paste | | | | | |
| B.SilkS | Bottom Silk Screen | Black | | | | |
Materials:
- FR4, 1.6 mm
- ENIG