def test_bit_is_set(self): r = bit_is_set(0x10, 0x01) self.assertEqual(r, False) r = bit_is_set(0x10, 0x10) self.assertEqual(r, True) r = bit_is_set(0x05, 0x01) self.assertEqual(r, True) r = bit_is_set(0x05, 0x02) self.assertEqual(r, False) r = bit_is_set(0x05, 0x04) self.assertEqual(r, True)
def _read_enabled_sensors(self) -> List[ESensorGroup]: self._seek(ENABLED_SENSORS_OFFSET) sensor_dtype = ChannelDataType(size=ENABLED_SENSORS_LEN, signed=False, le=True) sensor_bitfield = sensor_dtype.decode(self._read(ENABLED_SENSORS_LEN)) enabled_sensors = [] for sensor in ESensorGroup: bit_pos = SensorBitAssignments[sensor] if bit_is_set(sensor_bitfield, bit_pos): enabled_sensors += [sensor] return sort_sensors(enabled_sensors)
def rld_channels(self) -> List[ExGRLDLead]: rld_byte = self._get_rld_byte() return [ch for ch in ExGRLDLead if bit_is_set(rld_byte, ch.value)]
def rld_powerdown(self) -> bool: rld_byte = self._get_rld_byte() return not bit_is_set(rld_byte, self.RLD_PD_BIT)
def is_ch_powerdown(self, ch_id: int) -> bool: self.check_ch_id(ch_id) ch_byte = self._get_ch_byte(ch_id) return bit_is_set(ch_byte, self.PD_BIT)
def is_sync_master(self) -> bool: return bit_is_set(self._trial_config, TRIAL_CONFIG_MASTER)
def has_sync(self) -> bool: return bit_is_set(self._trial_config, TRIAL_CONFIG_SYNC)
def unpack_status_bitfields(self, val): values = [bit_is_set(val, f) for f in self.STATUS_BITFIELDS] return values