Aquarium Cooling Controller
ESP32 firmware for aquarium cooling fan control, monitoring, telemetry, and fault handling.
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions
fault_policy.h File Reference

Converts sensor and fan health into alarms, severity, and responses. More...

#include <Arduino.h>
#include "control_engine.h"
#include "fault_monitor.h"
Include dependency graph for fault_policy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FaultPolicySnapshot
 Complete policy decision for diagnostics and telemetry. More...
 

Namespaces

namespace  FaultPolicy
 Fault classification and telemetry labeling helpers.
 

Enumerations

enum class  AlarmCode : uint8_t { kNone , kWaterSensorFault , kFanFault , kWaterSensorAndFanFault }
 Stable alarm identifiers for telemetry and diagnostics. More...
 
enum class  FaultSeverity : uint8_t { kNone , kWarning , kCritical }
 Severity assigned to the current fault state. More...
 
enum class  FaultResponse : uint8_t { kNormalControl , kWaterFallback , kReportFanFault , kWaterFallbackAndReportFanFault }
 Control response selected for the current fault state. More...
 

Functions

FaultPolicySnapshot FaultPolicy::evaluate (const ControlSnapshot &controlSnapshot, const FaultMonitorSnapshot &faultSnapshot)
 Evaluates alarms and fault response from control and fan-monitor state.
 
const char * FaultPolicy::alarmCodeLabel (AlarmCode alarmCode)
 Converts an alarm code to a telemetry-safe label.
 
const char * FaultPolicy::severityLabel (FaultSeverity severity)
 Converts a severity value to a telemetry-safe label.
 
const char * FaultPolicy::responseLabel (FaultResponse response)
 Converts a fault response to a telemetry-safe label.
 

Detailed Description

Converts sensor and fan health into alarms, severity, and responses.

The policy layer keeps fault interpretation separate from control calculation and raw fan plausibility checks. It turns those lower-level snapshots into user-facing alarm codes and high-level response categories for telemetry.

Enumeration Type Documentation

◆ AlarmCode

enum class AlarmCode : uint8_t
strong

Stable alarm identifiers for telemetry and diagnostics.

Alarm codes are deliberately coarse and stable. They describe the externally relevant fault combination instead of exposing every internal counter or plausibility detail from the monitor.

Enumerator
kNone 

No active alarm.

kWaterSensorFault 

Water sensor is invalid.

kFanFault 

Fan RPM plausibility fault is active.

kWaterSensorAndFanFault 

Water sensor and fan faults are active together.

◆ FaultResponse

enum class FaultResponse : uint8_t
strong

Control response selected for the current fault state.

The response is a compact explanation of how the firmware should behave under the current fault combination. It is also published to MQTT so external integrations can react without duplicating firmware policy logic.

Enumerator
kNormalControl 

Continue normal control behavior.

kWaterFallback 

Use fallback PWM because water input is invalid.

kReportFanFault 

Continue commanding cooling but report fan fault.

kWaterFallbackAndReportFanFault 

Use fallback PWM and report fan fault.

◆ FaultSeverity

enum class FaultSeverity : uint8_t
strong

Severity assigned to the current fault state.

Severity expresses how much attention the fault needs. Water-sensor and fan faults are critical because cooling quality or cooling capacity is degraded.

Enumerator
kNone 

No service action required.

kWarning 

Degraded input but cooling can continue.

kCritical 

Cooling is degraded or requires service attention.