@measurequick/measurequick-report-generator 1.5.217 → 1.5.218
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -283,25 +283,41 @@ export async function getReport(payload, _test) {
|
|
|
283
283
|
coSupRaw,
|
|
284
284
|
});
|
|
285
285
|
|
|
286
|
+
// CO level helper function
|
|
287
|
+
// Normal: 0-8 ppm, Elevated: 9-35 ppm, Dangerous: 36-69 ppm, Emergency: 70+ ppm
|
|
288
|
+
function getCOLevel(ppm) {
|
|
289
|
+
if (!isFinite(ppm) || ppm <= 8) return "Normal";
|
|
290
|
+
if (ppm >= 9 && ppm <= 35) return "Elevated";
|
|
291
|
+
if (ppm >= 36 && ppm <= 69) return "Dangerous";
|
|
292
|
+
return "Emergency";
|
|
293
|
+
}
|
|
294
|
+
|
|
286
295
|
var reasons = [];
|
|
287
|
-
if (isFinite(coAmbRaw) && coAmbRaw >
|
|
288
|
-
if (isFinite(coRetRaw) && coRetRaw >
|
|
289
|
-
if (isFinite(coSupRaw) && coSupRaw >
|
|
296
|
+
if (isFinite(coAmbRaw) && coAmbRaw > 8) reasons.push({ type: "Ambient", value: coAmbRaw, level: getCOLevel(coAmbRaw) });
|
|
297
|
+
if (isFinite(coRetRaw) && coRetRaw > 8) reasons.push({ type: "Return", value: coRetRaw, level: getCOLevel(coRetRaw) });
|
|
298
|
+
if (isFinite(coSupRaw) && coSupRaw > 8) reasons.push({ type: "Supply", value: coSupRaw, level: getCOLevel(coSupRaw) });
|
|
290
299
|
var coHigh = reasons.length > 0;
|
|
291
|
-
VH_LOG("CO threshold check >
|
|
300
|
+
VH_LOG("CO threshold check > 8 ppm:", { coHigh, reasons });
|
|
292
301
|
|
|
293
302
|
if (coHigh) {
|
|
294
303
|
VH_LOG("Setting CO warnings in form fields: COWarning / COWarning2");
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
304
|
+
// Find the highest severity level
|
|
305
|
+
var highestLevel = "Elevated";
|
|
306
|
+
var maxPpm = 0;
|
|
307
|
+
for (var r = 0; r < reasons.length; r++) {
|
|
308
|
+
if (reasons[r].value > maxPpm) maxPpm = reasons[r].value;
|
|
309
|
+
if (reasons[r].level === "Emergency") highestLevel = "Emergency";
|
|
310
|
+
else if (reasons[r].level === "Dangerous" && highestLevel !== "Emergency") highestLevel = "Dangerous";
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// Build details string showing each elevated reading
|
|
314
|
+
var details = reasons.map(function(r) { return r.type + ": " + Math.round(r.value) + " ppm (" + r.level + ")"; }).join(", ");
|
|
315
|
+
|
|
316
|
+
var warningMsg = "WARNING: " + highestLevel + " CO Detected! " + details + "\nVentilate the area and investigate the source.";
|
|
317
|
+
var warningMsg2 = "WARNING: " + highestLevel + " CO Detected! " + details + " Ventilate the area and investigate the source.";
|
|
318
|
+
|
|
319
|
+
safeSetText(form, "COWarning", warningMsg);
|
|
320
|
+
safeSetText(form, "COWarning2", warningMsg2);
|
|
305
321
|
} else {
|
|
306
322
|
VH_LOG("Clearing CO warnings (values within threshold)");
|
|
307
323
|
// clear warnings if not applicable
|