Boolean
Record boolean values with equality validation.
You can create a boolean measurement with measurements:
measurements:
- name: Device Connected
validators:
- operator: "=="
expected_value: trueYou can set the measurement value in your Python phase:
def check_connection(run, measurements, device):
connected = device.is_connected()
measurements.device_connected = connected Definition
You can configure the measurement name and metadata.
| Property | Type | Required | Description |
|---|---|---|---|
key | string | No | Unique identifier for the measurement within the phase |
name | string | Yes | Display name (1-100 characters) |
unit | string | No | Measurement unit (max 50 characters) |
description | string | No | Detailed description (max 50,000 characters) |
TofuPilot auto-generates the key from name (snake_case) if not specified, and uses it for Python access (e.g., measurements.device_connected). The unit and description display in the web interface and reports.
Validators
You can add one or several validators to your measurement using the following properties:
| Property | Type | Required | Description |
|---|---|---|---|
operator | string | Yes | Comparison operator |
expected_value | boolean | Yes | Expected boolean value |
You can use the following operators for boolean measurements:
| Operator | Expected Value | Description | Example |
|---|---|---|---|
== | Boolean | Value must equal expected | expected_value: true |
!= | Boolean | Value must not equal expected | expected_value: false |
TofuPilot evaluates validators and sets the outcome to Pass if met, Fail if not, or Unset if no value provided.
Examples
Connection Verification
We will verify device connection is established:
phases:
- name: Connection Test
python:
module: verify_connection
measurements:
- name: Device Connected
description: Verify USB connection to device
validators:
- operator: "=="
expected_value: truedef verify_connection(run, measurements, device):
log.info("Checking device connection")
connected = device.is_connected()
measurements.device_connected = connected
if not connected:
log.error("Device not connected")Multiple Boolean Checks
We will check multiple device states in one phase:
phases:
- name: Error Check
python:
module: check_errors
measurements:
- name: Error State Active
description: Check if device is reporting errors
validators:
- operator: "!="
expected_value: true
- name: System Ready
description: Check if device is ready for testing
validators:
- operator: "=="
expected_value: truedef check_errors(run, measurements, device):
log.info("Checking device error state")
error_active = device.has_errors()
measurements.error_state_active = error_active
if error_active:
log.error("Device reporting errors")
ready = device.is_ready()
measurements.system_ready = ready
if not ready:
log.warning("Device not ready")How is this guide?