Skip to content

Using Scripts

Device control executes python scripts. See below the available properties and functions.

User class “u” is available for free usage. Following read-only resources are mapped in the user class:

PropertyDescription
u.flowList of flows
u.indexTime index within step (x0.25 second)
u.inputsList of system inputs
u.outputsDictionary of system outputs
u.pressureSystem pressure value
u.pressure_gaugeCoarse pressure gauge value
u.setpointCurrent set temperature
u.set_pointsList of set points within zones
u.step_indexCurrent process step index
u.step_timeCurrent process step time
u.tcsList of temperature values
u.tcs_healthList of TCs health status
u.vacuum_gaugeVacuum gauge value
u.volume_to_purgeVolume to purge value
u.pwr_pidPower PID to system
u.pwr_pid_fPower PID to system filtered
u.pwr_totalPower total to system
u.pwr_total_fPower total to system filtered
u.pwr_donePower done by system
u.pwr_done_fPower done by system filtered
u.trtThermal response tolerance

Note: All lists start from index zero. For example, to access TC1 health status use u.tcs_health[0]

Any other variable can be dynamically created, e.g., u.ax

Raises an alarm with red light and buzzer signal.

if not u.tcs_health[3]:
alarm('TC4 is broken')
stop()

Shows alert message on the screen.

u.a = u.tcs[1] - u.tcs[0]
if abs(u.a) > 10.5:
alert('Temperature deviation error')

Blocks switching to next step until temperature reaches set point. Timeout in seconds.

await_temp(30)

Returns the difference between the higlest and lowest value argument

diff(1, 5, 7, 4)
# returns 7 - 1 = 1

Force output to value. Available outputs:

#loop
if u.pressure_gauge < 250:
force('pre', 0)
#enter
force('ext-out1', 1)
#exit
force('ext-out1', 0)

Jump to step, optionally with a condition.

#loop
if u.tc[0] < 250:
jump('cooling')

Or conditionally:

#loop
jump('cooling', u.tc[0] < 250)

Holds for one loop iteration.

if u.vacuum_gauge > 0.08:
hold()

Prints string to console log.

log(u.tcs_health)

Reserved function.

Cuts power until process end.

#loop
if u.setpoint < 250:
power_off()

Change proportional parameter of particular zone.

prop(2, 55)

Change set point of particular zone.

setpoint(2, u.setpoint - 10)

Set thermal response tolerance threshold for the current run. Set to zero or negative to disable watchdog.

set_trtt(55)

Skip the rest of the step, optionally with a condition. Similar to stop().

Terminate execution, optionally with a condition.

#loop
if u.tc[0] < 75:
stop()

Or conditionally:

#loop
stop(u.tc[0] < 75)

Returns temperature of TCx (starting from 1).

u.my_temp = tc(4)

Script execution can be controlled with directives:

DirectiveDescription
#enterExecutes at entering step (default)
#loopExecutes during step loop
#exitExecutes at exiting step

Every script after the directive will be executed according to its position.

This example demonstrates how directives control execution flow across different stages of a process step:

u.ax = 0
#loop
u.ax += 0.25
#exit
alert('time elapsed: {:.2f}s'.format(u.ax))

Explanation:

  1. Initialization (implicit #enter): u.ax = 0

    • Executes once when the step is entered
    • Initializes a custom variable u.ax to track accumulated time
  2. Loop execution: #loop section with u.ax += 0.25

    • Executes repeatedly during each loop iteration of the step
    • Each iteration represents 0.25 seconds (since u.index increments by 0.25s)
    • The variable u.ax accumulates the elapsed time, adding 0.25s each loop
    • This continues for as long as the step is active
  3. Exit handling: #exit section with alert message

    • Executes once when the step is exited or skipped
    • Displays the total elapsed time using string formatting: {:.2f}s limits the value to 2 decimal places
    • Provides feedback on how long the step took to complete

Use Case: This pattern is useful for monitoring step duration, logging process timing data, or triggering actions based on accumulated time within a step.

Stop process and alert if vacuum is faulty after evacuation in previous step:

if u.pressure > 10:
alarm('Vacuum error, terminating...')
stop()

Stop process and alert in case of temperature deviation between any thermocouples and/or the setpoint:

#loop
if diff(u.tcs[0], u.tcs[1], u.tcs[3], u.setpoint) > 25:
alarm('Temperature deviation error, terminating...')
stop()