Full workflow example
The examples below bring together the steps from the previous guides. The first uses the high-level RunController.Run command and is the simplest way to execute a preconfigured method. The second uses the reusable step functions from the shared.steps.fluent_control module included in the UniteLabs workflow template and streams an XML command through the execution channel.
Simple high-level run
This workflow lists methods, discovers parameters, and runs the method with automatic dialog handling. It assumes the FluentControl software has a method named plate_prep with the variables plate_count and volume marked QueryAtStartup. Replace the method name and the parameters with your own.
To run this example, install the SDK (unitelabs-sdk[automate], see Automate your workflows).
import asyncio
from unitelabs.sdk import AsyncApiClient, workflow
@workflow(name="Tecan FluentControl quick run")
async def run_workflow():
client = AsyncApiClient()
service = await client.get_service_by_name(name="Tecan FluentControl")
methods = await service.run_controller.get_methods()
print(f"Available methods: {methods}")
# Optionally discover parameters the method expects
parameters = await service.run_controller.get_parameters(method="plate_prep")
print(f"Parameters: {parameters}")
await service.run_controller.run(
method="plate_prep",
parameters=[
{"Name": "plate_count", "Value": "4"},
{"Name": "volume", "Value": "150"},
],
auto_close_dialogs=True,
)
asyncio.run(run_workflow())
XML command stream example
This script uses the shared package from the workflow template and extends the method run with an XML command sent through the execution channel. It is written as a workflow: @step functions each perform one action, @phase functions group them, and the @workflow function sets the order. The workflow template shows the project layout and how to run it.
Prerequisites
- A Tecan FluentControl connector connected to the UniteLabs Platform
- A FluentControl method available on the instrument
- The
sharedpackage from the UniteLabs workflow template - The SDK with the
automateextra (unitelabs-sdk[automate](/get-started/automate-your-workflows/) installed - Familiarity with the XML command format (see Low-level control)
Full script
import asyncio
from shared.config.fluent_control import CONNECTOR_NAME, DEFAULT_METHOD_NAME
from shared.steps.fluent_control import (
check_execution_channel,
finish_command,
get_fluentcontrol_service,
prepare_method,
run_method,
)
from unitelabs.sdk import phase, step, workflow
# This example sends a UserPromptStatement. FluentControl blocks until
# the operator presses OK on the touchscreen.
# Build XML command strings following the ScriptGroup envelope format
# described in Low-level Control.
USER_PROMPT = (
"<ScriptGroup><Objects>"
'<Object Type="Tecan.Core.Scripting.UserPromptStatement">'
"<UserPromptStatement>"
"<Prompt>Verify the deck layout, then press OK to continue</Prompt>"
"<AutoClose>False</AutoClose><Timeout>1</Timeout>"
"<SoundFile></SoundFile><RepeatSound>False</RepeatSound>"
"<ChangeStatusLightColor>False</ChangeStatusLightColor>"
"<StatusLightColorString>#FFFFFF00</StatusLightColorString>"
"<IsBreakpoint>False</IsBreakpoint>"
"<IsDisabledForExecution>False</IsDisabledForExecution>"
"<LineNumber>1</LineNumber>"
"</UserPromptStatement></Object>"
"</Objects><Name></Name>"
"<IsBreakpoint>False</IsBreakpoint>"
"<IsDisabledForExecution>False</IsDisabledForExecution>"
"<LineNumber>0</LineNumber></ScriptGroup>"
)
@step(name="Wait for XML Channel")
async def wait_for_xml_channel(service) -> None:
"""Wait for FluentControl to open the XML channel."""
for _ in range(20):
if await service.execution_channel_controller.get_is_alive():
return
await asyncio.sleep(0.5)
raise TimeoutError("XML channel did not open within 10 seconds")
@step(name="Send XML Command")
async def send_xml_command(service, command: str) -> None:
"""Send an XML command through the execution channel."""
await service.execution_channel_controller.execute_command(command=command)
@phase(name="Phase 01: Connect and reset")
async def connect_and_reset(connector_name: str):
"""Connect and close any open channel from a previous session."""
service = await get_fluentcontrol_service(connector_name=connector_name)
await check_execution_channel(service=service)
return service
@phase(name="Phase 02: Run method with XML commands")
async def run_with_xml_commands(service, method_name: str) -> None:
"""Start the method, send an XML command, then close the XML channel and return FluentControl to EditMode."""
await prepare_method(service=service, method_name=method_name)
await run_method(service=service)
await wait_for_xml_channel(service=service)
await send_xml_command(service=service, command=USER_PROMPT)
await finish_command(service=service)
@workflow(name="Tecan FluentControl XML command stream")
async def run_workflow(
connector_name: str = CONNECTOR_NAME,
method_name: str = DEFAULT_METHOD_NAME,
):
service = await connect_and_reset(connector_name=connector_name)
await run_with_xml_commands(service=service, method_name=method_name)
asyncio.run(run_workflow())
Simulation mode
The shared.steps.fluent_control module includes FluentControlMock, a drop-in replacement for the live service that no-ops all calls. Use it during development to test the workflow structure without a connected instrument:
from shared.steps.fluent_control import FluentControlMock
service = FluentControlMock()
Pass FluentControlMock() wherever the live service is expected. All execute_command(), prepare_method(), run_method(), and finish_command() calls succeed silently.
Troubleshooting
Last updated