Scaffolding
This commit is contained in:
1 parent
bd1d65ab88
commit
3f9e1fef4f
2 files changed
+237
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,237 @@
|
||||
export type TimeSeriesPoint = { ts: number; value: number };
|
||||
|
||||
export type BagAnnotation = {
|
||||
type: 'mycelium' | 'contamination' | 'fruiting' | 'pinning';
|
||||
x: number;
|
||||
y: number;
|
||||
radius: number;
|
||||
confidence: number;
|
||||
};
|
||||
|
||||
export type BagSnapshot = {
|
||||
ts: number;
|
||||
image_url: string;
|
||||
colonization_pct: number;
|
||||
contamination_risk: 'none' | 'low' | 'medium' | 'high';
|
||||
annotations: BagAnnotation[];
|
||||
};
|
||||
|
||||
export type BagVision = {
|
||||
colonization_pct: number;
|
||||
colonization_confidence: number;
|
||||
contamination_risk: 'none' | 'low' | 'medium' | 'high';
|
||||
contamination_confidence: number;
|
||||
stage: 'inoculation' | 'colonization' | 'pinning' | 'fruiting' | 'harvest';
|
||||
snapshots: BagSnapshot[];
|
||||
projection: {
|
||||
estimated_ready_ts: number;
|
||||
colonization_curve: TimeSeriesPoint[];
|
||||
};
|
||||
};
|
||||
|
||||
export type BagTag = {
|
||||
strain_code: string;
|
||||
strain_name: string; // human-friendly name: "Blue Oyster", "Lion's Mane"
|
||||
substrate: string;
|
||||
inoculated_ts: number;
|
||||
batch_id: string;
|
||||
};
|
||||
|
||||
export type BagState = {
|
||||
bag_id: string;
|
||||
slot_id: string;
|
||||
tag: BagTag;
|
||||
vision: BagVision;
|
||||
};
|
||||
|
||||
export type ChamberSlot = {
|
||||
slot_id: string;
|
||||
position: { x: number; y: number; z: number };
|
||||
bag: BagState | null;
|
||||
};
|
||||
|
||||
export type ChamberEnvironment = {
|
||||
temp_c: number;
|
||||
rh_pct: number;
|
||||
co2_ppm?: number; // fruiting chamber
|
||||
co2e_ppm?: number; // colonization chamber
|
||||
voc_ppb: number;
|
||||
};
|
||||
|
||||
export type Chamber = {
|
||||
id: string;
|
||||
label: string;
|
||||
type: 'colonization' | 'fruiting';
|
||||
environment: ChamberEnvironment;
|
||||
slots: ChamberSlot[];
|
||||
};
|
||||
|
||||
export type EnvironmentReading = {
|
||||
ts: number;
|
||||
temp_c: number;
|
||||
rh_pct: number;
|
||||
co2_ppm: number;
|
||||
co2e_ppm?: number;
|
||||
voc_ppb: number;
|
||||
vpd: number;
|
||||
};
|
||||
|
||||
export type RecipeStage = 'inoculation' | 'colonization' | 'pinning' | 'fruiting' | 'harvest';
|
||||
|
||||
export type CultivarState = {
|
||||
meta: {
|
||||
device_id: string;
|
||||
firmware_version: string;
|
||||
uptime_s: number;
|
||||
wifi_rssi: number;
|
||||
timestamp_utc: number;
|
||||
};
|
||||
environment: {
|
||||
history: EnvironmentReading[];
|
||||
live: Omit<EnvironmentReading, 'ts'>;
|
||||
targets: { temp_c: number; rh_pct: number; co2_ppm: number };
|
||||
alerts: Array<{
|
||||
id: string;
|
||||
type: string;
|
||||
severity: 'info' | 'warn' | 'critical';
|
||||
message: string;
|
||||
ts: number;
|
||||
dismissed: boolean;
|
||||
}>;
|
||||
};
|
||||
chambers: Chamber[];
|
||||
hardware: {
|
||||
/** Each compartment has its own FAE fan */
|
||||
fans: Array<{ id: string; chamber_id: string; speed_pct: number; mode: 'auto' | 'manual' }>;
|
||||
/** One ultrasonic humidifier in the base, feeding both compartments */
|
||||
humidifier: { active: boolean; mode: 'auto' | 'manual'; reservoir_pct: number };
|
||||
/** Per-compartment lighting — colonization has a work/photo light,
|
||||
* fruiting has a grow/display light. No grow light in colonization. */
|
||||
lights: Array<{
|
||||
id: string;
|
||||
chamber_id: string;
|
||||
purpose: 'work' | 'grow' | 'photo';
|
||||
on: boolean;
|
||||
color_hex: string;
|
||||
brightness: number;
|
||||
}>;
|
||||
/** Reed-switch door sensors, one per compartment door */
|
||||
doors: Array<{ id: string; chamber_id: string; open: boolean }>;
|
||||
cameras: Array<{ id: string; chamber_id: string; position: string; last_capture_ts: number }>;
|
||||
};
|
||||
recipe: {
|
||||
id: string;
|
||||
name: string;
|
||||
species: string;
|
||||
stage: RecipeStage;
|
||||
stage_started_ts: number;
|
||||
stage_target_duration_h: number;
|
||||
stage_history: Array<{ stage: RecipeStage; started_ts: number; ended_ts: number | null }>;
|
||||
next_actions: Array<{ type: string; due_ts: number; description: string }>;
|
||||
};
|
||||
/** Recurring maintenance tasks the user handles by hand */
|
||||
maintenance: {
|
||||
/** Last time chamber walls + racks were wiped with 70% iso — every 2 weeks */
|
||||
last_wipe_ts: number;
|
||||
/** Last time humidifier reservoir was hand- or dishwasher-washed — every 4 weeks */
|
||||
last_reservoir_clean_ts: number;
|
||||
};
|
||||
ui: {
|
||||
selected_bag_id: string | null;
|
||||
onboarding_complete: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
export type WsDiff = {
|
||||
t: number;
|
||||
e?: { temp?: number; rh?: number; co2?: number; voc?: number; vpd?: number };
|
||||
hw?: { fans?: number[]; humidifier?: boolean; lights?: boolean[]; doors?: boolean[] };
|
||||
};
|
||||
|
||||
// Friendly stage names for display
|
||||
export const STAGE_LABELS: Record<BagVision['stage'], string> = {
|
||||
inoculation: 'Inoculated',
|
||||
colonization: 'Colonizing',
|
||||
pinning: 'Pinning',
|
||||
fruiting: 'Fruiting',
|
||||
harvest: 'Ready',
|
||||
};
|
||||
|
||||
// ── Sensor sweep data ─────────────────────────────────────────────────────
|
||||
|
||||
export type GasSweepPoint = {
|
||||
heater_temp_c: number;
|
||||
heater_dur_ms: number;
|
||||
zone: 1 | 2 | 3;
|
||||
resistance_raw: number;
|
||||
resistance_corr: number | null; // humidity corrected
|
||||
resistance_norm: number | null; // baseline normalized
|
||||
heater_stable: boolean;
|
||||
valid: boolean;
|
||||
};
|
||||
|
||||
export type ZoneScores = {
|
||||
Z1: number | null; // baseline zone — humidity/CO2 proxy
|
||||
Z2: number | null; // biological zone — mycelium/contamination
|
||||
Z3: number | null; // heavy zone — ammonia/sulfur
|
||||
};
|
||||
|
||||
export type SweepBaseline = {
|
||||
established: boolean;
|
||||
established_at: number | null;
|
||||
n_samples: number;
|
||||
R: Record<number, number>; // heater_temp_c → baseline resistance
|
||||
humidity_ref: number;
|
||||
temp_ref: number;
|
||||
co2_ref: number | null;
|
||||
};
|
||||
|
||||
export type SensorHealth = {
|
||||
scd43_present: boolean;
|
||||
temp_delta: number | null;
|
||||
humidity_delta: number | null;
|
||||
temp_ok: boolean;
|
||||
humidity_ok: boolean;
|
||||
};
|
||||
|
||||
export type EnvPayload = {
|
||||
ts: number;
|
||||
chamber_id: string;
|
||||
ambient: {
|
||||
temp_c: number;
|
||||
humidity_pct: number;
|
||||
pressure_hpa: number;
|
||||
valid: boolean;
|
||||
};
|
||||
co2: {
|
||||
ppm: number;
|
||||
valid: boolean;
|
||||
} | null;
|
||||
co2e_ppm: number | null; // derived on Linux side
|
||||
co2e_confidence: 'uncalibrated' | 'low' | 'medium' | 'high';
|
||||
voc_ppb: number | null; // Zone 2 score scaled
|
||||
sweep: GasSweepPoint[];
|
||||
zone_scores: ZoneScores;
|
||||
baseline: SweepBaseline;
|
||||
health: SensorHealth;
|
||||
anomalies: EnvAnomaly[];
|
||||
};
|
||||
|
||||
export type EnvAnomalyType =
|
||||
| 'z2_deviation' // biological zone shifted from baseline
|
||||
| 'z3_spike' // ammonia/sulfur detected
|
||||
| 'co2_threshold' // species CO2 limit exceeded
|
||||
| 'humidity_drift' // sensor cross-validation failed
|
||||
| 'temp_drift' // sensor cross-validation failed
|
||||
| 'baseline_unstable'; // baseline variance too high
|
||||
|
||||
export type EnvAnomaly = {
|
||||
id: string;
|
||||
type: EnvAnomalyType;
|
||||
severity: 'info' | 'warn' | 'critical';
|
||||
chamber_id: string;
|
||||
message: string; // human-readable, Cultivar-voice
|
||||
contaminant_hint?: string; // CONT-xxx id if applicable
|
||||
ts: number;
|
||||
dismissed: boolean;
|
||||
};
|
||||
Reference in new issue
Block a user