Self-test NPM: decodage npm_status au lieu des anciens champs erreur
Adapte le self-test au nouveau format retourne par get_data_modbus_v3.py (npm_status numerique decode bit par bit au lieu de notReady/fanError/etc.) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -320,10 +320,10 @@ async function selfTestSequence() {
|
||||
|
||||
try {
|
||||
if (sensor.type === 'npm') {
|
||||
// NPM sensor test
|
||||
// NPM sensor test (uses get_data_modbus_v3.py --dry-run)
|
||||
const npmResult = await new Promise((resolve, reject) => {
|
||||
$.ajax({
|
||||
url: 'launcher.php?type=npm&port=' + sensor.port,
|
||||
url: 'launcher.php?type=npm',
|
||||
dataType: 'json',
|
||||
method: 'GET',
|
||||
timeout: 15000,
|
||||
@@ -333,17 +333,30 @@ async function selfTestSequence() {
|
||||
});
|
||||
|
||||
selfTestReport.rawResponses['NPM Sensor'] = JSON.stringify(npmResult, null, 2);
|
||||
addSelfTestLog(`NPM response: PM1=${npmResult.PM1}, PM2.5=${npmResult.PM25}, PM10=${npmResult.PM10}`);
|
||||
addSelfTestLog(`NPM response: PM1=${npmResult.PM1}, PM2.5=${npmResult.PM25}, PM10=${npmResult.PM10}, status=${npmResult.npm_status_hex}`);
|
||||
|
||||
// Check for errors
|
||||
const npmErrors = ['notReady', 'fanError', 'laserError', 'heatError', 't_rhError', 'memoryError', 'degradedState'];
|
||||
const activeErrors = npmErrors.filter(e => npmResult[e] === 1);
|
||||
// Decode npm_status flags
|
||||
const status = npmResult.npm_status || 0;
|
||||
const statusFlags = {
|
||||
0x01: "Sleep mode",
|
||||
0x02: "Degraded mode",
|
||||
0x04: "Not ready",
|
||||
0x08: "Heater error",
|
||||
0x10: "THP sensor error",
|
||||
0x20: "Fan error",
|
||||
0x40: "Memory error",
|
||||
0x80: "Laser error"
|
||||
};
|
||||
const activeErrors = [];
|
||||
Object.entries(statusFlags).forEach(([mask, label]) => {
|
||||
if (status & mask) activeErrors.push(label);
|
||||
});
|
||||
|
||||
if (activeErrors.length > 0) {
|
||||
updateTestStatus(sensor.id, 'Warning', `Errors: ${activeErrors.join(', ')}`, 'bg-warning');
|
||||
updateTestStatus(sensor.id, 'Warning', `Status ${npmResult.npm_status_hex}: ${activeErrors.join(', ')}`, 'bg-warning');
|
||||
testsFailed++;
|
||||
} else if (npmResult.PM1 !== undefined && npmResult.PM25 !== undefined && npmResult.PM10 !== undefined) {
|
||||
updateTestStatus(sensor.id, 'Passed', `PM1: ${npmResult.PM1} | PM2.5: ${npmResult.PM25} | PM10: ${npmResult.PM10} ug/m3`, 'bg-success');
|
||||
updateTestStatus(sensor.id, 'Passed', `PM1: ${npmResult.PM1} | PM2.5: ${npmResult.PM25} | PM10: ${npmResult.PM10} µg/m³`, 'bg-success');
|
||||
testsPassed++;
|
||||
} else {
|
||||
updateTestStatus(sensor.id, 'Warning', 'Incomplete data received', 'bg-warning');
|
||||
|
||||
Reference in New Issue
Block a user