Esempio n. 1
0
	def __init__(
		self,
		parent,
		title='',
		sample_rate=1,
		size=scope_window.DEFAULT_WIN_SIZE,
		v_scale=0,
		t_scale=0,
		xy_mode=False,
		ac_couple=False,
		num_inputs=1,
		frame_rate=scope_window.DEFAULT_FRAME_RATE,
		**kwargs #do not end with a comma
	):
		if not t_scale: t_scale = 10.0/sample_rate
		#init
		gr.hier_block2.__init__(
			self,
			"scope_sink",
			gr.io_signature(num_inputs, num_inputs, self._item_size),
			gr.io_signature(0, 0, 0),
		)
		#scope
		msgq = gr.msg_queue(2)
		scope = gr.oscope_sink_f(sample_rate, msgq)
		#controller
		self.controller = pubsub()
		self.controller.subscribe(SAMPLE_RATE_KEY, scope.set_sample_rate)
		self.controller.publish(SAMPLE_RATE_KEY, scope.sample_rate)
		self.controller.subscribe(DECIMATION_KEY, scope.set_decimation_count)
		self.controller.publish(DECIMATION_KEY, scope.get_decimation_count)
		self.controller.subscribe(TRIGGER_LEVEL_KEY, scope.set_trigger_level)
		self.controller.publish(TRIGGER_LEVEL_KEY, scope.get_trigger_level)
		self.controller.subscribe(TRIGGER_MODE_KEY, scope.set_trigger_mode)
		self.controller.publish(TRIGGER_MODE_KEY, scope.get_trigger_mode)
		self.controller.subscribe(TRIGGER_SLOPE_KEY, scope.set_trigger_slope)
		self.controller.publish(TRIGGER_SLOPE_KEY, scope.get_trigger_slope)
		self.controller.subscribe(TRIGGER_CHANNEL_KEY, scope.set_trigger_channel)
		self.controller.publish(TRIGGER_CHANNEL_KEY, scope.get_trigger_channel)
		#connect
		if self._real:
			for i in range(num_inputs):
				self.connect(
					(self, i),
					ac_couple_block(self.controller, common.index_key(AC_COUPLE_KEY, i), ac_couple, SAMPLE_RATE_KEY),
					(scope, i),
				)
		else:
			for i in range(num_inputs):
				c2f = gr.complex_to_float() 
				self.connect((self, i), c2f)
				for j in range(2):
					self.connect(
						(c2f, j), 
						ac_couple_block(self.controller, common.index_key(AC_COUPLE_KEY, 2*i+j), ac_couple, SAMPLE_RATE_KEY),
						(scope, 2*i+j),
					)
			num_inputs *= 2
		#start input watcher
		common.input_watcher(msgq, self.controller, MSG_KEY)
		#create window
		self.win = scope_window.scope_window(
			parent=parent,
			controller=self.controller,
			size=size,
			title=title,
			frame_rate=frame_rate,
			num_inputs=num_inputs,
			sample_rate_key=SAMPLE_RATE_KEY,
			t_scale=t_scale,
			v_scale=v_scale,
			xy_mode=xy_mode,
			ac_couple_key=AC_COUPLE_KEY,
			trigger_level_key=TRIGGER_LEVEL_KEY,
			trigger_mode_key=TRIGGER_MODE_KEY,
			trigger_slope_key=TRIGGER_SLOPE_KEY,
			trigger_channel_key=TRIGGER_CHANNEL_KEY,
			decimation_key=DECIMATION_KEY,
			msg_key=MSG_KEY,
		)
		common.register_access_methods(self, self.win)
