Commit a3c13da8 authored by marco-buttu's avatar marco-buttu
Browse files

new_source as argument of check/startUpdating()

parent b70a2714
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -52,16 +52,6 @@ module Receivers {
        void setup(in string code) raises (ComponentErrors::ComponentErrorsEx);


        /** Call clearSource() before starting a scan over a new source.
         * 
         * This method has been introduced to avoid a change of sign of the
         * parallactic angle at 180°.
         * The issue is reported here: https://github.com/discos/discos/issues/328
         *
         */
        void clearSource();


        /** Put the derotator in the park position and reset the configuration
         *  
         * This method sets the default values:
@@ -115,6 +105,7 @@ module Receivers {
         * @param elevation the elevation (radians) at the beginning of the scan
         * @param ra the RA (radians) at the beginning of the scan
         * @param dec the DEC (radians) at the beginning of the scan
         * @param new_source True in case there will be a change of source
         * @param feasible_time the closest time for the dewar positioner to be
         *        able to execute the scan.
         *
@@ -144,6 +135,7 @@ module Receivers {
            in double elevation,
            in double ra,
            in double dec,
            in boolean new_source,
            out ACS::Time feasible_time
        ) raises (ComponentErrors::ComponentErrorsEx);

@@ -160,6 +152,7 @@ module Receivers {
         * @param elevation the elevation (radians) at the beginning of the scan
         * @param ra the RA (radians) at the beginning of the scan
         * @param dec the DEC (radians) at the beginning of the scan
         * @param new_source True in case there will be a change of source
         * @throw ComponentErrors::ComponentErrorsEx
         */
        void startUpdating(
@@ -168,7 +161,8 @@ module Receivers {
            in double azimuth,
            in double elevation,
            in double ra,
            in double dec
            in double dec,
            in boolean new_source
        ) raises (ComponentErrors::ComponentErrorsEx);


+6 −9
Original line number Diff line number Diff line
@@ -205,11 +205,6 @@ class DewarPositionerImpl(POA, cc, services, lcycle):
        logger.logNotice('derotator parked')


    def clearSource(self):
        logger.logNotice('cleaning the parallacting angle sign')
        self.positioner._clearSign()


    def getPosition(self):
        try:
            return self.positioner.getPosition()
@@ -358,10 +353,10 @@ class DewarPositionerImpl(POA, cc, services, lcycle):
        return ScanInfo(**self.positioner.getScanInfo())


    def checkUpdating(self, stime, axis, sector, az, el, ra, dec):
    def checkUpdating(self, stime, axis, sector, az, el, ra, dec, new_source):
        try:
            return self.positioner.checkUpdating(
                stime, axis, sector, az, el, ra, dec
                stime, axis, sector, az, el, ra, dec, new_source
            )
        except PositionerError, ex:
            logger.logError(ex.message)
@@ -381,10 +376,12 @@ class DewarPositionerImpl(POA, cc, services, lcycle):
            raise exc.getComponentErrorsEx()


    def startUpdating(self, axis, sector, az, el, ra, dec):
    def startUpdating(self, axis, sector, az, el, ra, dec, new_source):
        logger.logNotice('starting the derotator position updating')
        try:
            self.positioner.startUpdating(axis, sector, az, el, ra, dec)
            self.positioner.startUpdating(
                axis, sector, az, el, ra, dec, new_source
            )
        except PositionerError, ex:
            logger.logError(ex.message)
            exc = ComponentErrorsImpl.OperationErrorExImpl()
+10 −11
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ class Positioner(object):
            self.device = device
            self.device.setup()
            self._clearOffset()
            self._clearSign()
            self.sign = None
            self.is_setup = True
            time.sleep(0.4) # Give the device the time to accomplish the setup
            self.control.updateScanInfo({'iStaticPos': setupPosition})
@@ -147,8 +147,9 @@ class Positioner(object):
                %(self.control.target, self.device.getMinLimit(), self.device.getMaxLimit()))


    def checkUpdating(self, stime, axis, sector, az, el, ra, dec):
    def checkUpdating(self, stime, axis, sector, az, el, ra, dec, new_source):
        sectors = ('ANT_NORTH', 'ANT_SOUTH')
        sign = None if new_source else self.sign
        if not self.isSetup():
            raise NotAllowedError('positioner not configured: a setup() is required')
        elif str(axis) == 'MNG_BEAMPARK':
@@ -170,9 +171,9 @@ class Positioner(object):
        lat = self.siteInfo['latitude']
        try:
            if coordinateFrame == 'horizontal':
                iParallacticPos = getAngleFunction(lat, az, el)
                iParallacticPos = getAngleFunction(lat, az, el, sign)
            elif coordinateFrame == 'equatorial':
                iParallacticPos = getAngleFunction(lat, az, el, ra, dec)
                iParallacticPos = getAngleFunction(lat, az, el, ra, dec, sign)
            else:
                raise PositionerError('coordinate frame %s unknown' % coordinateFrame)
        except ZeroDivisionError:
@@ -219,8 +220,9 @@ class Positioner(object):
        return (ready, future_time)


    def startUpdating(self, axis, sector, az, el, ra, dec):
    def startUpdating(self, axis, sector, az, el, ra, dec, new_source):
        sectors = ('ANT_NORTH', 'ANT_SOUTH')
        sign = None if new_source else self.sign
        try:
            Positioner.generalLock.acquire()
            if not self.isSetup():
@@ -267,9 +269,9 @@ class Positioner(object):
                        lat = self.siteInfo['latitude']
                        try:
                            if coordinateFrame == 'horizontal':
                                iParallacticPos = getAngleFunction(lat, az, el, self.sign)
                                iParallacticPos = getAngleFunction(lat, az, el, sign)
                            elif coordinateFrame == 'equatorial':
                                iParallacticPos = getAngleFunction(lat, az, el, ra, dec, self.sign)
                                iParallacticPos = getAngleFunction(lat, az, el, ra, dec, sign)
                            else:
                                raise PositionerError('coordinate frame %s unknown' %coordinateFrame)
                        except ZeroDivisionError:
@@ -760,16 +762,13 @@ class Positioner(object):
        finally:
            Positioner.generalLock.release()

    def _clearSign(self):
        self.sign = None

    def _setDefault(self):
        self.t = None
        self.is_setup = False
        self.control = Control()
        self.conf.clearConfiguration()
        self._clearOffset()
        self._clearSign()
        self.sign = None


class Control(object):
+15 −7
Original line number Diff line number Diff line
@@ -36,7 +36,9 @@ class TestCheckUpdating(unittest.TestCase):
        with self.assertRaisesRegexp(ComponentErrorsEx, 'positioner not configured'):
            self.positioner.park()
            time.sleep(0.5)
            self.positioner.checkUpdating(0, MNG_TRACK, ANT_SOUTH, 0, 0, 0, 0)
            self.positioner.checkUpdating(
                0, MNG_TRACK, ANT_SOUTH, 0, 0, 0, 0, False
            )


    def test_mng_beampark(self):
@@ -47,7 +49,8 @@ class TestCheckUpdating(unittest.TestCase):
                starting_time,
                MNG_BEAMPARK,
                ANT_SOUTH,
                az, el, ra, dec
                az, el, ra, dec,
                False
        )
        self.assertEqual(value, True)
        self.assertEqual(feasible_time, starting_time)
