예제 #1
0
 def _get_supports_analog_trig(self):
     try:
         ul.set_trigger(
             self._board_num, TrigType.TRIG_ABOVE, 0, 0)
         return True
     except ULError:
         return False
예제 #2
0
파일: ai_info.py 프로젝트: jdechevr/mcculw
 def supports_analog_trig(self):
     analog_trig_supported = True
     try:
         ul.set_trigger(self._board_num, TrigType.TRIG_ABOVE, 0, 0)
     except ULError:
         analog_trig_supported = False
     return analog_trig_supported
예제 #3
0
	def configure(self):
		if not hasattr(self, 'board_num'):
			#incase an old session is running:
			ul.release_daq_device(0)
			#initialization vals
			board_num = 0
			ul_range = ULRange.BIP10VOLTS
			ul.set_trigger(board_num, TrigType.TRIG_POS_EDGE, 2000, 2000)
			self.board_num = board_num
			self.ul_range = ul_range
		return
예제 #4
0
파일: ULAI14.py 프로젝트: conandewitt/lotus
    def start_scan(self):
        low_chan = self.get_low_channel_num()
        high_chan = self.get_high_channel_num()

        if low_chan > high_chan:
            messagebox.showerror(
                "Error", "Low Channel Number must be greater than or equal to "
                "High Channel Number")
            self.start_button["state"] = tk.NORMAL
            return

        rate = 1000
        points_per_channel = 10
        num_channels = high_chan - low_chan + 1
        total_count = points_per_channel * num_channels
        range_ = self.ai_props.available_ranges[0]

        trig_type = TrigType.TRIG_ABOVE
        low_threshold_volts = 0.1
        high_threshold_volts = 1.53

        # Allocate a buffer for the scan
        if self.ai_props.resolution <= 16:
            # Use the win_buf_alloc method for devices with a resolution <= 16
            memhandle = ul.win_buf_alloc(total_count)
        else:
            # Use the win_buf_alloc_32 method for devices with a resolution >
            # 16
            memhandle = ul.win_buf_alloc_32(total_count)

        # Check if the buffer was successfully allocated
        if not memhandle:
            messagebox.showerror("Error", "Failed to allocate memory")
            self.start_button["state"] = tk.NORMAL
            return

        try:
            low_threshold, high_threshold = self.get_threshold_counts(
                range_, low_threshold_volts, high_threshold_volts)

            ul.set_trigger(self.board_num, trig_type, low_threshold,
                           high_threshold)

            # Run the scan
            ul.a_in_scan(self.board_num, low_chan, high_chan, total_count,
                         rate, range_, memhandle, ScanOptions.EXTTRIGGER)

            # Convert the memhandle to a ctypes array
            # Note: the ctypes array will only be valid until win_buf_free
            # is called.
            # A copy of the buffer can be created using win_buf_to_array
            # or win_buf_to_array_32 before the memory is freed. The copy can
            # be used at any time.
            if self.ai_props.resolution <= 16:
                # Use the memhandle_as_ctypes_array method for devices with a
                # resolution <= 16
                array = self.memhandle_as_ctypes_array(memhandle)
            else:
                # Use the memhandle_as_ctypes_array_32 method for devices with
                # a resolution > 16
                array = self.memhandle_as_ctypes_array_32(memhandle)

            # Display the values
            self.display_values(array, range_, total_count, low_chan,
                                high_chan)
        except ULError as e:
            self.show_ul_error(e)
        finally:
            # Free the allocated memory
            ul.win_buf_free(memhandle)
            self.start_button["state"] = tk.NORMAL
예제 #5
0
    def start_scan(self):
        range_ = self.ai_props.available_ranges[0]

        low_chan = self.get_low_channel_num()
        high_chan = self.get_high_channel_num()
        trig_type = self.get_trigger_type()
        trig_value_eng = self.get_trigger_level()
        trig_value = ul.from_eng_units(
            self.board_num, range_, trig_value_eng)

        if low_chan > high_chan:
            messagebox.showerror(
                "Error",
                "Low Channel Number must be greater than or equal to High "
                "Channel Number")
            self.start_button["state"] = tk.NORMAL
            return

        rate = 100
        points_per_channel = 10
        num_channels = high_chan - low_chan + 1
        total_count = points_per_channel * num_channels
        pretrig_points_per_channel = 5
        total_pretrig_count = pretrig_points_per_channel * num_channels

        # Allocate a buffer for the scan
        if self.ai_props.resolution <= 16:
            # Use the win_buf_alloc method for devices with a resolution <=
            # 16
            memhandle = ul.win_buf_alloc(total_count)
        else:
            messagebox.showerror(
                "Error",
                "This example can only be used with boards with a "
                "resolution less than or equal to 16.")
            self.start_button["state"] = tk.NORMAL
            return

        # Check if the buffer was successfully allocated
        if not memhandle:
            messagebox.showerror("Error", "Failed to allocate memory")
            self.start_button["state"] = tk.NORMAL
            return

        try:
            # Set the trigger settings (the level will be used for
            # both thresholds, since the irrelevant threshold is ignored
            # for TRIG_ABOVE and TRIG_BELOW
            ul.set_trigger(
                self.board_num, trig_type, trig_value, trig_value)

            # Run the scan
            ul.a_pretrig(
                self.board_num, low_chan, high_chan, total_pretrig_count,
                total_count, rate, range_, memhandle, 0)

            # Convert the memhandle to a ctypes array
            # Note: the ctypes array will only be valid until win_buf_free
            # is called.
            # A copy of the buffer can be created using win_buf_to_array
            # before the memory is freed. The copy can be used at any time.
            array = self.memhandle_as_ctypes_array(memhandle)

            # Display the values
            self.display_values(array, range_, total_count,
                                low_chan, high_chan)
        except ULError as e:
            self.show_ul_error(e)
        finally:
            # Free the allocated memory
            ul.win_buf_free(memhandle)
            self.start_button["state"] = tk.NORMAL