def getUser(id): accessType = getDatabase().getUserAccessType(id) if accessType == "UNAUTHORIZED": return User.User(id, 0, accessType) else: return User.User(id, ConfigurationManager.getDefaultSessionTime(), accessType)
def sessionChanged(self,newSession): lastSession = self.currentSession self.currentSession = newSession # Set the text if the session exists. if newSession is not None: self.screen.setLineText(1,ConfigurationManager.getMachineName()) self.sessionTimerThread.updateTime(newSession) # Display the started or extended message. if lastSession is None: self.messageChanged("Started session") self.buzzer.pulseBuzzer(2) self.leds.pulseColor("Red",2) else: if lastSession.getUser().getId() == newSession.getUser().getId(): self.messageChanged("Extended session") self.buzzer.pulseBuzzer(2) self.leds.pulseColor("Yellow",2) else: self.messageChanged("Started session") self.buzzer.pulseBuzzer(2) self.leds.pulseColor("Yellow",2) # Set the relay as active. self.relay.setActive(True) else: self.relay.setActive(False)
def __init__(self,hardwareController): super().__init__() self.hardwareController = hardwareController self.daemon = True self.lastTimeLeft = 0 self.buzzerStartTime = ConfigurationManager.getWarningAlarmActivationTime()
def test_getWarningAlarmActivationTime(self): self.assertEqual(ConfigurationManager.getWarningAlarmActivationTime(),20,"Setting is incorrect.")
def test_getDefaultSessionTime(self): self.assertEqual(ConfigurationManager.getDefaultSessionTime(),60,"Setting is incorrect.")
def test_getMachineName(self): self.assertEqual(ConfigurationManager.getMachineName(),"Test Machine","Setting is incorrect.")
def test_readSetting(self): self.assertEqual(ConfigurationManager.readSetting("DisplayName"),"Test Machine","Setting is incorrect.") self.assertEqual(ConfigurationManager.readSetting("DefaultSessionTime"),60,"Setting is incorrect.") self.assertEqual(ConfigurationManager.readSetting("AlarmActivationTime"),20,"Setting is incorrect.") self.assertEqual(ConfigurationManager.readSetting("CustomSetting"),True,"Setting is incorrect.")