@@ -61,7 +64,8 @@ class TestCheckUpdating(unittest.TestCase):
        starting_time = 0
        az, el, ra, dec = 0.6109, 0.6109, 0, 0  # 0.6109 -> 35 degrees
        self.antenna.setOffsets(az, el, ANT_HORIZONTAL)
        self.positioner.startUpdating(MNG_TRACK, ANT_NORTH, az, el, ra, dec)
        self.positioner.startUpdating(
            MNG_TRACK, ANT_NORTH, az, el, ra, dec, False)
        time.sleep(0.5)
        self.positioner.stopUpdating()
        time.sleep(0.5)
@@ -70,7 +74,8 @@ class TestCheckUpdating(unittest.TestCase):
                starting_time,
                MNG_TRACK,
                ANT_NORTH,
                az, el, ra, dec
                az, el, ra, dec,
                False  # new_source
        )
        self.assertEqual(value, True)
        self.assertGreater(feasible_time, timestamp)
@@ -95,7 +100,8 @@ class TestCheckUpdating(unittest.TestCase):
                starting_time,
                MNG_TRACK,
                ANT_NORTH,
                az, el, 0, 0
                az, el, 0, 0,
                False  # new_source
        )
        self.assertEqual(value, False)
        minimum_time = timestamp + int(required_time)
@@ -121,7 +127,8 @@ class TestCheckUpdating(unittest.TestCase):
                starting_time,
                MNG_TRACK,
                ANT_NORTH,
                az, el, 0, 0
                az, el, 0, 0,
                False  # new_source
        )
        self.assertEqual(value, True)
        self.assertLess(feasible_time, starting_time)
@@ -146,7 +153,8 @@ class TestCheckUpdating(unittest.TestCase):
                starting_time,
                MNG_TRACK,
                ANT_NORTH,
                az, el, 0, 0
                az, el, 0, 0,
                False  # new_source
        )
        self.assertEqual(value, False)
        self.assertGreater(feasible_time, starting_time)
