From 6820fa9eed0cb64f75b675127b217339c5f2c951 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 4 Sep 2025 14:04:33 +0200 Subject: [PATCH] feat: local-cpl-sim.mjs Detailansicht Modal in System --- .env.development | 2 +- .env.production | 2 +- CHANGELOG.md | 5 +++ package-lock.json | 4 +- package.json | 2 +- scripts/local-cpl-sim.mjs | 81 +++++++++++++++++++++++++++------------ 6 files changed, 67 insertions(+), 29 deletions(-) diff --git a/.env.development b/.env.development index e007cf8..df4af88 100644 --- a/.env.development +++ b/.env.development @@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_USE_CGI=false # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.839 +NEXT_PUBLIC_APP_VERSION=1.6.840 NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter) diff --git a/.env.production b/.env.production index 32345f4..b9d8162 100644 --- a/.env.production +++ b/.env.production @@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_USE_CGI=true # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.839 +NEXT_PUBLIC_APP_VERSION=1.6.840 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ab8e9c..07cc49a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.6.840] – 2025-09-04 + +- feat: local-cpl-sim.mjs analogInputs /Messwerteingäge / analoge Eingänge + +--- ## [1.6.839] – 2025-09-04 - feat: local-cpl-sim.mjs digitalInputs /Messwerteingänge diff --git a/package-lock.json b/package-lock.json index 003f0ec..4bfc9f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cpl-v4", - "version": "1.6.839", + "version": "1.6.840", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cpl-v4", - "version": "1.6.839", + "version": "1.6.840", "dependencies": { "@fontsource/roboto": "^5.1.0", "@headlessui/react": "^2.2.4", diff --git a/package.json b/package.json index 6f2a60c..e2e70b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cpl-v4", - "version": "1.6.839", + "version": "1.6.840", "private": true, "scripts": { "dev": "next dev -p 3000", diff --git a/scripts/local-cpl-sim.mjs b/scripts/local-cpl-sim.mjs index ece79e5..4b8f310 100644 --- a/scripts/local-cpl-sim.mjs +++ b/scripts/local-cpl-sim.mjs @@ -804,8 +804,10 @@ const server = http.createServer(async (req, res) => { // fall-through } } - // Service commands: analog inputs history via DIA0/DIA1/DIA2 - // Example: seite.ACP&DIA1=YYYY;MM;DD;YYYY;MM;DD;1xx;1 where 1xx is 100 + (eingang-1) + // Service commands: history data via DIA0/DIA1/DIA2 for Analog Inputs and System Spannungen/Temperaturen + // Examples: + // - Analog: seite.ACP&DIA1=YYYY;MM;DD;YYYY;MM;DD;1xx;1 where 1xx is 100 + (eingang-1) + // - System: seite.ACP&DIA1=YYYY;MM;DD;YYYY;MM;DD;108;1 (+15V), 110 (+5V), 114 (-15V), 115 (-98V), 116 (ADC Temp), 117 (CPU Temp) if (/^seite\.ACP/i.test(q) && /DIA[0-2]=/i.test(q)) { try { const m = q.match(/(DIA[0-2])=([^&]+)/i); @@ -814,31 +816,62 @@ const server = http.createServer(async (req, res) => { const parts = m[2].split(";"); // parts: [fy,fm,fd,ty,tm,td,channelCode(1xx), ...] const channel = parts.length >= 7 ? Number(parts[6]) : NaN; - const eingang = Number.isFinite(channel) ? channel - 99 : NaN; if ( ["DIA0", "DIA1", "DIA2"].includes(zeitraum) && - Number.isInteger(eingang) && - eingang >= 1 && - eingang <= 8 + Number.isFinite(channel) ) { - const fp = path.join( - process.cwd(), - "mocks", - "device-cgi-simulator", - "chartsData", - "analogInputs", - String(eingang), - `${zeitraum}.json` - ); - if (exists(fp)) { - const raw = fs.readFileSync(fp, "utf8"); - const daten = JSON.parse(raw); - res.writeHead(200, { - "Content-Type": "application/json", - "Cache-Control": "no-cache", - }); - res.end(JSON.stringify(daten)); - return; + // 1) Analog Inputs mapping (100..107 => Eingänge 1..8) + const eingang = channel - 99; // 100->1, 107->8 + if (Number.isInteger(eingang) && eingang >= 1 && eingang <= 8) { + const fp = path.join( + process.cwd(), + "mocks", + "device-cgi-simulator", + "chartsData", + "analogInputs", + String(eingang), + `${zeitraum}.json` + ); + if (exists(fp)) { + const raw = fs.readFileSync(fp, "utf8"); + const daten = JSON.parse(raw); + res.writeHead(200, { + "Content-Type": "application/json", + "Cache-Control": "no-cache", + }); + res.end(JSON.stringify(daten)); + return; + } + } + // 2) System Spannungen & Temperaturen channel mapping + const systemMap = { + 108: "systemspannung15Vplus", + 110: "systemspannung5Vplus", + 114: "systemspannung15Vminus", + 115: "systemspannung98Vminus", + 116: "temperaturADWandler", + 117: "temperaturProzessor", + }; + const folder = systemMap[channel]; + if (folder) { + const fp = path.join( + process.cwd(), + "mocks", + "device-cgi-simulator", + "chartsData", + folder, + `${zeitraum}.json` + ); + if (exists(fp)) { + const raw = fs.readFileSync(fp, "utf8"); + const daten = JSON.parse(raw); + res.writeHead(200, { + "Content-Type": "application/json", + "Cache-Control": "no-cache", + }); + res.end(JSON.stringify(daten)); + return; + } } } }