def __init__(self, prefix, name=None, command="VAL", readback="RBV", readback_slop=0.001, timeout=20.0, min_step=0): """prefix = EPICS motor record If is assumed that command value process varialbe is named 'VAL' and the readback process variable 'RBV', unless specified otherwise by the optional 'command' and 'readback' keywords. readback slop: A motion is considered finished when the difference between the command value and the readback value is smaller than this amount. timeout: The motion is considered finished when the readback value has not changed within the readback slop for this amount of time. min_step: only if the new position deviates from the current position by at least this ammount will a command to move to motor be sent to the IOC. """ Record.__init__(self, prefix) if name is not None: self.__db_name__ = name self.__command__ = command self.__readback__ = readback self.__readback_slop__ = readback_slop self.__timeout__ = timeout self.__min_step__ = min_step self.__last_command_value__ = nan self.__new_command_value__ = nan self.__motion_started__ = 0 self.__move_done__ = True self.__last_moving__ = 0
#!/usr/bin/env python from CA import Record, caget, caput, cainfo from numpy import * from time import sleep, time from logging import info import logging logging.basicConfig(level=logging.INFO) array_test = Record("NIH:TEST") ensemble = Record("NIH:ENSEMBLE") def assign_element(record, name, index, value): t0 = time() x = getattr(record, name) while x is None: x = getattr(record, name) sleep(0.1) x[index] = value setattr(record, name, x) while not nan_equal(getattr(record, name), x): sleep(0.1) info("%s.%s[%d]=%r: %.3f s" % (record, name, index, value, time() - t0)) def nan_equal(a, b): """Are two arrays containing nan identical, assuming nan == nan?""" from numpy import asarray from numpy.testing import assert_equal a, b = asarray(a), asarray(b) try:
##CAServer.verbose = True ##CAServer.DEBUG = True ##CAServer.LOG = True thermocouple_driver.logging = True from tempfile import gettempdir logfile = gettempdir() + "/thermocouple_debug.log" import logging logging.basicConfig(level=logging.DEBUG, format="%(asctime)s: %(message)s", filename=logfile) thermocouple_IOC.run() # Ensemble client, using EPICS channel access. from CA import Record thermocouple = Record("NIH:TC") if __name__ == "__main__": from sys import argv if "run_IOC" in argv: run_IOC() # For testing import logging logging.basicConfig(level=logging.INFO, format="%(asctime)s: %(message)s") from time import time from timeit import timeit import __builtin__ __builtin__.__dict__.update(locals()) # needed for "timeit" thermocouple_driver.logging = True self = thermocouple_driver # for debugging print('run_IOC()')
"""EPICS Channel Access Protocol""" from CA import PV, Record, caput, caget SAMPLET = Record("14IDB-NIH:SAMPLET") if __name__ == "__main__": print "SAMPLET.port_name.value" print "SAMPLET.T.unit" print "SAMPLET.T.value" print "SAMPLET.T.moving"
from EPICS_motor import EPICS_motor class Syringe_Pump(EPICS_motor): command_value = alias("VAL") # EPICS_motor.command_value not changable volume = [ EPICS_motor(prefix="NIH:PUMP%d:VOLUME"%(i+1),name="syringe_pump%d"%(i+1)) \ for i in range(0,4)] port = [ EPICS_motor(prefix="NIH:PUMP%d:PORT"%(i+1),name="syringe_pump%d"%(i+1)) \ for i in range(0,4)] from CA import Record pump = Record(prefix="NIH:PUMP") def sleep(seconds): """Delay execution by the given number of seconds""" # This version of "sleep" does not throw an excpetion if passed a negative # waiting time, but instead returns immediately. from time import sleep if seconds > 0: sleep(seconds) if __name__ == "__main__": from pdb import pm # for debugging import logging logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s: %(message)s")
# Hyun Sun Cho, Feb 24 2015 #!/usr/bin/python ver = 1.0 import wx from time import sleep from syringe_pump import SyringePump from CA import Record #p = SyringePump("syringe_pump") p = Record("NIH:syringe_pump") CurrentVolume = p.V #print CurrentVolume class JogPump(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, size=(320, 180)) panel = wx.Panel(self, -1) wx.Button(panel, -1, "Pump Init", (10, 120)) wx.StaticText(panel, -1, "Jog Speed [uL/s] : ", (20, 15), style=wx.ALIGN_CENTER_VERTICAL) wx.StaticText(panel, -1, "Jog Volume [uL] : ", (20, 50), style=wx.ALIGN_CENTER_VERTICAL) wx.StaticText(panel, -1,
syringe_pump_combined_driver: CAServer.register_object(obj, "NIH:" + obj.name) def stop_server(): """Serve the Syringe pump up on the network as EPCIS IOC. Return control when started.""" import CAServer print("stopping server") for obj in syringe_pump_driver,syringe_pump2_driver,\ syringe_pump_combined_driver: CAServer.unregister_object(obj, "NIH:" + obj.name) from CA import Record syringe_pump = Record("NIH:syringe_pump") syringe_pump2 = Record("NIH:syringe_pump2") syringe_pump_combined = Record("NIH:syringe_pump_combined") # Shortcuts: p = p1 = syringe_pump p2 = syringe_pump2 pc = syringe_pump_combined P = P1 = syringe_pump_driver P2 = syringe_pump2_driver PC = syringe_pump_combined_driver ##p2.log_all = False ##p1.log_all = False if __name__ == "__main__": from pdb import pm
"""Spectra Physics 3930 Lok-to-Clock frequency stabilizer for the Tsunami laser This is to make the device remote controllable accross the network using EPICS. Friedrich Schotte, 3 Jun 2013 - 27 Apr 2016 """ __version__ = "1.1.1" # EPICS_CA_ADDR_LIST from CA import Record from os import environ environ["EPICS_CA_ADDR_LIST"] = "id14l-spitfire2.cars.aps.anl.gov" LokToClock = Record("14IDL:LokToClock") if __name__ == "__main__": from CA import caget print 'caget("14IDL:LokToClock.locked")' print "LokToClock.locked" print "LokToClock.locked = 1"