+11 −11
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ class StartUpdatingTest(unittest.TestCase):
            self.positioner.setRewindingMode('MANUAL')
            az, el, target = self.prepare_negative_oor() 
            # after prepare_negative_oor(), startUpdating() will cause oor
            self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
            self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, True)
            time.sleep(0.5)
            self.assertTrue(self.positioner.isRewindingRequired())
            self.positioner.rewind(0)
@@ -49,7 +49,7 @@ class StartUpdatingTest(unittest.TestCase):
            self.positioner.setRewindingMode('MANUAL')
            az, el, target = self.prepare_negative_oor()
            # after prepare_negative_oor(), startUpdating() will cause oor
            self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
            self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, True)
            time.sleep(0.5)
            self.assertTrue(self.positioner.isRewindingRequired())
            self.positioner.rewind(4)
@@ -59,7 +59,7 @@ class StartUpdatingTest(unittest.TestCase):
        self.positioner.setRewindingMode('MANUAL')
        az, el, target = self.prepare_negative_oor()
        # after prepare_negative_oor(), startUpdating() will cause oor
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, True)
        time.sleep(0.5)
        self.assertEqual(self.positioner.isRewindingRequired(), True)
        self.assertEqual(self.positioner.isRewinding(), False)
@@ -70,7 +70,7 @@ class StartUpdatingTest(unittest.TestCase):
        self.positioner.setRewindingMode('MANUAL')
        az, el, target = self.prepare_negative_oor()
        # after prepare_negative_oor(), startUpdating() will cause oor
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, True)
        time.sleep(0.5)
        self.positioner.stopUpdating()
        time.sleep(1)
@@ -81,7 +81,7 @@ class StartUpdatingTest(unittest.TestCase):
        self.positioner.setRewindingMode('MANUAL')
        az, el, target = self.prepare_negative_oor() 
        # after prepare_negative_oor(), startUpdating() will cause oor
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, True)
        time.sleep(0.5)
        self.assertTrue(self.positioner.isRewindingRequired())
        steps = 2
@@ -120,7 +120,7 @@ class StartUpdatingTest(unittest.TestCase):
        self.assertLess(target, min_limit)
        # If sector is SOUTH, we expect a rewind of 60 degrees: -93 + 60 -> -33
        expected = target + 60
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, True)
        time.sleep(0.5)
        self.assertAlmostEqual(expected, self.device.getActPosition(), delta=0.1)

@@ -134,7 +134,7 @@ class StartUpdatingTest(unittest.TestCase):
        target = Pis + parallactic 
        self.assertLess(target, min_limit)
        expected = target + 120
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, True)
        time.sleep(0.5)
        self.assertAlmostEqual(expected, self.device.getActPosition(), delta=0.1)

@@ -153,7 +153,7 @@ class StartUpdatingTest(unittest.TestCase):
        self.assertGreater(target, min_limit)
        # We do not expect a rewind
        expected = target
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, False)
        time.sleep(0.5)
        self.assertAlmostEqual(expected, self.device.getActPosition(), delta=0.1)

@@ -184,7 +184,7 @@ class StartUpdatingTest(unittest.TestCase):
        self.antenna.setOffsets(az, el, ANT_HORIZONTAL)
        target = Pis + parallactic 
        self.assertLess(target, max_limit)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, True)
        time.sleep(0.5)
        self.assertAlmostEqual(target, self.device.getActPosition(), delta=0.1)
        self.assertTrue(self.positioner.isUpdating())
@@ -245,7 +245,7 @@ class StartUpdatingTest(unittest.TestCase):
        self.antenna.setOffsets(az, el, ANT_HORIZONTAL)
        target = Pis + parallactic 
        self.assertLess(target, max_limit)
        self.positioner.startUpdating(MNG_TRACK, ANT_NORTH, az, el, 0, 0)
        self.positioner.startUpdating(MNG_TRACK, ANT_NORTH, az, el, 0, 0, True)
        time.sleep(0.5)
        self.assertAlmostEqual(target, self.device.getActPosition(), delta=0.1)
        self.assertTrue(self.positioner.isUpdating())
@@ -294,7 +294,7 @@ class StartUpdatingTest(unittest.TestCase):
        self.antenna.setOffsets(az, el, ANT_HORIZONTAL)
        target = Pis + parallactic 
        self.assertGreater(target, min_limit)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0)
        self.positioner.startUpdating(MNG_TRACK, ANT_SOUTH, az, el, 0, 0, True)
        time.sleep(0.5)
        self.assertAlmostEqual(target, self.device.getActPosition(), delta=0.1)
        self.assertTrue(self.positioner.isUpdating())
Loading