service live configslop

This commit is contained in:
legop3
2026-09-14 17:56:53 -04:00
parent 881583ee0a
commit 91e0cc3886
69 changed files with 1188 additions and 619 deletions
@@ -5,7 +5,7 @@ const fs = require('fs');
const EventEmitter = require('events');
const io = require('../../globals/io');
const logger = require('../../globals/logger').child('audioLevelsService');
const { loadConfig } = require('../../configuration');
const { loadConfig, registerConfigurationHandler } = require('../../configuration');
const { resolveDataDir, resolveDataPath } = require('../../helpers/dataPaths');
const { isAdmin, roleEvents } = require('../roleService');
const roverManager = require('../roverManager');
@@ -344,6 +344,32 @@ io.on('connection', (socket) => {
loadState();
registerConfigurationHandler('audioLevels', async (nextConfig) => {
/*
Audio levels also have a durable operational store because administrators
can adjust them outside the configuration editor. Applying a configuration
revision intentionally updates that same live state, rather than changing
startup fallbacks that an existing store would immediately override.
*/
const current = loadState();
persistState({
...current,
hornGain: clampGain(nextConfig.hornGain, current.hornGain),
ttsGain: clampGain(nextConfig.ttsGain, current.ttsGain),
forwardGain: clampGain(nextConfig.forwardGain, current.forwardGain),
maxPersonalAdjustmentPercent: clampMaximumAdjustmentPercent(
nextConfig.maxPersonalAdjustmentPercent,
current.maxPersonalAdjustmentPercent,
),
updatedAt: Date.now(),
updatedBy: 'configuration',
adjustmentRangeUpdatedAt: Date.now(),
adjustmentRangeUpdatedBy: 'configuration',
});
pushLevelsToAllRovers();
emitChange('configuration_applied');
});
module.exports = {
ADJUSTMENT_FIELDS,
PERSONAL_ADJUSTMENT_PERMISSION,