340 lines
6.5 KiB
PHP
340 lines
6.5 KiB
PHP
<?php
|
|
|
|
|
|
session_start();
|
|
|
|
|
|
header('Content-Type: text/plain');
|
|
header('Cache-Control: no-cache');
|
|
ob_implicit_flush(true);
|
|
ob_end_flush();
|
|
|
|
|
|
|
|
$translationMap = [
|
|
"A" => "30",
|
|
"B" => "20",
|
|
"C" => "10",
|
|
"D" => "39",
|
|
"E" => "29",
|
|
"F" => "19",
|
|
"G" => "38",
|
|
"H" => "28",
|
|
"I" => "18",
|
|
"J" => "37",
|
|
"K" => "27",
|
|
"L" => "17",
|
|
"M" => "36",
|
|
"N" => "26",
|
|
"O" => "16",
|
|
"P" => "35",
|
|
"Q" => "25",
|
|
"R" => "15",
|
|
"S" => "34",
|
|
"T" => "24",
|
|
"U" => "14",
|
|
"V" => "33",
|
|
"W" => "23",
|
|
"X" => "13",
|
|
"Y" => "32",
|
|
"Z" => "22",
|
|
"AA" => "12",
|
|
"AB" => "31",
|
|
"AC" => "21",
|
|
"AD" => "11"
|
|
];
|
|
|
|
function translateArray($inputArray, $translationMap) {
|
|
return array_map(function($subArray) use ($translationMap) {
|
|
return array_map(function($item) use ($translationMap) {
|
|
return $translationMap[$item] ?? $item; // Falls kein Mapping existiert, bleibt das Original erhalten
|
|
}, $subArray);
|
|
}, $inputArray);
|
|
}
|
|
|
|
|
|
|
|
flush();
|
|
|
|
|
|
?>
|
|
|
|
<style>
|
|
|
|
div.check-loading-screen {
|
|
width: 250px;
|
|
height: auto;
|
|
background-color: #ebebeb;
|
|
margin: 0 auto;
|
|
text-align: left;
|
|
padding: 5px;
|
|
border-radius: 25px;
|
|
}
|
|
div.check-loading-screen div {
|
|
|
|
padding: 5px;
|
|
margin: 10px;
|
|
line-height: 30px;
|
|
transition-duration: .4s;
|
|
cursor: pointer;
|
|
border-radius: 10px;
|
|
|
|
}
|
|
div.check-loading-screen div img {
|
|
width: 30px;
|
|
margin-right: 20px;
|
|
vertical-align: middle;
|
|
filter: contrast(0.3);
|
|
line-height: 30px;
|
|
cursor: pointer;
|
|
display: inline-block;
|
|
}
|
|
</style>
|
|
|
|
<div class="check-loading-screen" id="_1">
|
|
<div>
|
|
<img src="/vendor/icons/load.gif">Initialisieren
|
|
</div>
|
|
<div>
|
|
<img src="/vendor/icons/clock-rotate-right.svg">Prüfung 1/2
|
|
</div>
|
|
|
|
<div>
|
|
<img src="/vendor/icons/clock-rotate-right.svg">Prüfung 2/2
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
flush();
|
|
|
|
|
|
|
|
|
|
// To Run the Python program
|
|
$command = escapeshellcmd('python3 /var/www/html/alt/python/plug-check.py');
|
|
|
|
// Use shell_exec to execute the command and capture the output
|
|
$output0 = shell_exec($command);
|
|
|
|
|
|
?>
|
|
|
|
<style>
|
|
#_1 {
|
|
display: none;
|
|
}
|
|
</style>
|
|
|
|
<div class="check-loading-screen" id="_2">
|
|
<div>
|
|
<img src="/vendor/icons/check.svg">Initialisieren
|
|
</div>
|
|
<div>
|
|
<img src="/vendor/icons/load.gif">Prüfung 1/2
|
|
</div>
|
|
|
|
<div>
|
|
<img src="/vendor/icons/clock-rotate-right.svg">Prüfung 2/2
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$command = escapeshellcmd('python3 /var/www/html/alt/python/plug-check.py');
|
|
|
|
|
|
// Use shell_exec to execute the command and capture the output
|
|
$bridges1 = shell_exec($command);
|
|
|
|
|
|
$number_bridges1 = count(json_decode($bridges1, true));
|
|
|
|
?>
|
|
<style>
|
|
#_2 {
|
|
display: none;
|
|
}
|
|
</style>
|
|
|
|
<div class="check-loading-screen" id="_3">
|
|
<div>
|
|
<img src="/vendor/icons/check.svg">Initialisieren
|
|
</div>
|
|
<div>
|
|
<img src="/vendor/icons/check.svg">Prüfung 1/2 (<?php echo $number_bridges1; ?>x)
|
|
</div>
|
|
|
|
<div>
|
|
<img src="/vendor/icons/load.gif">Prüfung 2/2
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$command = escapeshellcmd('python3 /var/www/html/alt/python/plug-check.py');
|
|
|
|
// Use shell_exec to execute the command and capture the output
|
|
$bridges2 = shell_exec($command);
|
|
|
|
?>
|
|
<style>
|
|
#_3 {
|
|
display: none;
|
|
}
|
|
</style>
|
|
<?php
|
|
|
|
|
|
|
|
$bridges1 = $bridges2;
|
|
|
|
if($bridges1 == $bridges2) {
|
|
|
|
|
|
$output = translateArray(json_decode($bridges1, true), $translationMap);
|
|
|
|
|
|
if($output == "error") {
|
|
die("Fehler");
|
|
}
|
|
|
|
//$output = [ ["16", "30"], ["30", "16"]];
|
|
|
|
$array = $output;
|
|
|
|
|
|
$doubles = []; // Array zur Verfolgung von Doppelungen
|
|
$errors = []; // Array für fehlende Doppelungen
|
|
|
|
// Schritt 1: Prüfung auf Doppelungen
|
|
foreach ($array as $pair) {
|
|
|
|
// Sortiere die Paare, um `[23,14]` und `[14,23]` gleich zu behandeln
|
|
sort($pair);
|
|
$key = implode("-", $pair);
|
|
|
|
if (isset($doubles[$key])) {
|
|
$doubles[$key]++; // Verbindung erneut gefunden
|
|
} else {
|
|
$doubles[$key] = 1; // Erstmaliges Auftreten
|
|
}
|
|
}
|
|
|
|
|
|
// Schritt 2: Bereinigung der doppelten Einträge
|
|
$unique = []; // Array für eindeutige Verbindungen
|
|
$seen = []; // Array zur Verfolgung bereits bearbeiteter Verbindungen
|
|
|
|
foreach ($array as $pair) {
|
|
// Sortiere das Paar
|
|
sort($pair);
|
|
$key = implode("-", $pair);
|
|
|
|
// Füge nur ein Exemplar hinzu
|
|
if (!isset($seen[$key])) {
|
|
$unique[] = $pair;
|
|
$seen[$key] = true; // Markiere als verarbeitet
|
|
}
|
|
}
|
|
|
|
$cleaned_output = json_encode($unique);
|
|
|
|
|
|
$url = '../stecker.php?data=' . urlencode($cleaned_output); // Kodiert es für die URL
|
|
|
|
?>
|
|
|
|
<div class="content-header">Ergebnis</div>
|
|
<hr />
|
|
<div class="toggle-switch">
|
|
<div align="right"><p>Gesamtergebnis</p></div>
|
|
<div><label class="switch"><input type="checkbox" onchange='$("#op-1").toggle(this.unchecked);$("#op-2").toggle(this.checked);'><span class="slider"></span></label></div>
|
|
<div align="left"><p>Einzelbrücken</p></div>
|
|
</div>
|
|
<div id="op-1">
|
|
<img src="<?php echo $url; ?>" />
|
|
</div>
|
|
<div id="op-2" style="display: none;">
|
|
<?php
|
|
|
|
foreach($unique as $unique_element) {
|
|
$cleaned_output = "[" . json_encode($unique_element) . "]";
|
|
$url = 'stecker.php?data=' . urlencode($cleaned_output); // Kodiert es für die URL
|
|
?>
|
|
<img style="margin-bottom: 5px;" src="<?php echo $url; ?>" />
|
|
<?php
|
|
}
|
|
?>
|
|
|
|
</div>
|
|
|
|
<hr />
|
|
<?php
|
|
|
|
|
|
}
|
|
else {
|
|
$output = "error";
|
|
|
|
/*
|
|
$url1 = 'stecker.php?data=' . urlencode(translateArray($bridges1, $translationMap)); // Kodiert es für die URL
|
|
$url2 = 'stecker.php?data=' . urlencode(translateArray($bridges2, $translationMap)); // Kodiert es für die URL
|
|
*/
|
|
|
|
?>
|
|
<style>
|
|
#_3 {
|
|
display: none;
|
|
}
|
|
</style>
|
|
|
|
<div class="check-loading-screen" id="_4">
|
|
<div>
|
|
<img src="/vendor/icons/check.svg">Initialisieren
|
|
</div>
|
|
<div>
|
|
<img src="/vendor/icons/xmark.svg">Prüfung 1/2
|
|
</div>
|
|
|
|
<div>
|
|
<img src="/vendor/icons/xmark.svg">Prüfung 2/2
|
|
</div>
|
|
</div>
|
|
<p>Es gab einen Fehler bei der Messung!</br>Messung 1 und Messung 2 lieferten keine übereinstimmenden Ergebnisse.<br>Bitte prüfen Sie, ob alle Steckverbindungen fest sitzen und vermeiden Sie Bewegungen, welche die Messung beeinträchtigen können.</br>Stellen Sie sicher, dass keine der Verbindungen gegen Erde kurzgeschlossen ist, da dies die Messung beeinträchtigt.<br>Erwägen Sie, eine erneute Messung zurchzuführen.</p>
|
|
<br>
|
|
<p>Ergebnis Messung 1:</p>
|
|
<i><?php echo $bridges1; ?><i>
|
|
<img src="<?php echo $url1; ?>" />
|
|
<p>Ergebnis Messung 2:</p>
|
|
<i><?php echo $bridges2; ?><i>
|
|
<img src="<?php echo $url2; ?>" />
|
|
<div class="save-button" onclick="window.location.href='#index'; pageload();$('.save-button').html('<img src=\'load.gif\' \>Bitte warten...');"><img src="/vendor/icons/nav-arrow-left.svg" \>Zurück</div>
|
|
|
|
|
|
|
|
<?php
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|