模板

一个项目的全部能力定义都在同一份声明式 iot.yaml 文件里:设备能力、安全边界、槽位、规则与告警。

下载 catalog.json
安全互锁 许可协议: MIT OR Apache-2.0 待 CI 核验

智能机房

加热与制冷跨设备互锁,杜绝同时通电;带对端数据新鲜度校验与看门狗安全值回落。

/templates/smart-server-room/iot.yaml (MIT OR Apache-2.0)
# SPDX-FileCopyrightText: IoT Platform contributors
# SPDX-License-Identifier: MIT OR Apache-2.0
schema_version: project-spec/v1
project_name: Smart server room
timezone: UTC
products:
  - schema_version: tsl/v1
    product_id: room_hvac
    version: "1.0.0"
    display_name: Room HVAC controller
    worst_case_latency_ms: 250
    properties:
      - {id: temperature, data_type: fixed_i64, scale: 1, unit: "°C", access: r, min_scaled: -400, max_scaled: 1000}
      - {id: heater, data_type: bool, access: rw, safe_value: false, on_boot: safe_value, lease_max_ms: 60000, max_continuous_ms: 600000}
      - {id: cooler, data_type: bool, access: rw, safe_value: false, on_boot: safe_value, lease_max_ms: 60000, max_continuous_ms: 600000}
    events: []
    services:
      - {id: heat, risk: normal, inputs: {}, physical_writes: {heater: {constant: true}, cooler: {constant: false}}}
      - {id: cool, risk: normal, inputs: {}, physical_writes: {heater: {constant: false}, cooler: {constant: true}}}
      - {id: idle, risk: normal, inputs: {}, physical_writes: {heater: {constant: false}, cooler: {constant: false}}}
    safety_invariants:
      device_local:
        interlocks:
          - id: heat_cool_exclusion
            forbidden_when_all_true:
              - {property_id: heater, op: eq, value: true}
              - {property_id: cooler, op: eq, value: true}
        dwell_and_slew:
          - {property_id: heater, min_dwell_sec: 15}
          - {property_id: cooler, min_dwell_sec: 45}
    release_ranges:
      properties: {heater: {values: [false, true]}, cooler: {values: [false, true]}}
      services: {heat: {allowed: true, params: {}}, cool: {allowed: true, params: {}}, idle: {allowed: true, params: {}}}
slots:
  - slot_id: rack_room
    product_ref: room_hvac@1.0.0
    cardinality: single
    alert_ranges: {temperature: {min_scaled: 160, max_scaled: 295}}
automation:
  rules:
    - id: cool_warm_room
      enabled: true
      execution_mode: shadow
      trigger: {slot_id: rack_room, property_id: temperature, op: gte, value: 275}
      action: {target_slot_id: rack_room, service_id: cool, params: {}}
    - id: heat_cold_room
      enabled: true
      execution_mode: shadow
      trigger: {slot_id: rack_room, property_id: temperature, op: lt, value: 175}
      action: {target_slot_id: rack_room, service_id: heat, params: {}}
  alerts:
    - {id: room_temperature, slot_id: rack_room, severity: warn, for_duration_sec: 30, cooldown_sec: 300}
ui_templates:
  - id: room_panel
    target: device_panel
    widgets:
      - {type: gauge, label: Room temperature, binding: temperature}
      - {type: status, label: Heating contactor, binding: heater}
      - {type: status, label: Cooling contactor, binding: cooler}
安全互锁 许可协议: MIT OR Apache-2.0 待 CI 核验

工业继电器与巡检

正反转互锁叠加最小冷却停留时间与变化率限制,可配合告警抓拍巡检。

说明:告警触发相机抓拍与媒体动作属于 Stage 4 媒体能力集。

/templates/industrial-relay/iot.yaml (MIT OR Apache-2.0)
# SPDX-FileCopyrightText: IoT Platform contributors
# SPDX-License-Identifier: MIT OR Apache-2.0
schema_version: project-spec/v1
project_name: Industrial relay and inspection camera
timezone: UTC
products:
  - schema_version: tsl/v1
    product_id: reversing_relay
    version: "1.0.0"
    worst_case_latency_ms: 100
    properties:
      - {id: forward, data_type: bool, access: rw, safe_value: false, on_boot: safe_value, lease_max_ms: 10000, max_continuous_ms: 60000}
      - {id: reverse, data_type: bool, access: rw, safe_value: false, on_boot: safe_value, lease_max_ms: 10000, max_continuous_ms: 60000}
      - {id: drive_fault, data_type: bool, access: r}
    services:
      - {id: jog_forward, risk: normal, inputs: {}, physical_writes: {forward: {constant: true}, reverse: {constant: false}}}
      - {id: jog_reverse, risk: high, inputs: {}, physical_writes: {forward: {constant: false}, reverse: {constant: true}}}
      - {id: stop_motor, risk: normal, inputs: {}, physical_writes: {forward: {constant: false}, reverse: {constant: false}}}
    events: []
    safety_invariants:
      device_local:
        interlocks:
          - id: opposing_contactors
            forbidden_when_all_true:
              - {property_id: forward, op: eq, value: true}
              - {property_id: reverse, op: eq, value: true}
          - id: trip_blocks_forward
            forbidden_when_all_true:
              - {property_id: drive_fault, op: eq, value: true}
              - {property_id: forward, op: eq, value: true}
          - id: trip_blocks_reverse
            forbidden_when_all_true:
              - {property_id: drive_fault, op: eq, value: true}
              - {property_id: reverse, op: eq, value: true}
        dwell_and_slew:
          - {property_id: forward, min_dwell_sec: 5}
          - {property_id: reverse, min_dwell_sec: 5}
    release_ranges:
      properties: {forward: {values: [false, true]}, reverse: {values: [false]}}
      services: {jog_forward: {allowed: true, params: {}}, jog_reverse: {allowed: false, params: {}}, stop_motor: {allowed: true, params: {}}}
  - schema_version: tsl/v1
    product_id: inspection_camera
    version: "1.0.0"
    properties:
      - {id: trip_contact, data_type: bool, access: r, display_name: Drive trip input}
    events: []
    services: []
    safety_invariants: {device_local: {}}
