138 lines
4 KiB
Text
138 lines
4 KiB
Text
// TemperatureMonitor.speck
|
|
// IoT with constraint-based verification
|
|
//
|
|
// Provenance: IoT sensor monitoring system for industrial safety.
|
|
// All temperature readings must be verified against safety constraints
|
|
// before triggering alerts or actions.
|
|
//
|
|
// SpeckBOM: Full BOM including sensor firmware hashes and
|
|
// constraint verification results for compliance.
|
|
//
|
|
// Author: Industrial IoT Team <iot@scoble.me>
|
|
// Source: Safety Critical Systems Design Review, ISO 13849 Compliance
|
|
|
|
speck TemperatureMonitor {
|
|
// SpeckBOM - declare toolchain and firmware hashes
|
|
bom {
|
|
compiler: "speckl-compile" version "0.2.0"
|
|
solver: "z3" version "4.12.5"
|
|
runtime: "wasm-runtime" version "1.0.0"
|
|
license: "MIT"
|
|
hash: "sha256: TemperatureMonitor-base-v1"
|
|
}
|
|
|
|
// Intent provenance - safety and compliance context
|
|
provenance {
|
|
regulation: "ISO 13849" // Machinery safety
|
|
regulation: "IEC 62061" // Functional safety
|
|
design_decision: "ADR-0048 Industrial IoT Architecture"
|
|
external_doc: "ISO 13849-2:2015 Annex B" at "https://www.iso.org/standard/59384.html"
|
|
external_doc: "IEC 62061:2021" at "https://www.iec.ch/dynamic/publication/62061"
|
|
}
|
|
|
|
// Traceability to safety requirements
|
|
satisfies SAFETY-REQ-001
|
|
satisfies SAFETY-REQ-002 clause "5.3.1"
|
|
satisfies ISO-13849-5 clause "Performance Level requirements"
|
|
|
|
// Authorship and origin
|
|
author: "Industrial IoT Team" <"iot@scoble.me">
|
|
source: architecture_review ref "AR-2024-0520"
|
|
source: compliance_audit ref "AUDIT-2024-INDUSTRY-001"
|
|
|
|
// Verification boundary - automatic verification for sensor data
|
|
review: auto
|
|
|
|
// Derives from sensor base, satisfies safety requirements
|
|
derives from SensorMonitor via "temperature-specific monitoring logic"
|
|
satisfies SENSOR-REQ-001
|
|
|
|
// Input: sensor readings and configuration
|
|
input: {
|
|
currentTemp: Real, // Current temperature reading (°C)
|
|
ambientTemp: Real, // Ambient temperature (°C)
|
|
setPoint: Real, // Target temperature (°C)
|
|
maxTemp: Real, // Maximum safe temperature (°C)
|
|
minTemp: Real, // Minimum safe temperature (°C)
|
|
hysteresis: Real, // Hysteresis band (°C)
|
|
sensorId: String, // Sensor identifier
|
|
calibrationOffset: Real // Calibration offset (°C)
|
|
}
|
|
|
|
// Output: monitoring result and actions
|
|
output: {
|
|
status: TempStatus,
|
|
alert: Bool,
|
|
action: TempAction,
|
|
safe: Bool,
|
|
deviation: Real,
|
|
timeInAlert: Real
|
|
}
|
|
|
|
// Constraints - temperature safety invariants
|
|
constraint: maxTemp > setPoint
|
|
constraint: setPoint > minTemp
|
|
constraint: hysteresis > 0
|
|
constraint: hysteresis < (maxTemp - minTemp) / 2
|
|
constraint: calibrationOffset >= -10
|
|
constraint: calibrationOffset <= 10
|
|
|
|
// Safety constraint - deviation must be within bounds
|
|
constraint: implies(safe, deviation <= hysteresis)
|
|
constraint: implies(not safe, deviation > hysteresis)
|
|
|
|
// Temperature range constraints
|
|
constraint: currentTemp >= minTemp - 20 // Allow temporary excursions
|
|
constraint: currentTemp <= maxTemp + 20
|
|
constraint: ambientTemp >= -40
|
|
constraint: ambientTemp <= 85
|
|
|
|
// Verification: alert logic is correct
|
|
verify: always(implies(
|
|
currentTemp > maxTemp + hysteresis,
|
|
alert
|
|
))
|
|
|
|
verify: always(implies(
|
|
currentTemp < minTemp - hysteresis,
|
|
alert
|
|
))
|
|
|
|
verify: always(implies(
|
|
alert,
|
|
action in [EmergencyShutDown, Warning, Override]
|
|
))
|
|
|
|
verify: always(implies(
|
|
not alert,
|
|
action == NormalOperation
|
|
))
|
|
|
|
// Events for safety audit trail
|
|
event TemperatureReading {
|
|
sensorId: String
|
|
temperature: Real
|
|
timestamp: Nat
|
|
}
|
|
|
|
event TemperatureAlert {
|
|
sensorId: String
|
|
temperature: Real
|
|
threshold: Real
|
|
alertType: String
|
|
timestamp: Nat
|
|
}
|
|
|
|
event SafetyAction {
|
|
sensorId: String
|
|
action: String
|
|
timestamp: Nat
|
|
}
|
|
|
|
event CalibrationWarning {
|
|
sensorId: String
|
|
offset: Real
|
|
reason: String
|
|
timestamp: Nat
|
|
}
|
|
}
|