Example #1
0
def main():
    hardware = Hardware()
    align_adcs = AlignADCs(hardware)
    try:
        t0 = time.time()
        align_adcs.align()
        t1 = time.time()
        logging.info("Alignment took %.1f s", t1 - t0)

        count = 0
        total_count = 0
        wait_seconds = 0
        hardware.send_message(messages.TriggerConditionMessage(1))
        while True:
            t0 = time.time()
            total_count += count
            count = 0
            while time.time() - t0 < 1.:
                msg = hardware.read_message()
                if type(msg) == messages.MeasuredDataMessage:
                    count += 1
            print "Frequency: %.1f" % (count / (time.time() - t0))
            if count == 0:
                wait_seconds += 1
            else:
                wait_seconds = 0
            if wait_seconds == 2 and total_count:
                print "I received a total of %d messages" % total_count
                total_count = 0
    except KeyboardInterrupt:
        print "Interrupted by user."
    finally:
        hardware.close()
Example #2
0
def main():
    hardware = Hardware()
    align_adcs = AlignADCs(hardware)
    try:
        t0 = time.time()
        align_adcs.align()
        t1 = time.time()
        logging.info("Alignment took %.1f s", t1 - t0)

        count = 0
        total_count = 0
        wait_seconds = 0
        hardware.send_message(messages.TriggerConditionMessage(1))
        while True:
            t0 = time.time()
            total_count += count
            count = 0
            while time.time() - t0 < 1.0:
                msg = hardware.read_message()
                if type(msg) == messages.MeasuredDataMessage:
                    count += 1
            print "Frequency: %.1f" % (count / (time.time() - t0))
            if count == 0:
                wait_seconds += 1
            else:
                wait_seconds = 0
            if wait_seconds == 2 and total_count:
                print "I received a total of %d messages" % total_count
                total_count = 0
    except KeyboardInterrupt:
        print "Interrupted by user."
    finally:
        hardware.close()
Example #3
0
def main():
    hardware = HiSPARCIII()

    try:
        if not os.path.isfile(CONFIGFILE):
            logging.info("No config file found.  Aligning ADCs.")
            align_adcs = AlignADCs(hardware)
            t0 = time.time()
            align_adcs.align()
            t1 = time.time()
            logging.info("Alignment took %.1f s", t1 - t0)
        else:
            logging.info("Reading config from file")
            config = ConfigParser()
            config.read(CONFIGFILE)
            hardware.config.read_config(config)

        hardware.config.trigger_condition = 0x80
        while True:
            msg = hardware.flush_and_get_measured_data_message()
            print '%d %d %d %d' % (msg.adc_ch1_pos.mean(),
                                   msg.adc_ch1_neg.mean(),
                                   msg.adc_ch2_pos.mean(),
                                   msg.adc_ch2_neg.mean())

            bl1 = msg.trace_ch1[:100].mean()
            bl1_pos = msg.adc_ch1_pos[:50].mean()
            bl1_neg = msg.adc_ch1_neg[:50].mean()
            ph1 = msg.trace_ch1.max()

            bl2 = msg.trace_ch2[:100].mean()
            bl2_pos = msg.adc_ch2_pos[:50].mean()
            bl2_neg = msg.adc_ch2_neg[:50].mean()
            ph2 = msg.trace_ch2.max()

            print "baselines: %d (%d, %d), %d (%d, %d)" % \
                (bl1, bl1_pos, bl1_neg, bl2, bl2_pos, bl2_neg)
            print "pulseheights: %d %d" % (ph1 - bl1, ph2 - bl2)
    except KeyboardInterrupt:
        print "Interrupted by user."
    finally:
        hardware.close()
        hardware.config.set_notifications_enabled(False)
        logging.info("Writing config to file")
        config = ConfigParser()
        hardware.config.write_config(config)
        with open(CONFIGFILE, 'w') as f:
            config.write(f)
        print
        print "All configuration settings:"
        print
        for attr in sorted(hardware.config.members()):
            print attr, getattr(hardware.config, attr)
        print
Example #4
0
def main():
    hardware = HiSPARCIII()

    try:
        if not os.path.isfile(CONFIGFILE):
            logging.info("No config file found.  Aligning ADCs.")
            align_adcs = AlignADCs(hardware)
            t0 = time.time()
            align_adcs.align()
            t1 = time.time()
            logging.info("Alignment took %.1f s", t1 - t0)
        else:
            logging.info("Reading config from file")
            config = ConfigParser()
            config.read(CONFIGFILE)
            hardware.config.read_config(config)

        hardware.config.trigger_condition = 0x80
        while True:
            msg = hardware.flush_and_get_measured_data_message()
            print '%d %d %d %d' % (
                msg.adc_ch1_pos.mean(), msg.adc_ch1_neg.mean(),
                msg.adc_ch2_pos.mean(), msg.adc_ch2_neg.mean())

            bl1 = msg.trace_ch1[:100].mean()
            bl1_pos = msg.adc_ch1_pos[:50].mean()
            bl1_neg = msg.adc_ch1_neg[:50].mean()
            ph1 = msg.trace_ch1.max()

            bl2 = msg.trace_ch2[:100].mean()
            bl2_pos = msg.adc_ch2_pos[:50].mean()
            bl2_neg = msg.adc_ch2_neg[:50].mean()
            ph2 = msg.trace_ch2.max()

            print "baselines: %d (%d, %d), %d (%d, %d)" % \
                (bl1, bl1_pos, bl1_neg, bl2, bl2_pos, bl2_neg)
            print "pulseheights: %d %d" % (ph1 - bl1, ph2 - bl2)
    except KeyboardInterrupt:
        print "Interrupted by user."
    finally:
        hardware.close()
        hardware.config.set_notifications_enabled(False)
        logging.info("Writing config to file")
        config = ConfigParser()
        hardware.config.write_config(config)
        with open(CONFIGFILE, 'w') as f:
            config.write(f)
        print
        print "All configuration settings:"
        print
        for attr in sorted(hardware.config.members()):
            print attr, getattr(hardware.config, attr)
        print
Example #5
0
    def initialize_device(self):
        logging.info("Reading config from file")
        self.config.read(ALL_CONFIG_FILES)

        logging.info("Initializing device configuration")
        self.device.config.read_config(self.config)

        if self.config.getboolean('DAQ', 'force_reset_gps'):
            logging.info("Force reset GPS to factory defaults.")
            self.gps.reset_defaults()
            self.config.set('DAQ', 'force_reset_gps', False)

        if self.config.getboolean('DAQ', 'force_align_adcs'):
            logging.info("Force aligning ADCs.")
            align_adcs = AlignADCs(self.device)
            align_adcs.align()
            self.config.set('DAQ', 'force_align_adcs', False)

        self.write_config()
Example #6
0
    def initialize_device(self):
        logging.info("Reading config from file")
        self.config.read(ALL_CONFIG_FILES)

        logging.info("Initializing device configuration")
        self.device.config.read_config(self.config)
        if USE_DEVICE2:
            self.device2.config.read_config(self.config)

        if self.config.getboolean('DAQ', 'force_reset_gps'):
            logging.info("Force reset GPS to factory defaults.")
            self.gps.reset_defaults()
            self.config.set('DAQ', 'force_reset_gps', 'False')

        if self.config.getboolean('DAQ', 'force_align_adcs'):
            logging.info("Force aligning ADCs.")
            align_adcs = AlignADCs(self.device)
            align_adcs.align()
            #if USE_DEVICE2:
            #align_adcs = AlignADCs(self.device2)
            #align_adcs.align()
            self.config.set('DAQ', 'force_align_adcs', 'False')

        self.write_config()