86 lines
1.7 KiB
C
86 lines
1.7 KiB
C
// auto_trigger.h - Auto-Logging Trigger Engine
|
|
|
|
#ifndef AUTO_TRIGGER_H
|
|
#define AUTO_TRIGGER_H
|
|
|
|
#include <Arduino.h>
|
|
#include "signal_manager.h"
|
|
|
|
// Maximum trigger conditions
|
|
#define MAX_TRIGGER_CONDITIONS 10
|
|
|
|
// Trigger operators
|
|
enum TriggerOperator {
|
|
TRIGGER_OP_GREATER,
|
|
TRIGGER_OP_LESS,
|
|
TRIGGER_OP_EQUAL,
|
|
TRIGGER_OP_GREATER_EQ,
|
|
TRIGGER_OP_LESS_EQ
|
|
};
|
|
|
|
// Logical operators between conditions
|
|
enum LogicalOperator {
|
|
LOGIC_AND,
|
|
LOGIC_OR
|
|
};
|
|
|
|
// Trigger condition
|
|
struct TriggerCondition {
|
|
char signalName[32];
|
|
TriggerOperator op;
|
|
float threshold;
|
|
bool active;
|
|
};
|
|
|
|
// Trigger configuration
|
|
struct TriggerConfig {
|
|
TriggerCondition conditions[MAX_TRIGGER_CONDITIONS];
|
|
uint8_t conditionCount;
|
|
LogicalOperator logicOp;
|
|
bool enabled;
|
|
bool autoStart;
|
|
bool autoStop;
|
|
uint32_t durationMs;
|
|
};
|
|
|
|
extern TriggerConfig triggerConfig;
|
|
extern bool triggerActive;
|
|
extern bool loggingActive;
|
|
|
|
// Initialize trigger engine
|
|
void initAutoTrigger();
|
|
|
|
// Add trigger condition
|
|
bool addTriggerCondition(const char* signalName, TriggerOperator op, float threshold);
|
|
|
|
// Remove trigger condition
|
|
bool removeTriggerCondition(uint8_t index);
|
|
|
|
// Clear all conditions
|
|
void clearTriggerConditions();
|
|
|
|
// Set logical operator
|
|
void setLogicalOperator(LogicalOperator op);
|
|
|
|
// Enable/disable trigger
|
|
void enableTrigger(bool enable);
|
|
|
|
// Set auto-start/stop
|
|
void setAutoStart(bool enable);
|
|
void setAutoStop(bool enable);
|
|
|
|
// Check trigger conditions
|
|
bool checkTriggerConditions();
|
|
|
|
// Update trigger (call periodically)
|
|
void updateTrigger();
|
|
|
|
// Load/save trigger config
|
|
bool loadTriggerConfig();
|
|
bool saveTriggerConfig();
|
|
|
|
// Get trigger status JSON
|
|
void getTriggerStatusJSON(char* buffer, size_t bufferSize);
|
|
|
|
#endif // AUTO_TRIGGER_H
|