{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://buildthesimulation.com/equipment/07-02/output-schema.json",
  "title": "BuildTheSimulation 07-02 sample exposure revision",
  "description":"Chamber observations clipped to extrapolation-free, half-open shelf occupancy intervals. A final leave-time knot is included to integrate up to departure.",
  "type":"object",
  "required":["schema","modelVersion","deviceId","catalogNumber","units","clock","intervalConvention","provenance","events","chamber","samples"],
  "properties":{
    "schema":{"const":"bts.incubator.exposure.v1"},
    "modelVersion":{"type":"string"},
    "deviceId":{"const":"07-02"},
    "catalogNumber":{"const":"51030285"},
    "units":{"const":{"time_s":"s","temp_C":"°C","co2_pct":"vol %"}},
    "clock":{"type":"string"},
    "intervalConvention":{"type":"string"},
    "provenance":{"type":"object","required":["kind","label","doorTiming"],"properties":{"kind":{"enum":["digitized-replay","simulated","imported"]},"label":{"type":"string"},"doorTiming":{"type":"string"},"source":{"type":"string","format":"uri"},"page":{"type":"integer"},"config":{"type":"object"}}},
    "events":{"type":"array","items":{"allOf":[{"$ref":"#/$defs/interval"},{"type":"object","required":["glass"],"properties":{"glass":{"type":"boolean"}}}]}},
    "chamber":{"$ref":"#/$defs/readings"},
    "samples":{"type":"array","minItems":1,"maxItems":12,"items":{"type":"object","required":["sampleId","shelf","enter_s","leave_s","parentRevision","revision","history","duration_s","glassOpen_s","doorIntervals","statistics","readings"],"properties":{
      "sampleId":{"type":"string","pattern":"^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$"},
      "shelf":{"type":"integer","minimum":1,"maximum":3},
      "enter_s":{"$ref":"#/$defs/time"},"leave_s":{"$ref":"#/$defs/time"},
      "parentRevision":{"type":"integer","minimum":0},"revision":{"type":"integer","minimum":1},
      "history":{"type":"array","minItems":1},"contactIds":{"type":"array","items":{"type":"string"}},
      "duration_s":{"type":"number","exclusiveMinimum":0},"glassOpen_s":{"$ref":"#/$defs/time"},
      "doorIntervals":{"type":"array","items":{"$ref":"#/$defs/interval"}},
      "statistics":{"type":"object","required":["temp_C","co2_pct"],"properties":{"temp_C":{"$ref":"#/$defs/statistic"},"co2_pct":{"$ref":"#/$defs/statistic"}}},
      "readings":{"$ref":"#/$defs/readings"}
    }}}
  },
  "$defs":{
    "time":{"type":"number","minimum":0,"maximum":7200},
    "interval":{"type":"object","required":["start_s","end_s"],"properties":{"start_s":{"$ref":"#/$defs/time"},"end_s":{"$ref":"#/$defs/time"}}},
    "readings":{"type":"array","minItems":2,"items":{"type":"object","required":["time_s","temp_C","co2_pct"],"properties":{"time_s":{"$ref":"#/$defs/time"},"temp_C":{"type":["number","null"],"minimum":0,"maximum":60},"co2_pct":{"type":["number","null"],"minimum":0,"maximum":20}}}},
    "statistic":{"type":["object","null"],"required":["min","max","mean","threshold","below_s"],"properties":{"min":{"type":"number"},"max":{"type":"number"},"mean":{"type":"number"},"threshold":{"type":"number"},"below_s":{"$ref":"#/$defs/time"}}}
  }
}
