Skip to content

TestDevice

A simulated instrument for learning and testing. No hardware required — all values are stored in memory. Always available, doesn't count against your connector limit. Includes a synthetic video stream and exercises every supported data type.

Safety gate

This driver keeps requiresSafetyGates: true on purpose, so it's the canonical sandbox for exploring the safety gate — try out limits, confirmations, simulate/block at each level, and audit log entries against it without risking real hardware.

Properties

Scalars

PropertyTypeAccessUnitDescription
labelstringR/WDevice label (default: "Test Device")
countintR/WEvent counter (increments with each stream tick)
temperaturedoubleR/W°CSimulated temperature (default: 22.5)
enabledboolR/WWhether the device is active
streamingboolR/WEnable/disable stream output
thresholddoubleR/WAlert threshold value (default: 50.0)
uptimedoubleRsSeconds since initialization (computed)

Arrays

PropertyTypeAccessDescription
spectrumdouble[]RSample spectrum data (10 sine-wave points)
histogramint[]RSample histogram (8 random bins, 0–100)
tagsstring[]R/WUser-defined string tags (default: ["test", "dev"])

Complex

PropertyTypeAccessDescription
logsstring[]RRecent log messages (last 20 entries)
statusobjectRComposite status: { label, enabled, temperature, count, uptime }
configobjectR/WArbitrary key-value config dictionary (default: { mode: "normal", verbose: false })
snapshotstringRCurrent video frame as base64-encoded JPEG

Actions

ActionArgsReturnsDescription
reset"OK"Reset all values to defaults
setThreshold{ value: double }"OK"Set the alert threshold
calculate{ a: double, b: double }doubleAdd two numbers and return the result
configure{ key: string, value: string }stringSet a named config value
loadProfile{ values: double[] }intLoad a numeric profile array, returns its length
filterTags{ tags: string[], prefix: string }string[]Filter tags by prefix and return matches
echo{ data: object }objectReturn the input object unchanged (object I/O test)
setBatch{ values: object }intSet multiple properties at once, returns count updated

Streams

StreamFormatRateDescription
dataJSON500ms{ timestamp, temperature, count, enabled }
videobase64 JPEG~10 FPSSynthetic animated frames — gradient background, bouncing dot, temperature bar, and overlaid text

Config Options

OptionTypeDefaultDescription
dashboardPortint9999Port for the built-in HTTP test dashboard
labelstring"Test Device"Initial label value
temperaturedouble22.5Initial temperature value
videoFpsint10Synthetic video frame rate
videoWidthint320Video frame width in pixels
videoHeightint240Video frame height in pixels

Built-in Dashboard

The driver runs a self-contained HTTP dashboard at http://localhost:<dashboardPort>/ (default 9999). It provides:

  • Live scalar and complex property display with type badges
  • Video stream viewer (refreshes at ~5 FPS)
  • Interactive controls for all writable properties (including tags and config)
  • Action execution with argument inputs for every action type
  • Result display for action return values
  • Log viewer
  • CLI reference guide

Example Connector

javascript
// workspace/connectors/test-device.js
//
// Driver dashboard GUI: http://localhost:9999/
export default {
  driver: "TestDevice",
  config: {
    label: "My Test",
    temperature: 25.0,
  },
  poll: ["temperature", "count", "enabled", "threshold", "tags"],
};

Example Script

javascript
const dev = connector("test-device");

// Scalars — property write (assignment) and read (no parens)
dev.temperature = 50;
log.info(`Temperature: ${dev.temperature}°C`);

// Actions with different arg types
const sum = dev.calculate({ a: 3, b: 4 });
log.info(`3 + 4 = ${sum}`);

// Array I/O — property write/read + action
dev.tags = ["sensor", "lab", "test"];
const filtered = dev.filterTags({ tags: dev.tags, prefix: "se" });
log.info(`Filtered: ${JSON.stringify(filtered)}`);

// Object I/O
const echoed = dev.echo({ data: { x: 1, nested: [2, 3] } });
log.info(`Echo: ${JSON.stringify(echoed)}`);

// Batch update
dev.setBatch({ values: { label: "Batch", temperature: 42, enabled: true } });

dev.reset();

Muxit — Hardware Orchestration Platform