Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

41 rinda
1.2KB

  1. from modules import cbpi
  2. from modules.core.controller import KettleController
  3. from modules.core.props import Property
  4. @cbpi.controller
  5. class Hysteresis(KettleController):
  6. # Custom Properties
  7. on = Property.Number("Offset On", True, 0, description="Offset below target temp when heater should switched on. Should be bigger then Offset Off")
  8. off = Property.Number("Offset Off", True, 0, description="Offset below target temp when heater should switched off. Should be smaller then Offset Off")
  9. def stop(self):
  10. '''
  11. Invoked when the automatic is stopped.
  12. Normally you switch off the actors and clean up everything
  13. :return: None
  14. '''
  15. super(KettleController, self).stop()
  16. self.heater_off()
  17. def run(self):
  18. '''
  19. Each controller is exectuted in its own thread. The run method is the entry point
  20. :return:
  21. '''
  22. while self.is_running():
  23. if self.get_temp() < self.get_target_temp() - float(self.on):
  24. self.heater_on(100)
  25. elif self.get_temp() >= self.get_target_temp() - float(self.off):
  26. self.heater_off()
  27. else:
  28. self.heater_off()
  29. self.sleep(1)