mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Use the EDAInfo data to send info to KiCAD
This commit is contained in:
parent
b76b2740a7
commit
bf5ed030fe
3 changed files with 22 additions and 10 deletions
|
@ -14,7 +14,7 @@ final class Version20231130180903 extends AbstractMigration
|
||||||
{
|
{
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return '';
|
return 'Added EDA fields';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
public function up(Schema $schema): void
|
||||||
|
|
|
@ -34,7 +34,7 @@ trait EDATrait
|
||||||
#[Embedded(class: EDAPartInfo::class)]
|
#[Embedded(class: EDAPartInfo::class)]
|
||||||
protected EDAPartInfo $eda_info;
|
protected EDAPartInfo $eda_info;
|
||||||
|
|
||||||
public function getEdaInfo(): ?EDAPartInfo
|
public function getEdaInfo(): EDAPartInfo
|
||||||
{
|
{
|
||||||
return $this->eda_info;
|
return $this->eda_info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,11 @@ class KiCADHelper
|
||||||
$repo = $this->em->getRepository(Category::class);
|
$repo = $this->em->getRepository(Category::class);
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
|
//Skip invisible categories
|
||||||
|
if ($category->getEdaInfo()->getInvisible() ?? false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/** @var $category Category */
|
/** @var $category Category */
|
||||||
//Ensure that the category contains parts
|
//Ensure that the category contains parts
|
||||||
if ($repo->getPartsCount($category) < 1) {
|
if ($repo->getPartsCount($category) < 1) {
|
||||||
|
@ -101,6 +106,11 @@ class KiCADHelper
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($parts as $part) {
|
foreach ($parts as $part) {
|
||||||
|
//If the part is invisible, then skip it
|
||||||
|
if ($part->getEdaInfo()->getInvisible() ?? $part->getCategory()?->getEdaInfo()->getInvisible() ?? false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'id' => (string)$part->getId(),
|
'id' => (string)$part->getId(),
|
||||||
'name' => $part->getName(),
|
'name' => $part->getName(),
|
||||||
|
@ -117,14 +127,16 @@ class KiCADHelper
|
||||||
$result = [
|
$result = [
|
||||||
'id' => (string)$part->getId(),
|
'id' => (string)$part->getId(),
|
||||||
'name' => $part->getName(),
|
'name' => $part->getName(),
|
||||||
"symbolIdStr" => "Device:R",
|
"symbolIdStr" => $part->getEdaInfo()->getKicadSymbol() ?? $part->getCategory()?->getEdaInfo()->getKicadSymbol() ?? "",
|
||||||
"exclude_from_bom" => $this->boolToKicadBool(false),
|
"exclude_from_bom" => $this->boolToKicadBool($part->getEdaInfo()->getExcludeFromBom() ?? $part->getCategory()?->getEdaInfo()->getExcludeFromBom() ?? false),
|
||||||
"exclude_from_board" => $this->boolToKicadBool(false),
|
"exclude_from_board" => $this->boolToKicadBool($part->getEdaInfo()->getExcludeFromBoard() ?? $part->getCategory()?->getEdaInfo()->getExcludeFromBoard() ?? false),
|
||||||
"exclude_from_sim" => $this->boolToKicadBool(true),
|
"exclude_from_sim" => $this->boolToKicadBool($part->getEdaInfo()->getExcludeFromSim() ?? $part->getCategory()?->getEdaInfo()->getExcludeFromSim() ?? false),
|
||||||
"fields" => []
|
"fields" => []
|
||||||
];
|
];
|
||||||
|
|
||||||
$result["fields"]["value"] = $this->createField($part->getName(), true);
|
$result["fields"]["footprint"] = $this->createField($part->getEdaInfo()->getKicadFootprint() ?? $part->getFootprint()?->getEdaInfo()->getKicadFootprint() ?? "");
|
||||||
|
$result["fields"]["reference"] = $this->createField($part->getEdaInfo()->getReferencePrefix() ?? 'U', true);
|
||||||
|
$result["fields"]["value"] = $this->createField($part->getEdaInfo()->getValue() ?? $part->getName(), true);
|
||||||
$result["fields"]["keywords"] = $this->createField($part->getTags());
|
$result["fields"]["keywords"] = $this->createField($part->getTags());
|
||||||
|
|
||||||
//Use the part info page as datasheet link. It must be an absolute URL.
|
//Use the part info page as datasheet link. It must be an absolute URL.
|
||||||
|
@ -148,7 +160,7 @@ class KiCADHelper
|
||||||
}
|
}
|
||||||
if ($part->getManufacturingStatus()) {
|
if ($part->getManufacturingStatus()) {
|
||||||
$result["fields"]["Manufacturing Status"] = $this->createField(
|
$result["fields"]["Manufacturing Status"] = $this->createField(
|
||||||
//Always use the english translation
|
//Always use the english translation
|
||||||
$this->translator->trans($part->getManufacturingStatus()->toTranslationKey(), locale: 'en')
|
$this->translator->trans($part->getManufacturingStatus()->toTranslationKey(), locale: 'en')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -158,12 +170,12 @@ class KiCADHelper
|
||||||
if ($part->getPartUnit()) {
|
if ($part->getPartUnit()) {
|
||||||
$unit = $part->getPartUnit()->getName();
|
$unit = $part->getPartUnit()->getName();
|
||||||
if ($part->getPartUnit()->getUnit() !== "") {
|
if ($part->getPartUnit()->getUnit() !== "") {
|
||||||
$unit .= ' (' . $part->getPartUnit()->getUnit() . ')';
|
$unit .= ' ('.$part->getPartUnit()->getUnit().')';
|
||||||
}
|
}
|
||||||
$result["fields"]["Part-DB Unit"] = $this->createField($unit);
|
$result["fields"]["Part-DB Unit"] = $this->createField($unit);
|
||||||
}
|
}
|
||||||
if ($part->getMass()) {
|
if ($part->getMass()) {
|
||||||
$result["fields"]["Mass"] = $this->createField($part->getMass());
|
$result["fields"]["Mass"] = $this->createField($part->getMass() . ' g');
|
||||||
}
|
}
|
||||||
$result["fields"]["Part-DB ID"] = $this->createField($part->getId());
|
$result["fields"]["Part-DB ID"] = $this->createField($part->getId());
|
||||||
if (!empty($part->getIpn())) {
|
if (!empty($part->getIpn())) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue