Esempio n. 1
0
 def _apply_fault_queue_length(self, config, length):
     bit_0_set = (length << 3) & FAULT_QUEUE_BIT_0
     bit_1_set = (length << 3) & FAULT_QUEUE_BIT_1
     config[0] = _set_bit_for_boolean(config[0], FAULT_QUEUE_BIT_0,
                                      bit_0_set)
     config[0] = _set_bit_for_boolean(config[0], FAULT_QUEUE_BIT_1,
                                      bit_1_set)
     return config
Esempio n. 2
0
 def _apply_fault_queue_length(self, config, length):
     bit_0_set = (length << 3) & FAULT_QUEUE_BIT_0
     bit_1_set = (length << 3) & FAULT_QUEUE_BIT_1
     config[0] = _set_bit_for_boolean(
         config[0],
         FAULT_QUEUE_BIT_0,
         bit_0_set
     )
     config[0] = _set_bit_for_boolean(
         config[0],
         FAULT_QUEUE_BIT_1,
         bit_1_set
     )
     return config
 def _apply_conversion_rate(self, config, rate):
     bit_0_set = (rate << 6) & CONVERSION_RATE_BIT_0
     bit_1_set = (rate << 6) & CONVERSION_RATE_BIT_1
     config[1] = _set_bit_for_boolean(
         config[1],
         CONVERSION_RATE_BIT_0,
         bit_0_set
     )
     config[1] = _set_bit_for_boolean(
         config[1],
         CONVERSION_RATE_BIT_1,
         bit_1_set
     )
     return config
Esempio n. 4
0
 def _apply_shutdown(self, config, shutdown_set):
     config[0] = _set_bit_for_boolean(
         config[0],
         SHUTDOWN_BIT,
         shutdown_set
     )
     return config
Esempio n. 5
0
 def _apply_thermostat_mode(self, config, mode_set):
     config[0] = _set_bit_for_boolean(
         config[0],
         THERMOSTAT_MODE_BIT,
         mode_set
     )
     return config
Esempio n. 6
0
 def _apply_alert_polarity(self, config, polarity_set):
     config[0] = _set_bit_for_boolean(
         config[0],
         POLARITY_BIT,
         polarity_set
     )
     return config
 def _apply_extended_mode(self, config, mode_set):
     config[1] = _set_bit_for_boolean(
         config[1],
         EXTENDED_MODE_BIT,
         mode_set
     )
     return config
Esempio n. 8
0
 def initiate_conversion(self):
     """
     Initiate a one-shot conversion.
     """
     current_config = self._get_config()
     if not current_config[0] & SHUTDOWN_BIT:
         raise RuntimeError(
             "Device must be shut down to initiate one-shot conversion")
     new_config = bytearray(current_config)
     new_config[0] = _set_bit_for_boolean(new_config[0], ONE_SHOT_BIT, True)
     self._set_config(new_config)
Esempio n. 9
0
 def _apply_shutdown(self, config, shutdown_set):
     config[0] = _set_bit_for_boolean(config[0], SHUTDOWN_BIT, shutdown_set)
     return config
Esempio n. 10
0
 def _apply_extended_mode(self, config, mode_set):
     config[1] = _set_bit_for_boolean(config[1], EXTENDED_MODE_BIT,
                                      mode_set)
     return config
Esempio n. 11
0
 def _apply_thermostat_mode(self, config, mode_set):
     config[0] = _set_bit_for_boolean(config[0], THERMOSTAT_MODE_BIT,
                                      mode_set)
     return config
Esempio n. 12
0
 def _apply_alert_polarity(self, config, polarity_set):
     config[0] = _set_bit_for_boolean(config[0], POLARITY_BIT, polarity_set)
     return config