Skip to content

Instantly share code, notes, and snippets.

@sloria
Last active December 19, 2015 04:18
Show Gist options
  • Select an option

  • Save sloria/5895669 to your computer and use it in GitHub Desktop.

Select an option

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())
@jim02762

jim02762 commented Sep 5, 2013

Copy link
Copy Markdown

Line 13 wouldn't work very well. Replace "& a m p ;" with just "&".

@arnib

arnib commented Feb 28, 2014

Copy link
Copy Markdown

Came to say the same thing.

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