Skip to content

Instantly share code, notes, and snippets.

@sloria
Last active December 19, 2015 04:18
Show Gist options
  • Save sloria/5895669 to your computer and use it in GitHub Desktop.
Save sloria/5895669 to your computer and use it in GitHub Desktop.
class Boiler:
def safety_check(self):
# Convert fixed-point floating point
temperature = self.modbus.read_holding()
pressure_psi = self.abb_f100.register / F100_FACTOR
if (psi_to_pascal(pressure_psi) > MAX_PRESSURE or
temperature > MAX_TEMPERATURE):
# Shutdown!
self.pnoz.relay[15] &= MASK_POWER_COIL
self.pnoz.port.write('$PL,15\0')
sleep(RELAY_RESPONSE_DELAY)
# Successful shutdown?
if self.pnoz.relay[16] & MASK_POWER_OFF:
# Play alarm
with open(BUZZER_MP3_FILE) as f:
play_sound(f.read())
@arnib
Copy link

arnib commented Feb 28, 2014

Came to say the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment