예제 #1
0
    def test_should_not_set_the_mode_on_the_second_command(self):
        mockOs = Mock()
        gpio_writer = GpioWriter(10,mockOs)
        gpio_writer.high()
        mockOs.reset_mock()
        gpio_writer.high()

        mockOs.system.assert_called_once_with("gpio -g write 10 1")
예제 #2
0
    def test_should_set_the_mode_on_the_first_command(self):
        mockOs = Mock()
        gpio_writer = GpioWriter(10, mockOs)
        gpio_writer.high()

        mockOs.system.assert_has_calls(
            [call("gpio -g mode 10 out"),
             call("gpio -g write 10 1")])
예제 #3
0
    def test_should_set_the_port_low(self):
        mockOs = Mock()
        gpio_writer = GpioWriter(10, mockOs)
        gpio_writer.low()

        mockOs.system.assert_has_calls(
            [call("gpio -g mode 10 out"),
             call("gpio -g write 10 0")])
예제 #4
0
    def __init__(self, gps=False, servo_port=SERVO_PORT):
        # devices
        self._gps = gps
        self.windsensor = WindSensor(I2C(WINDSENSOR_I2C_ADDRESS))
        self.compass = Compass(I2C(COMPASS_I2C_ADDRESS),
                               I2C(ACCELEROMETER_I2C_ADDRESS))
        self.red_led = GpioWriter(17, os)
        self.green_led = GpioWriter(18, os)

        # Navigation
        self.globe = Globe()
        self.timer = Timer()
        self.application_logger = self._rotating_logger(APPLICATION_NAME)
        self.position_logger = self._rotating_logger("position")
        self.exchange = Exchange(self.application_logger)
        self.timeshift = TimeShift(self.exchange, self.timer.time)
        self.event_source = EventSource(self.exchange, self.timer,
                                        self.application_logger,
                                        CONFIG['event source'])

        self.sensors = Sensors(self.gps, self.windsensor, self.compass,
                               self.timer.time, self.exchange,
                               self.position_logger, CONFIG['sensors'])
        self.gps_console_writer = GpsConsoleWriter(self.gps)
        self.rudder_servo = Servo(serial.Serial(servo_port),
                                  RUDDER_SERVO_CHANNEL, RUDDER_MIN_PULSE,
                                  RUDDER_MIN_ANGLE, RUDDER_MAX_PULSE,
                                  RUDDER_MAX_ANGLE)
        self.steerer = Steerer(self.rudder_servo, self.application_logger,
                               CONFIG['steerer'])
        self.helm = Helm(self.exchange, self.sensors, self.steerer,
                         self.application_logger, CONFIG['helm'])
        self.course_steerer = CourseSteerer(self.sensors, self.helm,
                                            self.timer,
                                            CONFIG['course steerer'])
        self.navigator = Navigator(self.sensors, self.globe, self.exchange,
                                   self.application_logger,
                                   CONFIG['navigator'])
        self.self_test = SelfTest(self.red_led, self.green_led, self.timer,
                                  self.rudder_servo, RUDDER_MIN_ANGLE,
                                  RUDDER_MAX_ANGLE)

        # Tracking
        self.tracking_logger = self._rotating_logger("track")
        self.tracking_sensors = Sensors(self.gps, self.windsensor,
                                        self.compass, self.timer.time,
                                        self.exchange, self.tracking_logger,
                                        CONFIG['sensors'])
        self.tracker = Tracker(self.tracking_logger, self.tracking_sensors,
                               self.timer)
예제 #5
0
    def test_should_not_set_the_mode_on_the_second_command(self):
        mockOs = Mock()
        gpio_writer = GpioWriter(10, mockOs)
        gpio_writer.high()
        mockOs.reset_mock()
        gpio_writer.high()

        mockOs.system.assert_called_once_with("gpio -g write 10 1")
예제 #6
0
    def test_should_set_the_mode_on_the_first_command(self):
        mockOs = Mock()
        gpio_writer = GpioWriter(10,mockOs)
        gpio_writer.high()

        mockOs.system.assert_has_calls([call("gpio -g mode 10 out"),call("gpio -g write 10 1")])
예제 #7
0
    def test_should_set_the_port_low(self):
        mockOs = Mock()
        gpio_writer = GpioWriter(10,mockOs)
        gpio_writer.low()

        mockOs.system.assert_has_calls([call("gpio -g mode 10 out"),call("gpio -g write 10 0")])