Esempio n. 1
0
		def add_dc(id, name, base):
			dc = DeviceConfig(id, name, d)
			dc.base = base
			dc.spacing = 1
			dc.num = 1000
			dc.time = 1
			cl._add_config(dc)
Esempio n. 2
0
	def _get_sc(self):
		d = Device(0, "test")

		dc = DeviceConfig(0, "foo", d)
		dc.base = 1000
		dc.spacing = 1
		dc.num = 1000
		dc.time = 1

		sc = SweepConfig(dc, 0, 3, 1)

		return sc
	def setUp(self):
		self.d = Device(0, "test")

		self.dc = DeviceConfig(0, "test", self.d)
		self.dc.base = 1000
		self.dc.spacing = 30
		self.dc.num = 1000
Esempio n. 4
0
    def get_config_list(self):
        """Query and return the list of supported device configurations.

		:return: a :py:class:`ConfigList` object
		"""
        config_list = ConfigList()

        device = None
        config = None

        description = self.alh.get("sensing/deviceConfigList")
        description = description.decode("ascii")
        configs_left = 0
        state = 0
        for line in description.split("\n"):
            g = re.match("dev #([0-9]+), (.+), ([0-9]+) configs:", line)
            if state == 0 and g:
                device = Device(int(g.group(1)), g.group(2))
                config_list._add_device(device)
                configs_left = int(g.group(3))
                state = 1
                continue

            g = re.match("  cfg #([0-9]+): (.+):", line)
            if state == 1 and g:
                config = DeviceConfig(int(g.group(1)), g.group(2), device)
                state = 2

                continue

            g = re.match(
                "     base: ([0-9]+) Hz, spacing: ([0-9]+) Hz, bw: ([0-9]+) Hz, channels: ([0-9]+), time: ([0-9]+) ms",
                line)
            if state == 2 and g:
                config.base = int(g.group(1))
                config.spacing = int(g.group(2))
                config.bw = int(g.group(3))
                config.num = int(g.group(4))
                config.time = int(g.group(5))

                config_list._add_config(config)

                configs_left -= 1
                if configs_left < 0:
                    raise CRCError
                elif configs_left == 0:
                    state = 0
                else:
                    state = 1

                continue

        if configs_left != 0:
            raise CRCError

        return config_list
	def get_config_list(self):
		"""Query and return the list of supported device configurations.

		Returns a ConfigList object.
		"""
		config_list = ConfigList()

		device = None
		config = None

		description = self.alh.get("sensing/deviceConfigList")
		for line in description.split("\n"):
			g = re.match("dev #([0-9]+), (.+), [0-9]+ configs:", line)
			if g:
				device = Device(int(g.group(1)), g.group(2))
				config_list._add_device(device)
				continue

			g = re.match("  cfg #([0-9]+): (.+):", line)
			if g:
				config = DeviceConfig(int(g.group(1)), g.group(2), device)
				config_list._add_config(config)
				continue

			g = re.match("     base: ([0-9]+) Hz, spacing: ([0-9]+) Hz, bw: ([0-9]+) Hz, channels: ([0-9]+), time: ([0-9]+) ms", line)
			if g:
				config.base = int(g.group(1))
				config.spacing = int(g.group(2))
				config.bw = int(g.group(3))
				config.num = int(g.group(4))
				config.time = int(g.group(5))
				continue

		return config_list
Esempio n. 6
0
    def setUp(self):
        d = Device(0, "test")

        dc = DeviceConfig(0, "foo", d)
        dc.base = 1000
        dc.spacing = 1
        dc.num = 1000

        sc = SweepConfig(dc, 0, 3, 1)

        p = SpectrumSensorProgram(sc, 0, 10, 1)

        self.r = r = SpectrumSensorResult(p)

        s = Sweep()
        s.timestamp = 0.0
        s.data = [0.0, 1.0, 2.0]
        r.sweeps.append(s)

        s = Sweep()
        s.timestamp = 1.0
        s.data = [3.0, 4.0]
        r.sweeps.append(s)
Esempio n. 7
0
	def setUp(self):
		d = Device(0, "test")

		dc = DeviceConfig(0, "foo", d)
		dc.base = 1000
		dc.spacing = 1
		dc.num = 1000

		sc = SweepConfig(dc, 0, 3, 1)

		p = SpectrumSensorProgram(sc, 0, 10, 1)

		self.r = r = SpectrumSensorResult(p)

		s = Sweep()
		s.timestamp = 0.0
		s.data = [ 0.0, 1.0, 2.0 ]
		r.sweeps.append(s)

		s = Sweep()
		s.timestamp = 1.0
		s.data = [ 3.0, 4.0 ]
		r.sweeps.append(s)
class TestDeviceConfig(unittest.TestCase):
	def setUp(self):
		self.d = Device(0, "test")

		self.dc = DeviceConfig(0, "test", self.d)
		self.dc.base = 1000
		self.dc.spacing = 30
		self.dc.num = 1000

	def test_get_full_sweep_config_1(self):
		sc = self.dc.get_full_sweep_config()
		self.assertEqual(sc.step_ch, 1)

	def test_get_full_sweep_config_2(self):
		sc = self.dc.get_full_sweep_config(step_hz=5)
		self.assertEqual(sc.step_ch, 1)

	def test_get_full_sweep_config_3(self):
		sc = self.dc.get_full_sweep_config(step_hz=35)
		self.assertEqual(sc.step_ch, 1)

	def test_get_full_sweep_config_3(self):
		sc = self.dc.get_full_sweep_config(step_hz=45)
		self.assertEqual(sc.step_ch, 2)
Esempio n. 9
0
	def get_config_list(self):
		"""Query and return the list of supported device configurations.

		:return: a :py:class:`ConfigList` object
		"""
		config_list = ConfigList()

		device = None
		config = None

		description = self.alh.get("sensing/deviceConfigList")
		description = description.decode("ascii")
		configs_left = 0
		state = 0
		for line in description.split("\n"):
			g = re.match("dev #([0-9]+), (.+), ([0-9]+) configs:", line)
			if state == 0 and g:
				device = Device(int(g.group(1)), g.group(2))
				config_list._add_device(device)
				configs_left = int(g.group(3))
				state = 1
				continue

			g = re.match("  cfg #([0-9]+): (.+):", line)
			if state == 1 and g:
				config = DeviceConfig(int(g.group(1)), g.group(2), device)
				state = 2

				continue

			g = re.match("     base: ([0-9]+) Hz, spacing: ([0-9]+) Hz, bw: ([0-9]+) Hz, channels: ([0-9]+), time: ([0-9]+) ms", line)
			if state == 2 and g:
				config.base = int(g.group(1))
				config.spacing = int(g.group(2))
				config.bw = int(g.group(3))
				config.num = int(g.group(4))
				config.time = int(g.group(5))

				config_list._add_config(config)

				configs_left -= 1
				if configs_left < 0:
					raise CRCError
				elif configs_left == 0:
					state = 0
				else:
					state = 1

				continue

		if configs_left != 0:
			raise CRCError

		return config_list
Esempio n. 10
0
    def _get_sc(self):
        d = Device(0, "test")

        dc = DeviceConfig(0, "foo", d)
        dc.base = 1000
        dc.spacing = 1
        dc.num = 1000
        dc.time = 1

        sc = SweepConfig(dc, 0, 3, 1)

        return sc