feat: local-cpl-sim.mjs Detailansicht Modal in System
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user