Examples

Frontend Example (Operator UI)

The upstream frontend_example.py — start StationServer on port 4444, launch the browser Operator UI, and run the same test five times in a row with a DUT ID prompt between runs.

Last updated · Verified with OpenHTF 1.6.1

The minimal Operator UI setup: a station server, the browser launcher, and a loop that runs the test repeatedly so the station stays up between units. Based on examples/frontend_example.py.

frontend_example.py
import openhtf as htf
from openhtf.output.servers import station_server
from openhtf.output.web_gui import web_launcher
from openhtf.plugs import user_input
from openhtf.util import configuration

CONF = configuration.CONF


@htf.measures(htf.Measurement('hello_world_measurement'))
def hello_world(test):
    test.logger.info('Hello World!')
    test.measurements.hello_world_measurement = 'Hello Again!'


def main():
    CONF.load(station_server_port='4444')
    with station_server.StationServer() as server:
        web_launcher.launch('http://localhost:4444')
        for _ in range(5):
            test = htf.Test(hello_world)
            test.add_output_callbacks(server.publish_final_state)
            test.execute(test_start=user_input.prompt_for_test_start())


if __name__ == '__main__':
    main()
Terminal
python frontend_example.py

The default browser opens http://localhost:4444, shows the station, and prompts for a DUT ID. Enter one in the browser or the console; the phase runs, the result appears in the history panel, and the prompt returns for the next unit. After five units the server stops.

What it shows

CONF.load(station_server_port='4444')

The server reads its port from configuration. Default 0 picks a free port, which is fine for a bench but not for a bookmarked URL. Configuration →

with station_server.StationServer() as server

Starts the Tornado server in a background thread and stops it on exit. Optional history_path shows past JSON records in the UI. Operator UI →

web_launcher.launch(url)

Opens the URL in the default browser. Omit it on a kiosk that already points a browser at the station.

server.publish_final_state

An output callback that pushes the finished record to the UI's history. Without it the UI only shows the live test.

for _ in range(5)

execute() runs one DUT. A production station loops forever (while True) and lets the operator abort with Ctrl-C.

Production notes

  • The UI is served on localhost without authentication. To reach it from another machine bind the host's IP and firewall accordingly, or use the multi-station dashboard to list stations on the LAN.
  • For HTTPS, user accounts, multiple tests per station and searchable history across stations, TofuPilot's Operator UI runs the same script unchanged.
  • If the page is blank, see the FAQ.

Next

On this page

First-pass yield
0%4.1
Track with TofuPilot