Initial commit: update

This commit is contained in:
chris
2026-10-20 20:22:38 +00:00
parent b6a6c5de5c
commit 1814ea3a0f
225 changed files with 15006 additions and 1 deletions

View File

@@ -0,0 +1,158 @@
/* Shopfloor-taugliche, einfache Offline-Rechner (kein Framework) */
(function(){
function n(v){
const x = Number(String(v).replace(",", "."));
return Number.isFinite(x) ? x : NaN;
}
function clamp01(x){ return Math.max(0, Math.min(1, x)); }
function fmtPct(x){
if (!Number.isFinite(x)) return "—";
return (x*100).toFixed(1).replace(".", ",") + " %";
}
function fmtNum(x){
if (!Number.isFinite(x)) return "—";
// ohne Tausendertrennzeichen, dafür robust auf HMIs
const s = (Math.round(x*1000)/1000).toString();
return s.replace(".", ",");
}
function setText(id, text){
const el = document.getElementById(id);
if (el) el.textContent = text;
}
function setBadge(id, kind, text){
const el = document.getElementById(id);
if (!el) return;
el.classList.remove("ok","warn","bad");
if (kind) el.classList.add(kind);
el.textContent = text;
}
// ----- OEE -----
function calcOEE(){
// Inputs: geplante Zeit, Stillstand, Idealzyklus, Total Count, Good Count
const plannedMin = n(document.getElementById("oee_planned_min").value);
const stopMin = n(document.getElementById("oee_stop_min").value);
const idealCycleSec = n(document.getElementById("oee_ideal_cycle_sec").value);
const totalCount = n(document.getElementById("oee_total").value);
const goodCount = n(document.getElementById("oee_good").value);
const runtimeMin = plannedMin - stopMin;
const runtimeSec = runtimeMin * 60;
const availability = plannedMin > 0 ? clamp01(runtimeMin / plannedMin) : NaN;
// Performance: (Ideal Cycle Time × Total Count) / Run Time
const performance = (idealCycleSec > 0 && runtimeSec > 0 && totalCount >= 0)
? clamp01((idealCycleSec * totalCount) / runtimeSec)
: NaN;
const quality = (totalCount > 0 && goodCount >= 0) ? clamp01(goodCount / totalCount) : NaN;
const oee = (Number.isFinite(availability) && Number.isFinite(performance) && Number.isFinite(quality))
? availability * performance * quality
: NaN;
setText("oee_runtime_min", fmtNum(runtimeMin));
setText("oee_availability", fmtPct(availability));
setText("oee_performance", fmtPct(performance));
setText("oee_quality", fmtPct(quality));
setText("oee_total_oee", fmtPct(oee));
// Diagnosis badges (grobe Shopfloor-Einordnung)
// >85% sehr gut, 70-85 ok, <70 kritisch (nur Richtwert)
if (!Number.isFinite(oee)){
setBadge("oee_badge","", "Bitte Eingaben prüfen");
return;
}
if (oee >= 0.85) setBadge("oee_badge","ok","Sehr gut (≥ 85%)");
else if (oee >= 0.70) setBadge("oee_badge","warn","OK (70–85%)");
else setBadge("oee_badge","bad","Kritisch (< 70%)");
const formula =
`Verfügbarkeit = Laufzeit / Geplante Zeit
= ${fmtNum(runtimeMin)} / ${fmtNum(plannedMin)} = ${fmtPct(availability)}
Leistung = (Idealzyklus × Gesamt) / Laufzeit
= (${fmtNum(idealCycleSec)}s × ${fmtNum(totalCount)}) / ${fmtNum(runtimeSec)}s = ${fmtPct(performance)}
Qualität = Gut / Gesamt
= ${fmtNum(goodCount)} / ${fmtNum(totalCount)} = ${fmtPct(quality)}
OEE = V × L × Q
= ${fmtPct(availability)} × ${fmtPct(performance)} × ${fmtPct(quality)} = ${fmtPct(oee)}`;
setText("oee_formula", formula);
}
function resetOEE(){
const ids = ["oee_planned_min","oee_stop_min","oee_ideal_cycle_sec","oee_total","oee_good"];
ids.forEach(id => { const el = document.getElementById(id); if (el) el.value = ""; });
["oee_runtime_min","oee_availability","oee_performance","oee_quality","oee_total_oee","oee_formula"].forEach(id => setText(id,"—"));
setBadge("oee_badge","", "Bereit");
}
// ----- FPY -----
function calcFPY(){
const total = n(document.getElementById("fpy_total").value);
const rework = n(document.getElementById("fpy_rework").value);
const scrap = n(document.getElementById("fpy_scrap").value);
const firstPassGood = total - rework - scrap;
const fpy = (total > 0) ? clamp01(firstPassGood / total) : NaN;
setText("fpy_firstpass", fmtNum(firstPassGood));
setText("fpy_result", fmtPct(fpy));
if (!Number.isFinite(fpy)){
setBadge("fpy_badge","", "Bitte Eingaben prüfen");
return;
}
if (fpy >= 0.98) setBadge("fpy_badge","ok","Sehr gut (≥ 98%)");
else if (fpy >= 0.95) setBadge("fpy_badge","warn","OK (95–98%)");
else setBadge("fpy_badge","bad","Kritisch (< 95%)");
const formula =
`First Pass Good = Gesamt − Nacharbeit − Ausschuss
= ${fmtNum(total)} − ${fmtNum(rework)} − ${fmtNum(scrap)} = ${fmtNum(firstPassGood)}
FPY = First Pass Good / Gesamt
= ${fmtNum(firstPassGood)} / ${fmtNum(total)} = ${fmtPct(fpy)}`;
setText("fpy_formula", formula);
}
function resetFPY(){
const ids = ["fpy_total","fpy_rework","fpy_scrap"];
ids.forEach(id => { const el = document.getElementById(id); if (el) el.value = ""; });
["fpy_firstpass","fpy_result","fpy_formula"].forEach(id => setText(id,"—"));
setBadge("fpy_badge","", "Bereit");
}
// wiring (only if elements exist on page)
document.addEventListener("DOMContentLoaded", function(){
// OEE buttons
const oeeCalcBtn = document.getElementById("oee_calc_btn");
const oeeResetBtn = document.getElementById("oee_reset_btn");
if (oeeCalcBtn) oeeCalcBtn.addEventListener("click", calcOEE);
if (oeeResetBtn) oeeResetBtn.addEventListener("click", resetOEE);
// FPY buttons
const fpyCalcBtn = document.getElementById("fpy_calc_btn");
const fpyResetBtn = document.getElementById("fpy_reset_btn");
if (fpyCalcBtn) fpyCalcBtn.addEventListener("click", calcFPY);
if (fpyResetBtn) fpyResetBtn.addEventListener("click", resetFPY);
// Optional: auto-calc on Enter
document.addEventListener("keydown", function(e){
if (e.key !== "Enter") return;
if (document.getElementById("oee_calc_btn")) calcOEE();
if (document.getElementById("fpy_calc_btn")) calcFPY();
});
// initial state badges
if (document.getElementById("oee_badge")) setBadge("oee_badge","", "Bereit");
if (document.getElementById("fpy_badge")) setBadge("fpy_badge","", "Bereit");
});
})();