Esempio n. 2
0
    def __init__(
            self,
            parent,
            title='',
            sample_rate=1,
            size=scope_window.DEFAULT_WIN_SIZE,
            v_scale=0,
            t_scale=0,
            v_offset=0,
            xy_mode=False,
            ac_couple=False,
            num_inputs=1,
            trig_mode=scope_window.DEFAULT_TRIG_MODE,
            y_axis_label='Counts',
            frame_rate=scope_window.DEFAULT_FRAME_RATE,
            use_persistence=False,
            persist_alpha=None,
            **kwargs  #do not end with a comma
    ):
        #ensure analog alpha
        if persist_alpha is None:
            actual_frame_rate = float(frame_rate)
            analog_cutoff_freq = 0.5  # Hertz
            #calculate alpha from wanted cutoff freq
            persist_alpha = 1.0 - math.exp(
                -2.0 * math.pi * analog_cutoff_freq / actual_frame_rate)

        if not t_scale: t_scale = 10.0 / sample_rate
        #init
        gr.hier_block2.__init__(
            self,
            "scope_sink",
            gr.io_signature(num_inputs, num_inputs, self._item_size),
            gr.io_signature(0, 0, 0),
        )
        #scope
        msgq = gr.msg_queue(2)
        scope = gr.oscope_sink_f(sample_rate, msgq)
        #controller
        self.controller = pubsub()
        self.controller.subscribe(SAMPLE_RATE_KEY, scope.set_sample_rate)
        self.controller.publish(SAMPLE_RATE_KEY, scope.sample_rate)
        self.controller.subscribe(DECIMATION_KEY, scope.set_decimation_count)
        self.controller.publish(DECIMATION_KEY, scope.get_decimation_count)
        self.controller.subscribe(TRIGGER_LEVEL_KEY, scope.set_trigger_level)
        self.controller.publish(TRIGGER_LEVEL_KEY, scope.get_trigger_level)
        self.controller.subscribe(TRIGGER_MODE_KEY, scope.set_trigger_mode)
        self.controller.publish(TRIGGER_MODE_KEY, scope.get_trigger_mode)
        self.controller.subscribe(TRIGGER_SLOPE_KEY, scope.set_trigger_slope)
        self.controller.publish(TRIGGER_SLOPE_KEY, scope.get_trigger_slope)
        self.controller.subscribe(TRIGGER_CHANNEL_KEY,
                                  scope.set_trigger_channel)
        self.controller.publish(TRIGGER_CHANNEL_KEY, scope.get_trigger_channel)
        actual_num_inputs = self._real and num_inputs or num_inputs * 2
        #init ac couple
        for i in range(actual_num_inputs):
            self.controller[common.index_key(AC_COUPLE_KEY, i)] = ac_couple

    #start input watcher
        common.input_watcher(msgq, self.controller, MSG_KEY)
        #create window
        self.win = scope_window.scope_window(
            parent=parent,
            controller=self.controller,
            size=size,
            title=title,
            frame_rate=frame_rate,
            num_inputs=actual_num_inputs,
            sample_rate_key=SAMPLE_RATE_KEY,
            t_scale=t_scale,
            v_scale=v_scale,
            v_offset=v_offset,
            xy_mode=xy_mode,
            trig_mode=trig_mode,
            y_axis_label=y_axis_label,
            ac_couple_key=AC_COUPLE_KEY,
            trigger_level_key=TRIGGER_LEVEL_KEY,
            trigger_mode_key=TRIGGER_MODE_KEY,
            trigger_slope_key=TRIGGER_SLOPE_KEY,
            trigger_channel_key=TRIGGER_CHANNEL_KEY,
            decimation_key=DECIMATION_KEY,
            msg_key=MSG_KEY,
            use_persistence=use_persistence,
            persist_alpha=persist_alpha,
        )
        common.register_access_methods(self, self.win)
        #connect
        if self._real:
            for i in range(num_inputs):
                self.wxgui_connect(
                    (self, i),
                    ac_couple_block(self.controller,
                                    common.index_key(AC_COUPLE_KEY, i),
                                    SAMPLE_RATE_KEY),
                    (scope, i),
                )
        else:
            for i in range(num_inputs):
                c2f = gr.complex_to_float()
                self.wxgui_connect((self, i), c2f)
                for j in range(2):
                    self.connect(
                        (c2f, j),
                        ac_couple_block(
                            self.controller,
                            common.index_key(AC_COUPLE_KEY, 2 * i + j),
                            SAMPLE_RATE_KEY),
                        (scope, 2 * i + j),
                    )
