Example script

An example of three cooperating scripts: we watch the oil temperature and write every limit violation to a file. The scripts share one scope, so they pass the open file and a counter between each other.

startup.py — Startup mode

# Prepares shared resources when the runtime starts.
report = open("temperature_violations.csv", "a", encoding="utf-8")
violation_count = 0
print("Temperature watch started")

watch_temperature.py — OnValueChanged mode

Bound to the OilTemp variable, Parameters: source=eng;mode=above;threshold=90;hysteresis=3.

# Runs when 90 °C is exceeded (the return below 87 °C is handled by hysteresis).
global violation_count
violation_count += 1
report.write(f"{qenex_trigger_variable_name};{qenex_trigger_new_value}\n")
print(f"Temperature exceeded: {qenex_trigger_new_value} °C "
      f"({violation_count} times in total)")

shutdown.py — Shutdown mode

# Cleans up when the runtime stops.
report.close()
print(f"Watch finished, total violations: {violation_count}")

Try it

  1. Create the three scripts in Home → Project Configuration → Scripts with the listed modes and Runtime checked.
  2. Start the communication (Runtime → Connect) — watch the script output in the Script-Logs window.

Scripts can also write values (OilTemp.RawValue = ...) — the same mechanism can build simple regulations or test sequences.

Next

Processing stored data — CSV post-processing.