Skip to content

Commit

Permalink
odb export: include mounting type atrribute of components
Browse files Browse the repository at this point in the history
  • Loading branch information
ii8 committed Sep 27, 2023
1 parent d2631ab commit 3647cbe
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/export_odb/attributes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ template <typename T> struct text_attribute {
template <typename T> struct is_feature : std::false_type {};
template <typename T> struct is_net : std::false_type {};
template <typename T> struct is_pkg : std::false_type {};
template <typename T> struct is_comp : std::false_type {};

template <class T> inline constexpr bool is_feature_v = is_feature<T>::value;
template <class T> inline constexpr bool is_net_v = is_net<T>::value;
template <class T> inline constexpr bool is_pkg_v = is_pkg<T>::value;
template <class T> inline constexpr bool is_comp_v = is_comp<T>::value;

#define ATTR_IS_FEATURE(a) \
template <> struct is_feature<a> : std::true_type {};
Expand All @@ -64,6 +66,9 @@ template <class T> inline constexpr bool is_pkg_v = is_pkg<T>::value;
#define ATTR_IS_PKG(a) \
template <> struct is_pkg<a> : std::true_type {};

#define ATTR_IS_COMP(a) \
template <> struct is_comp<a> : std::true_type {};

enum class drill { PLATED, NON_PLATED, VIA };
ATTR_NAME(drill)
ATTR_IS_FEATURE(drill)
Expand All @@ -75,6 +80,10 @@ enum class pad_usage { TOEPRINT, VIA, G_FIDUCIAL, L_FIDUCIAL, TOOLING_HOLE };
ATTR_NAME(pad_usage)
ATTR_IS_FEATURE(pad_usage)

enum class comp_mount_type { OTHER, SMT, THMT, PRESSFIT };
ATTR_NAME(comp_mount_type)
ATTR_IS_COMP(comp_mount_type)

MAKE_FLOAT_ATTR(drc_max_height, 3)
ATTR_IS_FEATURE(drc_max_height)

Expand Down
2 changes: 2 additions & 0 deletions src/export_odb/components.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Components : public AttributeProvider {

class Component : public RecordWithAttributes {
public:
template <typename T> using check_type = attribute::is_comp<T>;

Component(unsigned int i, unsigned int r) : index(i), pkg_ref(r)
{
}
Expand Down
2 changes: 2 additions & 0 deletions src/export_odb/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Components::Component &Step::add_component(const BoardPackage &bpkg)
comp.comp_name = make_legal_name(bpkg.component->refdes);
comp.part_name =
make_legal_name(bpkg.component->part ? bpkg.component->part->get_MPN() : bpkg.component->entity->name);
if (pkg.mtype)
comps.add_attribute(comp, pkg.mtype.value());

return comp;
}
Expand Down
4 changes: 4 additions & 0 deletions src/export_odb/eda_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,23 @@ EDAData::Pin &EDAData::Package::add_pin(const horizon::Pad &pad)
pin.type = Pin::Type::THROUGH_HOLE;
pin.mtype = Pin::MountType::THROUGH_HOLE;
pin.etype = Pin::ElectricalType::ELECTRICAL;
mtype = attribute::comp_mount_type::THMT;
break;

case Padstack::Type::TOP:
case Padstack::Type::BOTTOM:
pin.type = Pin::Type::SURFACE;
pin.mtype = Pin::MountType::SMT;
pin.etype = Pin::ElectricalType::ELECTRICAL;
if (!mtype)
mtype = attribute::comp_mount_type::SMT;
break;

case Padstack::Type::MECHANICAL:
pin.type = Pin::Type::THROUGH_HOLE;
pin.mtype = Pin::MountType::THROUGH_HOLE;
pin.etype = Pin::ElectricalType::MECHANICAL;
mtype = attribute::comp_mount_type::THMT;
break;

default:;
Expand Down
2 changes: 2 additions & 0 deletions src/export_odb/eda_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ class EDAData : public AttributeProvider {
uint64_t pitch;
int64_t xmin, ymin, xmax, ymax;

std::optional<attribute::comp_mount_type> mtype = std::nullopt;

std::list<std::unique_ptr<Outline>> outline;

Pin &add_pin(const horizon::Pad &pad);
Expand Down

0 comments on commit 3647cbe

Please sign in to comment.