feat: local-cpl-sim.mjs Detailansicht Modal in System

This commit is contained in:
ISA
2025-09-04 14:04:33 +02:00
parent 3daa6b1dbb
commit 6820fa9eed
6 changed files with 67 additions and 29 deletions

View File

@@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false
NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_EXPORT_STATIC=false
NEXT_PUBLIC_USE_CGI=false NEXT_PUBLIC_USE_CGI=false
# App-Versionsnummer # 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) NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter)

View File

@@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL
NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_EXPORT_STATIC=true
NEXT_PUBLIC_USE_CGI=true NEXT_PUBLIC_USE_CGI=true
# App-Versionsnummer # App-Versionsnummer
NEXT_PUBLIC_APP_VERSION=1.6.839 NEXT_PUBLIC_APP_VERSION=1.6.840
NEXT_PUBLIC_CPL_MODE=production NEXT_PUBLIC_CPL_MODE=production

View File

@@ -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 ## [1.6.839] 2025-09-04
- feat: local-cpl-sim.mjs digitalInputs /Messwerteingänge - feat: local-cpl-sim.mjs digitalInputs /Messwerteingänge

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.839", "version": "1.6.840",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.839", "version": "1.6.840",
"dependencies": { "dependencies": {
"@fontsource/roboto": "^5.1.0", "@fontsource/roboto": "^5.1.0",
"@headlessui/react": "^2.2.4", "@headlessui/react": "^2.2.4",

View File

@@ -1,6 +1,6 @@
{ {
"name": "cpl-v4", "name": "cpl-v4",
"version": "1.6.839", "version": "1.6.840",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev -p 3000", "dev": "next dev -p 3000",

View File

@@ -804,8 +804,10 @@ const server = http.createServer(async (req, res) => {
// fall-through // fall-through
} }
} }
// Service commands: analog inputs history via DIA0/DIA1/DIA2 // Service commands: history data via DIA0/DIA1/DIA2 for Analog Inputs and System Spannungen/Temperaturen
// Example: seite.ACP&DIA1=YYYY;MM;DD;YYYY;MM;DD;1xx;1 where 1xx is 100 + (eingang-1) // 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)) { if (/^seite\.ACP/i.test(q) && /DIA[0-2]=/i.test(q)) {
try { try {
const m = q.match(/(DIA[0-2])=([^&]+)/i); const m = q.match(/(DIA[0-2])=([^&]+)/i);
@@ -814,31 +816,62 @@ const server = http.createServer(async (req, res) => {
const parts = m[2].split(";"); const parts = m[2].split(";");
// parts: [fy,fm,fd,ty,tm,td,channelCode(1xx), ...] // parts: [fy,fm,fd,ty,tm,td,channelCode(1xx), ...]
const channel = parts.length >= 7 ? Number(parts[6]) : NaN; const channel = parts.length >= 7 ? Number(parts[6]) : NaN;
const eingang = Number.isFinite(channel) ? channel - 99 : NaN;
if ( if (
["DIA0", "DIA1", "DIA2"].includes(zeitraum) && ["DIA0", "DIA1", "DIA2"].includes(zeitraum) &&
Number.isInteger(eingang) && Number.isFinite(channel)
eingang >= 1 &&
eingang <= 8
) { ) {
const fp = path.join( // 1) Analog Inputs mapping (100..107 => Eingänge 1..8)
process.cwd(), const eingang = channel - 99; // 100->1, 107->8
"mocks", if (Number.isInteger(eingang) && eingang >= 1 && eingang <= 8) {
"device-cgi-simulator", const fp = path.join(
"chartsData", process.cwd(),
"analogInputs", "mocks",
String(eingang), "device-cgi-simulator",
`${zeitraum}.json` "chartsData",
); "analogInputs",
if (exists(fp)) { String(eingang),
const raw = fs.readFileSync(fp, "utf8"); `${zeitraum}.json`
const daten = JSON.parse(raw); );
res.writeHead(200, { if (exists(fp)) {
"Content-Type": "application/json", const raw = fs.readFileSync(fp, "utf8");
"Cache-Control": "no-cache", const daten = JSON.parse(raw);
}); res.writeHead(200, {
res.end(JSON.stringify(daten)); "Content-Type": "application/json",
return; "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;
}
} }
} }
} }