Esempio n. 1
0
 def run(self):
     lamp_controller = None
     try:
         lamp = self._create_objects()
         lamp_controller = LampController(lamp, self.logger)
         # MAIN LOOP
         while True:
             self._commands_controller(lamp_controller)
             time.sleep(3)  # every 3 seconds
     except Exception:
         self.logger.exception("Exception: %s", sys.exc_info()[1])
     except KeyboardInterrupt:
         self.logger.warn("Cancelled by user: %s", sys.exc_info()[1])
     finally:
         lamp_controller.switch_off()
Esempio n. 2
0
 def test_turn_on(self):
     controller = LampController()
     controller.turn_on()
     self.assertTrue(controller.is_on())
Esempio n. 3
0
 def test_set_on(self):
     controller = LampController()
     controller.set_on()
     self.assertTrue(controller.get_status())
Esempio n. 4
0
 def test_test_off(self):
     controller = LampController()
     controller.set_off()
     self.assertFalse(controller.get_status())
Esempio n. 5
0
 def setUp(self):
     self.controller = LampController()
     self.controller.create_lamp(1)
     self.controller.create_lamp(2)
     self.controller.create_ColorLamp(3, 'white')
     self.controller.create_LampArray(4)
Esempio n. 6
0
from controllers import LampController

if __name__ == "__main__":
    controller = LampController()
    while True:
        line = input()

        if line == "":
            exit(0)

        commands = line.split("")

        if commands[0] == "CL":
            # Create simple lamp with ID
            lamp_id = commands[1]
        elif commands[0] == "CCL":
            # Create color lamp with ID
            lamp_color = commands[1]
            lamp_id = commands[2]
        elif commands[0] == "CLA":
            # Create an empty lamp array with ID
            lamp_id = commands[1]
        elif commands[0] == "ALA":
            # Add lamp to array
            lamp_id = commands[1]
            lamp_array_id = commands[2]
        elif commands[0] == "RLA":
            # Remove lamp from array
            lamp_id = commands[1]
            lamp_array_id = commands[2]
        elif commands[0] == "S":
Esempio n. 7
0
 def setUp(self):
     self.controller = LampController()
     self.controller.create_lamp(1)
     self.controller.create_lamp(2)
     self.controller.create_colorLamp(3, 'Black')
Esempio n. 8
0
 def setUp(self):
     self.controller = LampController()
Esempio n. 9
0
 def test_turn_off_after_turn_on(self):
     controller = LampController()
     controller.turn_on()
     controller.turn_off()
     self.assertFalse(controller.is_on())