Esempio n. 3
0
	def __init__(
		self,
		parent,
		title='',
		sample_rate=1,
		size=scope_window.DEFAULT_WIN_SIZE,
		v_scale=0,
		t_scale=0,
		v_offset=0,
		xy_mode=False,
		ac_couple=False,
		num_inputs=1,
		trig_mode=scope_window.DEFAULT_TRIG_MODE,
		y_axis_label='Counts',
		frame_rate=scope_window.DEFAULT_FRAME_RATE,
                use_persistence=False,
                persist_alpha=None,
		**kwargs #do not end with a comma
	):
                #ensure analog alpha
                if persist_alpha is None:
                  actual_frame_rate=float(frame_rate)
                  analog_cutoff_freq=0.5 # Hertz
                  #calculate alpha from wanted cutoff freq
                  persist_alpha = 1.0 - math.exp(-2.0*math.pi*analog_cutoff_freq/actual_frame_rate)

		if not t_scale: t_scale = 10.0/sample_rate
		#init
		gr.hier_block2.__init__(
			self,
			"scope_sink",
			gr.io_signature(num_inputs, num_inputs, self._item_size),
			gr.io_signature(0, 0, 0),
		)
		#scope
		msgq = gr.msg_queue(2)
		scope = gr.oscope_sink_f(sample_rate, msgq)
		#controller
		self.controller = pubsub()
		self.controller.subscribe(SAMPLE_RATE_KEY, scope.set_sample_rate)
		self.controller.publish(SAMPLE_RATE_KEY, scope.sample_rate)
		self.controller.subscribe(DECIMATION_KEY, scope.set_decimation_count)
		self.controller.publish(DECIMATION_KEY, scope.get_decimation_count)
		self.controller.subscribe(TRIGGER_LEVEL_KEY, scope.set_trigger_level)
		self.controller.publish(TRIGGER_LEVEL_KEY, scope.get_trigger_level)
		self.controller.subscribe(TRIGGER_MODE_KEY, scope.set_trigger_mode)
		self.controller.publish(TRIGGER_MODE_KEY, scope.get_trigger_mode)
		self.controller.subscribe(TRIGGER_SLOPE_KEY, scope.set_trigger_slope)
		self.controller.publish(TRIGGER_SLOPE_KEY, scope.get_trigger_slope)
		self.controller.subscribe(TRIGGER_CHANNEL_KEY, scope.set_trigger_channel)
		self.controller.publish(TRIGGER_CHANNEL_KEY, scope.get_trigger_channel)
		actual_num_inputs = self._real and num_inputs or num_inputs*2
		#init ac couple
		for i in range(actual_num_inputs):
			self.controller[common.index_key(AC_COUPLE_KEY, i)] = ac_couple
		#start input watcher
		common.input_watcher(msgq, self.controller, MSG_KEY)
		#create window
		self.win = scope_window.scope_window(
			parent=parent,
			controller=self.controller,
			size=size,
			title=title,
			frame_rate=frame_rate,
			num_inputs=actual_num_inputs,
			sample_rate_key=SAMPLE_RATE_KEY,
			t_scale=t_scale,
			v_scale=v_scale,
			v_offset=v_offset,
			xy_mode=xy_mode,
			trig_mode=trig_mode,
			y_axis_label=y_axis_label,
			ac_couple_key=AC_COUPLE_KEY,
			trigger_level_key=TRIGGER_LEVEL_KEY,
			trigger_mode_key=TRIGGER_MODE_KEY,
			trigger_slope_key=TRIGGER_SLOPE_KEY,
			trigger_channel_key=TRIGGER_CHANNEL_KEY,
			decimation_key=DECIMATION_KEY,
			msg_key=MSG_KEY,
                        use_persistence=use_persistence,
                        persist_alpha=persist_alpha,
		)
		common.register_access_methods(self, self.win)
		#connect
		if self._real:
			for i in range(num_inputs):
				self.wxgui_connect(
					(self, i),
					ac_couple_block(self.controller, common.index_key(AC_COUPLE_KEY, i), SAMPLE_RATE_KEY),
					(scope, i),
				)
		else:
			for i in range(num_inputs):
				c2f = gr.complex_to_float()
				self.wxgui_connect((self, i), c2f)
				for j in range(2):
					self.connect(
						(c2f, j),
						ac_couple_block(self.controller, common.index_key(AC_COUPLE_KEY, 2*i+j), SAMPLE_RATE_KEY),
						(scope, 2*i+j),
					)