From: Hugo Villeneuve Date: Wed, 22 Jan 2014 14:43:39 +0000 (-0500) Subject: Support second Altium BOM format X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=39c2cca2f6c6e61e80efa5e4722dac178e80560e;p=eda-utils.git Support second Altium BOM format --- diff --git a/bomgen/Bomgen/conf.inc.php b/bomgen/Bomgen/conf.inc.php index a1bf549..8e758ef 100644 --- a/bomgen/Bomgen/conf.inc.php +++ b/bomgen/Bomgen/conf.inc.php @@ -3,9 +3,10 @@ /* Digikey export delimiter. */ define("CSV_DK_DELIM", "\t"); -define("QTY_COL_NAME", "Count"); +define("QTY_COL_NAME", "Quantity"); define("COMPANY_PN_COL_NAME", "P/N_LSI"); -define("DESIGNATOR_COL_NAME", "RefDes"); +define("DESIGNATOR_COL_NAME", "Designator"); +define("FOOTPRINT_COL_NAME", "Footprint"); define("ASSEMBLY_COL_NAME", "Asm"); define("DO_NOT_POPULATE_KEYWORD", "DNP"); diff --git a/bomgen/bomgen.php b/bomgen/bomgen.php index a1fc03b..de00211 100755 --- a/bomgen/bomgen.php +++ b/bomgen/bomgen.php @@ -50,8 +50,8 @@ $csv_infos = "width" => 30), COMPANY_PN_COL_NAME => array("nom" => "LSI P/N", "width" => 15), - "PatternName" => array("nom" => "Footprint", - "width" => 20), + FOOTPRINT_COL_NAME => array("nom" => "Footprint", + "width" => 20), ASSEMBLY_COL_NAME => array("nom" => "Assembly", "width" => 0), "UnitCost" => array("nom" => "Unit Cost", @@ -307,23 +307,36 @@ if (($handle = fopen($src, "r")) !== FALSE) { /* Combinaison de plusieurs lignes en une seule pour PCAD. */ refdes_combine($data, $num, $col_num_to_id, $col_id_to_num); +$voltage_present = false; + /* Génère une liste des colonnes pour le tri. */ foreach ($data as $key => $row) { $sort_type[$key] = $row[$col_id_to_num['Type']]; $sort_desc[$key] = $row[$col_id_to_num['Description']]; $sort_val[$key] = $row[$col_id_to_num['Value']]; - $sort_volt[$key] = $row[$col_id_to_num['Voltage']]; + + if (isset($col_id_to_num['Voltage'])) { + $voltage_present = true; + $sort_volt[$key] = $row[$col_id_to_num['Voltage']]; + } } /* * Triage des lignes selon la référence (colonne DESIGNATOR_COL_NAME), * et ensuite selon la description, la valeur et enfin le voltage. */ -array_multisort($sort_type, SORT_ASC, SORT_STRING, - $sort_desc, SORT_ASC, SORT_STRING, - $sort_val, SORT_ASC, SORT_NUMERIC, - $sort_volt, SORT_ASC, SORT_NUMERIC, - $data); +if ($voltage_present) { + array_multisort($sort_type, SORT_ASC, SORT_STRING, + $sort_desc, SORT_ASC, SORT_STRING, + $sort_val, SORT_ASC, SORT_NUMERIC, + $sort_volt, SORT_ASC, SORT_NUMERIC, + $data); +} else { + array_multisort($sort_type, SORT_ASC, SORT_STRING, + $sort_desc, SORT_ASC, SORT_STRING, + $sort_val, SORT_ASC, SORT_NUMERIC, + $data); +} if ($digikey_bom) { /* Exportation BOM digikey. */