Last active
December 19, 2015 04:18
-
-
Save sloria/5895669 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 13 wouldn't work very well. Replace "& a m p ;" with just "&".