Fix zones loading and mock data system
Critical fixes:
- Zones now load correctly: fixed snapcast mock to emit { result: buildStatus() }
- Mock data now enabled by default: VITE_USE_MOCK=true in docker-compose.dev.yml
- Added initial status broadcast and periodic updates (5s) in snapcast mock
NMEA2000 data enhancements:
- Added realistic fuel rate monitoring (10-15 L/hr)
- Added alternator output (30-60A)
- Added engine hours counter (continuous)
- Added tank level monitoring (fresh water, waste water, bilge)
- Added depth alarm threshold
- All values use correct SI units (radians, m/s, Kelvin)
- Data changes smoothly with random walk algorithm (no jumps)
- Position advances based on heading and speed
Documentation:
- Added MOCK_DATA_EXPLANATION.md with complete guide
- Explains NMEA 2000 standard
- Documents all 3 mock data sources
- Includes troubleshooting and customization guide
Changes:
- dashboard/src/mock/snapcast.mock.js: Fixed event format and added periodic updates
- dashboard/src/mock/signalk.mock.js: Enhanced with 7 new realistic parameters
- docker-compose.dev.yml: Set VITE_USE_MOCK=true for dev mode
- MOCK_DATA_EXPLANATION.md: New comprehensive documentation
Now zones load on app startup and all mock data is realistic and working!
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -36,6 +36,13 @@ export function createSignalKMock() {
|
||||
rudder: 2.5,
|
||||
airTemp: 14.2,
|
||||
fuel: 68,
|
||||
fuelRate: 12.5, // liters/hour
|
||||
engineHours: 2847,
|
||||
alternatorOutput: 45, // amps
|
||||
depthAlarm: 4.5, // meters
|
||||
waterUsed: 23, // liters
|
||||
wasteWater: 18, // liters
|
||||
freshWater: 156, // liters
|
||||
}
|
||||
|
||||
// Simulate boat moving along a rough course
|
||||
@@ -60,6 +67,12 @@ export function createSignalKMock() {
|
||||
state.battery2 = randomWalk(state.battery2, 24.5, 25.6, 0.04)
|
||||
state.waterTemp = randomWalk(state.waterTemp, 16, 20, 0.05)
|
||||
state.rudder = randomWalk(state.rudder, -15, 15, 1.5)
|
||||
state.fuelRate = randomWalk(state.fuelRate, 10, 15, 0.2)
|
||||
state.alternatorOutput = randomWalk(state.alternatorOutput, 30, 60, 2)
|
||||
state.waterUsed = randomWalk(state.waterUsed, 10, 30, 0.05)
|
||||
state.wasteWater = randomWalk(state.wasteWater, 5, 25, 0.04)
|
||||
state.freshWater = randomWalk(state.freshWater, 80, 160, 0.02)
|
||||
state.engineHours += 0.016 // 1 hour per 60 seconds
|
||||
advancePosition()
|
||||
|
||||
return {
|
||||
@@ -67,20 +80,43 @@ export function createSignalKMock() {
|
||||
source: { label: 'mock', type: 'NMEA2000' },
|
||||
timestamp: new Date().toISOString(),
|
||||
values: [
|
||||
// Navigation
|
||||
{ path: 'navigation.speedOverGround', value: state.sog * 0.514 },
|
||||
{ path: 'navigation.courseOverGroundTrue', value: degToRad(state.cog) },
|
||||
{ path: 'navigation.headingTrue', value: degToRad(state.heading) },
|
||||
{ path: 'navigation.position', value: { latitude: state.lat, longitude: state.lon } },
|
||||
|
||||
// Depth & water
|
||||
{ path: 'environment.depth.belowKeel', value: state.depth },
|
||||
{ path: 'environment.water.temperature', value: state.waterTemp + 273.15 },
|
||||
|
||||
// Wind
|
||||
{ path: 'environment.wind.speedApparent', value: state.windSpeed * 0.514 },
|
||||
{ path: 'environment.wind.angleApparent', value: degToRad(state.windAngle) },
|
||||
{ path: 'environment.water.temperature', value: state.waterTemp + 273.15 },
|
||||
|
||||
// Air
|
||||
{ path: 'environment.outside.temperature', value: state.airTemp + 273.15 },
|
||||
|
||||
// Engine
|
||||
{ path: 'propulsion.main.revolutions', value: state.rpm / 60 },
|
||||
{ path: 'propulsion.main.fuelRate', value: state.fuelRate / 3600 }, // kg/s (approximated)
|
||||
{ path: 'propulsion.main.alternatorOutput', value: state.alternatorOutput },
|
||||
|
||||
// Electrical
|
||||
{ path: 'electrical.batteries.starter.voltage', value: state.battery1 },
|
||||
{ path: 'electrical.batteries.house.voltage', value: state.battery2 },
|
||||
|
||||
// Steering
|
||||
{ path: 'steering.rudderAngle', value: degToRad(state.rudder) },
|
||||
|
||||
// Tanks (as ratio 0-1)
|
||||
{ path: 'tanks.fuel.0.currentLevel', value: state.fuel / 100 },
|
||||
{ path: 'tanks.freshWater.0.currentLevel', value: state.freshWater / 200 },
|
||||
{ path: 'tanks.wasteWater.0.currentLevel', value: state.wasteWater / 50 },
|
||||
{ path: 'tanks.wasteWater.0.pumpOverride', value: state.wasteWater > 30 },
|
||||
|
||||
// Engine hours (seconds)
|
||||
{ path: 'propulsion.main.engineHours', value: state.engineHours * 3600 },
|
||||
]
|
||||
}]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user