slots:
  - {slot_id: motor, product_ref: reversing_relay@1.0.0, cardinality: single}
  - slot_id: inspection
    product_ref: inspection_camera@1.0.0
    cardinality: single
    alert_ranges: {trip_contact: {values: [false]}}
automation:
  alerts:
    - {id: inspect_drive_trip, slot_id: inspection, severity: error, for_duration_sec: 1, cooldown_sec: 120, capture_snapshot: true}
  rules:
    - id: stop_on_trip
      enabled: true
      execution_mode: shadow
      trigger: {slot_id: motor, property_id: drive_fault, op: eq, value: true}
      action: {target_slot_id: motor, service_id: stop_motor, params: {}}
ui_templates:
  - id: inspection_status
    target: project_home
    widgets:
      - {type: status, label: Forward contactor, binding: forward}
      - {type: status, label: Reverse contactor, binding: reverse}
      - {type: status, label: Camera trip input, binding: trip_contact}
AI 试跑 许可协议: MIT OR Apache-2.0 待 CI 核验

温室 AI 控制

先在试跑模式观察并用 7 天历史回放测算,确认后再切为范围内自动、超范围逐条审批。

/templates/greenhouse-ai/iot.yaml (MIT OR Apache-2.0)
# SPDX-FileCopyrightText: IoT Platform contributors
# SPDX-License-Identifier: MIT OR Apache-2.0
schema_version: project-spec/v1
project_name: Greenhouse AI control
timezone: UTC
products:
  - schema_version: tsl/v1
    product_id: greenhouse_heater
    version: "1.0.0"
    worst_case_latency_ms: 500
    properties:
      - {id: temperature, data_type: fixed_i64, scale: 1, access: r, unit: "°C", min_scaled: -300, max_scaled: 800}
      - {id: fan_rpm, data_type: i64, access: r, unit: rpm, min_scaled: 0, max_scaled: 6000}
      - {id: heater_power, data_type: i64, access: rw, unit: W, min_scaled: 0, max_scaled: 2000, safe_value: 0, on_boot: safe_value, lease_max_ms: 30000, max_continuous_ms: 300000}
    events: []
    services:
      - id: set_heat
        risk: high
        inputs: {watts: i64}
        physical_writes: {heater_power: {argument: watts}}
    safety_invariants:
      device_local:
        hard_envelopes: [{property_id: heater_power, hard_min_scaled: 0, hard_max_scaled: 2000}]
        interlocks:
          - id: airflow_before_heat
            forbidden_when_all_true:
              - {property_id: heater_power, op: gt, value: 0}
              - {property_id: fan_rpm, op: lt, value: 800}
        dwell_and_slew:
          - {property_id: heater_power, min_dwell_sec: 10, max_delta_per_min_scaled: 900}
    release_ranges:
      properties: {heater_power: {min_scaled: 0, max_scaled: 800}}
      services: {set_heat: {allowed: true, params: {watts: {min_scaled: 0, max_scaled: 800}}}}
slots:
  - slot_id: seedlings
    product_ref: greenhouse_heater@1.0.0
    cardinality: single
    release_ranges:
      properties: {heater_power: {min_scaled: 0, max_scaled: 0}}
      services: {set_heat: {allowed: true, params: {watts: {min_scaled: 0, max_scaled: 0}}}}
    alert_ranges: {temperature: {min_scaled: 120, max_scaled: 300}}
automation:
  rules:
    - id: cold_seedlings
      enabled: true
      execution_mode: shadow
      trigger: {slot_id: seedlings, property_id: temperature, op: lt, value: 160}
      action: {target_slot_id: seedlings, service_id: set_heat, params: {watts: 400}}
  schedules:
    - {id: predawn_heat, cron: "30 5 * * *", timezone: UTC, execution_mode: shadow, target_slot_id: seedlings, service_id: set_heat, params: {watts: 400}}
  alerts:
    - {id: seedling_temperature, slot_id: seedlings, severity: warn, for_duration_sec: 60, cooldown_sec: 600}
ui_templates:
  - id: seedling_panel
    target: device_panel
    widgets:
      - {type: metric, label: Canopy temperature, binding: temperature}
      - {type: gauge, label: Measured fan speed, binding: fan_rpm}
      - {type: metric, label: Applied heater power, binding: heater_power}
支持 2D 平面图空间编辑、声明式界面布局与开源规范 iot.yaml 模板目录;扩展社区投稿将在实板门禁完成后开放。