feat: local-cpl-sim.mjs kabelueberwachung

This commit is contained in:
ISA
2025-09-04 11:16:06 +02:00
parent b62c477d50
commit 47e0efeb80
6 changed files with 52 additions and 5 deletions

View File

@@ -69,6 +69,38 @@ function getRelFromRoot(filePath) {
function tryServeSpecialMocks(res, relPath) {
const rp = relPath.replace(/^\/+/, "");
// Serve ready JS/JSON mocks for some routes
// Digital Inputs JSON
if (rp === "CPL/SERVICE/digitalInputs.json") {
const mockPath = path.join(
process.cwd(),
"mocks",
"device-cgi-simulator",
"SERVICE",
"digitalInputsMockData.json"
);
if (exists(mockPath)) return streamRaw(res, mockPath);
}
// Kabelüberwachung main JS (kueData.js)
if (rp === "CPL/SERVICE/kueData.js") {
const mockPath = path.join(
process.cwd(),
"mocks",
"device-cgi-simulator",
"SERVICE",
"kabelueberwachungMockData.js"
);
if (exists(mockPath)) return streamRaw(res, mockPath);
}
// Kabelüberwachung Knotenpunkte slot JS files
if (rp.startsWith("CPL/SERVICE/knotenpunkte/") && rp.endsWith(".js")) {
const mockPath = path.join(
process.cwd(),
"mocks",
"device-cgi-simulator",
rp.replace(/^CPL\//, "")
);
if (exists(mockPath)) return streamRaw(res, mockPath);
}
if (rp === "CPL/SERVICE/systemVoltTemp.js") {
const mockPath = path.join(
process.cwd(),
@@ -108,6 +140,16 @@ function tryServeSpecialMocks(res, relPath) {
);
if (exists(mockPath)) return streamRaw(res, mockPath);
}
// TDR reference curves (if mocks exist)
if (rp.startsWith("CPL/tdr-reference-curves/")) {
const mockPath = path.join(
process.cwd(),
"mocks",
"device-cgi-simulator",
rp.replace(/^CPL\//, "")
);
if (exists(mockPath)) return streamRaw(res, mockPath);
}
return false;
}