Skip to content

Background Script IOC

Dominic Oram edited this page Sep 14, 2020 · 12 revisions

Wiki > The Backend System > Specific Device IOC > Other > Background Script IOC

The background script IOC will run a script in the background. The script must be in python3 and be called background_script.py and be in the python configuration directory. For the second background ioc the script must be called background_script2.py.

If you want the IOC to register as started the user must include the lines:

from server_common.helpers import register_ioc_start

sys.path.insert(1, os.path.abspath(os.path.join(os.environ["KIT_ROOT"], "ISIS", "inst_servers", "master")))

register_ioc_start("BGRSCRPT_01")

Background Plot

A popular use of this is to generate a background plot. This can be using the script:

import sys
import os
from time import sleep

sys.path.insert(0, os.path.abspath(os.path.join(r"C:\\", "Instrument", "scripts")))
sys.path.insert(1, os.path.abspath(os.path.join(os.environ["KIT_ROOT"], "ISIS", "inst_servers", "master")))

from technique.muon.background_plot import BackgroundBlockPlot
from genie_python import genie as g
from server_common.helpers import register_ioc_start


register_ioc_start("BGRSCRPT_01")

g.set_instrument(None)

plot=BackgroundBlockPlot((("Temp_Sample", "value"), ("Temp_SP", "set point")), "Temperature").start()

while True:
    sleep(10)

In addition to this to show the plot add the following to the instrument init:

def init(inst):
    g.adv.open_plot_window(is_primary=False)
Clone this wiki locally