/* Copyright 2006-2026 The QElectroTech Team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. QElectroTech is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with QElectroTech. If not, see . */ #ifndef TERMINALCATALOG_H #define TERMINALCATALOG_H #include #include #include #include /** * @brief The TerminalCatalog namespace * Data shared between the terminal strip editor and the element editor : * usual sections (mm2) and widths (mm) of the terminals sold by the manufacturers. * Only the values found in the catalogs of the manufacturers are listed, * any other value can be typed by the user. * For Legrand and ABB Entrelec the value is the pitch ("pas") of the catalog. */ namespace TerminalCatalog { /** * Width (mm) of a terminal sold by a manufacturer. * For ABB Entrelec the value is the spacing (pitch) given by the catalog. */ struct WidthEntry { double mm; const char *label; double section; const char *manufacturer; }; inline const QVector §ions() { static const QVector sections_ {0.5, 0.75, 1, 1.5, 2.5, 4, 6, 10, 16, 25, 35, 50, 70, 95, 120, 150, 185, 240, 300}; return sections_; } /** * @brief awgForSection * @param mm2 : a section in mm2 * @return the nearest AWG / kcmil size, as text ("14", "1/0", "250 kcmil"), * or an empty string if the section has no usual equivalent. * The correspondence is approximate (the usual table of the manufacturers), * the two systems don't have the same steps. */ inline QString awgForSection(double mm2) { struct Awg { double mm2; const char *awg; }; static const Awg table_[] { {0.5, "20"}, {0.75, "18"}, {1, "17"}, {1.5, "16"}, {2.5, "14"}, {4, "12"}, {6, "10"}, {10, "8"}, {16, "6"}, {25, "4"}, {35, "2"}, {50, "1/0"}, {70, "2/0"}, {95, "3/0"}, {120, "250 kcmil"}, {150, "300 kcmil"}, {185, "350 kcmil"}, {240, "500 kcmil"}, {300, "600 kcmil"} }; for (const auto &entry : table_) { if (qAbs(entry.mm2 - mm2) < 0.0001) { return QString::fromLatin1(entry.awg); } } return QString(); } /** * @brief sectionText * @param mm2 : a section in mm2 * @param unit_text : the text of the section with its unit, for example "2,5 mm²" * @return @a unit_text followed by the AWG size if there is one : "2,5 mm² (AWG 14)" */ inline QString sectionText(double mm2, const QString &unit_text) { const auto awg_ = awgForSection(mm2); if (awg_.isEmpty()) { return unit_text; } return awg_.contains(QLatin1String("kcmil")) ? unit_text + QStringLiteral(" (%1)").arg(awg_) : unit_text + QStringLiteral(" (AWG %1)").arg(awg_); } inline const QVector &widthEntries() { static const QVector entries_ { {5.0, "ABB Entrelec MA 2.5/5", 2.5, "ABB Entrelec"}, {5.1, "Weidmüller WDU 2.5", 2.5, "Weidmüller"}, {5.2, "WAGO 2002 (TOPJOB S)", 2.5, "WAGO"}, {6.0, "ABB Entrelec M 4/6", 4.0, "ABB Entrelec"}, {6.0, "Legrand Viking 3 (4 mm²)", 4.0, "Legrand"}, {6.1, "Weidmüller WDU 4", 4.0, "Weidmüller"}, {6.2, "Phoenix Contact UT 4", 4.0, "Phoenix Contact"}, {7.5, "WAGO 2006 (TOPJOB S)", 6.0, "WAGO"}, {7.9, "Weidmüller WDU 6", 6.0, "Weidmüller"}, {8.0, "ABB Entrelec M 6/8", 6.0, "ABB Entrelec"}, {8.0, "ABB Entrelec M 4/8", 4.0, "ABB Entrelec"}, {8.2, "Phoenix Contact UT 6", 6.0, "Phoenix Contact"}, {10.0, "ABB Entrelec M 10/10", 10.0, "ABB Entrelec"}, {10.2, "Phoenix Contact UT 10", 10.0, "Phoenix Contact"}, {11.9, "Weidmüller WDU 16/ZA", 16.0, "Weidmüller"}, {12.0, "ABB Entrelec M 16/12", 16.0, "ABB Entrelec"}, {12.0, "Legrand Viking 3 (16 mm²)", 16.0, "Legrand"}, {12.2, "Phoenix Contact UT 16", 16.0, "Phoenix Contact"}, {16.0, "ABB Entrelec M 35/16", 35.0, "ABB Entrelec"}, {16.0, "Phoenix Contact UT 35", 35.0, "Phoenix Contact"}, {16.0, "Weidmüller WDU 35N", 35.0, "Weidmüller"}, {26.0, "ABB Entrelec M 35/26.FF", 35.0, "ABB Entrelec"}, {31.0, "ABB Entrelec M 70/31.AF", 70.0, "ABB Entrelec"}, {35.0, "ABB Entrelec M 120/35.F", 120.0, "ABB Entrelec"}, {42.0, "ABB Entrelec M 300/42.FF", 300.0, "ABB Entrelec"} }; return entries_; } /// Manufacturers of the catalog, in the order of the first entry. inline QStringList manufacturers() { QStringList list_; for (const auto &entry : widthEntries()) { const auto name_ = QString::fromUtf8(entry.manufacturer); if (!list_.contains(name_)) { list_ << name_; } } return list_; } } #endif // TERMINALCATALOG_H