UNPKG

@sailboat-computer/validation

Version:

Validation framework for sailboat computer v3

481 lines 13.1 kB
/** * Core types for the validation framework */ import { common, hardware_interface } from '@sailboat-computer/sailboat-types'; import type { RawSensorData, ValidatedSensorData, ValidationResult, SensorHealth, MaintenanceRecord } from '@sailboat-computer/sailboat-types/dist/hardware-interface'; export type MarineSensorTypeType = hardware_interface.MarineSensorType; export type SensorInterfaceType = hardware_interface.SensorInterface; declare const MarineSensorTypeValues: { UNKNOWN: hardware_interface.MarineSensorType; GPS: hardware_interface.MarineSensorType; COMPASS: hardware_interface.MarineSensorType; WIND: hardware_interface.MarineSensorType; DEPTH: hardware_interface.MarineSensorType; SPEED: hardware_interface.MarineSensorType; BATTERY_MONITOR: hardware_interface.MarineSensorType; SOLAR_CONTROLLER: hardware_interface.MarineSensorType; INVERTER: hardware_interface.MarineSensorType; TEMPERATURE: hardware_interface.MarineSensorType; HUMIDITY: hardware_interface.MarineSensorType; PRESSURE: hardware_interface.MarineSensorType; ENGINE_RPM: hardware_interface.MarineSensorType; ENGINE_TEMPERATURE: hardware_interface.MarineSensorType; ENGINE_PRESSURE: hardware_interface.MarineSensorType; FUEL_FLOW: hardware_interface.MarineSensorType; TANK_LEVEL: hardware_interface.MarineSensorType; FLOW_RATE: hardware_interface.MarineSensorType; PRESSURE_SENSOR: hardware_interface.MarineSensorType; ACCELEROMETER: hardware_interface.MarineSensorType; GYROSCOPE: hardware_interface.MarineSensorType; MAGNETOMETER: hardware_interface.MarineSensorType; AIS: hardware_interface.MarineSensorType; VHF: hardware_interface.MarineSensorType; }; declare const SensorInterfaceValues: { I2C: hardware_interface.SensorInterface; GPIO: hardware_interface.SensorInterface; ANALOG: hardware_interface.SensorInterface; MQTT: hardware_interface.SensorInterface; SIGNAL_K: hardware_interface.SensorInterface; VICTRON: hardware_interface.SensorInterface; SIMULATOR: hardware_interface.SensorInterface; }; declare const AlertSeverity: { INFO: common.AlertSeverity; WARNING: common.AlertSeverity; ALARM: common.AlertSeverity; CRITICAL: common.AlertSeverity; EMERGENCY: common.AlertSeverity; }; declare const HealthStatus: { HEALTHY: common.HealthStatus; DEGRADED: common.HealthStatus; UNHEALTHY: common.HealthStatus; CRITICAL: common.HealthStatus; UNKNOWN: common.HealthStatus; }; export { AlertSeverity, HealthStatus }; export { MarineSensorTypeValues as MarineSensorType, SensorInterfaceValues as SensorInterface, hardware_interface }; export type { RawSensorData, ValidatedSensorData, ValidationResult, SensorHealth, MaintenanceRecord }; export type AlertSeverityType = common.AlertSeverity; export type HealthStatusType = common.HealthStatus; /** * Confidence calculation components */ export interface ConfidenceCalculation { baseConfidence: number; validationAdjustments: { physicalValidation: number; operationalValidation: number; crossSensorValidation: number; }; sensorHealthAdjustments: { calibrationAge: number; failureHistory: number; environmentalImpact: number; }; contextualAdjustments: { operationalRelevance: number; temporalRelevance: number; }; } /** * Data source priority configuration */ export interface DataSourcePriority { dataType: string; sources: SourcePriorityRule[]; selectionStrategy: 'highest_priority' | 'weighted_average' | 'sensor_fusion'; fallbackStrategy: 'next_priority' | 'cached_data' | 'estimated_value'; } /** * Source priority rule */ export interface SourcePriorityRule { sourceId: string; basePriority: number; healthWeight: number; qualityWeight: number; confidenceThreshold: number; conditions?: { operationalContext?: string[]; environmentalConditions?: string[]; timeOfDay?: { start: string; end: string; }; }; } /** * Alternative data source information */ export interface AlternativeSource { sourceId: string; value: number | object; confidence: number; reason: string; } /** * Validation rule interface */ export interface ValidationRule { name: string; description: string; category: 'physical' | 'operational' | 'quality'; severity: AlertSeverityType; validate(data: RawSensorData, context: ValidationContext): ValidationResult; isApplicable(data: RawSensorData): boolean; getConfiguration(): Record<string, any>; } /** * Validation context for rule execution */ export interface ValidationContext { operationalContext: string; environmentalConditions: Record<string, any>; recentData: RawSensorData[]; sensorHealth: Record<string, SensorHealth>; crossSensorData: Record<string, RawSensorData>; } /** * Validation engine configuration */ export interface ValidationEngineConfig { enableBatchValidation: boolean; batchSize: number; parallelProcessing: boolean; caching: { validationRules: boolean; sensorSpecs: boolean; contextData: boolean; }; earlyTermination: { enabled: boolean; criticalRules: string[]; }; prioritization: { criticalDataFirst: boolean; healthBasedPriority: boolean; }; } /** * Validation metrics for monitoring */ export interface ValidationMetrics { throughput: { validationsPerSecond: number; averageValidationTime: number; batchProcessingEfficiency: number; }; qualityMetrics: { overallPassRate: number; ruleSpecificPassRates: Record<string, number>; confidenceDistribution: number[]; }; errorMetrics: { validationErrorRate: number; storageFailureRate: number; serviceUnavailabilityRate: number; }; healthMetrics: { sensorHealthDistribution: Record<string, number>; calibrationStatus: Record<string, Date>; maintenanceAlerts: number; }; } /** * Validation error handling configuration */ export interface ValidationErrorHandling { strategy: 'log_and_continue' | 'quarantine' | 'reject'; logAndContinue: { logLevel: 'debug' | 'info' | 'warn' | 'error'; includeInHealthMetrics: boolean; notifyThreshold: number; }; quarantine: { quarantineDuration: number; reviewRequired: boolean; alternativeSource: string; }; reject: { rejectReason: string; impactAssessment: boolean; userNotification: boolean; }; } /** * Marine-specific validation ranges */ export interface MarineValidationRanges { navigation: { gps: { position: { latitude: { min: number; max: number; }; longitude: { min: number; max: number; }; altitude: { min: number; max: number; }; }; accuracy: { hdop: { max: number; warning: number; }; satellites: { min: number; warning: number; }; }; movement: { maxSpeed: number; maxAcceleration: number; maxPositionJump: number; }; }; compass: { heading: { min: number; max: number; }; variation: { min: number; max: number; }; deviation: { min: number; max: number; }; rateOfChange: { max: number; }; }; wind: { speed: { min: number; max: number; typical: { min: number; max: number; }; }; direction: { min: number; max: number; }; gustFactor: { min: number; max: number; }; rateOfChange: { speed: { max: number; }; direction: { max: number; }; }; }; depth: { value: { min: number; max: number; }; rateOfChange: { max: number; }; }; }; environmental: { temperature: { seawater: { min: number; max: number; }; air: { min: number; max: number; }; interior: { min: number; max: number; }; rateOfChange: { max: number; }; }; pressure: { atmospheric: { min: number; max: number; typical: { min: number; max: number; }; }; rateOfChange: { max: number; }; }; humidity: { range: { min: number; max: number; }; rateOfChange: { max: number; }; }; }; electrical: { battery48v: { voltage: { min: number; max: number; normal: { min: number; max: number; }; critical: { min: number; max: number; }; }; current: { min: number; max: number; }; temperature: { min: number; max: number; charging: { min: number; max: number; }; }; }; battery12v: { voltage: { min: number; max: number; normal: { min: number; max: number; }; }; current: { min: number; max: number; }; }; solar: { voltage: { min: number; max: number; }; current: { min: number; max: number; }; power: { min: number; max: number; }; }; }; engine: { rpm: { min: number; max: number; idle: { min: number; max: number; }; cruise: { min: number; max: number; }; }; oilPressure: { min: number; max: number; idle: { min: number; max: number; }; cruise: { min: number; max: number; }; }; temperature: { min: number; max: number; normal: { min: number; max: number; }; rateOfChange: { max: number; }; }; fuelFlow: { min: number; max: number; efficiency: { min: number; max: number; }; }; }; fluidSystems: { tankLevels: { percentage: { min: number; max: number; }; rateOfChange: { max: number; }; }; pressure: { freshWater: { min: number; max: number; }; watermaker: { min: number; max: number; }; }; flowRates: { watermaker: { raw: { min: number; max: number; }; product: { min: number; max: number; }; }; }; anchor: { chainDeployed: { min: number; max: number; }; rateOfChange: { max: number; }; }; }; } //# sourceMappingURL=types.d.ts.map