Exemplo n.º 1
0
class Magnet(object):
    kick_delta = 0.0002  #in kG

    def __init__(self, device_name, z_pos):
        self.device_name = device_name
        self.z = z_pos
        self.bctrl_pv = Pv("{}:BCTRL".format(device_name))
        self.bact_pv = Pv("{}:BACT".format(device_name))

    @classmethod
    def pv_count(cls):
        return 2

    @property
    def name(self):
        return self.device_name

    def connect(self):
        self.bctrl_pv.connect()
        self.bact_pv.connect()

    def connected(self):
        if self.bctrl_pv.state() == 2 and self.bact_pv.state() == 2:
            return True
        else:
            return False

    def monitor(self):
        self.bctrl_pv.monitor(pyca.DBE_VALUE)
        self.bact_pv.monitor(pyca.DBE_VALUE)

    @property
    def kick_setpoint(self):
        return self.bctrl_pv.data["value"]

    @kick_setpoint.setter
    def kick_setpoint(self, new_setpoint):
        return self.bctrl_pv.put(new_setpoint)

    @property
    def kick_readback(self):
        return self.bact_pv.data["value"]

    def increase_kick(self):
        before_val = self.kick_setpoint
        new_val = before_val + (self.kick_delta)
        self.kick_setpoint = new_val

    def decrease_kick(self):
        before_val = self.kick_setpoint
        new_val = before_val - (self.kick_delta)
        self.kick_setpoint = new_val
Exemplo n.º 2
0
 def dopv(self, name, gui, format):
     pv = Pv(name, initialize=True)
     if pv != None:
         gui.setText("")
         pv.gui = gui
         pv.format = format
         self.pvlist.append(pv)
         pv.add_monitor_callback(lambda e: self.displayPV(pv, e))
         try:
             pv.wait_ready(0.5)
             pv.monitor()
         except:
             pass