def __init__(self, buff_size=700, D0=True, D1=True, D2=False, D3=False): # Devices an chanels self._DEVICE_LIST = [] self._DEVICE_LIST.append(Device( 0, buff_size)) if D0 else self._DEVICE_LIST.append(None) self._DEVICE_LIST.append(Device( 1, buff_size)) if D1 else self._DEVICE_LIST.append(None) self._DEVICE_LIST.append(Device( 2, buff_size)) if D2 else self._DEVICE_LIST.append(None) self._DEVICE_LIST.append(Device( 3, buff_size)) if D3 else self._DEVICE_LIST.append(None) self._ACTIVE_LIST = [D0, D1, D2, D3] self._received_list = list(map(lambda x: not x, self._ACTIVE_LIST)) self.buff_size = buff_size self.start_time = 0 self.last = 0 self.time = 0 self.is_writting = False self.labels = deque() self.writting_lists = deque() self.label_cursor = 0 self.lines = 0 self._file = None # HardCode self.device_list_name = ["0-R1", "1-R2", "2-L1", "3-L2"] self.sensor_list_name = ["Acc", "Gyr", "Mag"]
def init_devices(self): self.logger.debug("Entering init_devices()") self._color_service_global = ColorServiceGlobal(self._config) for key in self._config["device_configs"].keys(): device_id = key self.logger.debug(f"Init device with device id: {device_id}") self._devices[device_id] = Device( self._config, self._config["device_configs"][device_id], self._color_service_global) self.logger.debug("Leaving init_devices()")
def init_devices(self): print("Enter init_devices()") self._color_service_global = ColorServiceGlobal(self._config) for key in self._config["device_configs"].keys(): device_id = key print("Init device with device id:" + device_id) self._devices[device_id] = Device( self._config, self._config["device_configs"][device_id], self._color_service_global) print("Leave init_devices()")
class TestDevice(unittest.TestCase): device = Device(car="audi", mode="kierowca") def test_connect_to_car_true(self): self.device.connect_to_car(True) self.assertDictEqual(self.device.connected, { "info": "audi-kierowca", "state": True }) def test_connect_to_car_false(self): self.device.connect_to_car(False) self.assertDictEqual(self.device.connected, { "info": "audi-kierowca", "state": False })