Commit 99d9c207 authored by Marco Buttu's avatar Marco Buttu
Browse files

Bug to fix: auto rewinding does not work as expected. test_startUpdating fails.

parent 8d521260
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -22,20 +22,25 @@ class MockDevice(object):
        return self.is_updating

    def getMinLimit(self):
        return -230.0
        return -85.77

    def getMaxLimit(self):
        return +230.0
        return +125.23

    def getStep(self):
        return 60.0

    def setPosition(self, position):
        self.cmd_position = position
        if self.getMinLimit() < position < self.getMaxLimit():
            self.position = position

    def getActPosition(self):
        return self.position

    def getCmdPosition(self):
        return self.cmd_position

    def park(self):
        self._setDefault()

@@ -44,7 +49,7 @@ class MockDevice(object):
        return Property(0, completion)

    def _setDefault(self):
        self.position = 0.0
        self.position = self.cmd_position = 0.0
        self.is_ready = False
        self.is_tracking = False
        self.is_updating = False
+34 −0
Original line number Diff line number Diff line
@@ -119,6 +119,40 @@ class PositionerStartUpdatingTest(unittest2.TestCase):
        finally:
            self.p.stopUpdating()


    def test_custom_auto_rewinding(self):
        self.cdbconf.setup('KKG')
        self.cdbconf.setConfiguration('CUSTOM')
        latitude = radians(39.49)
        site_info = {'latitude': latitude}
        self.p.setup(site_info, self.source, self.device)
        self.p.setRewindingMode('AUTO')
        
        Pis = -23
        self.cdbconf.updateInitialPositions(Pis)
        try:
            # Az and el in radians; the related parallactic angle is -63
            az, el = 1.2217, 0.6109
            parallactic = PosGenerator.getParallacticAngle(latitude, az, el)
            target = Pis + parallactic
            min_limit = self.device.getMinLimit()
            # The final angle is -86, lower than the min limit (-85.77)
            self.assertLess(target, min_limit)

            self.source.setAzimuth(az)
            self.source.setElevation(el)
            self.p.startUpdating('MNG_TRACK', 'ANT_NORTH', az, el)

            # For the K Band, we expect a rewind of 120 degrees
            # rewind_angle = self.p.getAutoRewindingSteps() * self.device.getStep()
            rewind_angle = 180 # The maximum, in case getAutoRewindingSteps is 0
            expected = target + rewind_angle
            time.sleep(0.11)
            self.assertEqual(expected, self.device.getActPosition())
        finally:
            self.p.stopUpdating()


    def test_custom_opt(self):
        self.cdbconf.setup('KKG')
        self.cdbconf.setConfiguration('CUSTOM_OPT')