def trig(self): name = self.getString(self.name, MDSplus.DevBAD_NAME) status = MDSplus.Data.execute('AEON_TRIGGER("%s")' % (name, )) if (status & 1) == 0: raise MDSplus.DevCAMAC_ERROR('AEON 3248 Triggering %s status %d' % ( name, status, ))
def init(self): import math if self.debug: print("A3248 INIT starting") name = self.getString(self.name, MDSplus.DevBAD_NAME) gain = self.getInteger(self.gain, MDSplus.DevBAD_GAIN) if not gain in (1, 2, 4, 8): raise MDSplus.DevBAD_GAIN("Gain must be one of 1,r or 8") gain_code = int(math.log(gain, 2)) offset = self.getInteger(self.offset, MDSplus.DevBAD_OFFSET) offset = max(min(offset, 255), 0) gain_offset_reg = (gain_code << 8) | offset pretrig = max( min(self.getInteger(self.pretrig, MDSplus.DevBAD_PRE_TRIG), 32768), 0) posttrig_code = (32768 - pretrig) << 7 clock = self.getInteger(self.frequency, MDSplus.DevBAD_CLOCK_FREQ) if not clock in self.clock_freqs: raise MDSplus.DevBAD_CLOCK_FREQ("Clock must be in %r" % (self.clock_freqs, )) if self.ext_clock.length > 0: clock_code = 7 else: clock_code = 0 for f in self.clock_freqs: if clock == f: break clock_code = clock_code + 1 status_reg = clock_code << 8 if pretrig != 0: status_reg = status_reg | posttrig_code | (1 << 12) status = MDSplus.Data.execute('AEON_ARM("%s", %d, %d)' % ( name, gain_offset_reg, status_reg, )) if (status & 1) == 0: raise MDSplus.DevCAMAC_ERROR('AEON 3248 Arming %s status %d' % ( name, status, ))