Elektrotechnische Berechnungstools für Dolibarr: - Leitungsquerschnittsrechner (DIN VDE 0100-520, DIN VDE 0298-4) - Widerstandsrechner für Potentialausgleich (VDE 0100-534/540) - Selektivitäts-Assistent (VDE 0100-530) Features: - Dark Mode Unterstützung - Responsive Design - PDF-Export - Dolibarr-Berechtigungssystem Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
638 lines
25 KiB
PHP
638 lines
25 KiB
PHP
<?php
|
||
/* Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
|
||
*
|
||
* This program 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 3 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||
*/
|
||
|
||
/**
|
||
* \file tools/widerstandsrechner.php
|
||
* \ingroup elektroplanung
|
||
* \brief Widerstandsrechner für Potentialausgleich nach VDE 0100-534/540
|
||
*/
|
||
|
||
// Load Dolibarr environment
|
||
$res = 0;
|
||
if (!$res && file_exists("../../main.inc.php")) {
|
||
$res = @include "../../main.inc.php";
|
||
}
|
||
if (!$res && file_exists("../../../main.inc.php")) {
|
||
$res = @include "../../../main.inc.php";
|
||
}
|
||
if (!$res) {
|
||
die("Include of main fails");
|
||
}
|
||
|
||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
|
||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
|
||
|
||
// Load translation files
|
||
$langs->loadLangs(array("elektroplanung@elektroplanung"));
|
||
|
||
// Security check
|
||
if (!isModEnabled('elektroplanung')) {
|
||
accessforbidden('Module not enabled');
|
||
}
|
||
if (!$user->hasRight('elektroplanung', 'tools', 'read')) {
|
||
accessforbidden('Permission denied');
|
||
}
|
||
|
||
$form = new Form($db);
|
||
|
||
// Page header
|
||
llxHeader('', $langs->trans("ElektroplanungWiderstandsrechner"), '', '', 0, 0, array(
|
||
'https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js'
|
||
), array(
|
||
'/elektroplanung/css/elektroplanung.css'
|
||
), '', 'mod-elektroplanung page-widerstandsrechner');
|
||
|
||
// Viewport für Mobile
|
||
print '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">';
|
||
|
||
print load_fiche_titre($langs->trans("ElektroplanungWiderstandsrechner"), '', 'fa-microchip');
|
||
|
||
print '<div class="fichecenter">';
|
||
?>
|
||
|
||
<!-- Styles sind in /elektroplanung/css/elektroplanung.css -->
|
||
|
||
<div class="ep-calculator">
|
||
<!-- TABS -->
|
||
<div class="ep-tabs">
|
||
<div class="ep-tab active" onclick="wrSwitchTab('widerstand')">
|
||
<span class="fa fa-calculator"></span> <?php echo $langs->trans("ElektroplanungWiderstandBerechnung"); ?>
|
||
</div>
|
||
<div class="ep-tab" onclick="wrSwitchTab('querschnitt')">
|
||
<span class="fa fa-ruler"></span> <?php echo $langs->trans("ElektroplanungQuerschnittErmitteln"); ?>
|
||
</div>
|
||
<div class="ep-tab" onclick="wrSwitchTab('vde')">
|
||
<span class="fa fa-book"></span> <?php echo $langs->trans("ElektroplanungVDEAnforderungen"); ?>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- TAB 1: Widerstand berechnen -->
|
||
<div id="wrTabWiderstand" class="ep-tab-content active">
|
||
<div class="ep-toolbar">
|
||
<button class="butAction" onclick="wrBerechneWiderstand()">
|
||
<span class="fa fa-search"></span> <?php echo $langs->trans("Calculate"); ?>
|
||
</button>
|
||
<button class="butAction" onclick="wrExportPDF()">
|
||
<span class="fa fa-file-pdf-o"></span> PDF
|
||
</button>
|
||
<button class="butActionDelete" onclick="wrResetWiderstand()">
|
||
<span class="fa fa-refresh"></span> <?php echo $langs->trans("Reset"); ?>
|
||
</button>
|
||
</div>
|
||
|
||
<div class="ep-section">
|
||
<div class="ep-section-title">
|
||
<span class="fa fa-bolt"></span> <?php echo $langs->trans("ElektroplanungAnwendungsfall"); ?>
|
||
</div>
|
||
|
||
<div class="ep-form-grid">
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungAnwendung"); ?>:</label>
|
||
<select id="wrAnwendung" onchange="wrUpdateMaxWiderstand()">
|
||
<option value="pa_haupt" data-max="1.0"><?php echo $langs->trans("ElektroplanungHauptPA"); ?> (≤ 1Ω)</option>
|
||
<option value="pa_zusatz" data-max="0.5"><?php echo $langs->trans("ElektroplanungZusatzPA"); ?> (≤ 0.5Ω)</option>
|
||
<option value="spd_typ1" data-max="0.5"><?php echo $langs->trans("ElektroplanungSPDTyp1"); ?> (≤ 0.5Ω)</option>
|
||
<option value="spd_typ2" data-max="1.0"><?php echo $langs->trans("ElektroplanungSPDTyp2"); ?> (≤ 1Ω)</option>
|
||
<option value="blitzschutz" data-max="0.2"><?php echo $langs->trans("ElektroplanungBlitzschutz"); ?> (≤ 0.2Ω)</option>
|
||
<option value="custom" data-max="1.0"><?php echo $langs->trans("ElektroplanungBenutzerdefiniert"); ?></option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungMaxWiderstand"); ?> <span class="ep-unit">[Ω]</span></label>
|
||
<input type="number" id="wrMaxWiderstand" value="1.0" step="0.01" min="0.01">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="ep-section">
|
||
<div class="ep-section-title">
|
||
<span class="fa fa-plug"></span> <?php echo $langs->trans("ElektroplanungLeitungsdaten"); ?>
|
||
</div>
|
||
|
||
<div class="ep-form-grid">
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungQuerschnitt"); ?> <span class="ep-unit">[mm²]</span></label>
|
||
<select id="wrQuerschnitt">
|
||
<option value="4">4 mm²</option>
|
||
<option value="6" selected>6 mm²</option>
|
||
<option value="10">10 mm²</option>
|
||
<option value="16">16 mm²</option>
|
||
<option value="25">25 mm²</option>
|
||
<option value="35">35 mm²</option>
|
||
<option value="50">50 mm²</option>
|
||
<option value="70">70 mm²</option>
|
||
<option value="95">95 mm²</option>
|
||
<option value="120">120 mm²</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungLeitungslaenge"); ?> <span class="ep-unit">[m]</span></label>
|
||
<input type="number" id="wrLaenge" value="10" step="0.1" min="0.1">
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungLeitermaterial"); ?>:</label>
|
||
<select id="wrMaterial">
|
||
<option value="56" selected>Kupfer (Cu) - κ = 56</option>
|
||
<option value="35">Aluminium (Al) - κ = 35</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungTemperatur"); ?> <span class="ep-unit">[°C]</span></label>
|
||
<input type="number" id="wrTemperatur" value="20" step="1" min="-20" max="80">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="ep-section">
|
||
<div class="ep-section-title">
|
||
<span class="fa fa-link"></span> <?php echo $langs->trans("ElektroplanungVerbindungen"); ?>
|
||
</div>
|
||
|
||
<div class="ep-form-grid">
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungAnzahlKlemmen"); ?>:</label>
|
||
<input type="number" id="wrKlemmen" value="2" step="1" min="0" max="20">
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungWiderstandProKlemme"); ?> <span class="ep-unit">[mΩ]</span></label>
|
||
<input type="number" id="wrKlemmenWiderstand" value="0.5" step="0.1" min="0">
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungAnzahlSchienen"); ?>:</label>
|
||
<input type="number" id="wrSchienen" value="1" step="1" min="0" max="10">
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungWiderstandProSchiene"); ?> <span class="ep-unit">[mΩ]</span></label>
|
||
<input type="number" id="wrSchienenWiderstand" value="1.0" step="0.1" min="0">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- ERGEBNIS Widerstand -->
|
||
<div id="wrResultBox" class="ep-result-box">
|
||
<div class="ep-result-main" id="wrResultWiderstand">0.000 Ω</div>
|
||
<div class="ep-result-status" id="wrResultStatus">-</div>
|
||
|
||
<div class="ep-result-details">
|
||
<div class="ep-result-item">
|
||
<span><?php echo $langs->trans("ElektroplanungLeitungswiderstand"); ?>:</span>
|
||
<span class="ep-result-value" id="wrResultLeitung">-</span>
|
||
</div>
|
||
<div class="ep-result-item">
|
||
<span><?php echo $langs->trans("ElektroplanungKlemmenwiderstand"); ?>:</span>
|
||
<span class="ep-result-value" id="wrResultKlemmen">-</span>
|
||
</div>
|
||
<div class="ep-result-item">
|
||
<span><?php echo $langs->trans("ElektroplanungSchienenwiderstand"); ?>:</span>
|
||
<span class="ep-result-value" id="wrResultSchienen">-</span>
|
||
</div>
|
||
<div class="ep-result-item">
|
||
<span><?php echo $langs->trans("ElektroplanungMaxZulaessig"); ?>:</span>
|
||
<span class="ep-result-value" id="wrResultMax">-</span>
|
||
</div>
|
||
<div class="ep-result-item">
|
||
<span><?php echo $langs->trans("ElektroplanungReserve"); ?>:</span>
|
||
<span class="ep-result-value" id="wrResultReserve">-</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- TAB 2: Querschnitt ermitteln -->
|
||
<div id="wrTabQuerschnitt" class="ep-tab-content">
|
||
<div class="ep-toolbar">
|
||
<button class="butAction" onclick="wrBerechneQuerschnitt()">
|
||
<span class="fa fa-search"></span> <?php echo $langs->trans("ElektroplanungQuerschnittBerechnen"); ?>
|
||
</button>
|
||
</div>
|
||
|
||
<div class="ep-section">
|
||
<div class="ep-section-title">
|
||
<span class="fa fa-crosshairs"></span> <?php echo $langs->trans("ElektroplanungZielwerte"); ?>
|
||
</div>
|
||
|
||
<div class="ep-form-grid">
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungAnwendung"); ?>:</label>
|
||
<select id="wrQsAnwendung" onchange="wrQsUpdateMaxWiderstand()">
|
||
<option value="pa_haupt" data-max="1.0"><?php echo $langs->trans("ElektroplanungHauptPA"); ?> (≤ 1Ω)</option>
|
||
<option value="pa_zusatz" data-max="0.5"><?php echo $langs->trans("ElektroplanungZusatzPA"); ?> (≤ 0.5Ω)</option>
|
||
<option value="spd_typ1" data-max="0.5"><?php echo $langs->trans("ElektroplanungSPDTyp1"); ?> (≤ 0.5Ω)</option>
|
||
<option value="spd_typ2" data-max="1.0"><?php echo $langs->trans("ElektroplanungSPDTyp2"); ?> (≤ 1Ω)</option>
|
||
<option value="blitzschutz" data-max="0.2"><?php echo $langs->trans("ElektroplanungBlitzschutz"); ?> (≤ 0.2Ω)</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungMaxWiderstand"); ?> <span class="ep-unit">[Ω]</span></label>
|
||
<input type="number" id="wrQsMaxWiderstand" value="1.0" step="0.01" min="0.01" readonly>
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungLeitungslaenge"); ?> <span class="ep-unit">[m]</span></label>
|
||
<input type="number" id="wrQsLaenge" value="15" step="0.1" min="0.1">
|
||
</div>
|
||
|
||
<div class="ep-form-group">
|
||
<label><?php echo $langs->trans("ElektroplanungLeitermaterial"); ?>:</label>
|
||
<select id="wrQsMaterial">
|
||
<option value="56" selected>Kupfer (Cu)</option>
|
||
<option value="35">Aluminium (Al)</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- ERGEBNIS Querschnitt -->
|
||
<div id="wrQsResultBox" class="ep-result-box">
|
||
<div class="ep-result-main" id="wrQsResultQuerschnitt">- mm²</div>
|
||
<div class="ep-result-status"><?php echo $langs->trans("ElektroplanungMindestquerschnitt"); ?></div>
|
||
|
||
<div class="ep-result-details">
|
||
<div class="ep-result-item">
|
||
<span><?php echo $langs->trans("ElektroplanungBerechnet"); ?>:</span>
|
||
<span class="ep-result-value" id="wrQsResultBerechnet">-</span>
|
||
</div>
|
||
<div class="ep-result-item">
|
||
<span><?php echo $langs->trans("ElektroplanungTatsWiderstand"); ?>:</span>
|
||
<span class="ep-result-value" id="wrQsResultWiderstand">-</span>
|
||
</div>
|
||
<div class="ep-result-item">
|
||
<span><?php echo $langs->trans("ElektroplanungMaxLaenge"); ?>:</span>
|
||
<span class="ep-result-value" id="wrQsResultMaxLaenge">-</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- TAB 3: VDE Anforderungen -->
|
||
<div id="wrTabVde" class="ep-tab-content">
|
||
<div class="ep-section">
|
||
<div class="ep-section-title">
|
||
<span class="fa fa-book"></span> <?php echo $langs->trans("ElektroplanungVDEPotentialausgleich"); ?>
|
||
</div>
|
||
|
||
<p><?php echo $langs->trans("ElektroplanungVDEPABeschreibung"); ?></p>
|
||
|
||
<table class="ep-table">
|
||
<thead>
|
||
<tr>
|
||
<th><?php echo $langs->trans("ElektroplanungAnwendung"); ?></th>
|
||
<th><?php echo $langs->trans("ElektroplanungNorm"); ?></th>
|
||
<th><?php echo $langs->trans("ElektroplanungMaxWiderstand"); ?></th>
|
||
<th><?php echo $langs->trans("ElektroplanungMindestquerschnittCu"); ?></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td><strong><?php echo $langs->trans("ElektroplanungHauptPA"); ?></strong></td>
|
||
<td>VDE 0100-540</td>
|
||
<td>≤ 1 Ω</td>
|
||
<td>6 mm² (Cu) / 16 mm² (Al)</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong><?php echo $langs->trans("ElektroplanungZusatzPA"); ?></strong></td>
|
||
<td>VDE 0100-410</td>
|
||
<td>≤ 0.5 Ω</td>
|
||
<td>Je nach Anwendung</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong><?php echo $langs->trans("ElektroplanungSPDTyp1"); ?></strong></td>
|
||
<td>VDE 0100-534</td>
|
||
<td>≤ 0.5 Ω</td>
|
||
<td>16 mm² (Cu)</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong><?php echo $langs->trans("ElektroplanungSPDTyp2"); ?></strong></td>
|
||
<td>VDE 0100-534</td>
|
||
<td>≤ 1 Ω</td>
|
||
<td>6 mm² (Cu)</td>
|
||
</tr>
|
||
<tr>
|
||
<td><strong><?php echo $langs->trans("ElektroplanungBlitzschutz"); ?></strong></td>
|
||
<td>VDE 0185-305</td>
|
||
<td>≤ 0.2 Ω</td>
|
||
<td>25 mm² (Cu)</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
<div class="ep-section">
|
||
<div class="ep-section-title">
|
||
<span class="fa fa-bolt"></span> <?php echo $langs->trans("ElektroplanungSPDAnschluss"); ?>
|
||
</div>
|
||
|
||
<p><?php echo $langs->trans("ElektroplanungSPDBeschreibung"); ?></p>
|
||
|
||
<div class="ep-pa-diagram">
|
||
<svg viewBox="0 0 400 200" style="max-width: 400px;">
|
||
<!-- HAK -->
|
||
<rect x="10" y="80" width="60" height="40" class="ep-svg-box" />
|
||
<text x="40" y="105" text-anchor="middle" font-size="12" font-weight="bold" class="ep-svg-text">HAK</text>
|
||
|
||
<!-- Leitung zum SPD -->
|
||
<line x1="70" y1="100" x2="130" y2="100" class="ep-svg-line-primary" stroke-width="3"/>
|
||
<text x="100" y="90" text-anchor="middle" font-size="10" class="ep-svg-text">L ≤ 0.5m</text>
|
||
|
||
<!-- SPD -->
|
||
<rect x="130" y="70" width="50" height="60" class="ep-svg-spd" />
|
||
<text x="155" y="95" text-anchor="middle" font-size="10" font-weight="bold" class="ep-svg-text-dark">SPD</text>
|
||
<text x="155" y="115" text-anchor="middle" font-size="8" class="ep-svg-text-dark">Typ 1/2</text>
|
||
|
||
<!-- PE-Leitung -->
|
||
<line x1="155" y1="130" x2="155" y2="170" class="ep-svg-line-success" stroke-width="3"/>
|
||
<text x="165" y="155" font-size="9" class="ep-svg-text-success">PE</text>
|
||
|
||
<!-- PAS -->
|
||
<rect x="120" y="170" width="70" height="20" class="ep-svg-pas" />
|
||
<text x="155" y="184" text-anchor="middle" font-size="10" font-weight="bold" class="ep-svg-text-light">PAS</text>
|
||
|
||
<!-- Erdung -->
|
||
<line x1="155" y1="190" x2="155" y2="195" class="ep-svg-line-earth" stroke-width="2"/>
|
||
<line x1="140" y1="195" x2="170" y2="195" class="ep-svg-line-earth" stroke-width="2"/>
|
||
<line x1="145" y1="198" x2="165" y2="198" class="ep-svg-line-earth" stroke-width="1.5"/>
|
||
<line x1="150" y1="201" x2="160" y2="201" class="ep-svg-line-earth" stroke-width="1"/>
|
||
|
||
<!-- Beschriftungen -->
|
||
<text x="300" y="30" font-size="11" font-weight="bold" class="ep-svg-text"><?php echo $langs->trans("ElektroplanungLegende"); ?>:</text>
|
||
<rect x="300" y="40" width="15" height="10" class="ep-svg-box" />
|
||
<text x="320" y="49" font-size="9" class="ep-svg-text">HAK = Hausanschlusskasten</text>
|
||
<rect x="300" y="55" width="15" height="10" class="ep-svg-spd" />
|
||
<text x="320" y="64" font-size="9" class="ep-svg-text">SPD = Überspannungsschutz</text>
|
||
<rect x="300" y="70" width="15" height="10" class="ep-svg-pas" />
|
||
<text x="320" y="79" font-size="9" class="ep-svg-text">PAS = Potentialausgleichsschiene</text>
|
||
</svg>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="ep-info-box">
|
||
<strong><span class="fa fa-exclamation-triangle"></span> <?php echo $langs->trans("ElektroplanungWichtig"); ?>:</strong>
|
||
<ul style="margin-left: 20px; margin-top: 5px;">
|
||
<li><?php echo $langs->trans("ElektroplanungVDEHinweis1"); ?></li>
|
||
<li><?php echo $langs->trans("ElektroplanungVDEHinweis2"); ?></li>
|
||
<li><?php echo $langs->trans("ElektroplanungVDEHinweis3"); ?></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
// Globale Variablen
|
||
let wrCalculationData = {};
|
||
|
||
// Normquerschnitte
|
||
const wrNormQuerschnitte = [4, 6, 10, 16, 25, 35, 50, 70, 95, 120, 150, 185, 240];
|
||
|
||
// Tab-Wechsel
|
||
function wrSwitchTab(tab) {
|
||
document.querySelectorAll('.ep-tab').forEach(t => t.classList.remove('active'));
|
||
document.querySelectorAll('.ep-tab-content').forEach(c => c.classList.remove('active'));
|
||
|
||
document.querySelector(`.ep-tab[onclick*="${tab}"]`).classList.add('active');
|
||
document.getElementById('wrTab' + tab.charAt(0).toUpperCase() + tab.slice(1)).classList.add('active');
|
||
}
|
||
|
||
// Max Widerstand aktualisieren
|
||
function wrUpdateMaxWiderstand() {
|
||
const select = document.getElementById('wrAnwendung');
|
||
const maxInput = document.getElementById('wrMaxWiderstand');
|
||
const maxValue = select.options[select.selectedIndex].dataset.max;
|
||
maxInput.value = maxValue;
|
||
maxInput.readOnly = select.value !== 'custom';
|
||
}
|
||
|
||
function wrQsUpdateMaxWiderstand() {
|
||
const select = document.getElementById('wrQsAnwendung');
|
||
const maxInput = document.getElementById('wrQsMaxWiderstand');
|
||
maxInput.value = select.options[select.selectedIndex].dataset.max;
|
||
}
|
||
|
||
// Temperaturkorrektur für spezifischen Widerstand
|
||
function wrGetRhoTemp(kappa, temp) {
|
||
// ρ bei 20°C = 1/κ
|
||
// Temperaturkoeffizient α ≈ 0.00393 für Cu, 0.00403 für Al
|
||
const rho20 = 1 / kappa;
|
||
const alpha = kappa === 56 ? 0.00393 : 0.00403;
|
||
return rho20 * (1 + alpha * (temp - 20));
|
||
}
|
||
|
||
// Widerstand berechnen
|
||
function wrBerechneWiderstand() {
|
||
const querschnitt = parseFloat(document.getElementById('wrQuerschnitt').value);
|
||
const laenge = parseFloat(document.getElementById('wrLaenge').value);
|
||
const kappa = parseFloat(document.getElementById('wrMaterial').value);
|
||
const temperatur = parseFloat(document.getElementById('wrTemperatur').value);
|
||
const maxWiderstand = parseFloat(document.getElementById('wrMaxWiderstand').value);
|
||
const anzahlKlemmen = parseInt(document.getElementById('wrKlemmen').value);
|
||
const widerstandKlemme = parseFloat(document.getElementById('wrKlemmenWiderstand').value) / 1000; // mΩ -> Ω
|
||
const anzahlSchienen = parseInt(document.getElementById('wrSchienen').value);
|
||
const widerstandSchiene = parseFloat(document.getElementById('wrSchienenWiderstand').value) / 1000; // mΩ -> Ω
|
||
|
||
// ρ bei Temperatur berechnen
|
||
const rho = wrGetRhoTemp(kappa, temperatur);
|
||
|
||
// R = ρ * l / A
|
||
const R_leitung = rho * laenge / querschnitt;
|
||
const R_klemmen = anzahlKlemmen * widerstandKlemme;
|
||
const R_schienen = anzahlSchienen * widerstandSchiene;
|
||
const R_gesamt = R_leitung + R_klemmen + R_schienen;
|
||
|
||
const istOK = R_gesamt <= maxWiderstand;
|
||
const reserve = ((maxWiderstand - R_gesamt) / maxWiderstand) * 100;
|
||
|
||
// Daten speichern
|
||
wrCalculationData = {
|
||
querschnitt, laenge, kappa, temperatur, maxWiderstand,
|
||
anzahlKlemmen, widerstandKlemme, anzahlSchienen, widerstandSchiene,
|
||
rho, R_leitung, R_klemmen, R_schienen, R_gesamt, istOK, reserve,
|
||
material: kappa === 56 ? 'Kupfer' : 'Aluminium',
|
||
anwendung: document.getElementById('wrAnwendung').options[document.getElementById('wrAnwendung').selectedIndex].text
|
||
};
|
||
|
||
// Ergebnisse anzeigen
|
||
const resultBox = document.getElementById('wrResultBox');
|
||
resultBox.className = 'ep-result-box show ' + (istOK ? (reserve > 30 ? 'success' : 'warning') : 'error');
|
||
|
||
document.getElementById('wrResultWiderstand').textContent = R_gesamt.toFixed(4) + ' Ω';
|
||
document.getElementById('wrResultStatus').textContent = istOK
|
||
? '✓ <?php echo addslashes($langs->trans("ElektroplanungWiderstandOK")); ?>'
|
||
: '✗ <?php echo addslashes($langs->trans("ElektroplanungWiderstandZuHoch")); ?>';
|
||
|
||
document.getElementById('wrResultLeitung').textContent = (R_leitung * 1000).toFixed(2) + ' mΩ';
|
||
document.getElementById('wrResultKlemmen').textContent = (R_klemmen * 1000).toFixed(2) + ' mΩ';
|
||
document.getElementById('wrResultSchienen').textContent = (R_schienen * 1000).toFixed(2) + ' mΩ';
|
||
document.getElementById('wrResultMax').textContent = maxWiderstand.toFixed(2) + ' Ω';
|
||
document.getElementById('wrResultReserve').textContent = reserve.toFixed(1) + '%';
|
||
|
||
resultBox.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||
}
|
||
|
||
// Querschnitt ermitteln
|
||
function wrBerechneQuerschnitt() {
|
||
const maxWiderstand = parseFloat(document.getElementById('wrQsMaxWiderstand').value);
|
||
const laenge = parseFloat(document.getElementById('wrQsLaenge').value);
|
||
const kappa = parseFloat(document.getElementById('wrQsMaterial').value);
|
||
|
||
// A = ρ * l / R
|
||
const rho = 1 / kappa; // bei 20°C
|
||
const A_min = rho * laenge / maxWiderstand;
|
||
|
||
// Nächsten Normquerschnitt finden
|
||
let querschnitt = wrNormQuerschnitte[wrNormQuerschnitte.length - 1];
|
||
for (let qs of wrNormQuerschnitte) {
|
||
if (qs >= A_min) {
|
||
querschnitt = qs;
|
||
break;
|
||
}
|
||
}
|
||
|
||
// Tatsächlicher Widerstand mit Normquerschnitt
|
||
const R_tats = rho * laenge / querschnitt;
|
||
|
||
// Max Länge mit diesem Querschnitt
|
||
const L_max = maxWiderstand * querschnitt / rho;
|
||
|
||
// Ergebnisse anzeigen
|
||
const resultBox = document.getElementById('wrQsResultBox');
|
||
resultBox.className = 'ep-result-box show success';
|
||
|
||
document.getElementById('wrQsResultQuerschnitt').textContent = querschnitt + ' mm²';
|
||
document.getElementById('wrQsResultBerechnet').textContent = A_min.toFixed(2) + ' mm²';
|
||
document.getElementById('wrQsResultWiderstand').textContent = (R_tats * 1000).toFixed(2) + ' mΩ (' + R_tats.toFixed(4) + ' Ω)';
|
||
document.getElementById('wrQsResultMaxLaenge').textContent = L_max.toFixed(1) + ' m';
|
||
|
||
resultBox.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||
}
|
||
|
||
// Reset
|
||
function wrResetWiderstand() {
|
||
document.getElementById('wrAnwendung').value = 'pa_haupt';
|
||
document.getElementById('wrMaxWiderstand').value = 1.0;
|
||
document.getElementById('wrQuerschnitt').value = 6;
|
||
document.getElementById('wrLaenge').value = 10;
|
||
document.getElementById('wrMaterial').value = 56;
|
||
document.getElementById('wrTemperatur').value = 20;
|
||
document.getElementById('wrKlemmen').value = 2;
|
||
document.getElementById('wrKlemmenWiderstand').value = 0.5;
|
||
document.getElementById('wrSchienen').value = 1;
|
||
document.getElementById('wrSchienenWiderstand').value = 1.0;
|
||
|
||
document.getElementById('wrResultBox').classList.remove('show');
|
||
wrUpdateMaxWiderstand();
|
||
}
|
||
|
||
// PDF Export
|
||
function wrExportPDF() {
|
||
if (!wrCalculationData.R_gesamt) {
|
||
alert('Bitte erst eine Berechnung durchführen!');
|
||
return;
|
||
}
|
||
|
||
const { jsPDF } = window.jspdf;
|
||
const doc = new jsPDF();
|
||
const data = wrCalculationData;
|
||
const datum = new Date().toLocaleDateString('de-DE');
|
||
|
||
let y = 20;
|
||
|
||
doc.setFontSize(18);
|
||
doc.setFont(undefined, 'bold');
|
||
doc.text('Widerstandsberechnung Potentialausgleich', 105, y, { align: 'center' });
|
||
y += 8;
|
||
|
||
doc.setFontSize(10);
|
||
doc.setFont(undefined, 'normal');
|
||
doc.text('Nach VDE 0100-534/540', 105, y, { align: 'center' });
|
||
y += 5;
|
||
doc.text('Erstellt: ' + datum, 105, y, { align: 'center' });
|
||
y += 10;
|
||
|
||
doc.line(20, y, 190, y);
|
||
y += 10;
|
||
|
||
doc.setFontSize(14);
|
||
doc.setFont(undefined, 'bold');
|
||
doc.text('Anwendung', 20, y);
|
||
y += 7;
|
||
|
||
doc.setFontSize(10);
|
||
doc.setFont(undefined, 'normal');
|
||
doc.text(data.anwendung, 20, y);
|
||
y += 10;
|
||
|
||
doc.setFontSize(14);
|
||
doc.setFont(undefined, 'bold');
|
||
doc.text('Leitungsdaten', 20, y);
|
||
y += 7;
|
||
|
||
doc.setFontSize(10);
|
||
doc.setFont(undefined, 'normal');
|
||
doc.text(`Querschnitt: ${data.querschnitt} mm²`, 20, y); y += 6;
|
||
doc.text(`Länge: ${data.laenge} m`, 20, y); y += 6;
|
||
doc.text(`Material: ${data.material}`, 20, y); y += 6;
|
||
doc.text(`Temperatur: ${data.temperatur}°C`, 20, y); y += 10;
|
||
|
||
doc.setFontSize(14);
|
||
doc.setFont(undefined, 'bold');
|
||
doc.text('Ergebnis', 20, y);
|
||
y += 7;
|
||
|
||
doc.setFontSize(14);
|
||
if (data.istOK) {
|
||
doc.setTextColor(16, 185, 129);
|
||
doc.text(`Gesamtwiderstand: ${data.R_gesamt.toFixed(4)} Ω - OK`, 20, y);
|
||
} else {
|
||
doc.setTextColor(239, 68, 68);
|
||
doc.text(`Gesamtwiderstand: ${data.R_gesamt.toFixed(4)} Ω - ZU HOCH`, 20, y);
|
||
}
|
||
doc.setTextColor(0, 0, 0);
|
||
y += 8;
|
||
|
||
doc.setFontSize(10);
|
||
doc.setFont(undefined, 'normal');
|
||
doc.text(`Leitungswiderstand: ${(data.R_leitung * 1000).toFixed(2)} mΩ`, 20, y); y += 6;
|
||
doc.text(`Klemmenwiderstand: ${(data.R_klemmen * 1000).toFixed(2)} mΩ`, 20, y); y += 6;
|
||
doc.text(`Schienenwiderstand: ${(data.R_schienen * 1000).toFixed(2)} mΩ`, 20, y); y += 6;
|
||
doc.text(`Max. zulässig: ${data.maxWiderstand.toFixed(2)} Ω`, 20, y); y += 6;
|
||
doc.text(`Reserve: ${data.reserve.toFixed(1)}%`, 20, y);
|
||
|
||
doc.setFontSize(8);
|
||
doc.setTextColor(150);
|
||
doc.text('Elektroplanung - Widerstandsberechnung - Alle Angaben ohne Gewähr', 105, 290, { align: 'center' });
|
||
|
||
doc.save(`Widerstandsberechnung_${data.querschnitt}mm2_${datum.replace(/\./g, '-')}.pdf`);
|
||
}
|
||
|
||
// Initial
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
wrUpdateMaxWiderstand();
|
||
});
|
||
</script>
|
||
|
||
<?php
|
||
print '</div>';
|
||
|
||
llxFooter();
|
||
$db->close();
|