Exemple #1
0
    def generate_packet(self):
        """Generates a packet based upon the current class variables. Note that
        current temperature is not sent, as the original application sent zeros
        to the roaster for the current temperature."""
        roaster_time = utils.seconds_to_float(self.time_remaining)
        packet = (self._header.value + self._temp_unit.value +
                  self._flags.value + self._current_state.value +
                  self.fan_speed.to_bytes(1, byteorder='big') +
                  int(float(roaster_time * 10)).to_bytes(1, byteorder='big') +
                  self.heat_setting.to_bytes(1, byteorder='big') +
                  b'\x00\x00' + self._footer)

        return packet
Exemple #2
0
    def generate_packet(self):
        """Generates a packet based upon the current class variables. Note that
        current temperature is not sent, as the original application sent zeros
        to the roaster for the current temperature."""
        roaster_time = utils.seconds_to_float(self.time_remaining)
        packet = (
            self._header.value +
            self._temp_unit.value +
            self._flags.value +
            self._current_state.value +
            self.fan_speed.to_bytes(1, byteorder='big') +
            int(float(roaster_time * 10)).to_bytes(1, byteorder='big') +
            self.heat_setting.to_bytes(1, byteorder='big') +
            b'\x00\x00' +
            self._footer)

        return packet
Exemple #3
0
    def _generate_packet(self):
        """Generates a packet based upon the current class variables. Note that
        current temperature is not sent, as the original application sent zeros
        to the roaster for the current temperature."""
        roaster_time = utils.seconds_to_float(self._time_remaining.value)
        packet = (
            self._header.value +
            self._temp_unit.value +
            self._flags.value +
            self._current_state.value +
            struct.pack(">B", self._fan_speed.value) +
            struct.pack(">B", int(round(roaster_time * 10.0))) +
            struct.pack(">B", self._heat_setting.value) +
            b'\x00\x00' +
            self._footer)

        return packet
 def test_seconds_to_float_exact(self):
     self.assertEqual(9.9, utils.seconds_to_float(594))
 def test_seconds_to_float_high(self):
     self.assertEqual(9.9, utils.seconds_to_float(595))
 def test_seconds_to_float(self):
     self.assertEqual(6.6, utils.seconds_to_float(394))
 def test_seconds_to_float_exact(self):
     self.assertEqual(9.9, utils.seconds_to_float(594))
 def test_seconds_to_float_high(self):
     self.assertEqual(9.9, utils.seconds_to_float(595))
 def test_seconds_to_float(self):
     self.assertEqual(6.6, utils.seconds_to_float(394))