Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
 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)]
Ejemplo n.º 4
0
 def rld_powerdown(self) -> bool:
     rld_byte = self._get_rld_byte()
     return not bit_is_set(rld_byte, self.RLD_PD_BIT)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
 def is_sync_master(self) -> bool:
     return bit_is_set(self._trial_config, TRIAL_CONFIG_MASTER)
Ejemplo n.º 7
0
 def has_sync(self) -> bool:
     return bit_is_set(self._trial_config, TRIAL_CONFIG_SYNC)
Ejemplo n.º 8
0
 def unpack_status_bitfields(self, val):
     values = [bit_is_set(val, f) for f in self.STATUS_BITFIELDS]
     return values