def build_typed_pvs(): """Build generic PVs""" dynamic_pvs = {} builder.aOut('AO:STATIC', **ANALOGUE_VALUES) builder.aIn('AI:STATIC', **ANALOGUE_VALUES) dynamic_pvs.update({ builder.aOut('AO:DYNAMIC', **ANALOGUE_VALUES): lambda pv: increment(pv, 10)}) builder.longOut('LONGO:STATIC',**LONG_VALUES) builder.longIn('LONGI:STATIC',**LONG_VALUES) dynamic_pvs.update({ builder.aOut('LONGO:DYNAMIC', **LONG_VALUES): lambda pv: increment(pv, 10)}) builder.boolOut('BOOLO:STATIC', **BOOLEAN_VALUES) builder.boolIn('BOOLI:STATIC', **BOOLEAN_VALUES) dynamic_pvs.update({ builder.boolOut('BOOLO:DYNAMIC', **BOOLEAN_VALUES): lambda pv: increment(pv, 1)}) builder.stringOut('STRINGO:STATIC', initial_value=STRINGS[0]) builder.stringIn('STRINGI:STATIC', initial_value=STRINGS[0]) dynamic_pvs.update({ builder.stringOut('STRINGO:DYNAMIC', initial_value=STRINGS[0]): update_string}) enum_pv = builder.mbbOut('MBBO:STATIC', *STRINGS, initial_value=0) enum_pv = builder.mbbIn('MBBI:STATIC', *STRINGS, initial_value=0) dynamic_pvs.update({ builder.mbbOut('MBBO:DYNAMIC', *STRINGS, initial_value=0): lambda pv: increment(pv, len(STRINGS) - 1)}) return lambda: update_pvs(dynamic_pvs)
def __init__(self, boardList): self.boardList = boardList #create pv to place BBC voltages self.placevalues = builder.boolOut("BBCplacevalues", ZNAM=0, ONAM=1, HIGH=0.1, on_update=self.place_voltages) self.diction_ary = {} self.activefile = 1 self.chooseFile = builder.longOut("BBC_setting", initial_value=self.activefile, on_update=self.request_change) #create pv to reload dictionary if changes were made according to the files where demand voltages #are retrieved from self.reload = builder.boolOut("reload_BBC", ZNAM=0, ONAM=1, HIGH=0.1, on_update=self.reload_dictionary) #create pv to retrieve file status of BBC self.fileInUse = builder.stringIn("BBCfilestatus") #create pv to set BBC voltages to zero self.turnoffBBC = builder.boolOut("BBCturnoff", ZNAM=0, ONAM=1, HIGH=0.1, on_update=self.turnoff_BBC) self.listofstringIns = [] self.maximum = 10 for i in range(self.maximum): self.listofstringIns.append( builder.stringIn("BBCfile" + str(i + 1)))
def __init__(self, boardList): self.boardList = boardList #pv created to place VPD demand voltages self.placevalues = builder.boolOut("VPDplacevalues", ZNAM=0, ONAM=1, HIGH=0.1, on_update=self.place_voltages) #pv created to turn VPD voltages to 0 self.turnvoltageoff = builder.boolOut("turnoffVPD", ZNAM=0, ONAM=1, HIGH=0.1, on_update=self.turnoff_VPD) self.activefile = 1 self.dictionary = {} self.chooseFile = builder.longOut("VPD_setting", initial_value=self.activefile, on_update=self.request_change) self.reload = builder.boolOut("reload_VPD", ZNAM=0, ONAM=1, HIGH=0.1, on_update=self.reload_dictionary) self.fileInUse = builder.stringIn("VPDfilestatus") self.listofstringIns = [] self.maximum = 10 for i in range(self.maximum): self.listofstringIns.append( builder.stringIn("VPDfile" + str(i + 1)))
def test_hlopr_inherits_drvhl(): """Test that H/LOPR values are set to the DRVH/L values""" lo = builder.longOut("ABC", DRVH=5, DRVL=10) assert lo.DRVH.Value() == 5 assert lo.HOPR.Value() == 5 assert lo.DRVL.Value() == 10 assert lo.LOPR.Value() == 10
def __init__(self, boardList, relay): self.relay = relay self.boardList = boardList self.bdbegin = 0 self.bdend = 15 self.cnbegin = 0 self.cnend = 15 #these pvs were created because the user can pick from a range of boards and channels to #change their limits self.ACboardb = builder.longOut("ACBbegin", initial_value=self.bdbegin) self.ACboarde = builder.longOut("ACBend", initial_value=self.bdend) self.ACchanb = builder.longOut("ACCbegin", initial_value=self.cnbegin) self.ACchane = builder.longOut("ACCend", initial_value=self.cnend) #this pv holds the new value for the limit self.actrip = builder.aOut("ac_tripval", initial_value=10) #this pv will be a button that the user can press to confirm their changes self.setactrip = builder.boolOut("setactrip", ZNAM=0, ONAM=1, HIGH=0.1, on_update=self.set_limits)
def blocking_test_func(self, device_name, conn): builder.SetDeviceName(device_name) count_rec = builder.longIn("BLOCKING-COUNTER", initial_value=0) async def blocking_update_func(new_val): """A function that will block for some time""" log("CHILD: blocking_update_func starting") await asyncio.sleep(0.5) log("CHILD: Finished sleep!") completed_count = count_rec.get() + 1 count_rec.set(completed_count) log( "CHILD: blocking_update_func finished, completed ", completed_count ) builder.longOut( "BLOCKING-REC", on_update=blocking_update_func, always_update=True, blocking=True ) dispatcher = asyncio_dispatcher.AsyncioDispatcher() builder.LoadDatabase() softioc.iocInit(dispatcher) conn.send("R") # "Ready" log("CHILD: Sent R over Connection to Parent") # Keep process alive while main thread runs CAGET if conn.poll(TIMEOUT): val = conn.recv() assert val == "D", "Did not receive expected Done character" log("CHILD: Received exit command, child exiting")
def create_records(configure_scan_function, start_scan_function, min_x, min_y, min_z, max_x, max_y, max_z): """Create the records for the scan interface""" # We'll return them in a dict records = {} # Start the scan records["start_scan"] = builder.mbbOut('START', initial_value=0, PINI='NO', NOBT=2, ZRVL=0, ZRST='Start', ONVL=1, ONST='Starting', on_update=start_scan_function, always_update=True) records["configure_scan"] = builder.mbbOut( 'CONFIGURE', initial_value=0, PINI='NO', NOBT=2, ZRVL=0, ZRST='Configure', ONVL=1, ONST='Configuring', on_update=configure_scan_function, always_update=True) # Status to say we're sending commands records["STATE"] = builder.mbbIn("STATE", initial_value=0, PINI='YES', NOBT=2, ZRVL=STATE_NOT_CONFIGRED, ZRST='Not configured', ZRSV="INVALID", ONVL=STATE_PREPARING, ONST='Preparing', ONSV="MINOR", TWVL=STATE_ERROR, TWST='Error', TWSV="MAJOR", THVL=STATE_READY, THST='Ready', THSV="NO_ALARM", FRVL=STATE_SCAN_RUNNING, FRST="Scan running", FRSV="NO_ALARM") # Number of steps in x records["NX"] = builder.longOut("NX", initial_value=30, PINI='YES', LOPR=1, HOPR=1000000) # Number of steps in y records["NY"] = builder.longOut("NY", initial_value=30, PINI='YES', DRVL=1, DRVH=1000000) # Number of steps in z records["NZ"] = builder.longOut("NZ", initial_value=30, PINI='YES', DRVL=1, DRVH=1000000) # x step size / um records["DX"] = builder.aOut("DX", initial_value=0.1, PINI='YES', DRVL=0.001, DRVH=300.0, EGU="um", PREC=3) # y step size / um records["DY"] = builder.aOut("DY", initial_value=0.1, PINI='YES', DRVL=0.001, DRVH=300.0, EGU="um", PREC=3) # z step size / um records["DZ"] = builder.aOut("DZ", initial_value=0.1, PINI='YES', DRVL=0.001, DRVH=300.0, EGU="um", PREC=3) # x centre position / um records["X0"] = builder.aOut("X0", initial_value=150, PINI='YES', DRVL=min_x, DRVH=max_x, EGU="um", PREC=3) # y centre position / um records["Y0"] = builder.aOut("Y0", initial_value=150, PINI='YES', DRVL=min_y, DRVH=max_y, EGU="um", PREC=3) # z centre position / um records["Z0"] = builder.aOut("Z0", initial_value=150, PINI='YES', DRVL=min_z, DRVH=max_z, EGU="um", PREC=3) # Theta rotation about Y / degrees records["THETA"] = builder.aOut("THETA", initial_value=0.0, PINI='YES', DRVL=-360, DRVH=360, EGU="deg", PREC=3) # EXPOSURE time / ms records["EXPOSURE"] = builder.aOut("EXPOSURE", initial_value=100, PINI='YES', DRVL=0.001, DRVH=300.0, EGU="ms", PREC=1) # Move time / ms records["MOVETIME"] = builder.aOut("MOVETIME", initial_value=40, PINI='YES', DRVL=0.001, DRVH=300.0, EGU="ms", PREC=1) return records
await asyncio.sleep(1) conn.send("C") # "Complete" # Set a different initial value sim_records.t_ai.set(23.45) # Create a record to set the alarm t_ao = builder.aOut('ALARM', on_update=callback) async def on_update_name_callback(value, name): print(name, "value", value) builder.longOut( "NAME-CALLBACK", initial_value = 3, always_update=True, on_update_name=on_update_name_callback, blocking=True ) # Run the IOC builder.LoadDatabase() softioc.iocInit(asyncio_dispatcher.AsyncioDispatcher()) conn.send("R") # "Ready" # Make sure coverage is written on epicsExit from pytest_cov.embed import cleanup sys._run_exitfuncs = cleanup select_and_recv(conn, "D") # "Done"